Changeset 86341 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 30, 2020 10:22:52 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 140630
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r86340 r86341 990 990 src/globals/UIVirtualBoxEventHandler.cpp \ 991 991 src/globals/UIVirtualBoxClientEventHandler.cpp \ 992 src/helpbrowser/UIHelpBrowserWidget.cpp \993 992 src/logviewer/UIVMLogViewerFilterPanel.cpp \ 994 993 src/logviewer/UIVMLogViewerSearchPanel.cpp \ … … 1531 1530 UICommon_QT_MODULES.darwin += MacExtras 1532 1531 UICommon_QT_MODULES.win += WinExtras 1533 UICommon_QT_MODULES += Help1534 1532 ifdef VBOX_GUI_WITH_QTGLFRAMEBUFFER 1535 1533 UICommon_QT_MODULES += OpenGL -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r86340 r86341 1372 1372 const QString strSuffix = "pdf"; 1373 1373 #elif defined(VBOX_WS_X11) 1374 # if defined(VBOX_WITH_DOCS_QHELP) 1375 const QString strName = "UserManual"; 1376 const QString strSuffix = "qhc"; 1377 # else 1374 # if defined(VBOX_OSE) || !defined(VBOX_WITH_KCHMVIEWER) 1378 1375 const QString strName = "UserManual"; 1379 1376 const QString strSuffix = "pdf"; 1377 # else 1378 const QString strName = "VirtualBox"; 1379 const QString strSuffix = "chm"; 1380 1380 # endif 1381 1381 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r86340 r86341 3393 3393 } 3394 3394 3395 void UIMessageCenter::showHelpBrowser(const QString strHelpFilePath, QWidget *pParent /* = 0 */) 3396 { 3395 void UIMessageCenter::showHelpBrowser(const QString strHelpFileLocation, QWidget *pParent /* = 0 */) 3396 { 3397 Q_UNUSED(strHelpFileLocation); 3397 3398 QWidget *pDialogParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown()); 3398 3399 AssertReturnVoid(pDialogParent); … … 3400 3401 3401 3402 QIManagerDialog *pHelpBrowserDialog; 3402 UIHelpBrowserDialogFactory dialogFactory (strHelpFilePath);3403 UIHelpBrowserDialogFactory dialogFactory; 3403 3404 3404 3405 dialogFactory.prepare(pHelpBrowserDialog); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r86340 r86341 598 598 const QString &strAutoConfirmId) const; 599 599 600 void showHelpBrowser(const QString strHelpFile Path, QWidget *pParent = 0);600 void showHelpBrowser(const QString strHelpFileLocation, QWidget *pParent = 0); 601 601 602 602 /** Holds the list of shown warnings. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.cpp
r86340 r86341 44 44 *********************************************************************************************************************************/ 45 45 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath /* = QString() */) 47 :m_strHelpFilePath(strHelpFilePath) 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory() 48 47 { 49 48 } … … 51 50 void UIHelpBrowserDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 52 51 { 53 pDialog = new UIHelpBrowserDialog(pCenterWidget , m_strHelpFilePath);52 pDialog = new UIHelpBrowserDialog(pCenterWidget); 54 53 } 55 54 … … 59 58 *********************************************************************************************************************************/ 60 59 61 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget , const QString &strHelpFilePath)60 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget) 62 61 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 63 , m_strHelpFilePath(strHelpFilePath)64 62 { 65 63 } … … 82 80 { 83 81 /* Create widget: */ 84 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath,true /* show toolbar */, this);82 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, true /* show toolbar */, this); 85 83 if (pWidget) 86 84 { … … 107 105 void UIHelpBrowserDialog::loadSettings() 108 106 { 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); 109 126 } 110 127 111 128 void UIHelpBrowserDialog::saveSettings() 112 129 { 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()); 113 135 } 114 136 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.h
r86340 r86341 45 45 public: 46 46 47 UIHelpBrowserDialogFactory( const QString &strHelpFilePath = QString());47 UIHelpBrowserDialogFactory(); 48 48 49 49 protected: … … 53 53 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */; 54 54 55 private:56 57 QString m_strHelpFilePath;58 55 }; 59 56 … … 66 63 public: 67 64 68 UIHelpBrowserDialog(QWidget *pCenterWidget , const QString &strHelpFilePath);65 UIHelpBrowserDialog(QWidget *pCenterWidget); 69 66 70 67 protected: … … 104 101 private: 105 102 106 QString m_strHelpFilePath;107 103 }; 108 104 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86340 r86341 20 20 #include <QDir> 21 21 #include <QFont> 22 #include <QtHelp/QHelpEngine>23 #include <QHelpContentWidget>24 22 #include <QMenu> 23 #include <QPainter> 24 #include <QPlainTextEdit> 25 25 #include <QScrollBar> 26 26 #include <QStyle> 27 #include <QTextB rowser>28 #include <Q HBoxLayout>27 #include <QTextBlock> 28 #include <QVBoxLayout> 29 29 #ifdef RT_OS_SOLARIS 30 30 # include <QFontDatabase> … … 50 50 #include "CSystemProperties.h" 51 51 52 class UIHelpBrowserViewer : public QTextBrowser53 {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 else77 return QTextBrowser::loadResource(type, name);78 }79 80 81 52 UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, 82 const QString &strHelpFilePath,83 53 bool fShowToolbar /* = true */, 84 54 QWidget *pParent /* = 0 */) … … 87 57 , m_fShowToolbar(fShowToolbar) 88 58 , m_fIsPolished(false) 59 , m_pTabWidget(0) 60 , m_pSearchPanel(0) 61 , m_pFilterPanel(0) 62 , m_pBookmarksPanel(0) 63 , m_pOptionsPanel(0) 89 64 , m_pMainLayout(0) 90 , m_pTabWidget(0)91 65 , m_pToolBar(0) 92 , m_ strHelpFilePath(strHelpFilePath)93 , m_ pHelpEngine(0)94 , m_ pTextBrowser(0)66 , m_bShowLineNumbers(true) 67 , m_bWrapLines(false) 68 , m_font(QFontDatabase::systemFont(QFontDatabase::FixedFont)) 95 69 { 96 70 /* Prepare VM Log-Viewer: */ 97 71 prepare(); 72 restorePanelVisibility(); 98 73 } 99 74 … … 104 79 } 105 80 81 int UIHelpBrowserWidget::defaultLogPageWidth() const 82 { 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 106 101 QMenu *UIHelpBrowserWidget::menu() const 107 102 { … … 109 104 } 110 105 106 QFont UIHelpBrowserWidget::currentFont() const 107 { 108 const UIVMLogPage* logPage = currentLogPage(); 109 if (!logPage) 110 return QFont(); 111 return logPage->currentFont(); 112 } 111 113 112 114 bool UIHelpBrowserWidget::shouldBeMaximized() const … … 115 117 } 116 118 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) 163 { 164 if (iterator.value() == pSenderAction) 165 pPanel = iterator.key(); 166 } 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 117 292 void UIHelpBrowserWidget::prepare() 118 293 { 294 /* Load options: */ 119 295 loadOptions(); 120 296 297 /* Prepare stuff: */ 121 298 prepareActions(); 299 /* Prepare widgets: */ 122 300 prepareWidgets(); 123 301 124 if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine) 125 { 126 m_pHelpEngine->setupData(); 127 //m_pHelpEngine->registerDocumentation(m_strHelpFilePath)); 128 } 129 302 /* Apply language settings: */ 130 303 retranslateUi(); 304 305 /* Setup escape shortcut: */ 306 manageEscapeShortCut(); 131 307 } 132 308 … … 139 315 { 140 316 /* Create main layout: */ 141 m_pMainLayout = new Q HBoxLayout(this);317 m_pMainLayout = new QVBoxLayout(this); 142 318 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);152 319 } 153 320 … … 180 347 void UIHelpBrowserWidget::loadOptions() 181 348 { 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 } 182 379 } 183 380 184 381 void UIHelpBrowserWidget::saveOptions() 185 382 { 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); 186 390 } 187 391 … … 224 428 void UIHelpBrowserWidget::keyPressEvent(QKeyEvent *pEvent) 225 429 { 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" 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 } -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86340 r86341 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_ helpbrowser_UIHelpBrowserWidget_h19 #define FEQT_INCLUDED_SRC_ helpbrowser_UIHelpBrowserWidget_h18 #ifndef FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h 19 #define FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 23 23 24 24 /* Qt includes: */ 25 26 25 #include <QKeySequence> 27 26 #include <QPair> … … 37 36 38 37 /* Forward declarations: */ 39 class Q HelpEngine;38 class QITabWidget; 40 39 class QPlainTextEdit; 41 class UIHelpBrowserViewer; 42 class QHBoxLayout; 43 class QITabWidget; 44 class QIToolBar; 40 class QVBoxLayout; 45 41 class UIActionPool; 46 42 class UIDialogPanel; 43 class QIToolBar; 44 class UIVMLogPage; 45 class UIVMLogViewerBookmarksPanel; 46 class UIVMLogViewerFilterPanel; 47 class UIVMLogViewerPanel; 48 class UIVMLogViewerSearchPanel; 49 class UIVMLogViewerOptionsPanel; 47 50 48 51 /** QWidget extension providing GUI for VirtualBox LogViewer. It … … 62 65 * @param enmEmbedding Brings the type of widget embedding. 63 66 * @param fShowToolbar Brings whether we should create/show toolbar.*/ 64 UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath,67 UIHelpBrowserWidget(EmbedTo enmEmbedding, 65 68 bool fShowToolbar = true, QWidget *pParent = 0); 66 69 /** Destructs the VM Log-Viewer. */ 67 70 ~UIHelpBrowserWidget(); 71 /** Returns the width of the current log page. return 0 if there is no current log page: */ 72 int defaultLogPageWidth() const; 68 73 69 74 /** Returns the menu. */ … … 75 80 #endif 76 81 82 QFont currentFont() const; 77 83 78 84 protected: … … 83 89 private slots: 84 90 85 void sltHandleHelpEngineSetupFinished(); 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 /** @} */ 86 125 87 126 private: 88 127 89 void prepare(); 90 void prepareActions(); 91 void prepareWidgets(); 92 void prepareToolBar(); 93 void loadOptions(); 94 95 void saveOptions(); 96 void cleanup(); 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(); 142 143 /** Saves options. */ 144 void saveOptions(); 145 /** Cleanups VM Log-Viewer. */ 146 void cleanup(); 147 /** @} */ 97 148 98 149 /** @name Event handling stuff. … … 106 157 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 107 158 /** @} */ 159 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 checking 176 several things in the following order: 177 - when there are no more panels visible assign it to the parent dialog 178 - grab it from the dialog as soon as a panel becomes visible again 179 - assigned it to the most recently "unhidden" panel */ 180 void manageEscapeShortCut(); 108 181 109 182 /** Holds the widget's embedding type. */ … … 118 191 119 192 /** Holds container for log-pages. */ 120 QHBoxLayout *m_pMainLayout; 121 QITabWidget *m_pTabWidget; 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 122 209 /** @name Toolbar and menu variables. 123 210 * @{ */ … … 125 212 /** @} */ 126 213 127 QString m_strHelpFilePath; 128 QHelpEngine *m_pHelpEngine; 129 UIHelpBrowserViewer *m_pTextBrowser; 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 /** @} */ 130 222 }; 131 223 132 #endif /* !FEQT_INCLUDED_SRC_ helpbrowser_UIHelpBrowserWidget_h */224 #endif /* !FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h */
Note:
See TracChangeset
for help on using the changeset viewer.