Changeset 70074 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 12, 2017 9:26:08 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.cpp
r70029 r70074 191 191 void QIManagerDialog::prepareToolBar() 192 192 { 193 if(!m_pWidgetToolbar) 194 return; 193 195 /* Enable unified toolbar on macOS: */ 194 196 addToolBar(m_pWidgetToolbar); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp
r70029 r70074 58 58 { 59 59 button(ButtonType_Close)->setText(UIVMLogViewerWidget::tr("Close")); 60 button(ButtonType_Close)->setShortcut(Qt::Key_Escape); 61 /* Setup a dialog caption: */ 62 if (!m_comMachine.isNull()) 63 setWindowTitle(tr("%1 - Log Viewer").arg(m_comMachine.GetName())); 64 else 65 setWindowTitle(UIVMLogViewerWidget::tr("Log Viewer")); 60 66 } 61 67 … … 63 69 { 64 70 /* Create widget: */ 65 UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget( this, m_comMachine);71 UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget(EmbedTo_Dialog, this, m_comMachine); 66 72 AssertPtrReturnVoid(pWidget); 67 73 { 68 74 /* Configure widget: */ 69 75 setWidget(pWidget); 70 //setWidgetMenu(pWidget->menu());76 setWidgetMenu(pWidget->menu()); 71 77 #ifdef VBOX_WS_MAC 72 //setWidgetToolbar(pWidget->toolbar());78 setWidgetToolbar(pWidget->toolbar()); 73 79 #endif 74 80 /* Add into layout: */ … … 80 86 { 81 87 /* Apply window icons: */ 82 setWindowIcon(UIIconPool::iconSetFull(":/ diskimage_32px.png", ":/diskimage_16px.png"));88 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png")); 83 89 } 90 91 void UIVMLogViewerDialog::finalize() 92 { 93 retranslateUi(); 94 } 95 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.h
r70029 r70074 63 63 virtual void configure() /* override */; 64 64 virtual void configureCentralWidget() /* override */; 65 virtual void finalize() /* override */; 65 66 66 67 private: -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70029 r70074 23 23 # include <QDateTime> 24 24 # include <QDir> 25 # include <QDialogButtonBox>26 25 # include <QVBoxLayout> 27 26 # if defined(RT_OS_SOLARIS) 28 27 # include <QFontDatabase> 29 28 # endif 30 # include <QPushButton>31 29 # include <QTextEdit> 32 30 … … 40 38 # include "UIVMLogViewerFilterPanel.h" 41 39 # include "UIVMLogViewerSearchPanel.h" 40 # include "UIToolBar.h" 42 41 43 42 /* COM includes: */ … … 48 47 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 49 48 50 UIVMLogViewerWidget::UIVMLogViewerWidget( QWidget *pParent, const CMachine &machine)49 UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine) 51 50 : QIWithRetranslateUI<QWidget>(pParent) 52 51 , m_fIsPolished(false) 53 52 , m_comMachine(machine) 54 , m_pButtonBox(0)55 53 , m_pMainLayout(0) 56 , m_pButtonFind(0) 57 , m_pButtonRefresh(0) 58 , m_pButtonSave(0) 59 , m_pButtonFilter(0) 60 54 , m_enmEmbedding(enmEmbedding) 55 , m_pToolBar(0) 56 , m_pActionFind(0) 57 , m_pActionFilter(0) 58 , m_pActionRefresh(0) 59 , m_pActionSave(0) 60 , m_pMenu(0) 61 61 { 62 62 /* Prepare VM Log-Viewer: */ … … 90 90 } 91 91 92 void UIVMLogViewerWidget::s earch()92 void UIVMLogViewerWidget::sltFind() 93 93 { 94 94 /* Show/hide search-panel: */ … … 96 96 } 97 97 98 void UIVMLogViewerWidget:: refresh()98 void UIVMLogViewerWidget::sltRefresh() 99 99 { 100 100 /* Disconnect this connection to avoid initial signals during page creation/deletion: */ … … 176 176 connect(m_pViewerContainer, SIGNAL(currentChanged(int)), m_pFilterPanel, SLOT(applyFilter(int))); 177 177 178 /* Enable/Disable save button& tab widget according log presence: */179 m_p ButtonFind->setEnabled(isAnyLogPresent);180 m_p ButtonSave->setEnabled(isAnyLogPresent);181 m_p ButtonFilter->setEnabled(isAnyLogPresent);178 /* Enable/Disable toolbar actions (except Refresh) & tab widget according log presence: */ 179 m_pActionFind->setEnabled(isAnyLogPresent); 180 m_pActionFilter->setEnabled(isAnyLogPresent); 181 m_pActionSave->setEnabled(isAnyLogPresent); 182 182 m_pViewerContainer->setEnabled(isAnyLogPresent); 183 183 } 184 184 185 void UIVMLogViewerWidget::s ave()185 void UIVMLogViewerWidget::sltSave() 186 186 { 187 187 /* Prepare "save as" dialog: */ … … 211 211 } 212 212 213 void UIVMLogViewerWidget:: filter()213 void UIVMLogViewerWidget::sltFilter() 214 214 { 215 215 /* Show/hide filter-panel: */ … … 219 219 void UIVMLogViewerWidget::prepare() 220 220 { 221 m_pButtonBox = new QDialogButtonBox(this);222 221 m_pMainLayout = new QVBoxLayout(this); 223 222 224 m_pMainLayout->addWidget(m_pButtonBox);225 226 /* Apply window icons: */227 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));223 prepareActions(); 224 225 prepareToolBar(); 226 prepareMenu(); 228 227 229 228 /* Prepare widgets: */ 230 229 prepareWidgets(); 231 230 232 /* Prepare connections: */233 prepareConnections();234 235 231 /* Reading log files: */ 236 refresh();232 sltRefresh(); 237 233 238 234 /* Loading language constants: */ … … 247 243 { 248 244 /* Add VM Log-Viewer container to main-layout: */ 249 m_pMainLayout->insertWidget( 0, m_pViewerContainer);245 m_pMainLayout->insertWidget(1, m_pViewerContainer); 250 246 } 251 247 … … 258 254 m_pSearchPanel->hide(); 259 255 /* Add VM Log-Viewer search-panel to main-layout: */ 260 m_pMainLayout->insertWidget( 1, m_pSearchPanel);256 m_pMainLayout->insertWidget(2, m_pSearchPanel); 261 257 } 262 258 … … 269 265 m_pFilterPanel->hide(); 270 266 /* Add VM Log-Viewer filter-panel to main-layout: */ 271 m_pMainLayout->insertWidget(2, m_pFilterPanel); 272 } 273 274 /* Create find-button: */ 275 m_pButtonFind = m_pButtonBox->addButton(QString::null, QDialogButtonBox::ActionRole); 276 AssertPtrReturnVoid(m_pButtonFind); 277 /* Create filter-button: */ 278 m_pButtonFilter = m_pButtonBox->addButton(QString::null, QDialogButtonBox::ActionRole); 279 AssertPtrReturnVoid(m_pButtonFilter); 280 281 /* Create save-button: */ 282 m_pButtonSave = m_pButtonBox->addButton(QDialogButtonBox::Save); 283 AssertPtrReturnVoid(m_pButtonSave); 284 /* Create refresh-button: */ 285 m_pButtonRefresh = m_pButtonBox->addButton(QString::null, QDialogButtonBox::ActionRole); 286 AssertPtrReturnVoid(m_pButtonRefresh); 287 } 288 289 void UIVMLogViewerWidget::prepareConnections() 290 { 291 /* Prepare connections: */ 292 connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 293 connect(m_pButtonFind, SIGNAL(clicked()), this, SLOT(search())); 294 connect(m_pButtonRefresh, SIGNAL(clicked()), this, SLOT(refresh())); 295 connect(m_pButtonSave, SIGNAL(clicked()), this, SLOT(save())); 296 connect(m_pButtonFilter, SIGNAL(clicked()), this, SLOT(filter())); 267 m_pMainLayout->insertWidget(3, m_pFilterPanel); 268 } 269 } 270 271 void UIVMLogViewerWidget::prepareActions() 272 { 273 /* Create and configure 'Find' action: */ 274 m_pActionFind = new QAction(this); 275 AssertPtrReturnVoid(m_pActionFind); 276 { 277 m_pActionFind->setShortcut(QKeySequence("Ctrl+F")); 278 connect(m_pActionFind, &QAction::triggered, this, &UIVMLogViewerWidget::sltFind); 279 } 280 281 /* Create and configure 'Filter' action: */ 282 m_pActionFilter = new QAction(this); 283 AssertPtrReturnVoid(m_pActionFilter); 284 { 285 m_pActionFilter->setShortcut(QKeySequence("Ctrl+T")); 286 connect(m_pActionFilter, &QAction::triggered, this, &UIVMLogViewerWidget::sltFilter); 287 } 288 289 /* Create and configure 'Refresh' action: */ 290 m_pActionRefresh = new QAction(this); 291 AssertPtrReturnVoid(m_pActionRefresh); 292 { 293 m_pActionRefresh->setShortcut(QKeySequence("F5")); 294 connect(m_pActionRefresh, &QAction::triggered, this, &UIVMLogViewerWidget::sltRefresh); 295 } 296 297 /* Create and configure 'Save' action: */ 298 m_pActionSave = new QAction(this); 299 AssertPtrReturnVoid(m_pActionSave); 300 { 301 m_pActionSave->setShortcut(QKeySequence("Ctrl+S")); 302 connect(m_pActionSave, &QAction::triggered, this, &UIVMLogViewerWidget::sltSave); 303 } 304 305 /* Update action icons: */ 306 prepareActionIcons(); 307 } 308 309 void UIVMLogViewerWidget::prepareActionIcons() 310 { 311 QString strPrefix = "log_viewer"; 312 313 if (m_pActionFind) 314 m_pActionFind->setIcon(UIIconPool::iconSet(QString(":/%1_find_24px.png").arg(strPrefix), 315 QString(":/%1_find_disabled_24px.png").arg(strPrefix))); 316 317 if (m_pActionFilter) 318 m_pActionFilter->setIcon(UIIconPool::iconSet(QString(":/%1_filter_24px.png").arg(strPrefix), 319 QString(":/%1_filter_disabled_24px.png").arg(strPrefix))); 320 321 322 if (m_pActionRefresh) 323 m_pActionRefresh->setIcon(UIIconPool::iconSet(QString(":/%1_refresh_24px.png").arg(strPrefix), 324 QString(":/%1_refresh_disabled_24px.png").arg(strPrefix))); 325 326 327 if (m_pActionSave) 328 m_pActionSave->setIcon(UIIconPool::iconSet(QString(":/%1_save_24px.png").arg(strPrefix), 329 QString(":/%1_save_disabled_24px.png").arg(strPrefix))); 330 331 332 } 333 334 void UIVMLogViewerWidget::prepareToolBar() 335 { 336 /* Create toolbar: */ 337 m_pToolBar = new UIToolBar(parentWidget()); 338 AssertPtrReturnVoid(m_pToolBar); 339 { 340 /* Configure toolbar: */ 341 const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375); 342 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 343 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 344 /* Add toolbar actions: */ 345 if (m_pActionFind) 346 m_pToolBar->addAction(m_pActionFind); 347 348 if (m_pActionFilter) 349 m_pToolBar->addAction(m_pActionFilter); 350 351 if (m_pActionRefresh) 352 m_pToolBar->addAction(m_pActionRefresh); 353 354 if (m_pActionSave) 355 m_pToolBar->addAction(m_pActionSave); 356 357 #ifdef VBOX_WS_MAC 358 /* Check whether we are embedded into a stack: */ 359 if (m_enmEmbedding == EmbedTo_Stack) 360 { 361 /* Add into layout: */ 362 layout()->addWidget(m_pToolBar); 363 } 364 #else 365 /* Add into layout: */ 366 m_pMainLayout->insertWidget(0, m_pToolBar); 367 #endif 368 } 369 } 370 371 void UIVMLogViewerWidget::prepareMenu() 372 { 373 /* Create 'LogViewer' menu: */ 374 m_pMenu = new QMenu(this); 375 AssertPtrReturnVoid(m_pMenu); 376 { 377 if (m_pActionFind) 378 m_pMenu->addAction(m_pActionFind); 379 if (m_pActionFilter) 380 m_pMenu->addAction(m_pActionFilter); 381 if (m_pActionRefresh) 382 m_pMenu->addAction(m_pActionRefresh); 383 if (m_pActionSave) 384 m_pMenu->addAction(m_pActionSave); 385 } 297 386 } 298 387 … … 303 392 void UIVMLogViewerWidget::retranslateUi() 304 393 { 305 /* Setup a dialog caption: */ 306 if (!m_comMachine.isNull()) 307 setWindowTitle(tr("%1 - VirtualBox Log Viewer").arg(m_comMachine.GetName())); 308 309 /* Translate other tags: */ 310 m_pButtonFind->setText(tr("&Find")); 311 m_pButtonRefresh->setText(tr("&Refresh")); 312 m_pButtonSave->setText(tr("&Save")); 313 m_pButtonFilter->setText(tr("Fil&ter")); 394 if(m_pMenu) 395 { 396 m_pMenu->setTitle(tr("&Log Viewer")); 397 } 398 399 if (m_pActionFind) 400 { 401 m_pActionFind->setText(tr("&Find...")); 402 m_pActionFind->setToolTip(tr("Find a string within the log")); 403 m_pActionFind->setStatusTip(tr("Find a string within the log")); 404 } 405 406 if (m_pActionFilter) 407 { 408 m_pActionFilter->setText(tr("&Filter...")); 409 m_pActionFilter->setToolTip(tr("Filter the log wrt. the given string")); 410 m_pActionFilter->setStatusTip(tr("Filter the log wrt. the given string")); 411 } 412 413 if (m_pActionRefresh) 414 { 415 m_pActionRefresh->setText(tr("&Refresh...")); 416 m_pActionRefresh->setToolTip(tr("Reload the log")); 417 m_pActionRefresh->setStatusTip(tr("Reload the log")); 418 } 419 420 if (m_pActionSave) 421 { 422 m_pActionSave->setText(tr("&Save...")); 423 m_pActionSave->setToolTip(tr("Save the log")); 424 m_pActionSave->setStatusTip(tr("Save the log")); 425 } 426 427 /* Translate toolbar: */ 428 #ifdef VBOX_WS_MAC 429 // WORKAROUND: 430 // There is a bug in Qt Cocoa which result in showing a "more arrow" when 431 // the necessary size of the toolbar is increased. Also for some languages 432 // the with doesn't match if the text increase. So manually adjust the size 433 // after changing the text. */ 434 if (m_pToolBar) 435 m_pToolBar->updateLayout(); 436 #endif 314 437 } 315 438 … … 424 547 return m_logMap[currentLogPage()]; 425 548 } 549 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70029 r70074 25 25 26 26 /* GUI includes: */ 27 #include "QIManagerDialog.h" 27 28 #include "QIWithRetranslateUI.h" 28 29 … … 32 33 33 34 /* Forward declarations: */ 34 class QDialogButtonBox;35 35 class QITabWidget; 36 class QPushButton;37 36 class QTextEdit; 38 37 class QVBoxLayout; 38 class UIToolBar; 39 39 class UIVMLogViewerFilterPanel; 40 40 class UIVMLogViewerSearchPanel; … … 54 54 /** Constructs the VM Log-Viewer by passing @a pParent to QWidget base-class constructor. 55 55 * @param machine Specifies the machine for which VM Log-Viewer is requested. */ 56 UIVMLogViewerWidget( QWidget *pParent, const CMachine &machine);56 UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent, const CMachine &machine); 57 57 /** Destructs the VM Log-Viewer. */ 58 58 ~UIVMLogViewerWidget(); … … 60 60 int currentLogPagewidth() const; 61 61 62 /** Returns the menu. */ 63 QMenu *menu() const { return m_pMenu; } 64 65 #ifdef VBOX_WS_MAC 66 /** Returns the toolbar. */ 67 UIToolBar *toolbar() const { return m_pToolBar; } 68 #endif 69 62 70 protected: 63 71 … … 69 77 70 78 /** Handles search action triggering. */ 71 void s earch();79 void sltFind(); 72 80 /** Handles refresh action triggering. */ 73 void refresh();81 void sltRefresh(); 74 82 /** Handles save action triggering. */ 75 void s ave();83 void sltSave(); 76 84 /** Handles filter action triggering. */ 77 void filter();85 void sltFilter(); 78 86 79 87 private: … … 85 93 /** Prepares widgets. */ 86 94 void prepareWidgets(); 87 /** Prepares connections. */ 88 void prepareConnections(); 95 void prepareActions(); 96 void prepareActionIcons(); 97 void prepareToolBar(); 98 void prepareMenu(); 89 99 90 100 /** Cleanups VM Log-Viewer. */ … … 110 120 const QString& currentLog(); 111 121 112 113 122 /** Holds whether the dialog is polished. */ 114 123 bool m_fIsPolished; … … 132 141 VMLogMap m_logMap; 133 142 134 QDialogButtonBox *m_pButtonBox;135 143 QVBoxLayout *m_pMainLayout; 136 144 137 /** Holds the find button instance. */ 138 QPushButton *m_pButtonFind; 139 /** Holds the refresh button instance. */ 140 QPushButton *m_pButtonRefresh; 141 /** Holds the save button instance. */ 142 QPushButton *m_pButtonSave; 143 /** Holds the filter button instance. */ 144 QPushButton *m_pButtonFilter; 145 /** Holds the widget embedding type. */ 146 const EmbedTo m_enmEmbedding; 147 148 /** @name Toolbar and menu variables. 149 * @{ */ 150 /** Holds the toolbar widget instance. */ 151 UIToolBar *m_pToolBar; 152 /** Holds the Find action instance. */ 153 QAction *m_pActionFind; 154 /** Holds the Filter action instance. */ 155 QAction *m_pActionFilter; 156 /** Holds the Refresh action instance. */ 157 QAction *m_pActionRefresh; 158 /** Holds the Save action instance. */ 159 QAction *m_pActionSave; 160 /** Holds the menu object instance. */ 161 QMenu *m_pMenu; 162 /** @} */ 145 163 146 164 friend class UIVMLogViewerSearchPanel; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r70031 r70074 1024 1024 continue; 1025 1025 1026 /* Show VM Log Viewer: */ 1026 QIManagerDialog *pLogViewerDialog = 0; 1027 /* Create and Show VM Log Viewer: */ 1027 1028 if (!m_logViewers[pItem->machine().GetHardwareUUID()]) 1028 1029 { 1029 QIManagerDialog *pLogViewerDialog;1030 1030 UIVMLogViewerDialogFactory dialogFactory(pItem->machine()); 1031 1031 dialogFactory.prepare(pLogViewerDialog, this); … … 1033 1033 { 1034 1034 m_logViewers[pItem->machine().GetHardwareUUID()] = pLogViewerDialog; 1035 1036 /* Show instance: */1037 pLogViewerDialog->show();1038 pLogViewerDialog->setWindowState(pLogViewerDialog->windowState() & ~Qt::WindowMinimized);1039 pLogViewerDialog->activateWindow();1040 1035 connect(pLogViewerDialog, &QIManagerDialog::sigClose, 1041 1036 this, &UISelectorWindow::sltCloseLogViewerWindow); 1042 1037 } 1038 } 1039 else 1040 { 1041 pLogViewerDialog = m_logViewers[pItem->machine().GetHardwareUUID()]; 1042 } 1043 if (pLogViewerDialog) 1044 { 1045 /* Show instance: */ 1046 pLogViewerDialog->show(); 1047 pLogViewerDialog->setWindowState(pLogViewerDialog->windowState() & ~Qt::WindowMinimized); 1048 pLogViewerDialog->activateWindow(); 1043 1049 } 1044 1050 }
Note:
See TracChangeset
for help on using the changeset viewer.