Changeset 86340 in vbox
- Timestamp:
- Sep 30, 2020 9:43:27 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r86337 r86340 990 990 src/globals/UIVirtualBoxEventHandler.cpp \ 991 991 src/globals/UIVirtualBoxClientEventHandler.cpp \ 992 src/helpbrowser/UIHelpBrowserWidget.cpp \ 992 993 src/logviewer/UIVMLogViewerFilterPanel.cpp \ 993 994 src/logviewer/UIVMLogViewerSearchPanel.cpp \ … … 1530 1531 UICommon_QT_MODULES.darwin += MacExtras 1531 1532 UICommon_QT_MODULES.win += WinExtras 1533 UICommon_QT_MODULES += Help 1532 1534 ifdef VBOX_GUI_WITH_QTGLFRAMEBUFFER 1533 1535 UICommon_QT_MODULES += OpenGL -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r86154 r86340 1372 1372 const QString strSuffix = "pdf"; 1373 1373 #elif defined(VBOX_WS_X11) 1374 # if defined(VBOX_OSE) || !defined(VBOX_WITH_KCHMVIEWER) 1374 # if defined(VBOX_WITH_DOCS_QHELP) 1375 const QString strName = "UserManual"; 1376 const QString strSuffix = "qhc"; 1377 # else 1375 1378 const QString strName = "UserManual"; 1376 1379 const QString strSuffix = "pdf"; 1377 # else1378 const QString strName = "VirtualBox";1379 const QString strSuffix = "chm";1380 1380 # endif 1381 1381 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r86337 r86340 3393 3393 } 3394 3394 3395 void UIMessageCenter::showHelpBrowser(const QString strHelpFileLocation, QWidget *pParent /* = 0 */) 3396 { 3397 Q_UNUSED(strHelpFileLocation); 3395 void UIMessageCenter::showHelpBrowser(const QString strHelpFilePath, QWidget *pParent /* = 0 */) 3396 { 3398 3397 QWidget *pDialogParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown()); 3399 3398 AssertReturnVoid(pDialogParent); … … 3401 3400 3402 3401 QIManagerDialog *pHelpBrowserDialog; 3403 UIHelpBrowserDialogFactory dialogFactory ;3402 UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath); 3404 3403 3405 3404 dialogFactory.prepare(pHelpBrowserDialog); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r86337 r86340 598 598 const QString &strAutoConfirmId) const; 599 599 600 void showHelpBrowser(const QString strHelpFile Location, QWidget *pParent = 0);600 void showHelpBrowser(const QString strHelpFilePath, QWidget *pParent = 0); 601 601 602 602 /** Holds the list of shown warnings. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.cpp
r86337 r86340 44 44 *********************************************************************************************************************************/ 45 45 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory() 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath /* = QString() */) 47 :m_strHelpFilePath(strHelpFilePath) 47 48 { 48 49 } … … 50 51 void UIHelpBrowserDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 51 52 { 52 pDialog = new UIHelpBrowserDialog(pCenterWidget );53 pDialog = new UIHelpBrowserDialog(pCenterWidget, m_strHelpFilePath); 53 54 } 54 55 … … 58 59 *********************************************************************************************************************************/ 59 60 60 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget )61 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath) 61 62 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 63 , m_strHelpFilePath(strHelpFilePath) 62 64 { 63 65 } … … 80 82 { 81 83 /* Create widget: */ 82 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, true /* show toolbar */, this);84 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath, true /* show toolbar */, this); 83 85 if (pWidget) 84 86 { … … 105 107 void UIHelpBrowserDialog::loadSettings() 106 108 { 107 /* Invent default window geometry: */108 const QRect availableGeo = gpDesktop->availableGeometry(this);109 int iDefaultWidth = availableGeo.width() / 2;110 int iDefaultHeight = availableGeo.height() * 3 / 4;111 /* Try obtain the default width of the current logviewer: */112 const UIHelpBrowserWidget *pWidget = qobject_cast<const UIHelpBrowserWidget*>(widget());113 if (pWidget)114 {115 const int iWidth = pWidget->defaultLogPageWidth();116 if (iWidth != 0)117 iDefaultWidth = iWidth;118 }119 QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);120 121 /* Load geometry from extradata: */122 const QRect geo = gEDataManager->logWindowGeometry(this, centerWidget(), defaultGeo);123 LogRel2(("GUI: UIHelpBrowserDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",124 geo.x(), geo.y(), geo.width(), geo.height()));125 restoreGeometry(geo);126 109 } 127 110 128 111 void UIHelpBrowserDialog::saveSettings() 129 112 { 130 /* Save geometry to extradata: */131 const QRect geo = currentGeometry();132 LogRel2(("GUI: UIHelpBrowserDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",133 geo.x(), geo.y(), geo.width(), geo.height()));134 gEDataManager->setLogWindowGeometry(geo, isCurrentlyMaximized());135 113 } 136 114 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.h
r86337 r86340 45 45 public: 46 46 47 UIHelpBrowserDialogFactory( );47 UIHelpBrowserDialogFactory(const QString &strHelpFilePath = QString()); 48 48 49 49 protected: … … 53 53 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */; 54 54 55 private: 56 57 QString m_strHelpFilePath; 55 58 }; 56 59 … … 63 66 public: 64 67 65 UIHelpBrowserDialog(QWidget *pCenterWidget );68 UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath); 66 69 67 70 protected: … … 101 104 private: 102 105 106 QString m_strHelpFilePath; 103 107 }; 104 108 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86338 r86340 20 20 #include <QDir> 21 21 #include <QFont> 22 #include <QtHelp/QHelpEngine> 23 #include <QHelpContentWidget> 22 24 #include <QMenu> 23 #include <QPainter>24 #include <QPlainTextEdit>25 25 #include <QScrollBar> 26 26 #include <QStyle> 27 #include <QTextB lock>28 #include <Q VBoxLayout>27 #include <QTextBrowser> 28 #include <QHBoxLayout> 29 29 #ifdef RT_OS_SOLARIS 30 30 # include <QFontDatabase> … … 50 50 #include "CSystemProperties.h" 51 51 52 class UIHelpBrowserViewer : public QTextBrowser 53 { 54 Q_OBJECT; 55 56 public: 57 58 UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0); 59 virtual QVariant loadResource(int type, const QUrl &name) /* override */; 60 61 private: 62 63 const QHelpEngine* m_pHelpEngine; 64 }; 65 66 UIHelpBrowserViewer::UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent /* = 0 */) 67 :QTextBrowser(pParent) 68 , m_pHelpEngine(pHelpEngine) 69 { 70 } 71 72 QVariant UIHelpBrowserViewer::loadResource(int type, const QUrl &name) 73 { 74 if (name.scheme() == "qthelp" && m_pHelpEngine) 75 return QVariant(m_pHelpEngine->fileData(name)); 76 else 77 return QTextBrowser::loadResource(type, name); 78 } 79 80 52 81 UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, 82 const QString &strHelpFilePath, 53 83 bool fShowToolbar /* = true */, 54 84 QWidget *pParent /* = 0 */) … … 57 87 , m_fShowToolbar(fShowToolbar) 58 88 , m_fIsPolished(false) 89 , m_pMainLayout(0) 59 90 , m_pTabWidget(0) 60 , m_pSearchPanel(0)61 , m_pFilterPanel(0)62 , m_pBookmarksPanel(0)63 , m_pOptionsPanel(0)64 , m_pMainLayout(0)65 91 , m_pToolBar(0) 66 , m_ bShowLineNumbers(true)67 , m_ bWrapLines(false)68 , m_ font(QFontDatabase::systemFont(QFontDatabase::FixedFont))92 , m_strHelpFilePath(strHelpFilePath) 93 , m_pHelpEngine(0) 94 , m_pTextBrowser(0) 69 95 { 70 96 /* Prepare VM Log-Viewer: */ 71 97 prepare(); 72 restorePanelVisibility();73 98 } 74 99 … … 79 104 } 80 105 81 int UIHelpBrowserWidget::defaultLogPageWidth() const82 {83 if (!m_pTabWidget)84 return 0;85 86 QWidget *pContainer = m_pTabWidget->currentWidget();87 if (!pContainer)88 return 0;89 90 QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();91 if (!pBrowser)92 return 0;93 /* Compute a width for 132 characters plus scrollbar and frame width: */94 int iDefaultWidth = pBrowser->fontMetrics().width(QChar('x')) * 132 +95 pBrowser->verticalScrollBar()->width() +96 pBrowser->frameWidth() * 2;97 98 return iDefaultWidth;99 }100 101 106 QMenu *UIHelpBrowserWidget::menu() const 102 107 { … … 104 109 } 105 110 106 QFont UIHelpBrowserWidget::currentFont() const107 {108 const UIVMLogPage* logPage = currentLogPage();109 if (!logPage)110 return QFont();111 return logPage->currentFont();112 }113 111 114 112 bool UIHelpBrowserWidget::shouldBeMaximized() const … … 117 115 } 118 116 119 void UIHelpBrowserWidget::sltDeleteBookmark(int index) 120 { 121 UIVMLogPage* logPage = currentLogPage(); 122 if (!logPage) 123 return; 124 logPage->deleteBookmark(index); 125 if (m_pBookmarksPanel) 126 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 127 } 128 129 void UIHelpBrowserWidget::sltDeleteAllBookmarks() 130 { 131 UIVMLogPage* logPage = currentLogPage(); 132 if (!logPage) 133 return; 134 logPage->deleteAllBookmarks(); 135 136 if (m_pBookmarksPanel) 137 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 138 } 139 140 void UIHelpBrowserWidget::sltUpdateBookmarkPanel() 141 { 142 if (!currentLogPage() || !m_pBookmarksPanel) 143 return; 144 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 145 } 146 147 void UIHelpBrowserWidget::gotoBookmark(int bookmarkIndex) 148 { 149 if (!currentLogPage()) 150 return; 151 currentLogPage()->scrollToBookmark(bookmarkIndex); 152 } 153 154 void UIHelpBrowserWidget::sltPanelActionToggled(bool fChecked) 155 { 156 QAction *pSenderAction = qobject_cast<QAction*>(sender()); 157 if (!pSenderAction) 158 return; 159 UIDialogPanel* pPanel = 0; 160 /* Look for the sender() within the m_panelActionMap's values: */ 161 for (QMap<UIDialogPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin(); 162 iterator != m_panelActionMap.end(); ++iterator) 117 void UIHelpBrowserWidget::prepare() 118 { 119 loadOptions(); 120 121 prepareActions(); 122 prepareWidgets(); 123 124 if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine) 163 125 { 164 if (iterator.value() == pSenderAction)165 pPanel = iterator.key();126 m_pHelpEngine->setupData(); 127 //m_pHelpEngine->registerDocumentation(m_strHelpFilePath)); 166 128 } 167 if (!pPanel) 168 return; 169 if (fChecked) 170 showPanel(pPanel); 171 else 172 hidePanel(pPanel); 173 } 174 175 void UIHelpBrowserWidget::sltSearchResultHighLigting() 176 { 177 if (!m_pSearchPanel || !currentLogPage()) 178 return; 179 currentLogPage()->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector()); 180 } 181 182 void UIHelpBrowserWidget::sltHandleSearchUpdated() 183 { 184 if (!m_pSearchPanel || !currentLogPage()) 185 return; 186 } 187 188 void UIHelpBrowserWidget::sltTabIndexChange(int tabIndex) 189 { 190 Q_UNUSED(tabIndex); 191 192 /* Dont refresh the search here as it is refreshed by the filtering mechanism 193 which is updated as tab current index changes: */ 194 195 /* We keep a separate QVector<LogBookmark> for each log page: */ 196 if (m_pBookmarksPanel && currentLogPage()) 197 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 198 } 199 200 void UIHelpBrowserWidget::sltFilterApplied(bool isOriginal) 201 { 202 if (currentLogPage()) 203 currentLogPage()->setFiltered(!isOriginal); 204 /* Reapply the search to get highlighting etc. correctly */ 205 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 206 m_pSearchPanel->refresh(); 207 } 208 209 void UIHelpBrowserWidget::sltLogPageFilteredChanged(bool isFiltered) 210 { 211 /* Disable bookmark panel since bookmarks are stored as line numbers within 212 the original log text and does not mean much in a reduced/filtered one. */ 213 if (m_pBookmarksPanel) 214 m_pBookmarksPanel->disableEnableBookmarking(!isFiltered); 215 } 216 217 void UIHelpBrowserWidget::sltHandleHidePanel(UIDialogPanel *pPanel) 218 { 219 hidePanel(pPanel); 220 } 221 222 void UIHelpBrowserWidget::sltShowLineNumbers(bool bShowLineNumbers) 223 { 224 if (m_bShowLineNumbers == bShowLineNumbers) 225 return; 226 227 m_bShowLineNumbers = bShowLineNumbers; 228 /* Set all log page instances. */ 229 for (int i = 0; i < m_logPageList.size(); ++i) 230 { 231 UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]); 232 if (pLogPage) 233 pLogPage->setShowLineNumbers(m_bShowLineNumbers); 234 } 235 } 236 237 void UIHelpBrowserWidget::sltWrapLines(bool bWrapLines) 238 { 239 if (m_bWrapLines == bWrapLines) 240 return; 241 242 m_bWrapLines = bWrapLines; 243 /* Set all log page instances. */ 244 for (int i = 0; i < m_logPageList.size(); ++i) 245 { 246 UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]); 247 if (pLogPage) 248 pLogPage->setWrapLines(m_bWrapLines); 249 } 250 } 251 252 void UIHelpBrowserWidget::sltFontSizeChanged(int fontSize) 253 { 254 if (m_font.pointSize() == fontSize) 255 return; 256 m_font.setPointSize(fontSize); 257 for (int i = 0; i < m_logPageList.size(); ++i) 258 { 259 UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]); 260 if (pLogPage) 261 pLogPage->setCurrentFont(m_font); 262 } 263 } 264 265 void UIHelpBrowserWidget::sltChangeFont(QFont font) 266 { 267 if (m_font == font) 268 return; 269 m_font = font; 270 for (int i = 0; i < m_logPageList.size(); ++i) 271 { 272 UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]); 273 if (pLogPage) 274 pLogPage->setCurrentFont(m_font); 275 } 276 } 277 278 void UIHelpBrowserWidget::sltResetOptionsToDefault() 279 { 280 sltShowLineNumbers(true); 281 sltWrapLines(false); 282 sltChangeFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); 283 284 if (m_pOptionsPanel) 285 { 286 m_pOptionsPanel->setShowLineNumbers(true); 287 m_pOptionsPanel->setWrapLines(false); 288 m_pOptionsPanel->setFontSizeInPoints(m_font.pointSize()); 289 } 290 } 291 292 void UIHelpBrowserWidget::prepare() 293 { 294 /* Load options: */ 295 loadOptions(); 296 297 /* Prepare stuff: */ 298 prepareActions(); 299 /* Prepare widgets: */ 300 prepareWidgets(); 301 302 /* Apply language settings: */ 129 303 130 retranslateUi(); 304 305 /* Setup escape shortcut: */306 manageEscapeShortCut();307 131 } 308 132 … … 315 139 { 316 140 /* Create main layout: */ 317 m_pMainLayout = new Q VBoxLayout(this);141 m_pMainLayout = new QHBoxLayout(this); 318 142 AssertReturnVoid(m_pMainLayout); 143 m_pHelpEngine = new QHelpEngine(m_strHelpFilePath, this); 144 connect(m_pHelpEngine, &QHelpEngine::setupFinished, 145 this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished); 146 147 // m_pTabWidget = new QITabWidget; 148 // m_pMainLayout->addWidget(m_pTabWidget); 149 m_pTextBrowser = new UIHelpBrowserViewer(m_pHelpEngine); 150 AssertReturnVoid(m_pTextBrowser); 151 m_pMainLayout->addWidget(m_pTextBrowser); 319 152 } 320 153 … … 347 180 void UIHelpBrowserWidget::loadOptions() 348 181 { 349 m_bWrapLines = gEDataManager->logViewerWrapLines();350 m_bShowLineNumbers = gEDataManager->logViewerShowLineNumbers();351 QFont loadedFont = gEDataManager->logViewerFont();352 if (loadedFont != QFont())353 m_font = loadedFont;354 }355 356 void UIHelpBrowserWidget::restorePanelVisibility()357 {358 /** Reset the action states first: */359 foreach(QAction* pAction, m_panelActionMap.values())360 {361 pAction->blockSignals(true);362 pAction->setChecked(false);363 pAction->blockSignals(false);364 }365 366 /* Load the visible panel list and show them: */367 QStringList strNameList = gEDataManager->logViewerVisiblePanels();368 foreach(const QString strName, strNameList)369 {370 foreach(UIDialogPanel* pPanel, m_panelActionMap.keys())371 {372 if (strName == pPanel->panelName())373 {374 showPanel(pPanel);375 break;376 }377 }378 }379 182 } 380 183 381 184 void UIHelpBrowserWidget::saveOptions() 382 185 { 383 /* Save a list of currently visible panels: */384 QStringList strNameList;385 foreach(UIDialogPanel* pPanel, m_visiblePanelsList)386 strNameList.append(pPanel->panelName());387 gEDataManager->setLogViewerVisiblePanels(strNameList);388 389 gEDataManager->setLogViweverOptions(m_font, m_bWrapLines, m_bShowLineNumbers);390 186 } 391 187 … … 428 224 void UIHelpBrowserWidget::keyPressEvent(QKeyEvent *pEvent) 429 225 { 430 /* Depending on key pressed: */ 431 switch (pEvent->key()) 432 { 433 /* Process Back key as switch to previous tab: */ 434 case Qt::Key_Back: 435 { 436 if (m_pTabWidget->currentIndex() > 0) 437 { 438 m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() - 1); 439 return; 440 } 441 break; 442 } 443 /* Process Forward key as switch to next tab: */ 444 case Qt::Key_Forward: 445 { 446 if (m_pTabWidget->currentIndex() < m_pTabWidget->count()) 447 { 448 m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() + 1); 449 return; 450 } 451 break; 452 } 453 default: 454 break; 455 } 456 QWidget::keyPressEvent(pEvent); 457 } 458 459 QPlainTextEdit* UIHelpBrowserWidget::logPage(int pIndex) const 460 { 461 if (!m_pTabWidget->isEnabled()) 462 return 0; 463 QWidget* pContainer = m_pTabWidget->widget(pIndex); 464 if (!pContainer) 465 return 0; 466 QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>(); 467 return pBrowser; 468 } 469 470 void UIHelpBrowserWidget::createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow /* = false */) 471 { 472 if (!m_pTabWidget) 473 return; 474 475 /* Create page-container: */ 476 UIVMLogPage* pLogPage = new UIVMLogPage(); 477 if (pLogPage) 478 { 479 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIHelpBrowserWidget::sltUpdateBookmarkPanel); 480 connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIHelpBrowserWidget::sltLogPageFilteredChanged); 481 /* Initialize setting for this log page */ 482 pLogPage->setShowLineNumbers(m_bShowLineNumbers); 483 pLogPage->setWrapLines(m_bWrapLines); 484 pLogPage->setCurrentFont(m_font); 485 486 /* Set the file name only if we really have log file to read. */ 487 if (!noLogsToShow) 488 pLogPage->setLogFileName(strFileName); 489 490 /* Add page-container to viewer-container: */ 491 int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName()); 492 493 pLogPage->setTabIndex(tabIndex); 494 m_logPageList.resize(m_pTabWidget->count()); 495 m_logPageList[tabIndex] = pLogPage; 496 497 /* Set text edit since we want to display this text: */ 498 if (!noLogsToShow) 499 { 500 pLogPage->setTextEditText(strLogContent); 501 /* Set the log string of the UIVMLogPage: */ 502 pLogPage->setLogString(strLogContent); 503 } 504 /* In case there are some errors append the error text as html: */ 505 else 506 { 507 pLogPage->setTextEditTextAsHtml(strLogContent); 508 pLogPage->markForError(); 509 } 510 pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector()); 511 } 512 } 513 514 const UIVMLogPage *UIHelpBrowserWidget::currentLogPage() const 515 { 516 int currentTabIndex = m_pTabWidget->currentIndex(); 517 if (currentTabIndex >= m_logPageList.size()) 518 return 0; 519 return qobject_cast<const UIVMLogPage*>(m_logPageList.at(currentTabIndex)); 520 } 521 522 UIVMLogPage *UIHelpBrowserWidget::currentLogPage() 523 { 524 int currentTabIndex = m_pTabWidget->currentIndex(); 525 if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1) 526 return 0; 527 528 return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex)); 529 } 530 531 void UIHelpBrowserWidget::resetHighlighthing() 532 { 533 /* Undo the document changes to remove highlighting: */ 534 UIVMLogPage* logPage = currentLogPage(); 535 if (!logPage) 536 return; 537 logPage->documentUndo(); 538 logPage->clearScrollBarMarkingsVector(); 539 } 540 541 void UIHelpBrowserWidget::hidePanel(UIDialogPanel* panel) 542 { 543 if (!panel) 544 return; 545 if (panel->isVisible()) 546 panel->setVisible(false); 547 QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 548 if (iterator != m_panelActionMap.end()) 549 { 550 if (iterator.value() && iterator.value()->isChecked()) 551 iterator.value()->setChecked(false); 552 } 553 m_visiblePanelsList.removeOne(panel); 554 manageEscapeShortCut(); 555 } 556 557 void UIHelpBrowserWidget::showPanel(UIDialogPanel* panel) 558 { 559 if (panel && panel->isHidden()) 560 panel->setVisible(true); 561 QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 562 if (iterator != m_panelActionMap.end()) 563 { 564 if (!iterator.value()->isChecked()) 565 iterator.value()->setChecked(true); 566 } 567 m_visiblePanelsList.push_back(panel); 568 manageEscapeShortCut(); 569 } 570 571 void UIHelpBrowserWidget::manageEscapeShortCut() 572 { 573 /* if there is no visible panels give the escape shortcut to parent dialog: */ 574 if (m_visiblePanelsList.isEmpty()) 575 { 576 emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 577 return; 578 } 579 /* Take the escape shortcut from the dialog: */ 580 emit sigSetCloseButtonShortCut(QKeySequence()); 581 /* Just loop thru the visible panel list and set the esc key to the 582 panel which made visible latest */ 583 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 584 { 585 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 586 } 587 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 588 } 226 QWidget::keyPressEvent(pEvent); 227 } 228 229 230 void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished() 231 { 232 AssertReturnVoid(m_pTextBrowser && m_pHelpEngine); 233 234 QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList()); 235 m_pTextBrowser->setSource(files[0]); 236 } 237 238 #include "UIHelpBrowserWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86337 r86340 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_ logviewer_UIHelpBrowserWidget_h19 #define FEQT_INCLUDED_SRC_ logviewer_UIHelpBrowserWidget_h18 #ifndef FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h 19 #define FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 23 23 24 24 /* Qt includes: */ 25 25 26 #include <QKeySequence> 26 27 #include <QPair> … … 36 37 37 38 /* Forward declarations: */ 39 class QHelpEngine; 40 class QPlainTextEdit; 41 class UIHelpBrowserViewer; 42 class QHBoxLayout; 38 43 class QITabWidget; 39 class QPlainTextEdit; 40 class QVBoxLayout; 44 class QIToolBar; 41 45 class UIActionPool; 42 46 class UIDialogPanel; 43 class QIToolBar;44 class UIVMLogPage;45 class UIVMLogViewerBookmarksPanel;46 class UIVMLogViewerFilterPanel;47 class UIVMLogViewerPanel;48 class UIVMLogViewerSearchPanel;49 class UIVMLogViewerOptionsPanel;50 47 51 48 /** QWidget extension providing GUI for VirtualBox LogViewer. It … … 65 62 * @param enmEmbedding Brings the type of widget embedding. 66 63 * @param fShowToolbar Brings whether we should create/show toolbar.*/ 67 UIHelpBrowserWidget(EmbedTo enmEmbedding, 64 UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, 68 65 bool fShowToolbar = true, QWidget *pParent = 0); 69 66 /** Destructs the VM Log-Viewer. */ 70 67 ~UIHelpBrowserWidget(); 71 /** Returns the width of the current log page. return 0 if there is no current log page: */72 int defaultLogPageWidth() const;73 68 74 69 /** Returns the menu. */ … … 80 75 #endif 81 76 82 QFont currentFont() const;83 77 84 78 protected: … … 89 83 private slots: 90 84 91 /** @name Bookmark related slots 92 * @{ */ 93 /** Deletes the bookmark with @p index from the current logs bookmark list. */ 94 void sltDeleteBookmark(int index); 95 /** Receives delete all signal from the bookmark panel and notifies UIVMLogPage. */ 96 void sltDeleteAllBookmarks(); 97 /** Manages bookmark panel update when bookmark vector is updated. */ 98 void sltUpdateBookmarkPanel(); 99 /** Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */ 100 void gotoBookmark(int bookmarkIndex); 101 /** @} */ 102 103 void sltPanelActionToggled(bool fChecked); 104 /** Handles the search result highlight changes. */ 105 void sltSearchResultHighLigting(); 106 void sltHandleSearchUpdated(); 107 /** Handles the tab change of the logviewer. */ 108 void sltTabIndexChange(int tabIndex); 109 /* if @a isOriginal true than the result of the filtering is equal to 110 the original log file for some reason. */ 111 void sltFilterApplied(bool isOriginal); 112 /* Handles the UIVMLogPage signal which is emitted when isFiltered property 113 of UIVMLogPage is changed. */ 114 void sltLogPageFilteredChanged(bool isFiltered); 115 void sltHandleHidePanel(UIDialogPanel *pPanel); 116 117 /** @name Slots to handle signals from settings panel 118 * @{ */ 119 void sltShowLineNumbers(bool bShowLineNumbers); 120 void sltWrapLines(bool bWrapLine); 121 void sltFontSizeChanged(int fontSize); 122 void sltChangeFont(QFont font); 123 void sltResetOptionsToDefault(); 124 /** @} */ 85 void sltHandleHelpEngineSetupFinished(); 125 86 126 87 private: 127 88 128 /** @name Prepare/Cleanup 129 * @{ */ 130 /** Prepares VM Log-Viewer. */ 131 void prepare(); 132 /** Prepares actions. */ 133 void prepareActions(); 134 /** Prepares widgets. */ 135 void prepareWidgets(); 136 /** Prepares toolbar. */ 137 void prepareToolBar(); 138 /** Loads options. */ 139 void loadOptions(); 140 /** Shows the panels that have been visible the last time logviewer is closed. */ 141 void restorePanelVisibility(); 89 void prepare(); 90 void prepareActions(); 91 void prepareWidgets(); 92 void prepareToolBar(); 93 void loadOptions(); 142 94 143 /** Saves options. */ 144 void saveOptions(); 145 /** Cleanups VM Log-Viewer. */ 146 void cleanup(); 147 /** @} */ 95 void saveOptions(); 96 void cleanup(); 148 97 149 98 /** @name Event handling stuff. … … 158 107 /** @} */ 159 108 160 161 /** Returns the log-page from the tab with index @a pIndex. */162 QPlainTextEdit* logPage(int pIndex) const;163 /** Returns the newly created log-page using @a strPage filename. */164 void createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow = false);165 166 const UIVMLogPage *currentLogPage() const;167 UIVMLogPage *currentLogPage();168 169 /** Resets document (of the curent tab) and scrollbar highligthing */170 void resetHighlighthing();171 172 void hidePanel(UIDialogPanel* panel);173 void showPanel(UIDialogPanel* panel);174 175 /** Make sure escape key is assigned to only a single widget. This is done by checking176 several things in the following order:177 - when there are no more panels visible assign it to the parent dialog178 - grab it from the dialog as soon as a panel becomes visible again179 - assigned it to the most recently "unhidden" panel */180 void manageEscapeShortCut();181 182 109 /** Holds the widget's embedding type. */ 183 110 const EmbedTo m_enmEmbedding; … … 191 118 192 119 /** Holds container for log-pages. */ 193 QITabWidget *m_pTabWidget; 194 /** Stores the UIVMLogPage instances. This is modified as we add and remove new tabs 195 * to the m_pTabWidget. Index is the index of the tab widget. */ 196 QVector<QWidget*> m_logPageList; 197 198 /** @name Panel instances and a QMap for mapping panel instances to related actions. 199 * @{ */ 200 UIVMLogViewerSearchPanel *m_pSearchPanel; 201 UIVMLogViewerFilterPanel *m_pFilterPanel; 202 UIVMLogViewerBookmarksPanel *m_pBookmarksPanel; 203 UIVMLogViewerOptionsPanel *m_pOptionsPanel; 204 QMap<UIDialogPanel*, QAction*> m_panelActionMap; 205 QList<UIDialogPanel*> m_visiblePanelsList; 206 /** @} */ 207 QVBoxLayout *m_pMainLayout; 208 120 QHBoxLayout *m_pMainLayout; 121 QITabWidget *m_pTabWidget; 209 122 /** @name Toolbar and menu variables. 210 123 * @{ */ … … 212 125 /** @} */ 213 126 214 /** @name Toolbar and menu variables. Cache these to restore them after refresh. 215 * @{ */ 216 /** Showing/hiding line numbers and line wraping options are set per 217 UIHelpBrowserWidget and applies to all log pages (all tabs) */ 218 bool m_bShowLineNumbers; 219 bool m_bWrapLines; 220 QFont m_font; 221 /** @} */ 127 QString m_strHelpFilePath; 128 QHelpEngine *m_pHelpEngine; 129 UIHelpBrowserViewer *m_pTextBrowser; 222 130 }; 223 131 224 #endif /* !FEQT_INCLUDED_SRC_ logviewer_UIHelpBrowserWidget_h */132 #endif /* !FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h */
Note:
See TracChangeset
for help on using the changeset viewer.