Changeset 86906 in vbox
- Timestamp:
- Nov 18, 2020 7:06:07 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141386
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r86846 r86906 17 17 18 18 /* Qt includes: */ 19 #include <QAbstractButton> 19 20 #include <QDir> 20 21 #include <QFileInfo> … … 612 613 error(pParent, MessageType_Error, 613 614 tr("Failed to acquire machine parameter."), UIErrorString::formatErrorInfo(comMachine)); 615 } 616 617 void UIMessageCenter::cannotFindHelpFile(const QString &strFileLocation, QWidget *pParent /* = 0 */) const 618 { 619 /* Show the error: */ 620 error(pParent, MessageType_Error, 621 tr("Failed to find help file."), 622 QString("%1:<!--EOM-->%2").arg(tr("The following file could not found")).arg(strFileLocation)); 614 623 } 615 624 … … 3225 3234 #elif defined (VBOX_WS_X11) 3226 3235 # if defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) 3227 showHelpBrowser(strLocation); 3228 # endif /* #if defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))&& (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) */ 3229 # ifndef VBOX_OSE 3236 showHelpBrowser(strLocation, QString()); 3237 # elif !defined(VBOX_OSE) 3230 3238 char szViewerPath[RTPATH_MAX]; 3231 3239 int rc; … … 3425 3433 } 3426 3434 3427 void UIMessageCenter::showHelpBrowser(const QString strHelpFilePath, QWidget *pParent /* = 0 */)3435 void UIMessageCenter::showHelpBrowser(const QString &strHelpFilePath, const QString &strKeyword, QWidget *pParent /* = 0 */) 3428 3436 { 3429 3437 Q_UNUSED(pParent); 3438 if (!QFileInfo(strHelpFilePath).exists()) 3439 { 3440 cannotFindHelpFile(strHelpFilePath, pParent); 3441 return; 3442 } 3430 3443 if (!m_pHelpBrowserDialog) 3431 3444 { 3432 3433 UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath); 3445 UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath, strKeyword); 3434 3446 dialogFactory.prepare(m_pHelpBrowserDialog); 3435 3447 AssertReturnVoid(m_pHelpBrowserDialog); … … 3452 3464 UIHelpBrowserDialogFactory().cleanup(pDialog); 3453 3465 } 3466 3467 void UIMessageCenter::sltHandleDialogHelpButtonPress() 3468 { 3469 # if defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) 3470 3471 QAbstractButton *pSender = qobject_cast<QAbstractButton*>(sender()); 3472 if (!pSender) 3473 return; 3474 QVariant keyWordProp = pSender->property("helptag"); 3475 if (!keyWordProp.isValid() || !keyWordProp.canConvert(QMetaType::QString)) 3476 return; 3477 QString strKeyword = keyWordProp.toString(); 3478 showHelpBrowser(uiCommon().helpFile(), strKeyword); 3479 # endif /* #if defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))&& (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) */ 3480 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r86846 r86906 266 266 void cannotAcquireVirtualBoxParameter(const CVirtualBox &comVBox, QWidget *pParent = 0) const; 267 267 void cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent = 0) const; 268 void cannotFindHelpFile(const QString &strFileLocation, QWidget *pParent = 0) const; 268 269 269 270 /* API: Selector warnings: */ … … 552 553 void sltShowUserManual(const QString &strLocation); 553 554 void sltCloseHelpBrowser(); 555 void sltHandleDialogHelpButtonPress(); 554 556 555 557 private slots: … … 602 604 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3, 603 605 const QString &strAutoConfirmId) const; 604 605 void showHelpBrowser(const QString strHelpFilePath, QWidget *pParent = 0); 606 /** @param strKeyword is passed possbily from a hrlp button and used by QHelpEngine infrastructure to find a 607 * corresponding Url. */ 608 void showHelpBrowser(const QString &strHelpFilePath, const QString &strKeyword, QWidget *pParent = 0); 606 609 607 610 /** Holds the list of shown warnings. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.cpp
r86844 r86906 44 44 *********************************************************************************************************************************/ 45 45 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath /* = QString() */) 47 :m_strHelpFilePath(strHelpFilePath) 46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath, 47 const QString &strKeyword /* = QString() */) 48 : m_strHelpFilePath(strHelpFilePath) 49 , m_strKeyword(strKeyword) 50 { 51 } 52 53 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory() 54 : m_strHelpFilePath(QString()) 55 , m_strKeyword(QString()) 48 56 { 49 57 } … … 51 59 void UIHelpBrowserDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 52 60 { 53 pDialog = new UIHelpBrowserDialog(pCenterWidget, m_strHelpFilePath );61 pDialog = new UIHelpBrowserDialog(pCenterWidget, m_strHelpFilePath, m_strKeyword); 54 62 } 55 63 … … 59 67 *********************************************************************************************************************************/ 60 68 61 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath) 69 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath, 70 const QString &strKeyword /* = QString() */) 62 71 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 63 72 , m_strHelpFilePath(strHelpFilePath) 73 , m_strKeyword(strKeyword) 64 74 { 65 75 } … … 82 92 { 83 93 #if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) 84 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath, true /* show toolbar */, this);94 UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath, m_strKeyword); 85 95 if (pWidget) 86 96 { -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.h
r86581 r86906 43 43 class SHARED_LIBRARY_STUFF UIHelpBrowserDialogFactory : public QIManagerDialogFactory 44 44 { 45 45 46 public: 46 47 47 UIHelpBrowserDialogFactory(const QString &strHelpFilePath = QString()); 48 /** @param strHelpFilePath: the full path of the qHelp archive file. 49 * @param strKeyword: optional keyword string. Used in context sensitive help. */ 50 UIHelpBrowserDialogFactory(const QString &strHelpFilePath, const QString &strKeyword = QString()); 51 UIHelpBrowserDialogFactory(); 48 52 49 53 protected: … … 56 60 57 61 QString m_strHelpFilePath; 62 QString m_strKeyword; 58 63 }; 59 60 61 64 62 65 class SHARED_LIBRARY_STUFF UIHelpBrowserDialog : public QIWithRetranslateUI<QIManagerDialog> … … 66 69 public: 67 70 68 UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath); 71 UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath, 72 const QString &strKeyword = QString()); 69 73 70 74 protected: … … 105 109 106 110 QString m_strHelpFilePath; 111 QString m_strKeyword; 107 112 }; 108 113 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86884 r86906 277 277 virtual QVariant loadResource(int type, const QUrl &name) /* override */; 278 278 void emitHistoryChangedSignal(); 279 void setSource(const QUrl &url , const QString &strError);279 void setSource(const QUrl &url) /* override */; 280 280 void toggleFindInPageWidget(bool fVisible); 281 281 int initialFontPointSize() const; … … 381 381 UIHelpBrowserViewer *m_pContentViewer; 382 382 const QHelpEngine* m_pHelpEngine; 383 QString m_strPageNotFoundText;384 383 QUrl m_homeUrl; 385 384 }; … … 404 403 const QStringList &urlList, QWidget *pParent = 0); 405 404 QStringList tabUrlList() const; 406 void initilizeTabs(); 405 /** Either start with a single tab showin the home url or saved tab(s). Depending on the params. passed to ctor. */ 406 void initializeTabs(); 407 /** Initialize with a single url. Effectively disables multitab. Possibly used in context sensitive help mode. */ 408 void initializeSingleTab(const QUrl &url); 407 409 /* Url of the current tab. */ 408 410 QUrl currentSource() const; … … 416 418 int fontPointSize() const; 417 419 void setFontScaleWidgetVisible(bool fToggled); 420 void setMultiTabEnabled(bool fFlag); 418 421 419 422 protected: … … 438 441 QUrl m_homeUrl; 439 442 QStringList m_savedUrlList; 443 /** Immediately switch the newly created tab. Otherwise open the tab in background. */ 440 444 bool m_fSwitchToNewTab; 445 bool m_fMultiTabEnabled; 446 bool m_fToolBarVisible; 441 447 }; 442 448 … … 832 838 { 833 839 m_pContentViewer->blockSignals(true); 834 m_pContentViewer->setSource(url , m_strPageNotFoundText);840 m_pContentViewer->setSource(url); 835 841 m_pContentViewer->blockSignals(false); 836 842 /* emit historyChanged signal explicitly since we have blocked the signals: */ … … 925 931 this, &UIHelpBrowserTab::sltHandleAddBookmarkAction); 926 932 927 m_pContentViewer->setSource(initialUrl , m_strPageNotFoundText);933 m_pContentViewer->setSource(initialUrl); 928 934 } 929 935 … … 985 991 void UIHelpBrowserTab::retranslateUi() 986 992 { 987 m_strPageNotFoundText = tr("<div><p><h3>404. Not found.</h3>The page <b>%1</b> could not be found.</p></div>");988 989 993 setActionTextAndToolTip(m_pHomeAction, tr("Home"), tr("Return to start page")); 990 994 setActionTextAndToolTip(m_pBackwardAction, tr("Backward"), tr("Navigate to previous page")); … … 998 1002 if (!m_pContentViewer) 999 1003 return; 1000 m_pContentViewer->setSource(m_homeUrl , m_strPageNotFoundText);1004 m_pContentViewer->setSource(m_homeUrl); 1001 1005 } 1002 1006 … … 1126 1130 } 1127 1131 1128 void UIHelpBrowserViewer::setSource(const QUrl &url, const QString &strError) 1129 { 1130 if (!url.isValid()) 1131 setText(strError.arg(url.toString())); 1132 else 1133 QTextBrowser::setSource(url); 1132 void UIHelpBrowserViewer::setSource(const QUrl &url) 1133 { 1134 QTextBrowser::setSource(url); 1135 QTextDocument *pDocument = document(); 1136 if (!pDocument || pDocument->isEmpty()) 1137 { 1138 setText(tr("<div><p><h3>404. Not found.</h3>The page <b>%1</b> could not be found.</p></div>").arg(url.toString())); 1139 } 1134 1140 } 1135 1141 … … 1412 1418 , m_savedUrlList(urlList) 1413 1419 , m_fSwitchToNewTab(true) 1420 , m_fMultiTabEnabled(true) 1421 , m_fToolBarVisible(true) 1414 1422 { 1415 1423 prepare(); … … 1418 1426 void UIHelpBrowserTabManager::addNewTab(const QUrl &initialUrl) 1419 1427 { 1428 if (!m_fMultiTabEnabled && count() >= 1) 1429 return; 1420 1430 UIHelpBrowserTab *pTabWidget = new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl); 1421 1431 AssertReturnVoid(pTabWidget); 1432 pTabWidget->setToolBarVisible(m_fToolBarVisible); 1422 1433 int index = addTab(pTabWidget, pTabWidget->documentTitle()); 1423 1434 connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged, … … 1443 1454 } 1444 1455 1445 void UIHelpBrowserTabManager::initi lizeTabs()1456 void UIHelpBrowserTabManager::initializeTabs() 1446 1457 { 1447 1458 clearAndDeleteTabs(); 1459 /* Start with a single tab showing the home URL: */ 1448 1460 if (m_savedUrlList.isEmpty()) 1449 1461 addNewTab(QUrl()); 1462 /* Start with saved tab(s): */ 1450 1463 else 1451 1464 for (int i = 0; i < m_savedUrlList.size(); ++i) 1452 1465 addNewTab(m_savedUrlList[i]); 1466 } 1467 1468 void UIHelpBrowserTabManager::initializeSingleTab(const QUrl &url) 1469 { 1470 m_fMultiTabEnabled = false; 1471 clearAndDeleteTabs(); 1472 addNewTab(url); 1453 1473 } 1454 1474 … … 1489 1509 void UIHelpBrowserTabManager::setToolBarVisible(bool fVisible) 1490 1510 { 1511 /* Make sure existing tabs are configured: */ 1491 1512 for (int i = 0; i < count(); ++i) 1492 1513 { … … 1496 1517 pTab->setToolBarVisible(fVisible); 1497 1518 } 1519 /* This is for the tabs that will be created later: */ 1520 m_fToolBarVisible = fVisible; 1498 1521 } 1499 1522 … … 1617 1640 *********************************************************************************************************************************/ 1618 1641 1619 UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, 1620 const QString &strHelpFilePath, 1621 bool fShowToolbar /* = true */, 1622 QWidget *pParent /* = 0 */) 1642 UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, 1643 const QString &strKeyword /* = QString() */, QWidget *pParent /* = 0 */) 1623 1644 : QIWithRetranslateUI<QWidget>(pParent) 1624 1645 , m_enmEmbedding(enmEmbedding) 1625 , m_fShowToolbar(fShowToolbar)1626 1646 , m_fIsPolished(false) 1627 1647 , m_pMainLayout(0) … … 1630 1650 , m_pToolBar(0) 1631 1651 , m_strHelpFilePath(strHelpFilePath) 1652 , m_strKeyword(strKeyword) 1653 , m_fContextSensitiveMode(strKeyword.isEmpty() ? false : true) 1632 1654 , m_pHelpEngine(0) 1633 1655 , m_pSplitter(0) … … 1763 1785 1764 1786 m_pSplitter->addWidget(m_pTabManager); 1765 1766 m_pSplitter->setStretchFactor( 0,1);1767 m_pSplitter->setStretchFactor(1, 4); 1787 m_pSplitter->setStretchFactor(0,0); 1788 m_pSplitter->setStretchFactor(1,1); 1789 1768 1790 m_pSplitter->setChildrenCollapsible(false); 1769 1791 … … 1796 1818 m_pTabWidget->insertTab(HelpBrowserTabs_Search, m_pSearchContainerWidget, QString()); 1797 1819 m_pTabWidget->setTabPosition(QTabWidget::South); 1820 1821 1798 1822 m_pSearchEngine = m_pHelpEngine->searchEngine(); 1799 1823 AssertReturnVoid(m_pSearchEngine); … … 1887 1911 void UIHelpBrowserWidget::saveOptions() 1888 1912 { 1889 if (m_pTabManager) 1913 /* dont save the url list if context sensitive mode; */ 1914 if (m_pTabManager && !m_fContextSensitiveMode) 1890 1915 gEDataManager->setHelpBrowserLastUrlList(m_pTabManager->tabUrlList()); 1891 1916 } … … 2022 2047 void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished() 2023 2048 { 2024 AssertReturnVoid(m_pTabManager && m_pHelpEngine);2025 m_pTabManager->initilizeTabs();2026 2049 } 2027 2050 … … 2070 2093 void UIHelpBrowserWidget::sltHandleIndexingFinished() 2071 2094 { 2072 if (m_pSearchContainerWidget) 2073 m_pSearchContainerWidget->setEnabled(true); 2095 AssertReturnVoid(m_pTabManager && 2096 m_pHelpEngine && 2097 m_pSearchContainerWidget); 2098 2099 m_pSearchContainerWidget->setEnabled(true); 2100 if (!m_fContextSensitiveMode) 2101 m_pTabManager->initializeTabs(); 2102 else 2103 { 2104 QMap<QString, QUrl> map = m_pHelpEngine->linksForIdentifier(m_strKeyword); 2105 if (!map.isEmpty()) 2106 { 2107 /* We have to a have a single url per keyword in this case: */ 2108 QUrl keywordUrl = map.first(); 2109 m_pTabManager->initializeSingleTab(keywordUrl); 2110 } 2111 } 2074 2112 } 2075 2113 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86884 r86906 68 68 69 69 UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, 70 bool fShowToolbar = true, QWidget *pParent = 0);70 const QString &strKeyword = QString(), QWidget *pParent = 0); 71 71 ~UIHelpBrowserWidget(); 72 72 … … 135 135 /** Hold sthe action-pool reference. */ 136 136 UIActionPool *m_pActionPool; 137 /** Holds whether we should create/show toolbar. */138 const bool m_fShowToolbar;139 137 140 138 /** Holds whether the dialog is polished. */ … … 152 150 153 151 QString m_strHelpFilePath; 152 /** Start the browser with this keyword. When not empty widget is shown `only` with html viewer and single tab.*/ 153 QString m_strKeyword; 154 bool m_fContextSensitiveMode; 154 155 QHelpEngine *m_pHelpEngine; 155 156 QSplitter *m_pSplitter; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp
r86356 r86906 26 26 #include "UIWizardPage.h" 27 27 #include "UICommon.h" 28 #include "UIMessageCenter.h" 28 29 #include "QIRichTextLabel.h" 29 30 #include "UIExtraDataManager.h" … … 50 51 /* Make sure custom buttons shown even if final page is first to show: */ 51 52 sltCurrentIdChanged(startId()); 53 54 /* If help button is enabled by the subclass, connect it to proper slot: */ 55 if (button(QWizard::HelpButton)) 56 connect(button(QWizard::HelpButton), &QAbstractButton::pressed, 57 &(msgCenter()), &UIMessageCenter::sltHandleDialogHelpButtonPress); 52 58 } 53 59 … … 533 539 } 534 540 #endif /* !VBOX_WS_MAC */ 535 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r85150 r86906 16 16 */ 17 17 18 /* Qt includes: */ 19 #include <QAbstractButton> 20 18 21 /* GUI includes: */ 19 22 #include "UICommon.h" … … 54 57 , m_iUSBCount(0) 55 58 { 59 setOptions(options() | QWizard::HaveHelpButton); 60 if (button(QWizard::HelpButton)) 61 button(QWizard::HelpButton)->setProperty("helptag", "gui-createvm"); 56 62 #ifndef VBOX_WS_MAC 57 63 /* Assign watermark: */
Note:
See TracChangeset
for help on using the changeset viewer.