Changeset 73693 in vbox for trunk/src/VBox
- Timestamp:
- Aug 15, 2018 2:33:09 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp
r72713 r73693 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVMLogViewer class implementation.3 * VBox Qt GUI - UIVMLogViewerDialog class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 27 27 # include <QKeyEvent> 28 28 # include <QLabel> 29 # include <QScrollBar>30 29 # include <QPlainTextEdit> 31 30 # include <QPushButton> 31 # include <QScrollBar> 32 32 # include <QVBoxLayout> 33 33 … … 41 41 # ifdef VBOX_WS_MAC 42 42 # include "VBoxUtils-darwin.h" 43 # endif /* VBOX_WS_MAC */43 # endif 44 44 45 45 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 46 46 47 UIVMLogViewerDialogFactory::UIVMLogViewerDialogFactory(const CMachine &machine) 48 :m_comMachine(machine) 47 48 /********************************************************************************************************************************* 49 * Class UIVMLogViewerDialogFactory implementation. * 50 *********************************************************************************************************************************/ 51 52 UIVMLogViewerDialogFactory::UIVMLogViewerDialogFactory(const CMachine &comMachine /* = CMachine() */) 53 : m_comMachine(comMachine) 49 54 { 50 55 } … … 55 60 } 56 61 57 UIVMLogViewerDialog::UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &machine) 62 63 /********************************************************************************************************************************* 64 * Class UIVMLogViewerDialog implementation. * 65 *********************************************************************************************************************************/ 66 67 UIVMLogViewerDialog::UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &comMachine) 58 68 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 59 , m_comMachine( machine)69 , m_comMachine(comMachine) 60 70 { 61 71 } … … 63 73 void UIVMLogViewerDialog::retranslateUi() 64 74 { 65 button(ButtonType_Close)->setText(UIVMLogViewerWidget::tr("Close")); 66 /* Setup a dialog caption: */ 75 /* Translate window title: */ 67 76 if (!m_comMachine.isNull()) 68 77 setWindowTitle(tr("%1 - Log Viewer").arg(m_comMachine.GetName())); 69 78 else 70 79 setWindowTitle(UIVMLogViewerWidget::tr("Log Viewer")); 80 81 /* Translate buttons: */ 82 button(ButtonType_Close)->setText(UIVMLogViewerWidget::tr("Close")); 83 } 84 85 void UIVMLogViewerDialog::configure() 86 { 87 /* Apply window icons: */ 88 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png")); 71 89 } 72 90 … … 74 92 { 75 93 /* Create widget: */ 76 UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget(EmbedTo_Dialog, this, m_comMachine);94 UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget(EmbedTo_Dialog, m_comMachine, this); 77 95 if (pWidget) 78 96 { … … 83 101 setWidgetToolbar(pWidget->toolbar()); 84 102 #endif 103 connect(pWidget, &UIVMLogViewerWidget::sigSetCloseButtonShortCut, 104 this, &UIVMLogViewerDialog::sltSetCloseButtonShortCut); 105 85 106 /* Add into layout: */ 86 107 centralWidget()->layout()->addWidget(pWidget); 87 connect(pWidget, &UIVMLogViewerWidget::sigSetCloseButtonShortCut,88 this, &UIVMLogViewerDialog::sltSetCloseButtonShortCut);89 108 } 90 }91 92 void UIVMLogViewerDialog::configure()93 {94 /* Apply window icons: */95 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));96 109 } 97 110 98 111 void UIVMLogViewerDialog::finalize() 99 112 { 113 /* Apply language settings: */ 100 114 retranslateUi(); 115 116 // WTF? Why here? 101 117 button(ButtonType_Close)->setShortcut(Qt::Key_Escape); 102 118 } … … 104 120 void UIVMLogViewerDialog::loadSettings() 105 121 { 106 const UIVMLogViewerWidget *pWidget = qobject_cast<const UIVMLogViewerWidget *>(widget()); 122 /* Acquire widget: */ 123 const UIVMLogViewerWidget *pWidget = qobject_cast<const UIVMLogViewerWidget*>(widget()); 107 124 108 125 /* Restore window geometry: */ 109 /* Getting available geometry to calculate default geometry: */110 126 const QRect desktopRect = gpDesktop->availableGeometry(this); 111 127 int iDefaultWidth = desktopRect.width() / 2; 112 128 int iDefaultHeight = desktopRect.height() * 3 / 4; 113 129 114 /* Try obtain the default width of the current logviewer */130 /* Try obtain the default width of the current logviewer: */ 115 131 if (pWidget) 116 132 { 117 int width = pWidget->defaultLogPageWidth();118 if ( width != 0)119 iDefaultWidth = width;133 int iWidth = pWidget->defaultLogPageWidth(); 134 if (iWidth != 0) 135 iDefaultWidth = iWidth; 120 136 } 121 137 … … 153 169 } 154 170 155 void UIVMLogViewerDialog::sltSetCloseButtonShortCut(QKeySequence short Cut)171 void UIVMLogViewerDialog::sltSetCloseButtonShortCut(QKeySequence shortcut) 156 172 { 157 173 if (button(ButtonType_Close)) 158 button(ButtonType_Close)->setShortcut(short Cut);174 button(ButtonType_Close)->setShortcut(shortcut); 159 175 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.h
r72713 r73693 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVMLogViewer class declaration.3 * VBox Qt GUI - UIVMLogViewerDialog class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 39 39 40 40 41 /** QIManagerDialogFactory used as a factory for Virtual Media Manager dialog. */41 /** QIManagerDialogFactory extension used as a factory for Log Viewer dialog. */ 42 42 class SHARED_LIBRARY_STUFF UIVMLogViewerDialogFactory : public QIManagerDialogFactory 43 43 { 44 44 public: 45 UIVMLogViewerDialogFactory(const CMachine &machine); 45 46 /** Constructs Log Viewer factory acquiring additional arguments. 47 * @param comMachine Brings the machine for which VM Log-Viewer is requested. */ 48 UIVMLogViewerDialogFactory(const CMachine &comMachine = CMachine()); 46 49 47 50 protected: 51 48 52 /** Creates derived @a pDialog instance. 49 53 * @param pCenterWidget Brings the widget to center wrt. pCenterWidget. */ 50 54 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */; 51 CMachine m_comMachine; 55 56 /** Holds the machine reference. */ 57 CMachine m_comMachine; 52 58 }; 53 59 54 60 55 /** A QIDialog to displaymachine logs. */61 /** QIManagerDialog extension providing GUI with the dialog displaying machine logs. */ 56 62 class SHARED_LIBRARY_STUFF UIVMLogViewerDialog : public QIWithRetranslateUI<QIManagerDialog> 57 63 { … … 60 66 public: 61 67 62 UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &machine); 68 /** Constructs Log Viewer dialog. 69 * @param pCenterWidget Brings the widget reference to center according to. 70 * @param comMachine Brings the machine reference. */ 71 UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &comMachine); 63 72 64 73 protected: 65 74 75 /** @name Event-handling stuff. 76 * @{ */ 77 /** Handles translation event. */ 78 virtual void retranslateUi() /* override */; 79 /** @} */ 80 66 81 /** @name Prepare/cleanup cascade. 67 82 * @{ */ 83 /** Configures all. */ 68 84 virtual void configure() /* override */; 85 /** Configures central-widget. */ 69 86 virtual void configureCentralWidget() /* override */; 87 /** Perform final preparations. */ 70 88 virtual void finalize() /* override */; 89 /** Loads dialog setting such as geometry from extradata. */ 90 virtual void loadSettings() /* override */; 91 92 /** Saves dialog setting into extradata. */ 71 93 virtual void saveSettings() const /* override */; 72 virtual void loadSettings() /* override */;73 94 /** @} */ 74 /* Reads the related extradata to determine if the dialog should be maximized. */ 75 virtual bool shouldBeMaximized() const /* override */; 95 96 /** @name Functions related to geometry restoration. 97 * @{ */ 98 /** Returns whether the window should be maximized when geometry being restored. */ 99 virtual bool shouldBeMaximized() const /* override */; 100 /** @} */ 76 101 77 102 private slots: 78 103 79 void sltSetCloseButtonShortCut(QKeySequence shortCut); 104 /** Must be handles soemthing related to close @a shortcut. */ 105 void sltSetCloseButtonShortCut(QKeySequence shortcut); 80 106 81 107 private: 82 108 83 void retranslateUi();84 CMachine m_comMachine;109 /** Holds the machine reference. */ 110 CMachine m_comMachine; 85 111 }; 86 112 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r72724 r73693 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVMLogViewer class implementation.3 * VBox Qt GUI - UIVMLogViewerWidget class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 57 57 58 58 59 UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */, const CMachine &machine /* = CMachine() */) 59 UIVMLogViewerWidget::UIVMLogViewerWidget(EmbedTo enmEmbedding, 60 const CMachine &comMachine /* = CMachine() */, 61 QWidget *pParent /* = 0 */) 60 62 : QIWithRetranslateUI<QWidget>(pParent) 63 , m_enmEmbedding(enmEmbedding) 64 , m_comMachine(comMachine) 61 65 , m_fIsPolished(false) 62 , m_comMachine(machine)63 66 , m_pTabWidget(0) 64 67 , m_pSearchPanel(0) … … 67 70 , m_pSettingsPanel(0) 68 71 , m_pMainLayout(0) 69 , m_enmEmbedding(enmEmbedding)70 72 , m_pToolBar(0) 71 73 , m_pActionFind(0) … … 86 88 UIVMLogViewerWidget::~UIVMLogViewerWidget() 87 89 { 88 saveSettings();89 90 /* Cleanup VM Log-Viewer: */ 90 91 cleanup(); 91 }92 93 void UIVMLogViewerWidget::loadSettings()94 {95 m_bWrapLines = gEDataManager->logViewerWrapLines();96 m_bShowLineNumbers = gEDataManager->logViewerShowLineNumbers();97 QFont loadedFont = gEDataManager->logViewerFont();98 if (loadedFont != QFont())99 m_font = loadedFont;100 }101 102 void UIVMLogViewerWidget::saveSettings()103 {104 gEDataManager->setLogViweverSettings(m_font, m_bWrapLines, m_bShowLineNumbers);105 92 } 106 93 … … 125 112 } 126 113 114 void UIVMLogViewerWidget::setMachine(const CMachine &comMachine) 115 { 116 if (comMachine == m_comMachine) 117 return; 118 m_comMachine = comMachine; 119 sltRefresh(); 120 } 121 122 QFont UIVMLogViewerWidget::currentFont() const 123 { 124 const UIVMLogPage* logPage = currentLogPage(); 125 if (!logPage) 126 return QFont(); 127 return logPage->currentFont(); 128 } 129 127 130 bool UIVMLogViewerWidget::shouldBeMaximized() const 128 131 { 129 132 return gEDataManager->logWindowShouldBeMaximized(); 130 }131 132 void UIVMLogViewerWidget::sltDeleteBookmark(int index)133 {134 UIVMLogPage* logPage = currentLogPage();135 if (!logPage)136 return;137 logPage->deleteBookmark(index);138 if (m_pBookmarksPanel)139 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector());140 }141 142 void UIVMLogViewerWidget::sltDeleteAllBookmarks()143 {144 UIVMLogPage* logPage = currentLogPage();145 if (!logPage)146 return;147 logPage->deleteAllBookmarks();148 149 if (m_pBookmarksPanel)150 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector());151 }152 153 void UIVMLogViewerWidget::sltUpdateBookmarkPanel()154 {155 if (!currentLogPage() || !m_pBookmarksPanel)156 return;157 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector());158 }159 160 void UIVMLogViewerWidget::gotoBookmark(int bookmarkIndex)161 {162 if (!currentLogPage())163 return;164 currentLogPage()->scrollToBookmark(bookmarkIndex);165 }166 167 void UIVMLogViewerWidget::sltPanelActionTriggered(bool checked)168 {169 QAction *pSenderAction = qobject_cast<QAction*>(sender());170 if (!pSenderAction)171 return;172 UIVMLogViewerPanel* pPanel = 0;173 /* Look for the sender() within the m_panelActionMap's values: */174 for (QMap<UIVMLogViewerPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin();175 iterator != m_panelActionMap.end(); ++iterator)176 {177 if (iterator.value() == pSenderAction)178 pPanel = iterator.key();179 }180 if (!pPanel)181 return;182 if (checked)183 showPanel(pPanel);184 else185 hidePanel(pPanel);186 133 } 187 134 … … 238 185 m_pTabWidget->setCurrentIndex(tabIndex); 239 186 sltTabIndexChange(tabIndex); 187 240 188 /* Enable/Disable toolbar actions (except Refresh) & tab widget according log presence: */ 241 189 if (m_pActionFind) … … 247 195 if (m_pActionBookmarks) 248 196 m_pActionBookmarks->setEnabled(!noLogsToShow); 249 250 197 if (m_pActionSettings) 251 198 m_pActionSettings->setEnabled(!noLogsToShow); 199 252 200 m_pTabWidget->show(); 253 201 if (m_pSearchPanel && m_pSearchPanel->isVisible()) … … 304 252 } 305 253 254 void UIVMLogViewerWidget::sltDeleteBookmark(int index) 255 { 256 UIVMLogPage* logPage = currentLogPage(); 257 if (!logPage) 258 return; 259 logPage->deleteBookmark(index); 260 if (m_pBookmarksPanel) 261 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 262 } 263 264 void UIVMLogViewerWidget::sltDeleteAllBookmarks() 265 { 266 UIVMLogPage* logPage = currentLogPage(); 267 if (!logPage) 268 return; 269 logPage->deleteAllBookmarks(); 270 271 if (m_pBookmarksPanel) 272 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 273 } 274 275 void UIVMLogViewerWidget::sltUpdateBookmarkPanel() 276 { 277 if (!currentLogPage() || !m_pBookmarksPanel) 278 return; 279 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 280 } 281 282 void UIVMLogViewerWidget::gotoBookmark(int bookmarkIndex) 283 { 284 if (!currentLogPage()) 285 return; 286 currentLogPage()->scrollToBookmark(bookmarkIndex); 287 } 288 289 void UIVMLogViewerWidget::sltPanelActionToggled(bool fChecked) 290 { 291 QAction *pSenderAction = qobject_cast<QAction*>(sender()); 292 if (!pSenderAction) 293 return; 294 UIVMLogViewerPanel* pPanel = 0; 295 /* Look for the sender() within the m_panelActionMap's values: */ 296 for (QMap<UIVMLogViewerPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin(); 297 iterator != m_panelActionMap.end(); ++iterator) 298 { 299 if (iterator.value() == pSenderAction) 300 pPanel = iterator.key(); 301 } 302 if (!pPanel) 303 return; 304 if (fChecked) 305 showPanel(pPanel); 306 else 307 hidePanel(pPanel); 308 } 309 306 310 void UIVMLogViewerWidget::sltSearchResultHighLigting() 307 311 { … … 399 403 } 400 404 } 405 401 406 void UIVMLogViewerWidget::sltResetSettingsToDefault() 402 407 { … … 413 418 } 414 419 415 void UIVMLogViewerWidget::setMachine(const CMachine &machine)416 {417 if (machine == m_comMachine)418 return;419 m_comMachine = machine;420 sltRefresh();421 }422 423 420 void UIVMLogViewerWidget::prepare() 424 421 { 425 loadSettings();422 /* Create main layout: */ 426 423 m_pMainLayout = new QVBoxLayout(this); 427 424 425 /* Prepare stuff: */ 428 426 prepareActions(); 429 427 prepareToolBar(); 430 431 428 prepareMenu(); 432 429 prepareWidgets(); 433 430 /* Load settings: */ 431 loadSettings(); 434 432 435 433 /* Reading log files: */ … … 439 437 retranslateUi(); 440 438 441 m_panelActionMap.insert(m_pBookmarksPanel, m_pActionBookmarks);442 m_panelActionMap.insert(m_pSearchPanel, m_pActionFind);443 m_panelActionMap.insert(m_pFilterPanel, m_pActionFilter);444 m_panelActionMap.insert(m_pSettingsPanel, m_pActionSettings);445 439 manageEscapeShortCut(); 446 }447 448 void UIVMLogViewerWidget::prepareWidgets()449 {450 /* Configure layout: */451 layout()->setContentsMargins(0, 0, 0, 0);452 #ifdef VBOX_WS_MAC453 layout()->setSpacing(10);454 #else455 layout()->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);456 #endif457 458 /* Create VM Log-Viewer container: */459 m_pTabWidget = new QITabWidget;460 if (m_pTabWidget)461 {462 /* Add VM Log-Viewer container to main-layout: */463 m_pMainLayout->addWidget(m_pTabWidget);464 }465 466 /* Create VM Log-Viewer search-panel: */467 m_pSearchPanel = new UIVMLogViewerSearchPanel(0, this);468 if (m_pSearchPanel)469 {470 /* Configure VM Log-Viewer search-panel: */471 installEventFilter(m_pSearchPanel);472 m_pSearchPanel->hide();473 /* Add VM Log-Viewer search-panel to main-layout: */474 m_pMainLayout->addWidget(m_pSearchPanel);475 connect(m_pSearchPanel, &UIVMLogViewerSearchPanel::sigHighlightingUpdated,476 this, &UIVMLogViewerWidget::sltSearchResultHighLigting);477 }478 479 /* Create VM Log-Viewer filter-panel: */480 m_pFilterPanel = new UIVMLogViewerFilterPanel(0, this);481 if (m_pFilterPanel)482 {483 /* Configure VM Log-Viewer filter-panel: */484 installEventFilter(m_pFilterPanel);485 m_pFilterPanel->hide();486 /* Add VM Log-Viewer filter-panel to main-layout: */487 m_pMainLayout->addWidget(m_pFilterPanel);488 connect(m_pFilterPanel, &UIVMLogViewerFilterPanel::sigFilterApplied,489 this, &UIVMLogViewerWidget::sltFilterApplied);490 }491 492 m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this);493 if (m_pBookmarksPanel)494 {495 m_pBookmarksPanel->hide();496 m_pMainLayout->addWidget(m_pBookmarksPanel);497 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmark,498 this, &UIVMLogViewerWidget::sltDeleteBookmark);499 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks,500 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks);501 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,502 this, &UIVMLogViewerWidget::gotoBookmark);503 }504 505 m_pSettingsPanel = new UIVMLogViewerSettingsPanel(0, this);506 if (m_pSettingsPanel)507 {508 m_pSettingsPanel->hide();509 /* Initialize settings' panel checkboxes and input fields: */510 m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers);511 m_pSettingsPanel->setWrapLines(m_bWrapLines);512 m_pSettingsPanel->setFontSizeInPoints(m_font.pointSize());513 514 m_pMainLayout->addWidget(m_pSettingsPanel);515 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigShowLineNumbers, this, &UIVMLogViewerWidget::sltShowLineNumbers);516 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigWrapLines, this, &UIVMLogViewerWidget::sltWrapLines);517 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFontSizeInPoints, this, &UIVMLogViewerWidget::sltFontSizeChanged);518 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFont, this, &UIVMLogViewerWidget::sltChangeFont);519 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigResetToDefaults, this, &UIVMLogViewerWidget::sltResetSettingsToDefault);520 }521 440 } 522 441 … … 529 448 m_pActionFind->setShortcut(QKeySequence("Ctrl+F")); 530 449 m_pActionFind->setCheckable(true); 531 connect(m_pActionFind, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionT riggered);450 connect(m_pActionFind, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionToggled); 532 451 } 533 452 … … 538 457 m_pActionFilter->setShortcut(QKeySequence("Ctrl+T")); 539 458 m_pActionFilter->setCheckable(true); 540 connect(m_pActionFilter, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionT riggered);459 connect(m_pActionFilter, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionToggled); 541 460 } 542 461 /* Create and configure 'Bookmark' action: */ … … 549 468 m_pActionBookmarks->setShortcut(QKeySequence("Ctrl+D")); 550 469 m_pActionBookmarks->setCheckable(true); 551 connect(m_pActionBookmarks, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionT riggered);470 connect(m_pActionBookmarks, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionToggled); 552 471 } 553 472 … … 558 477 m_pActionSettings->setShortcut(QKeySequence("Ctrl+P")); 559 478 m_pActionSettings->setCheckable(true); 560 connect(m_pActionSettings, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionT riggered);479 connect(m_pActionSettings, &QAction::triggered, this, &UIVMLogViewerWidget::sltPanelActionToggled); 561 480 } 562 481 … … 586 505 void UIVMLogViewerWidget::prepareActionIcons() 587 506 { 588 QString strPrefix = "log_viewer";589 590 507 if (m_pActionFind) 591 m_pActionFind->setIcon(UIIconPool::iconSet(QString(":/ %1_find_22px.png").arg(strPrefix),592 QString(":/%1_find_disabled_22px.png").arg(strPrefix)));508 m_pActionFind->setIcon(UIIconPool::iconSet(QString(":/log_viewer_find_22px.png"), 509 QString(":/log_viewer_find_disabled_22px.png"))); 593 510 if (m_pActionFilter) 594 m_pActionFilter->setIcon(UIIconPool::iconSet(QString(":/ %1_filter_22px.png").arg(strPrefix),595 QString(":/%1_filter_disabled_22px.png").arg(strPrefix)));511 m_pActionFilter->setIcon(UIIconPool::iconSet(QString(":/log_viewer_filter_22px.png"), 512 QString(":/log_viewer_filter_disabled_22px.png"))); 596 513 if (m_pActionRefresh) 597 m_pActionRefresh->setIcon(UIIconPool::iconSet(QString(":/ %1_refresh_22px.png").arg(strPrefix),598 QString(":/%1_refresh_disabled_22px.png").arg(strPrefix)));514 m_pActionRefresh->setIcon(UIIconPool::iconSet(QString(":/log_viewer_refresh_22px.png"), 515 QString(":/log_viewer_refresh_disabled_22px.png"))); 599 516 if (m_pActionSave) 600 m_pActionSave->setIcon(UIIconPool::iconSet(QString(":/ %1_save_22px.png").arg(strPrefix),601 QString(":/%1_save_disabled_22px.png").arg(strPrefix)));517 m_pActionSave->setIcon(UIIconPool::iconSet(QString(":/log_viewer_save_22px.png"), 518 QString(":/log_viewer_save_disabled_22px.png"))); 602 519 if (m_pActionBookmarks) 603 m_pActionBookmarks->setIcon(UIIconPool::iconSet(QString(":/ %1_bookmark_22px.png").arg(strPrefix),604 QString(":/%1_bookmark_disabled_22px.png").arg(strPrefix)));520 m_pActionBookmarks->setIcon(UIIconPool::iconSet(QString(":/log_viewer_bookmark_22px.png"), 521 QString(":/log_viewer_bookmark_disabled_22px.png"))); 605 522 if (m_pActionSettings) 606 m_pActionSettings->setIcon(UIIconPool::iconSet(QString(":/ %1_settings_22px.png").arg(strPrefix),607 QString(":/ %1_settings_disabled_22px.png").arg(strPrefix)));523 m_pActionSettings->setIcon(UIIconPool::iconSet(QString(":/log_viewer_settings_22px.png"), 524 QString(":/log_viewer_settings_disabled_22px.png"))); 608 525 } 609 526 … … 618 535 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 619 536 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 537 620 538 /* Add toolbar actions: */ 621 539 if (m_pActionSave) … … 679 597 } 680 598 599 void UIVMLogViewerWidget::prepareWidgets() 600 { 601 /* Configure layout: */ 602 layout()->setContentsMargins(0, 0, 0, 0); 603 #ifdef VBOX_WS_MAC 604 layout()->setSpacing(10); 605 #else 606 layout()->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2); 607 #endif 608 609 /* Create VM Log-Viewer container: */ 610 m_pTabWidget = new QITabWidget; 611 if (m_pTabWidget) 612 { 613 /* Add into layout: */ 614 m_pMainLayout->addWidget(m_pTabWidget); 615 } 616 617 /* Create VM Log-Viewer search-panel: */ 618 m_pSearchPanel = new UIVMLogViewerSearchPanel(0, this); 619 if (m_pSearchPanel) 620 { 621 /* Configure VM Log-Viewer search-panel: */ 622 installEventFilter(m_pSearchPanel); 623 m_pSearchPanel->hide(); 624 connect(m_pSearchPanel, &UIVMLogViewerSearchPanel::sigHighlightingUpdated, 625 this, &UIVMLogViewerWidget::sltSearchResultHighLigting); 626 m_panelActionMap.insert(m_pSearchPanel, m_pActionFind); 627 628 /* Add into layout: */ 629 m_pMainLayout->addWidget(m_pSearchPanel); 630 } 631 632 /* Create VM Log-Viewer filter-panel: */ 633 m_pFilterPanel = new UIVMLogViewerFilterPanel(0, this); 634 if (m_pFilterPanel) 635 { 636 /* Configure VM Log-Viewer filter-panel: */ 637 installEventFilter(m_pFilterPanel); 638 m_pFilterPanel->hide(); 639 connect(m_pFilterPanel, &UIVMLogViewerFilterPanel::sigFilterApplied, 640 this, &UIVMLogViewerWidget::sltFilterApplied); 641 m_panelActionMap.insert(m_pFilterPanel, m_pActionFilter); 642 643 /* Add into layout: */ 644 m_pMainLayout->addWidget(m_pFilterPanel); 645 } 646 647 m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(0, this); 648 if (m_pBookmarksPanel) 649 { 650 /* Configure VM Log-Viewer bookmarks-panel: */ 651 m_pBookmarksPanel->hide(); 652 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmark, 653 this, &UIVMLogViewerWidget::sltDeleteBookmark); 654 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks, 655 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks); 656 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected, 657 this, &UIVMLogViewerWidget::gotoBookmark); 658 m_panelActionMap.insert(m_pBookmarksPanel, m_pActionBookmarks); 659 660 /* Add into layout: */ 661 m_pMainLayout->addWidget(m_pBookmarksPanel); 662 } 663 664 m_pSettingsPanel = new UIVMLogViewerSettingsPanel(0, this); 665 if (m_pSettingsPanel) 666 { 667 /* Configure VM Log-Viewer settings-panel: */ 668 m_pSettingsPanel->hide(); 669 m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers); 670 m_pSettingsPanel->setWrapLines(m_bWrapLines); 671 m_pSettingsPanel->setFontSizeInPoints(m_font.pointSize()); 672 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigShowLineNumbers, this, &UIVMLogViewerWidget::sltShowLineNumbers); 673 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigWrapLines, this, &UIVMLogViewerWidget::sltWrapLines); 674 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFontSizeInPoints, this, &UIVMLogViewerWidget::sltFontSizeChanged); 675 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigChangeFont, this, &UIVMLogViewerWidget::sltChangeFont); 676 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigResetToDefaults, this, &UIVMLogViewerWidget::sltResetSettingsToDefault); 677 m_panelActionMap.insert(m_pSettingsPanel, m_pActionSettings); 678 679 /* Add into layout: */ 680 m_pMainLayout->addWidget(m_pSettingsPanel); 681 } 682 } 683 684 void UIVMLogViewerWidget::loadSettings() 685 { 686 m_bWrapLines = gEDataManager->logViewerWrapLines(); 687 m_bShowLineNumbers = gEDataManager->logViewerShowLineNumbers(); 688 QFont loadedFont = gEDataManager->logViewerFont(); 689 if (loadedFont != QFont()) 690 m_font = loadedFont; 691 } 692 693 void UIVMLogViewerWidget::saveSettings() 694 { 695 gEDataManager->setLogViweverSettings(m_font, m_bWrapLines, m_bShowLineNumbers); 696 } 697 681 698 void UIVMLogViewerWidget::cleanup() 682 699 { 700 /* Save settings: */ 701 saveSettings(); 683 702 } 684 703 … … 807 826 } 808 827 809 const UIVMLogPage *UIVMLogViewerWidget::currentLogPage() const810 {811 int currentTabIndex = m_pTabWidget->currentIndex();812 if (currentTabIndex >= m_logPageList.size())813 return 0;814 return qobject_cast<const UIVMLogPage*>(m_logPageList.at(currentTabIndex));815 }816 UIVMLogPage *UIVMLogViewerWidget::currentLogPage()817 {818 int currentTabIndex = m_pTabWidget->currentIndex();819 if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1)820 return 0;821 822 return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex));823 }824 825 void UIVMLogViewerWidget::hidePanel(UIVMLogViewerPanel* panel)826 {827 if (panel && panel->isVisible())828 panel->setVisible(false);829 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);830 if (iterator != m_panelActionMap.end())831 {832 if (iterator.value() && iterator.value()->isChecked())833 iterator.value()->setChecked(false);834 }835 m_visiblePanelsList.removeOne(panel);836 manageEscapeShortCut();837 }838 839 void UIVMLogViewerWidget::showPanel(UIVMLogViewerPanel* panel)840 {841 if (panel && panel->isHidden())842 panel->setVisible(true);843 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);844 if (iterator != m_panelActionMap.end())845 {846 if (!iterator.value()->isChecked())847 iterator.value()->setChecked(true);848 }849 m_visiblePanelsList.push_back(panel);850 manageEscapeShortCut();851 }852 853 void UIVMLogViewerWidget::manageEscapeShortCut()854 {855 /* if there is no visible panels give the escape shortcut to parent dialog: */856 if (m_visiblePanelsList.isEmpty())857 {858 emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape));859 return;860 }861 /* Take the escape shortcut from the dialog: */862 emit sigSetCloseButtonShortCut(QKeySequence());863 /* Just loop thru the visible panel list and set the esc key to the864 panel which made visible latest */865 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)866 {867 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());868 }869 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));870 }871 872 828 QPlainTextEdit* UIVMLogViewerWidget::logPage(int pIndex) const 873 829 { … … 879 835 QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>(); 880 836 return pBrowser; 837 } 838 839 void UIVMLogViewerWidget::createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow /* = false */) 840 { 841 if (!m_pTabWidget) 842 return; 843 844 /* Create page-container: */ 845 UIVMLogPage* pLogPage = new UIVMLogPage(); 846 if (pLogPage) 847 { 848 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel); 849 connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged); 850 /* Initialize setting for this log page */ 851 pLogPage->setShowLineNumbers(m_bShowLineNumbers); 852 pLogPage->setWrapLines(m_bWrapLines); 853 pLogPage->setCurrentFont(m_font); 854 855 /* Set the file name only if we really have log file to read. */ 856 if (!noLogsToShow) 857 pLogPage->setLogFileName(strFileName); 858 859 /* Add page-container to viewer-container: */ 860 int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName()); 861 862 pLogPage->setTabIndex(tabIndex); 863 m_logPageList.resize(m_pTabWidget->count()); 864 m_logPageList[tabIndex] = pLogPage; 865 866 /* Set text edit since we want to display this text: */ 867 if (!noLogsToShow) 868 { 869 pLogPage->setTextEditText(strLogContent); 870 /* Set the log string of the UIVMLogPage: */ 871 pLogPage->setLogString(strLogContent); 872 } 873 /* In case there are some errors append the error text as html: */ 874 else 875 { 876 pLogPage->setTextEditTextAsHtml(strLogContent); 877 pLogPage->markForError(); 878 } 879 } 880 } 881 882 const UIVMLogPage *UIVMLogViewerWidget::currentLogPage() const 883 { 884 int currentTabIndex = m_pTabWidget->currentIndex(); 885 if (currentTabIndex >= m_logPageList.size()) 886 return 0; 887 return qobject_cast<const UIVMLogPage*>(m_logPageList.at(currentTabIndex)); 888 } 889 890 UIVMLogPage *UIVMLogViewerWidget::currentLogPage() 891 { 892 int currentTabIndex = m_pTabWidget->currentIndex(); 893 if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1) 894 return 0; 895 896 return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex)); 881 897 } 882 898 … … 939 955 } 940 956 941 void UIVMLogViewerWidget::createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow /* = false */)942 {943 if (!m_pTabWidget)944 return;945 946 /* Create page-container: */947 UIVMLogPage* pLogPage = new UIVMLogPage();948 if (pLogPage)949 {950 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel);951 connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged);952 /* Initialize setting for this log page */953 pLogPage->setShowLineNumbers(m_bShowLineNumbers);954 pLogPage->setWrapLines(m_bWrapLines);955 pLogPage->setCurrentFont(m_font);956 957 /* Set the file name only if we really have log file to read. */958 if (!noLogsToShow)959 pLogPage->setLogFileName(strFileName);960 961 /* Add page-container to viewer-container: */962 int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName());963 964 pLogPage->setTabIndex(tabIndex);965 m_logPageList.resize(m_pTabWidget->count());966 m_logPageList[tabIndex] = pLogPage;967 968 /* Set text edit since we want to display this text: */969 if (!noLogsToShow)970 {971 pLogPage->setTextEditText(strLogContent);972 /* Set the log string of the UIVMLogPage: */973 pLogPage->setLogString(strLogContent);974 }975 /* In case there are some errors append the error text as html: */976 else977 {978 pLogPage->setTextEditTextAsHtml(strLogContent);979 pLogPage->markForError();980 }981 }982 }983 984 957 void UIVMLogViewerWidget::resetHighlighthing() 985 958 { … … 992 965 } 993 966 994 QFont UIVMLogViewerWidget::currentFont() const 995 { 996 const UIVMLogPage* logPage = currentLogPage(); 997 if (!logPage) 998 return QFont(); 999 return logPage->currentFont(); 1000 } 967 void UIVMLogViewerWidget::hidePanel(UIVMLogViewerPanel* panel) 968 { 969 if (panel && panel->isVisible()) 970 panel->setVisible(false); 971 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 972 if (iterator != m_panelActionMap.end()) 973 { 974 if (iterator.value() && iterator.value()->isChecked()) 975 iterator.value()->setChecked(false); 976 } 977 m_visiblePanelsList.removeOne(panel); 978 manageEscapeShortCut(); 979 } 980 981 void UIVMLogViewerWidget::showPanel(UIVMLogViewerPanel* panel) 982 { 983 if (panel && panel->isHidden()) 984 panel->setVisible(true); 985 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 986 if (iterator != m_panelActionMap.end()) 987 { 988 if (!iterator.value()->isChecked()) 989 iterator.value()->setChecked(true); 990 } 991 m_visiblePanelsList.push_back(panel); 992 manageEscapeShortCut(); 993 } 994 995 void UIVMLogViewerWidget::manageEscapeShortCut() 996 { 997 /* if there is no visible panels give the escape shortcut to parent dialog: */ 998 if (m_visiblePanelsList.isEmpty()) 999 { 1000 emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 1001 return; 1002 } 1003 /* Take the escape shortcut from the dialog: */ 1004 emit sigSetCloseButtonShortCut(QKeySequence()); 1005 /* Just loop thru the visible panel list and set the esc key to the 1006 panel which made visible latest */ 1007 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 1008 { 1009 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 1010 } 1011 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 1012 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r72713 r73693 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVMLogViewer class declaration.3 * VBox Qt GUI - UIVMLogViewerWidget class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 57 57 58 58 public: 59 59 60 /** Constructs the VM Log-Viewer by passing @a pParent to QWidget base-class constructor. 60 * @param machine Specifies the machine for which VM Log-Viewer is requested. */ 61 UIVMLogViewerWidget(EmbedTo enmEmbedding, QWidget *pParent = 0, const CMachine &machine = CMachine()); 61 * @param enmEmbedding Brings the type of widget embedding. 62 * @param comMachine Brings the machine for which VM Log-Viewer is requested. */ 63 UIVMLogViewerWidget(EmbedTo enmEmbedding, 64 const CMachine &comMachine = CMachine(), QWidget *pParent = 0); 62 65 /** Destructs the VM Log-Viewer. */ 63 66 ~UIVMLogViewerWidget(); … … 73 76 #endif 74 77 75 /** Sets the machine whose logs to show. */76 void setMachine(const CMachine & machine);78 /** Defines the @a comMachine whose logs to show. */ 79 void setMachine(const CMachine &comMachine); 77 80 QFont currentFont() const; 78 81 … … 95 98 /** Receives delete all signal from the bookmark panel and notifies UIVMLogPage. */ 96 99 void sltDeleteAllBookmarks(); 97 /** Manages bookmark panel update when bookmark vector is updated */100 /** Manages bookmark panel update when bookmark vector is updated. */ 98 101 void sltUpdateBookmarkPanel(); 99 /* Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */102 /** Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */ 100 103 void gotoBookmark(int bookmarkIndex); 101 104 /** @} */ 102 105 103 void sltPanelActionT riggered(bool checked);106 void sltPanelActionToggled(bool fChecked); 104 107 /** Handles the search result highlight changes. */ 105 108 void sltSearchResultHighLigting(); … … 128 131 /** Prepares VM Log-Viewer. */ 129 132 void prepare(); 133 /** Prepares actions. */ 134 void prepareActions(); 135 /** Prepares action icons. */ 136 void prepareActionIcons(); 137 /** Prepares toolbar. */ 138 void prepareToolBar(); 139 /** Prepares menu. */ 140 void prepareMenu(); 130 141 /** Prepares widgets. */ 131 142 void prepareWidgets(); 132 void prepareActions();133 void prepareActionIcons();134 void prepareToolBar(); 135 void prepareMenu();136 143 /** Loads settings. */ 144 void loadSettings(); 145 146 /** Saves settings. */ 147 void saveSettings(); 137 148 /** Cleanups VM Log-Viewer. */ 138 149 void cleanup(); … … 142 153 * @{ */ 143 154 /** Handles translation event. */ 144 v oid retranslateUi();155 virtual void retranslateUi() /* override */; 145 156 146 157 /** Handles Qt show @a pEvent. */ 147 v oid showEvent(QShowEvent *pEvent);158 virtual void showEvent(QShowEvent *pEvent) /* override */; 148 159 /** Handles Qt key-press @a pEvent. */ 149 v oid keyPressEvent(QKeyEvent *pEvent);160 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 150 161 /** @} */ 151 162 … … 156 167 void createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow = false); 157 168 158 169 const UIVMLogPage *currentLogPage() const; 159 170 UIVMLogPage *currentLogPage(); 160 const UIVMLogPage *currentLogPage() const;161 171 162 172 /** Attempts to read the logs through the API, returns true if there exists any logs, false otherwise. */ … … 176 186 void manageEscapeShortCut(); 177 187 178 /** @name Load/save some settings from/to extra data 179 * @{ */ 180 void loadSettings(); 181 void saveSettings(); 182 /** @} */ 188 /** Holds the widget's embedding type. */ 189 const EmbedTo m_enmEmbedding; 190 /** Holds the machine instance. */ 191 CMachine m_comMachine; 183 192 184 193 /** Holds whether the dialog is polished. */ 185 194 bool m_fIsPolished; 186 187 /** Holds the machine instance. */188 CMachine m_comMachine;189 195 190 196 /** Holds container for log-pages. */ … … 204 210 /** @} */ 205 211 QVBoxLayout *m_pMainLayout; 206 207 /** Holds the widget's embedding type. */208 const EmbedTo m_enmEmbedding;209 212 210 213 /** @name Toolbar and menu variables. -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r73691 r73693 1077 1077 * a second call to this function and result in double delete!!!: */ 1078 1078 m_logViewers.erase(sendersIterator); 1079 UIVMLogViewerDialogFactory( CMachine()).cleanup(pDialog);1079 UIVMLogViewerDialogFactory().cleanup(pDialog); 1080 1080 } 1081 1081 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r72813 r73693 2413 2413 m_pLogViewerDialog = 0; 2414 2414 pDialog->close(); 2415 UIVMLogViewerDialogFactory( CMachine()).cleanup(pDialog);2415 UIVMLogViewerDialogFactory().cleanup(pDialog); 2416 2416 } 2417 2417 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r73533 r73693 1131 1131 this function and result in double delete!!!: */ 1132 1132 m_logViewers.erase(sendersIterator); 1133 UIVMLogViewerDialogFactory( CMachine()).cleanup(pDialog);1133 UIVMLogViewerDialogFactory().cleanup(pDialog); 1134 1134 } 1135 1135
Note:
See TracChangeset
for help on using the changeset viewer.