- Timestamp:
- Apr 8, 2021 10:49:01 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r88408 r88410 100 100 101 101 void prepare(); 102 //int fontPercentage() const;103 102 104 103 QHBoxLayout *m_pMainLayout; … … 189 188 void sigAddBookmark(const QUrl &url, const QString &strTitle); 190 189 void sigLinkHighlighted(const QString &strLink); 190 void sigZoomPercentageChanged(int iPercentage); 191 191 192 192 public: … … 221 221 virtual void retranslateUi() /* override */; 222 222 void setActionTextAndToolTip(QAction *pAction, const QString &strText, const QString &strToolTip); 223 // int initialFontPointSize() const;224 // void setFontPointSize(int iPointSize);225 // int fontPointSize() const;226 223 227 224 QAction *m_pHomeAction; … … 278 275 void sltHandleCloseCurrentTab(); 279 276 void sltHandleCloseOtherTabs(); 277 void sltHandleZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation); 280 278 281 279 protected: … … 290 288 void sltHandleContextMenuTabClose(); 291 289 void sltHandleCurrentChanged(int iTabIndex); 292 void sltHandleZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation);293 290 void sltShowTabBarContextMenu(const QPoint &pos); 294 291 void sltHandleCloseOtherTabsContextMenuAction(); 292 void sltZoomPercentageChanged(int iPercentage); 295 293 296 294 private: … … 305 303 /* Returns the tab index with @Url if there is one. Returns -1 otherwise. */ 306 304 int findTab(const QUrl &Url) const; 307 // void setFontPointSize(int iPointSize);308 // int initialFontPointSize() const;309 // int fontPointSize() const;310 305 311 306 const QHelpEngine* m_pHelpEngine; … … 354 349 m_pPlusButton && 355 350 m_pValueLabel); 356 357 //m_pValueLabel->setText(QString("%1%2").arg(QString::number(fontPercentage())).arg("%"));358 351 359 352 m_pMinusButton->setIcon(UIIconPool::iconSet(":/help_browser_minus_32px.png")); … … 582 575 m_pContentViewer->zoom(enmZoomOperation); 583 576 } 584 // void UIHelpBrowserTab::setZoomPercentage(int iZoomPercentage)585 // {586 // if (m_pContentViewer)587 // m_pContentViewer->setZoomPercentage(iZoomPercentage);588 // }589 590 // int UIHelpBrowserTab::initialFontPointSize() const591 // {592 // if (m_pContentViewer)593 // return m_pContentViewer->initialFontPointSize();594 // return 0;595 // }596 597 // void UIHelpBrowserTab::setFontPointSize(int iPointSize)598 // {599 // if (m_pContentViewer)600 // {601 // if (m_pContentViewer->font().pointSize() == iPointSize)602 // return;603 // QFont mFont = m_pContentViewer->font();604 // mFont.setPointSize(iPointSize);605 // m_pContentViewer->setFont(mFont);606 // }607 // }608 609 // int UIHelpBrowserTab::fontPointSize() const610 // {611 // if (!m_pContentViewer)612 // return 0;613 // return m_pContentViewer->font().pointSize();614 // }615 577 616 578 void UIHelpBrowserTab::prepare(const QUrl &initialUrl) … … 652 614 connect(m_pContentViewer, static_cast<void(UIHelpViewer::*)(const QString&)>(&UIHelpViewer::highlighted), 653 615 this, &UIHelpBrowserTab::sigLinkHighlighted); 616 connect(m_pContentViewer, &UIHelpViewer::sigZoomPercentageChanged, 617 this, &UIHelpBrowserTab::sigZoomPercentageChanged); 654 618 655 619 m_pContentViewer->setSource(initialUrl); … … 847 811 connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark, 848 812 this, &UIHelpBrowserTabManager::sigAddBookmark); 849 //connect(pTabWidget, &UIHelpBrowserTab::sigZoomPercentageChanged,850 // this, &UIHelpBrowserTabManager::sltHandleZoomOperation);813 connect(pTabWidget, &UIHelpBrowserTab::sigZoomPercentageChanged, 814 this, &UIHelpBrowserTabManager::sltZoomPercentageChanged); 851 815 connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted, 852 816 this, &UIHelpBrowserTabManager::sigLinkHighlighted); … … 860 824 connect(m_pZoomWidget, &UIZoomWidget::sigZoomChanged, 861 825 this, &UIHelpBrowserTabManager::sltHandleZoomOperation); 826 m_pZoomWidget->setZoomPercentage(100); 862 827 } 863 828 } … … 1000 965 } 1001 966 1002 // int UIHelpBrowserTabManager::initialFontPointSize() const1003 // {1004 // UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());1005 // if (!pTab)1006 // return 0;1007 // return pTab->initialFontPointSize();1008 // }1009 1010 // void UIHelpBrowserTabManager::setFontPointSize(int iPointSize)1011 // {1012 // for (int i = 0; i < count(); ++i)1013 // {1014 // UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));1015 // if (!pTab)1016 // continue;1017 // pTab->setFontPointSize(iPointSize);1018 // }1019 // // if (m_pZoomWidget)1020 // // m_pZoomWidget->setFontPointSize(iPointSize);1021 // }1022 1023 // int UIHelpBrowserTabManager::fontPointSize() const1024 // {1025 // UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());1026 // if (!pTab)1027 // return 0;1028 // return pTab->fontPointSize();1029 // }1030 1031 967 void UIHelpBrowserTabManager::setZoomWidgetVisible(bool fToggled) 1032 968 { … … 1096 1032 return; 1097 1033 closeAllTabsBut(iTabIndex); 1034 } 1035 1036 void UIHelpBrowserTabManager::sltZoomPercentageChanged(int iPercentage) 1037 { 1038 if (m_pZoomWidget) 1039 m_pZoomWidget->setZoomPercentage(iPercentage); 1098 1040 } 1099 1041 … … 1199 1141 , m_pZoomInAction(0) 1200 1142 , m_pZoomOutAction(0) 1201 , m_p FontSizeResetAction(0)1143 , m_pZoomResetAction(0) 1202 1144 , m_fModelContentCreated(false) 1203 1145 , m_fIndexingFinished(false) … … 1296 1238 m_pZoomOutAction->setIcon(UIIconPool::iconSet(":/help_browser_minus_32px.png")); 1297 1239 1298 m_p FontSizeResetAction = new QAction(this);1299 m_p FontSizeResetAction->setIcon(UIIconPool::iconSet(":/help_browser_reset_32px.png"));1240 m_pZoomResetAction = new QAction(this); 1241 m_pZoomResetAction->setIcon(UIIconPool::iconSet(":/help_browser_reset_32px.png")); 1300 1242 1301 1243 connect(m_pZoomInAction, &QAction::triggered, … … 1303 1245 connect(m_pZoomOutAction, &QAction::triggered, 1304 1246 this, &UIHelpBrowserWidget::sltHandleZoomActions); 1305 connect(m_p FontSizeResetAction, &QAction::triggered,1247 connect(m_pZoomResetAction, &QAction::triggered, 1306 1248 this, &UIHelpBrowserWidget::sltHandleZoomActions); 1307 1249 } … … 1451 1393 if (m_pZoomOutAction) 1452 1394 m_pViewMenu->addAction(m_pZoomOutAction); 1453 if (m_p FontSizeResetAction)1454 m_pViewMenu->addAction(m_p FontSizeResetAction);1395 if (m_pZoomResetAction) 1396 m_pViewMenu->addAction(m_pZoomResetAction); 1455 1397 m_pViewMenu->addSeparator(); 1456 1398 if (m_pShowHideSideBarAction) … … 1578 1520 m_pShowHideToolBarAction->setText(tr("Show Tool Bar")); 1579 1521 if (m_pShowHideZoomWidgetAction) 1580 m_pShowHideZoomWidgetAction->setText(tr("Show Font ScaleWidget"));1522 m_pShowHideZoomWidgetAction->setText(tr("Show Zoom Widget")); 1581 1523 if (m_pShowHideStatusBarAction) 1582 1524 m_pShowHideStatusBarAction->setText(tr("Show Status Bar")); … … 1592 1534 if (m_pZoomOutAction) 1593 1535 m_pZoomOutAction->setText(tr("Zoom &Out")); 1594 if (m_p FontSizeResetAction)1595 m_p FontSizeResetAction->setText(tr("&Reset Zoom"));1536 if (m_pZoomResetAction) 1537 m_pZoomResetAction->setText(tr("&Reset Zoom")); 1596 1538 } 1597 1539 … … 1864 1806 void UIHelpBrowserWidget::sltHandleZoomActions() 1865 1807 { 1866 // if (!sender() || !m_pTabManager) 1867 // return; 1868 // int iFontPointSize = m_pTabManager->fontPointSize(); 1869 // if (sender() == m_pFontSizeResetAction) 1870 // iFontPointSize = m_pTabManager->initialFontPointSize(); 1871 // else if (sender() == m_pZoomInAction) 1872 // iFontPointSize += iZoomPercentageStep; 1873 // else if (sender() == m_pZoomOutAction) 1874 // iFontPointSize -= iZoomPercentageStep; 1875 1876 // if (iFontPointSize >= zoomPercentageMinMax.second * m_pTabManager->initialFontPointSize() || 1877 // iFontPointSize <= zoomPercentageMinMax.first * m_pTabManager->initialFontPointSize()) 1878 // return; 1879 // m_pTabManager->setFontPointSize(iFontPointSize); 1808 if (!sender() || !m_pTabManager) 1809 return; 1810 UIHelpViewer::ZoomOperation enmOperation = UIHelpViewer::ZoomOperation_Reset; 1811 if (sender() == m_pZoomResetAction) 1812 enmOperation = UIHelpViewer::ZoomOperation_Reset; 1813 else if (sender() == m_pZoomInAction) 1814 enmOperation = UIHelpViewer::ZoomOperation_In; 1815 else if (sender() == m_pZoomOutAction) 1816 enmOperation = UIHelpViewer::ZoomOperation_Out; 1817 m_pTabManager->sltHandleZoomOperation(enmOperation); 1880 1818 } 1881 1819 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r88408 r88410 169 169 QAction *m_pZoomInAction; 170 170 QAction *m_pZoomOutAction; 171 QAction *m_p FontSizeResetAction;171 QAction *m_pZoomResetAction; 172 172 173 173 /* This is set t true when handling QHelpContentModel::contentsCreated signal. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r88408 r88410 50 50 #ifdef VBOX_WITH_QHELP_VIEWER 51 51 52 //static int iZoomPercentageStep = 20;52 static int iZoomPercentageStep = 20; 53 53 const QPair<int, int> UIHelpViewer::zoomPercentageMinMax = QPair<int, int>(20, 300); 54 54 … … 341 341 , m_iSelectedMatchIndex(0) 342 342 , m_iSearchTermLength(0) 343 , m_iZoomPercentage(100) 343 344 { 344 345 m_iInitialFontPointSize = font().pointSize(); … … 415 416 } 416 417 417 int UIHelpViewer::initialFontPointSize() const418 {419 return m_iInitialFontPointSize;420 }421 422 418 void UIHelpViewer::setFont(const QFont &font) 423 419 { … … 441 437 void UIHelpViewer::zoom(ZoomOperation enmZoomOperation) 442 438 { 443 Q_UNUSED(enmZoomOperation); 444 } 445 439 int iPrevZoom = m_iZoomPercentage; 440 switch (enmZoomOperation) 441 { 442 case ZoomOperation_In: 443 m_iZoomPercentage += iZoomPercentageStep; 444 break; 445 case ZoomOperation_Out: 446 m_iZoomPercentage -= iZoomPercentageStep; 447 break; 448 case ZoomOperation_Reset: 449 default: 450 m_iZoomPercentage = 100; 451 break; 452 } 453 454 if (m_iZoomPercentage > zoomPercentageMinMax.second || 455 m_iZoomPercentage < zoomPercentageMinMax.first) 456 m_iZoomPercentage = iPrevZoom; 457 scaleFont(); 458 459 emit sigZoomPercentageChanged(m_iZoomPercentage); 460 } 446 461 447 462 void UIHelpViewer::contextMenuEvent(QContextMenuEvent *event) … … 640 655 } 641 656 642 void UIHelpViewer::iterateDocumentImages()643 {644 m_imageSizesMap.clear();645 QTextCursor cursor = textCursor();646 cursor.movePosition(QTextCursor::Start);647 while (!cursor.atEnd())648 {649 cursor.movePosition(QTextCursor::NextCharacter);650 if (cursor.charFormat().isImageFormat())651 {652 QTextImageFormat imageFormat = cursor.charFormat().toImageFormat();653 m_imageSizesMap[imageFormat.name()] = imageFormat.width();654 }655 }656 }657 658 657 void UIHelpViewer::sltHandleOpenLinkInNewTab() 659 658 { … … 731 730 } 732 731 732 void UIHelpViewer::iterateDocumentImages() 733 { 734 m_imageSizesMap.clear(); 735 QTextCursor cursor = textCursor(); 736 cursor.movePosition(QTextCursor::Start); 737 while (!cursor.atEnd()) 738 { 739 cursor.movePosition(QTextCursor::NextCharacter); 740 if (cursor.charFormat().isImageFormat()) 741 { 742 QTextImageFormat imageFormat = cursor.charFormat().toImageFormat(); 743 m_imageSizesMap[imageFormat.name()] = imageFormat.width(); 744 } 745 } 746 } 747 748 void UIHelpViewer::scaleFont() 749 { 750 QFont mFont = font(); 751 mFont.setPointSize(m_iInitialFontPointSize * m_iZoomPercentage / 100.); 752 setFont(mFont); 753 } 754 733 755 #include "UIHelpViewer.moc" 734 756 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h
r88408 r88410 36 36 class UIHelpViewer : public QIWithRetranslateUI<QTextBrowser> 37 37 { 38 38 39 Q_OBJECT; 39 40 … … 47 48 void sigGoHome(); 48 49 void sigAddBookmark(); 50 void sigZoomPercentageChanged(int iPercentage); 49 51 50 52 public: … … 62 64 void emitHistoryChangedSignal(); 63 65 void setSource(const QUrl &url) /* override */; 64 int initialFontPointSize() const;65 66 void setFont(const QFont &); 66 67 bool isFindInPageWidgetVisible() const; … … 99 100 void selectMatch(int iMatchIndex, int iSearchStringLength); 100 101 void iterateDocumentImages(); 102 void scaleFont(); 101 103 const QHelpEngine* m_pHelpEngine; 102 104 UIFindInPageWidget *m_pFindInPageWidget; … … 111 113 /** A container to store the original image sizes in the document. key is image name value is the width. */ 112 114 QMap<QString, qreal> m_imageSizesMap; 115 /** As percentage. */ 116 int m_iZoomPercentage; 113 117 }; 114 118
Note:
See TracChangeset
for help on using the changeset viewer.