Changeset 86794 in vbox
- Timestamp:
- Nov 3, 2020 12:22:16 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86791 r86794 83 83 virtual QVariant loadResource(int type, const QUrl &name) /* override */; 84 84 void emitHistoryChangedSignal(); 85 void setSource(const QUrl &url, const QString &strError); 85 86 86 87 public slots: … … 152 153 { 153 154 Q_OBJECT; 155 156 signals: 157 158 void sigSourceChanged(const QUrl &url); 154 159 155 160 public: … … 210 215 { 211 216 m_pContentViewer->blockSignals(true); 212 m_pContentViewer->setSource(url );217 m_pContentViewer->setSource(url, m_strPageNotFoundText); 213 218 m_pContentViewer->blockSignals(false); 214 219 /* emit historyChanged signal explicitly since we have blocked the signals: */ … … 242 247 this, &UIHelpBrowserTab::sltAnchorClicked); 243 248 244 m_pContentViewer->setSource(initialUrl );249 m_pContentViewer->setSource(initialUrl, m_strPageNotFoundText); 245 250 } 246 251 … … 311 316 if (!m_pContentViewer) 312 317 return; 313 if (m_homeUrl.isValid()) 314 m_pContentViewer->setSource(m_homeUrl); 318 m_pContentViewer->setSource(m_homeUrl, m_strPageNotFoundText); 315 319 } 316 320 … … 406 410 } 407 411 412 void UIHelpBrowserViewer::setSource(const QUrl &url, const QString &strError) 413 { 414 if (!url.isValid()) 415 setText(strError.arg(url.toString())); 416 else 417 QTextBrowser::setSource(url); 418 } 419 408 420 409 421 /********************************************************************************************************************************* … … 425 437 clearAndDeleteTabs(); 426 438 /* Add a single tab with m_homeUrl: */ 427 if (m_savedUrlList.isEmpty()) 428 { 429 addTab(new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, QUrl()), QString()); 430 } 431 else 432 { 433 addTab(new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, m_savedUrlList[0]), QString()); 434 435 } 439 QUrl initialUrl; 440 if (!m_savedUrlList.isEmpty()) 441 initialUrl = m_savedUrlList[0]; 442 UIHelpBrowserTab *pTabWidget = new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl); 443 addTab(pTabWidget, QString()); 444 connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged, 445 this, &UIHelpBrowserTabManager::sigSourceChanged); 436 446 } 437 447 … … 600 610 m_pSplitter->setChildrenCollapsible(false); 601 611 612 connect(m_pTabManager, &UIHelpBrowserTabManager::sigSourceChanged, 613 this, &UIHelpBrowserWidget::sltHandleHelpBrowserViewerSourceChange); 602 614 connect(m_pHelpEngine, &QHelpEngine::setupFinished, 603 615 this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished); 604 // connect(m_pContentWidget, &QHelpContentWidget::linkActivated,605 // m_pContentViewer, &UIHelpBrowserViewer::setSource);606 616 connect(m_pContentWidget, &QHelpContentWidget::clicked, 607 617 this, &UIHelpBrowserWidget::sltHandleContentWidgetItemClicked); 608 // connect(m_pIndexWidget, &QHelpIndexWidget::linkActivated,609 // m_pContentViewer, &UIHelpBrowserViewer::setSource);610 618 connect(m_pContentModel, &QHelpContentModel::contentsCreated, 611 619 this, &UIHelpBrowserWidget::sltHandleContentsCreated); 620 612 621 613 622 if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine) … … 826 835 } 827 836 828 void UIHelpBrowserWidget::show404Error(const QUrl & /*url*/)829 {830 // QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList());831 // int iIndex = -1;832 // for (int i = 0; i < files.size(); ++i)833 // {834 // if (files[i].toString().contains("index.html", Qt::CaseInsensitive))835 // {836 // iIndex = i;837 // break;838 // }839 // }840 // if (iIndex == -1)841 // {842 // /* If index html/htm could not be found try to find a html file at least: */843 // for (int i = 0; i < files.size(); ++i)844 // {845 // if (files[i].toString().contains(".html", Qt::CaseInsensitive) ||846 // files[i].toString().contains(".htm", Qt::CaseInsensitive))847 // {848 // iIndex = i;849 // break;850 // }851 // }852 // }853 // if (iIndex != -1 && files.size() > iIndex)854 // return files[iIndex];855 // return QUrl();856 // #else857 // return QUrl();858 }859 860 837 void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished() 861 838 { 862 839 AssertReturnVoid(m_pTabManager && m_pHelpEngine); 863 840 m_pTabManager->initilizeTabs(); 864 /* Search for the index of the index.htnl: */ 865 // QUrl url = findIndexHtml(); 866 // if (url.isValid()) 867 // m_pContentViewer->setSource(url); 868 // else 869 // show404Error(url); 870 } 871 841 } 872 842 873 843 void UIHelpBrowserWidget::sltHandleContentWidgetItemClicked(const QModelIndex & index) -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86791 r86794 107 107 void cleanup(); 108 108 QUrl findIndexHtml() const; 109 void show404Error(const QUrl &url);110 109 /** @name Event handling stuff. 111 110 * @{ */ 112 111 /** Handles translation event. */ 113 virtual void retranslateUi() /* override */;112 virtual void retranslateUi() /* override */; 114 113 115 /** Handles Qt show @a pEvent. */116 virtual void showEvent(QShowEvent *pEvent) /* override */;117 /** Handles Qt key-press @a pEvent. */118 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;114 /** Handles Qt show @a pEvent. */ 115 virtual void showEvent(QShowEvent *pEvent) /* override */; 116 /** Handles Qt key-press @a pEvent. */ 117 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 119 118 /** @} */ 120 119
Note:
See TracChangeset
for help on using the changeset viewer.