Changeset 95251 in vbox
- Timestamp:
- Jun 12, 2022 5:01:37 PM (2 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
r95069 r95251 74 74 static const int iBookmarkUrlDataType = 6; 75 75 76 static int iZoomPercentageStep = 20; 77 const QPair<int, int> zoomPercentageMinMax = QPair<int, int>(20, 300); 76 78 77 79 /********************************************************************************************************************************* … … 196 198 void sigLinkHighlighted(const QString &strLink); 197 199 #endif 198 void sigZoomPercentageChanged(int iPercentage);199 200 void sigFindInPageWidgetVisibilityChanged(bool fVisible); 200 201 void sigHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable); 201 202 void sigMouseOverImage(const QString &strImageName); 203 void sigZoomRequest(UIHelpViewer::ZoomOperation enmZoomOperation); 202 204 203 205 public: … … 211 213 void setToolBarVisible(bool fVisible); 212 214 void print(QPrinter &printer); 213 void zoom(UIHelpViewer::ZoomOperation enmZoomOperation);214 int zoomPercentage() const;215 215 void setZoomPercentage(int iZoomPercentage); 216 216 void setHelpFileList(const QList<QUrl> &helpFileList); … … 302 302 void printCurrent(QPrinter &printer); 303 303 void switchToTab(int iIndex); 304 /** Returns the zoom percentage of 0th tab. */305 304 int zoomPercentage() const; 306 /** Sets the zoom percentage of all tabs. */307 305 void setZoomPercentage(int iZoomPercentage); 308 306 void setHelpFileList(const QList<QUrl> &helpFileList); … … 318 316 void sltCloseCurrentTab(); 319 317 void sltCloseOtherTabs(); 320 void sltZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation);321 318 void sltHomeAction(); 322 319 void sltAddBookmarkAction(); … … 324 321 void sltBackwardAction(); 325 322 void sltReloadPageAction(); 323 void sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation); 326 324 327 325 private slots: … … 356 354 QStringList m_tabTitleList; 357 355 QList<QUrl> m_helpFileList; 356 /** As percentage. */ 357 int m_iZoomPercentage; 358 358 }; 359 359 … … 624 624 } 625 625 626 void UIHelpBrowserTab::zoom(UIHelpViewer::ZoomOperation enmZoomOperation)627 {628 if (m_pContentViewer)629 m_pContentViewer->zoom(enmZoomOperation);630 }631 632 626 void UIHelpBrowserTab::setZoomPercentage(int iZoomPercentage) 633 627 { … … 672 666 if (m_pContentViewer) 673 667 return m_pContentViewer->sltSelectPreviousMatch(); 674 }675 676 int UIHelpBrowserTab::zoomPercentage() const677 {678 if (m_pContentViewer)679 return m_pContentViewer->zoomPercentage();680 return 100;681 668 } 682 669 … … 723 710 this, &UIHelpBrowserTab::sigLinkHighlighted); 724 711 #endif 725 connect(m_pContentViewer, &UIHelpViewer::sigZoomPercentageChanged,726 this, &UIHelpBrowserTab::sigZoomPercentageChanged);727 712 connect(m_pContentViewer, &UIHelpViewer::copyAvailable, 728 713 this, &UIHelpBrowserTab::sigCopyAvailableChanged); … … 731 716 connect(m_pContentViewer, &UIHelpViewer::sigMouseOverImage, 732 717 this, &UIHelpBrowserTab::sigMouseOverImage); 718 connect(m_pContentViewer, &UIHelpViewer::sigZoomRequest, 719 this, &UIHelpBrowserTab::sigZoomRequest); 733 720 734 721 m_pContentViewer->setSource(initialUrl); … … 929 916 , m_fSwitchToNewTab(true) 930 917 , m_fToolBarVisible(true) 918 , m_iZoomPercentage(100) 931 919 { 932 920 Q_UNUSED(m_fSwitchToNewTab); … … 956 944 connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark, 957 945 this, &UIHelpBrowserTabManager::sigAddBookmark); 958 connect(pTabWidget, &UIHelpBrowserTab::sigZoomPercentageChanged,959 this, &UIHelpBrowserTabManager::sigZoomPercentageChanged);960 946 connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted, 961 947 this, &UIHelpBrowserTabManager::sigLinkHighlighted); … … 968 954 connect(pTabWidget, &UIHelpBrowserTab::sigMouseOverImage, 969 955 this, &UIHelpBrowserTabManager::sigMouseOverImage); 956 connect(pTabWidget, &UIHelpBrowserTab::sigZoomRequest, 957 this, &UIHelpBrowserTabManager::sltHandleZoomRequest); 970 958 971 959 pTabWidget->setZoomPercentage(zoomPercentage()); 972 973 974 975 960 pTabWidget->setHelpFileList(m_helpFileList); 961 setFocusProxy(pTabWidget); 962 if (!fBackground) 963 setCurrentIndex(index); 976 964 } 977 965 … … 1110 1098 int UIHelpBrowserTabManager::zoomPercentage() const 1111 1099 { 1112 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(0)); 1113 if (pTab) 1114 return pTab->zoomPercentage(); 1115 return 100; 1116 } 1117 1118 void UIHelpBrowserTabManager::setZoomPercentage(int iZoomPercentage) 1119 { 1120 for (int i = 0; i < count(); ++i) 1121 { 1122 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i)); 1123 if (pTab) 1124 pTab->setZoomPercentage(iZoomPercentage); 1125 } 1100 return m_iZoomPercentage; 1126 1101 } 1127 1102 … … 1256 1231 } 1257 1232 1258 void UIHelpBrowserTabManager::sltZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation)1259 {1260 for (int i = 0; i < count(); ++i)1261 {1262 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));1263 if (pTab)1264 pTab->zoom(enmZoomOperation);1265 }1266 }1267 1268 1233 void UIHelpBrowserTabManager::sltShowTabBarContextMenu(const QPoint &pos) 1269 1234 { … … 1308 1273 if (pTab) 1309 1274 pTab->sltBackwardAction(); 1275 } 1276 1277 void UIHelpBrowserTabManager::sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation) 1278 { 1279 int iZoomPercentage = m_iZoomPercentage; 1280 switch (enmOperation) 1281 { 1282 case UIHelpViewer::ZoomOperation_In: 1283 iZoomPercentage += iZoomPercentageStep; 1284 break; 1285 case UIHelpViewer::ZoomOperation_Out: 1286 iZoomPercentage -= iZoomPercentageStep; 1287 break; 1288 case UIHelpViewer::ZoomOperation_Reset: 1289 default: 1290 iZoomPercentage = 100; 1291 break; 1292 } 1293 setZoomPercentage(iZoomPercentage); 1294 } 1295 1296 void UIHelpBrowserTabManager::setZoomPercentage(int iZoomPercentage) 1297 { 1298 1299 if (iZoomPercentage > zoomPercentageMinMax.second || 1300 iZoomPercentage < zoomPercentageMinMax.first) 1301 return; 1302 1303 m_iZoomPercentage = iZoomPercentage; 1304 1305 for (int i = 0; i < count(); ++i) 1306 { 1307 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i)); 1308 if (pTab) 1309 pTab->setZoomPercentage(m_iZoomPercentage); 1310 } 1311 emit sigZoomPercentageChanged(m_iZoomPercentage); 1310 1312 } 1311 1313 … … 2224 2226 return; 2225 2227 UIHelpViewer::ZoomOperation enmOperation = (UIHelpViewer::ZoomOperation)(iZoomOperation); 2226 m_pTabManager->slt ZoomOperation(enmOperation);2228 m_pTabManager->sltHandleZoomRequest(enmOperation); 2227 2229 } 2228 2230 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r95076 r95251 55 55 #ifdef VBOX_WITH_QHELP_VIEWER 56 56 57 static int iZoomPercentageStep = 20;58 const QPair<int, int> UIHelpViewer::zoomPercentageMinMax = QPair<int, int>(20, 300);59 60 61 57 /********************************************************************************************************************************* 62 58 * UIContextMenuNavigationAction definition. * … … 402 398 , m_iSelectedMatchIndex(0) 403 399 , m_iSearchTermLength(0) 404 , m_iZoomPercentage(100)405 400 , m_fOverlayMode(false) 406 401 , m_fCursorChanged(false) 407 402 , m_pOverlayLabel(0) 403 , m_iZoomPercentage(100) 408 404 { 409 405 m_iInitialFontPointSize = font().pointSize(); … … 546 542 } 547 543 548 void UIHelpViewer::zoom(ZoomOperation enmZoomOperation) 549 { 544 void UIHelpViewer::setZoomPercentage(int iZoomPercentage) 545 { 546 m_iZoomPercentage = iZoomPercentage; 550 547 clearOverlay(); 551 int iPrevZoom = m_iZoomPercentage;552 switch (enmZoomOperation)553 {554 case ZoomOperation_In:555 iPrevZoom += iZoomPercentageStep;556 break;557 case ZoomOperation_Out:558 iPrevZoom -= iZoomPercentageStep;559 break;560 case ZoomOperation_Reset:561 default:562 iPrevZoom = 100;563 break;564 }565 setZoomPercentage(iPrevZoom);566 }567 568 void UIHelpViewer::setZoomPercentage(int iZoomPercentage)569 {570 if (iZoomPercentage > zoomPercentageMinMax.second ||571 iZoomPercentage < zoomPercentageMinMax.first ||572 m_iZoomPercentage == iZoomPercentage)573 return;574 575 m_iZoomPercentage = iZoomPercentage;576 548 scaleFont(); 577 549 scaleImages(); 578 emit sigZoomPercentageChanged(m_iZoomPercentage);579 550 } 580 551 … … 590 561 { 591 562 return textCursor().hasSelection(); 592 }593 594 int UIHelpViewer::zoomPercentage() const595 {596 return m_iZoomPercentage;597 563 } 598 564 … … 690 656 { 691 657 if (pEvent->angleDelta().y() > 0) 692 zoom(ZoomOperation_In);658 emit sigZoomRequest(ZoomOperation_In); 693 659 else if (pEvent->angleDelta().y() < 0) 694 zoom(ZoomOperation_Out);660 emit sigZoomRequest(ZoomOperation_Out); 695 661 } 696 662 } … … 804 770 { 805 771 case Qt::Key_Equal: 806 zoom(ZoomOperation_In);772 emit sigZoomRequest(ZoomOperation_In); 807 773 break; 808 774 case Qt::Key_Minus: 809 zoom(ZoomOperation_Out);775 emit sigZoomRequest(ZoomOperation_Out); 810 776 break; 811 777 case Qt::Key_0: 812 zoom(ZoomOperation_Reset);778 emit sigZoomRequest(ZoomOperation_Reset); 813 779 break; 814 780 default: -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h
r94064 r95251 46 46 Q_OBJECT; 47 47 48 signals:49 50 void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);51 void sigFindInPageWidgetToogle(bool fVisible);52 void sigFontPointSizeChanged(int iFontPointSize);53 void sigGoBackward();54 void sigGoForward();55 void sigGoHome();56 void sigAddBookmark();57 void sigZoomPercentageChanged(int iPercentage);58 void sigMouseOverImage(const QString &strImageName);59 60 48 public: 61 49 … … 68 56 }; 69 57 58 signals: 59 60 void sigOpenLinkInNewTab(const QUrl &url, bool fBackground); 61 void sigFindInPageWidgetToogle(bool fVisible); 62 void sigFontPointSizeChanged(int iFontPointSize); 63 void sigGoBackward(); 64 void sigGoForward(); 65 void sigGoHome(); 66 void sigAddBookmark(); 67 void sigMouseOverImage(const QString &strImageName); 68 void sigZoomRequest(ZoomOperation enmZoomOperation); 69 70 public: 71 70 72 UIHelpViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0); 71 73 virtual QVariant loadResource(int type, const QUrl &name) RT_OVERRIDE; … … 76 78 void setFont(const QFont &); 77 79 bool isFindInPageWidgetVisible() const; 78 void zoom(ZoomOperation enmZoomOperation);79 int zoomPercentage() const;80 80 void setZoomPercentage(int iZoomPercentage); 81 81 void setHelpFileList(const QList<QUrl> &helpFileList); … … 155 155 /** A container to store the original image sizes/positions in the document. key is image name value is DocumentImage. */ 156 156 QHash<QString, DocumentImage> m_imageMap; 157 /** As percentage. */158 int m_iZoomPercentage;159 157 /** Used to change th document cursor back from m_handCursor. */ 160 158 QCursor m_defaultCursor; … … 167 165 QLabel *m_pOverlayLabel; 168 166 QGraphicsBlurEffect *m_pOverlayBlurEffect; 167 int m_iZoomPercentage; 169 168 }; 170 169
Note:
See TracChangeset
for help on using the changeset viewer.