Changeset 88392 in vbox
- Timestamp:
- Apr 7, 2021 10:41:40 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r87697 r88392 262 262 UIHelpBrowserTabManager(const QHelpEngine *pHelpEngine, const QUrl &homeUrl, 263 263 const QStringList &urlList, QWidget *pParent = 0); 264 /* Return the list of urls of all open tabs as QStringList. */264 /* Returns the list of urls of all open tabs as QStringList. */ 265 265 QStringList tabUrlList() const; 266 266 QStringList tabTitleList() const; … … 273 273 void setToolBarVisible(bool fVisible); 274 274 void printCurrent(QPrinter &printer); 275 int initialFontPointSize() const;275 int initialFontPointSize() const; 276 276 void setFontPointSize(int iPointSize); 277 int fontPointSize() const;277 int fontPointSize() const; 278 278 void setFontScaleWidgetVisible(bool fToggled); 279 279 void switchToTab(int iIndex); … … 308 308 /** Closes all tabs other than the one with index @param iTabIndex. */ 309 309 void closeAllTabsBut(int iTabIndex); 310 /* Returns the tab index with @Url if there is one. Returns -1 otherwise. */ 311 int findTab(const QUrl &Url) const; 310 312 const QHelpEngine* m_pHelpEngine; 311 313 UIFontScaleWidget *m_pFontScaleWidget; … … 838 840 void UIHelpBrowserTabManager::addNewTab(const QUrl &initialUrl, bool fBackground) 839 841 { 840 UIHelpBrowserTab *pTabWidget = new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl); 841 AssertReturnVoid(pTabWidget); 842 pTabWidget->setToolBarVisible(m_fToolBarVisible); 843 int index = addTab(pTabWidget, pTabWidget->documentTitle()); 844 connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged, 845 this, &UIHelpBrowserTabManager::sigSourceChanged); 846 connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate, 847 this, &UIHelpBrowserTabManager::sltHandletabTitleChange); 848 connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab, 849 this, &UIHelpBrowserTabManager::sltHandleOpenLinkInNewTab); 850 connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark, 851 this, &UIHelpBrowserTabManager::sigAddBookmark); 852 connect(pTabWidget, &UIHelpBrowserTab::sigFontPointSizeChanged, 853 this, &UIHelpBrowserTabManager::sltHandleFontSizeChange); 854 connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted, 855 this, &UIHelpBrowserTabManager::sigLinkHighlighted); 856 857 if (!fBackground) 858 setCurrentIndex(index); 859 860 if (!m_pFontScaleWidget) 861 { 862 m_pFontScaleWidget = new UIFontScaleWidget(initialFontPointSize(), this); 863 connect(m_pFontScaleWidget, &UIFontScaleWidget::sigFontPointSizeChanged, 864 this, &UIHelpBrowserTabManager::sltHandleFontSizeChange); 865 } 842 /* If there is already a tab with a source which is equal to @initialUrl then make it current: */ 843 int iExistIndex = findTab(initialUrl); 844 if (iExistIndex != -1) 845 { 846 setCurrentIndex(iExistIndex); 847 return; 848 } 849 850 UIHelpBrowserTab *pTabWidget = new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl); 851 AssertReturnVoid(pTabWidget); 852 pTabWidget->setToolBarVisible(m_fToolBarVisible); 853 int index = addTab(pTabWidget, pTabWidget->documentTitle()); 854 connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged, 855 this, &UIHelpBrowserTabManager::sigSourceChanged); 856 connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate, 857 this, &UIHelpBrowserTabManager::sltHandletabTitleChange); 858 connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab, 859 this, &UIHelpBrowserTabManager::sltHandleOpenLinkInNewTab); 860 connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark, 861 this, &UIHelpBrowserTabManager::sigAddBookmark); 862 connect(pTabWidget, &UIHelpBrowserTab::sigFontPointSizeChanged, 863 this, &UIHelpBrowserTabManager::sltHandleFontSizeChange); 864 connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted, 865 this, &UIHelpBrowserTabManager::sigLinkHighlighted); 866 867 if (!fBackground) 868 setCurrentIndex(index); 869 870 if (!m_pFontScaleWidget) 871 { 872 m_pFontScaleWidget = new UIFontScaleWidget(initialFontPointSize(), this); 873 connect(m_pFontScaleWidget, &UIFontScaleWidget::sigFontPointSizeChanged, 874 this, &UIHelpBrowserTabManager::sltHandleFontSizeChange); 875 } 866 876 } 867 877 … … 893 903 addTab(widgetList[iTabIndex], strTitle); 894 904 updateTabUrlTitleList(); 905 } 906 907 int UIHelpBrowserTabManager::findTab(const QUrl &Url) const 908 { 909 for (int i = 0; i < count(); ++i) 910 { 911 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i)); 912 if (!pTab || !pTab->source().isValid()) 913 continue; 914 if (pTab->source() == Url) 915 return i; 916 } 917 return -1; 895 918 } 896 919 … … 956 979 return list; 957 980 } 958 959 981 960 982 void UIHelpBrowserTabManager::setToolBarVisible(bool fVisible) -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r87659 r88392 31 31 #include <QHBoxLayout> 32 32 #include <QScrollBar> 33 #include <QTextBlock> 33 34 #include <QWidgetAction> 34 35 #ifdef RT_OS_SOLARIS … … 374 375 QTextBrowser::setSource(url); 375 376 QTextDocument *pDocument = document(); 377 //iterateDocumentImages(); 376 378 if (!pDocument || pDocument->isEmpty()) 377 379 { … … 525 527 if (!strAnchor.isEmpty()) 526 528 { 527 QString strLink = source().resolved(strAnchor).toString(); 528 emit sigOpenLinkInNewTab(strLink, true); 529 if (pEvent->modifiers() & Qt::ControlModifier) 530 { 531 QString strLink = source().resolved(strAnchor).toString(); 532 emit sigOpenLinkInNewTab(strLink, true); 533 return; 534 } 529 535 } 530 536 QIWithRetranslateUI<QTextBrowser>::mousePressEvent(pEvent); … … 620 626 } 621 627 628 void UIHelpViewer::iterateDocumentImages() 629 { 630 QTextCursor cursor = textCursor(); 631 cursor.movePosition(QTextCursor::Start); 632 while (!cursor.atEnd()) 633 { 634 cursor.movePosition(QTextCursor::NextCharacter); 635 if (cursor.charFormat().isImageFormat()) 636 { 637 QTextImageFormat imageFormat = cursor.charFormat().toImageFormat(); 638 printf("%s %lf\n", qPrintable(imageFormat.name()), imageFormat.width()); 639 } 640 } 641 } 642 622 643 void UIHelpViewer::sltHandleOpenLinkInNewTab() 623 644 { -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h
r87656 r88392 87 87 void highlightFinds(int iSearchTermLength); 88 88 void selectMatch(int iMatchIndex, int iSearchStringLength); 89 void iterateDocumentImages(); 89 90 const QHelpEngine* m_pHelpEngine; 90 91 UIFindInPageWidget *m_pFindInPageWidget; … … 97 98 int m_iSearchTermLength; 98 99 int m_iInitialFontPointSize; 100 QMap<QString, qreal> m_imageSizesMap; 99 101 }; 100 102
Note:
See TracChangeset
for help on using the changeset viewer.