Changeset 88436 in vbox
- Timestamp:
- Apr 9, 2021 1:35:23 PM (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
r88423 r88436 39 39 # include <QFontDatabase> 40 40 #endif 41 #include <QWidgetAction> 41 42 42 43 /* GUI includes: */ … … 71 72 72 73 /********************************************************************************************************************************* 73 * UIZoom Widget definition.*74 * UIZoomMenuAction definition. * 74 75 *********************************************************************************************************************************/ 75 class UIZoom Widget : public QIWithRetranslateUI<QWidget>76 class UIZoomMenuAction : public QIWithRetranslateUI<QWidgetAction> 76 77 { 77 78 … … 80 81 signals: 81 82 82 void sigZoomChanged( UIHelpViewer::ZoomOperation enmOperation);83 void sigZoomChanged(int iOperation); 83 84 84 85 public: 85 86 86 87 UIZoomWidget(QWidget *pParent = 0); 88 int zoomPercentage() const; 87 UIZoomMenuAction(QWidget *pParent = 0); 89 88 void setZoomPercentage(int iZoomPercentage); 90 89 … … 101 100 void prepare(); 102 101 103 QHBoxLayout *m_pMainLayout;104 102 QIToolButton *m_pMinusButton; 105 103 QIToolButton *m_pResetButton; 106 104 QIToolButton *m_pPlusButton; 107 105 QLabel *m_pValueLabel; 106 QLabel *m_pLabel; 108 107 }; 109 108 … … 255 254 void sigTabsListChanged(const QStringList &titleList); 256 255 void sigLinkHighlighted(const QString &strLink); 256 void sigZoomPercentageChanged(int iPercentage); 257 257 258 258 public: … … 271 271 void setToolBarVisible(bool fVisible); 272 272 void printCurrent(QPrinter &printer); 273 void setZoomWidgetVisible(bool fToggled);274 273 void switchToTab(int iIndex); 275 /** returns the zoom percentage of 0th tab. */274 /** Returns the zoom percentage of 0th tab. */ 276 275 int zoomPercentage() const; 277 276 /** Sets the zoom percentage of all tabs. */ … … 284 283 void sltHandleCloseOtherTabs(); 285 284 void sltHandleZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation); 286 287 protected:288 289 virtual void paintEvent(QPaintEvent *pEvent) /* override */;290 285 291 286 private slots: … … 298 293 void sltShowTabBarContextMenu(const QPoint &pos); 299 294 void sltHandleCloseOtherTabsContextMenuAction(); 300 void sltZoomPercentageChanged(int iPercentage);301 295 302 296 private: … … 313 307 314 308 const QHelpEngine* m_pHelpEngine; 315 UIZoomWidget *m_pZoomWidget;316 309 QUrl m_homeUrl; 317 310 QStringList m_savedUrlList; … … 325 318 326 319 /********************************************************************************************************************************* 327 * UIZoom Widget implementation.*320 * UIZoomMenuAction implementation. * 328 321 *********************************************************************************************************************************/ 329 330 UIZoomWidget::UIZoomWidget(QWidget *pParent /* = 0 */) 331 :QIWithRetranslateUI<QWidget>(pParent) 332 , m_pMainLayout(0) 322 UIZoomMenuAction::UIZoomMenuAction(QWidget *pParent /* = 0 */) 323 :QIWithRetranslateUI<QWidgetAction>(pParent) 333 324 , m_pMinusButton(0) 334 325 , m_pResetButton(0) 335 326 , m_pPlusButton(0) 336 327 , m_pValueLabel(0) 328 , m_pLabel(0) 337 329 { 338 330 prepare(); 339 } 340 341 void UIZoomWidget::retranslateUi() 342 { 343 } 344 345 void UIZoomWidget::prepare() 346 { 347 setAutoFillBackground(true); 348 m_pMainLayout = new QHBoxLayout(this); 349 AssertReturnVoid(m_pMainLayout); 350 m_pMainLayout->setSpacing(0); 351 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 331 retranslateUi(); 332 } 333 334 void UIZoomMenuAction::setZoomPercentage(int iZoomPercentage) 335 { 336 if (m_pValueLabel) 337 m_pValueLabel->setText(QString("%1%2").arg(QString::number(iZoomPercentage)).arg("%")); 338 } 339 340 void UIZoomMenuAction::retranslateUi() 341 { 342 if (m_pLabel) 343 m_pLabel->setText(UIHelpBrowserWidget::tr("Zoom")); 344 } 345 346 void UIZoomMenuAction::prepare() 347 { 348 QWidget *pWidget = new QWidget; 349 setDefaultWidget(pWidget); 350 // if (pWidget) 351 // pWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 352 353 QHBoxLayout *pMainLayout = new QHBoxLayout(pWidget); 354 pMainLayout->setSpacing(0); 355 AssertReturnVoid(pMainLayout); 356 357 m_pLabel = new QLabel; 352 358 m_pMinusButton = new QIToolButton; 353 359 m_pResetButton = new QIToolButton; 354 360 m_pPlusButton = new QIToolButton; 355 361 m_pValueLabel = new QLabel; 362 m_pValueLabel->setAlignment(Qt::AlignCenter); 363 m_pValueLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 356 364 AssertReturnVoid(m_pMinusButton && 357 365 m_pResetButton && … … 363 371 m_pPlusButton->setIcon(UIIconPool::iconSet(":/help_browser_plus_32px.png")); 364 372 365 connect(m_pPlusButton, &QIToolButton::pressed, this, &UIZoomWidget::sltZoomOperation); 366 connect(m_pMinusButton, &QIToolButton::pressed, this, &UIZoomWidget::sltZoomOperation); 367 connect(m_pResetButton, &QIToolButton::pressed, this, &UIZoomWidget::sltZoomOperation); 368 369 m_pMainLayout->addWidget(m_pResetButton); 370 m_pMainLayout->addWidget(m_pMinusButton); 371 m_pMainLayout->addWidget(m_pValueLabel); 372 m_pMainLayout->addWidget(m_pPlusButton); 373 } 374 375 void UIZoomWidget::setZoomPercentage(int iZoomPercentage) 376 { 377 if (m_pValueLabel) 378 m_pValueLabel->setText(QString("%1%2").arg(QString::number(iZoomPercentage)).arg("%")); 379 } 380 381 void UIZoomWidget::sltZoomOperation() 373 connect(m_pPlusButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation); 374 connect(m_pMinusButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation); 375 connect(m_pResetButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation); 376 377 pMainLayout->addWidget(m_pLabel); 378 pMainLayout->addWidget(m_pResetButton); 379 pMainLayout->addWidget(m_pMinusButton); 380 pMainLayout->addWidget(m_pValueLabel, Qt::AlignCenter); 381 pMainLayout->addWidget(m_pPlusButton); 382 } 383 384 void UIZoomMenuAction::sltZoomOperation() 382 385 { 383 386 if (!sender()) … … 390 393 else if (sender() == m_pResetButton) 391 394 enmOperation = UIHelpViewer::ZoomOperation_Reset; 392 emit sigZoomChanged( enmOperation);395 emit sigZoomChanged((int)enmOperation); 393 396 } 394 397 … … 807 810 : QITabWidget(pParent) 808 811 , m_pHelpEngine(pHelpEngine) 809 , m_pZoomWidget(0)810 812 , m_homeUrl(homeUrl) 811 813 , m_savedUrlList(urlList) … … 840 842 this, &UIHelpBrowserTabManager::sigAddBookmark); 841 843 connect(pTabWidget, &UIHelpBrowserTab::sigZoomPercentageChanged, 842 this, &UIHelpBrowserTabManager::s ltZoomPercentageChanged);844 this, &UIHelpBrowserTabManager::sigZoomPercentageChanged); 843 845 connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted, 844 846 this, &UIHelpBrowserTabManager::sigLinkHighlighted); … … 849 851 if (!fBackground) 850 852 setCurrentIndex(index); 851 852 if (!m_pZoomWidget)853 {854 m_pZoomWidget = new UIZoomWidget(this);855 connect(m_pZoomWidget, &UIZoomWidget::sigZoomChanged,856 this, &UIHelpBrowserTabManager::sltHandleZoomOperation);857 m_pZoomWidget->setZoomPercentage(100);858 }859 853 } 860 854 … … 985 979 } 986 980 987 void UIHelpBrowserTabManager::paintEvent(QPaintEvent *pEvent)988 {989 if (m_pZoomWidget)990 {991 int iMargin = 1.5 * qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);992 m_pZoomWidget->move(width() - m_pZoomWidget->width() - iMargin,993 height() - m_pZoomWidget->height() - iMargin);994 }995 QITabWidget::paintEvent(pEvent);996 }997 998 void UIHelpBrowserTabManager::setZoomWidgetVisible(bool fToggled)999 {1000 if (m_pZoomWidget)1001 m_pZoomWidget->setVisible(fToggled);1002 }1003 1004 981 void UIHelpBrowserTabManager::switchToTab(int iIndex) 1005 982 { … … 1086 1063 return; 1087 1064 closeAllTabsBut(iTabIndex); 1088 }1089 1090 void UIHelpBrowserTabManager::sltZoomPercentageChanged(int iPercentage)1091 {1092 if (m_pZoomWidget)1093 m_pZoomWidget->setZoomPercentage(iPercentage);1094 1065 } 1095 1066 … … 1191 1162 , m_pShowHideSideBarAction(0) 1192 1163 , m_pShowHideToolBarAction(0) 1193 , m_pShowHideZoomWidgetAction(0)1194 1164 , m_pShowHideStatusBarAction(0) 1195 , m_pZoomInAction(0) 1196 , m_pZoomOutAction(0) 1197 , m_pZoomResetAction(0) 1165 , m_pZoomMenuAction(0) 1198 1166 , m_fModelContentCreated(false) 1199 1167 , m_fIndexingFinished(false) … … 1264 1232 this, &UIHelpBrowserWidget::sltHandleWidgetVisibilityToggle); 1265 1233 1266 m_pShowHideZoomWidgetAction = new QAction(this);1267 m_pShowHideZoomWidgetAction->setCheckable(true);1268 m_pShowHideZoomWidgetAction->setChecked(true);1269 connect(m_pShowHideZoomWidgetAction, &QAction::toggled,1270 this, &UIHelpBrowserWidget::sltHandleWidgetVisibilityToggle);1271 1272 1234 m_pShowHideStatusBarAction = new QAction(this); 1273 1235 m_pShowHideStatusBarAction->setCheckable(true); … … 1285 1247 this, &UIHelpBrowserWidget::sigCloseDialog); 1286 1248 1287 /* For size control actions: */ 1288 m_pZoomInAction = new QAction(this); 1289 m_pZoomInAction->setIcon(UIIconPool::iconSet(":/help_browser_plus_32px.png")); 1290 1291 m_pZoomOutAction = new QAction(this); 1292 m_pZoomOutAction->setIcon(UIIconPool::iconSet(":/help_browser_minus_32px.png")); 1293 1294 m_pZoomResetAction = new QAction(this); 1295 m_pZoomResetAction->setIcon(UIIconPool::iconSet(":/help_browser_reset_32px.png")); 1296 1297 connect(m_pZoomInAction, &QAction::triggered, 1298 this, &UIHelpBrowserWidget::sltHandleZoomActions); 1299 connect(m_pZoomOutAction, &QAction::triggered, 1300 this, &UIHelpBrowserWidget::sltHandleZoomActions); 1301 connect(m_pZoomResetAction, &QAction::triggered, 1249 m_pZoomMenuAction = new UIZoomMenuAction(this); 1250 connect(m_pZoomMenuAction, &UIZoomMenuAction::sigZoomChanged, 1302 1251 this, &UIHelpBrowserWidget::sltHandleZoomActions); 1303 1252 } … … 1348 1297 connect(m_pTabManager, &UIHelpBrowserTabManager::sigLinkHighlighted, 1349 1298 this, &UIHelpBrowserWidget::sigLinkHighlighted); 1299 connect(m_pTabManager, &UIHelpBrowserTabManager::sigZoomPercentageChanged, 1300 this, &UIHelpBrowserWidget::sltZoomPercentageChanged); 1350 1301 1351 1302 connect(m_pHelpEngine, &QHelpEngine::setupFinished, … … 1444 1395 m_pFileMenu->addAction(m_pCloseDialogAction); 1445 1396 1446 if (m_pZoomInAction) 1447 m_pViewMenu->addAction(m_pZoomInAction); 1448 if (m_pZoomOutAction) 1449 m_pViewMenu->addAction(m_pZoomOutAction); 1450 if (m_pZoomResetAction) 1451 m_pViewMenu->addAction(m_pZoomResetAction); 1452 m_pViewMenu->addSeparator(); 1397 if (m_pZoomMenuAction) 1398 m_pViewMenu->addAction(m_pZoomMenuAction); 1453 1399 if (m_pShowHideSideBarAction) 1454 1400 m_pViewMenu->addAction(m_pShowHideSideBarAction); 1455 1401 if (m_pShowHideToolBarAction) 1456 1402 m_pViewMenu->addAction(m_pShowHideToolBarAction); 1457 if (m_pShowHideZoomWidgetAction)1458 m_pViewMenu->addAction(m_pShowHideZoomWidgetAction);1459 1403 if (m_pShowHideStatusBarAction) 1460 1404 m_pViewMenu->addAction(m_pShowHideStatusBarAction); … … 1579 1523 if (m_pShowHideToolBarAction) 1580 1524 m_pShowHideToolBarAction->setText(tr("Show Tool Bar")); 1581 if (m_pShowHideZoomWidgetAction)1582 m_pShowHideZoomWidgetAction->setText(tr("Show Zoom Widget"));1583 1525 if (m_pShowHideStatusBarAction) 1584 1526 m_pShowHideStatusBarAction->setText(tr("Show Status Bar")); 1585 1586 1527 1587 1528 if (m_pPrintAction) … … 1589 1530 if (m_pCloseDialogAction) 1590 1531 m_pCloseDialogAction->setText(tr("Close")); 1591 1592 if (m_pZoomInAction)1593 m_pZoomInAction->setText(tr("Zoom &In"));1594 if (m_pZoomOutAction)1595 m_pZoomOutAction->setText(tr("Zoom &Out"));1596 if (m_pZoomResetAction)1597 m_pZoomResetAction->setText(tr("&Reset Zoom"));1598 1532 } 1599 1533 … … 1634 1568 if (m_pTabManager) 1635 1569 m_pTabManager->setToolBarVisible(fToggled); 1636 }1637 else if (sender() == m_pShowHideZoomWidgetAction)1638 {1639 if (m_pTabManager)1640 m_pTabManager->setZoomWidgetVisible(fToggled);1641 1570 } 1642 1571 else if (sender() == m_pShowHideStatusBarAction) … … 1864 1793 } 1865 1794 1866 void UIHelpBrowserWidget::sltHandleZoomActions() 1867 { 1868 if (!sender() || !m_pTabManager) 1869 return; 1870 UIHelpViewer::ZoomOperation enmOperation = UIHelpViewer::ZoomOperation_Reset; 1871 if (sender() == m_pZoomResetAction) 1872 enmOperation = UIHelpViewer::ZoomOperation_Reset; 1873 else if (sender() == m_pZoomInAction) 1874 enmOperation = UIHelpViewer::ZoomOperation_In; 1875 else if (sender() == m_pZoomOutAction) 1876 enmOperation = UIHelpViewer::ZoomOperation_Out; 1795 void UIHelpBrowserWidget::sltHandleZoomActions(int iZoomOperation) 1796 { 1797 if (iZoomOperation >= (int) UIHelpViewer::ZoomOperation_Max) 1798 return; 1799 UIHelpViewer::ZoomOperation enmOperation = (UIHelpViewer::ZoomOperation)(iZoomOperation); 1877 1800 m_pTabManager->sltHandleZoomOperation(enmOperation); 1878 1801 } … … 1909 1832 } 1910 1833 1834 void UIHelpBrowserWidget::sltZoomPercentageChanged(int iPercentage) 1835 { 1836 if (m_pZoomMenuAction) 1837 m_pZoomMenuAction->setZoomPercentage(iPercentage); 1838 } 1839 1911 1840 1912 1841 #include "UIHelpBrowserWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r88410 r88436 46 46 class UIBookmarksListContainer; 47 47 class UIHelpBrowserTabManager; 48 class UIZoomMenuAction; 48 49 49 50 #ifdef VBOX_WITH_QHELP_VIEWER … … 91 92 void sltCopyLink(); 92 93 void sltAddNewBookmark(const QUrl &url, const QString &strTitle); 93 void sltHandleZoomActions( );94 void sltHandleZoomActions(int iZoomOperation); 94 95 void sltHandleTabListChanged(const QStringList &titleList); 95 96 void sltHandleTabChoose(); 96 97 void sltHandleCurrentTabChanged(int iIndex); 98 void sltZoomPercentageChanged(int iPercentage); 97 99 98 100 private: … … 165 167 QAction *m_pShowHideSideBarAction; 166 168 QAction *m_pShowHideToolBarAction; 167 QAction *m_pShowHideZoomWidgetAction;168 169 QAction *m_pShowHideStatusBarAction; 169 QAction *m_pZoomInAction; 170 QAction *m_pZoomOutAction; 171 QAction *m_pZoomResetAction; 170 UIZoomMenuAction *m_pZoomMenuAction; 172 171 173 172 /* This is set t true when handling QHelpContentModel::contentsCreated signal. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r88430 r88436 78 78 void setForwardAvailable(bool fAvailable); 79 79 80 protected:81 82 83 private slots:84 85 86 80 private: 87 81 … … 185 179 pMainLayout->addWidget(m_pAddBookmarkButton); 186 180 pMainLayout->setContentsMargins(0, 0, 0, 0); 187 //pMainLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));188 181 189 182 connect(m_pBackwardButton, &QIToolButton::pressed,
Note:
See TracChangeset
for help on using the changeset viewer.