Changeset 86866 in vbox
- Timestamp:
- Nov 12, 2020 7:28:34 AM (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
r86861 r86866 80 80 static const int iBookmarkUrlDataType = 6; 81 81 static const QPair<float, float> fontScaleMinMax(0.5f, 3.f); 82 static int iFontPointSizeChangeStep = 2; 82 83 83 84 /********************************************************************************************************************************* … … 303 304 int initialFontPointSize() const; 304 305 void setFontPointSize(int iPointSize); 306 int fontPointSize() const; 305 307 306 308 private slots: … … 368 370 int initialFontPointSize() const; 369 371 void setFontPointSize(int iPointSize); 372 int fontPointSize() const; 370 373 371 374 protected: … … 477 480 if (!sender()) 478 481 return; 479 int iStep = 2;480 482 int iNewSize = m_iFontPointSize; 481 483 if (sender() == m_pMinusButton) 482 iNewSize -= i Step;484 iNewSize -= iFontPointSizeChangeStep; 483 485 else if (sender() == m_pPlusButton) 484 iNewSize += i Step;486 iNewSize += iFontPointSizeChangeStep; 485 487 else if (sender() == m_pResetButton) 486 488 iNewSize = m_iInitialFontPointSize; … … 767 769 } 768 770 771 int UIHelpBrowserTab::fontPointSize() const 772 { 773 if (!m_pContentViewer) 774 return 0; 775 return m_pContentViewer->font().pointSize(); 776 } 777 769 778 void UIHelpBrowserTab::prepare(const QUrl &initialUrl) 770 779 { … … 1352 1361 if (m_pFontScaleWidget) 1353 1362 m_pFontScaleWidget->setFontPointSize(iPointSize); 1363 } 1364 1365 int UIHelpBrowserTabManager::fontPointSize() const 1366 { 1367 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget()); 1368 if (!pTab) 1369 return 0; 1370 return pTab->fontPointSize(); 1354 1371 } 1355 1372 … … 1448 1465 , m_pShowHideSideBarAction(0) 1449 1466 , m_pShowHideToolBarAction(0) 1467 , m_pFontSizeLargerAction(0) 1468 , m_pFontSizeSmallerAction(0) 1469 , m_pFontSizeResetAction(0) 1450 1470 , m_fModelContentCreated(false) 1451 1471 { … … 1457 1477 UIHelpBrowserWidget::~UIHelpBrowserWidget() 1458 1478 { 1459 /* Cleanup VM Log-Viewer: */1460 1479 cleanup(); 1461 1480 } … … 1477 1496 void UIHelpBrowserWidget::prepare() 1478 1497 { 1479 /* Create main layout: */1480 1498 m_pMainLayout = new QVBoxLayout(this); 1481 1499 AssertReturnVoid(m_pMainLayout); 1482 1500 1483 1501 prepareActions(); 1484 //prepareToolBar();1485 1502 prepareWidgets(); 1486 1503 prepareSearchWidgets(); … … 1506 1523 connect(m_pPrintDialogAction, &QAction::triggered, 1507 1524 this, &UIHelpBrowserWidget::sltShowPrintDialog); 1525 1526 m_pFontSizeLargerAction = new QAction(this); 1527 m_pFontSizeLargerAction->setIcon(UIIconPool::iconSet(":/help_browser_plus_32px.png")); 1528 1529 m_pFontSizeSmallerAction = new QAction(this); 1530 m_pFontSizeSmallerAction->setIcon(UIIconPool::iconSet(":/help_browser_minus_32px.png")); 1531 1532 m_pFontSizeResetAction = new QAction(this); 1533 m_pFontSizeResetAction->setIcon(UIIconPool::iconSet(":/help_browser_reset_32px.png")); 1534 1535 connect(m_pFontSizeLargerAction, &QAction::triggered, 1536 this, &UIHelpBrowserWidget::sltHandleFontSizeactions); 1537 connect(m_pFontSizeSmallerAction, &QAction::triggered, 1538 this, &UIHelpBrowserWidget::sltHandleFontSizeactions); 1539 connect(m_pFontSizeResetAction, &QAction::triggered, 1540 this, &UIHelpBrowserWidget::sltHandleFontSizeactions); 1508 1541 } 1509 1542 … … 1590 1623 connect(m_pSearchResultWidget, &QHelpContentWidget::customContextMenuRequested, 1591 1624 this, &UIHelpBrowserWidget::sltShowLinksContextMenu); 1592 1593 // connect(searchEngine, &QHelpSearchEngine::searchingStarted,1594 // this, &SearchWidget::searchingStarted);1595 // connect(searchEngine, &QHelpSearchEngine::searchingFinished,1596 // this, &SearchWidget::searchingFinished);1597 1598 1625 connect(m_pSearchEngine, &QHelpSearchEngine::indexingStarted, 1599 1626 this, &UIHelpBrowserWidget::sltHandleIndexingStarted); 1600 1627 connect(m_pSearchEngine, &QHelpSearchEngine::indexingFinished, 1601 1628 this, &UIHelpBrowserWidget::sltHandleIndexingFinished); 1602 1603 1629 connect(m_pSearchEngine, &QHelpSearchEngine::searchingStarted, 1604 1630 this, &UIHelpBrowserWidget::sltHandleSearchingStarted); … … 1610 1636 { 1611 1637 m_pTopLayout = new QHBoxLayout; 1612 /* Create toolbar: */1613 1638 m_pToolBar = new QIToolBar(parentWidget()); 1614 1639 if (m_pToolBar) 1615 1640 { 1616 /* Configure toolbar: */1617 1641 m_pToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); 1618 1642 const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize)); 1619 1643 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 1620 // m_pToolBar->addAction(m_pBackwardAction);1621 // m_pToolBar->addAction(m_pForwardAction);1622 // m_pToolBar->addAction(m_pHomeAction);1623 // m_pToolBar->addAction(m_pAddBookmarkAction);1624 1644 1625 1645 #ifdef VBOX_WS_MAC … … 1648 1668 m_pFileMenu->addAction(m_pPrintDialogAction); 1649 1669 1670 if (m_pFontSizeLargerAction) 1671 m_pViewMenu->addAction(m_pFontSizeLargerAction); 1672 if (m_pFontSizeSmallerAction) 1673 m_pViewMenu->addAction(m_pFontSizeSmallerAction); 1674 if (m_pFontSizeResetAction) 1675 m_pViewMenu->addAction(m_pFontSizeResetAction); 1676 m_pViewMenu->addSeparator(); 1650 1677 if (m_pShowHideSideBarAction) 1651 1678 m_pViewMenu->addAction(m_pShowHideSideBarAction); … … 1656 1683 void UIHelpBrowserWidget::loadOptions() 1657 1684 { 1658 // if (m_pContentViewer && m_pHelpEngine)1659 // {1660 // QUrl url(gEDataManager->helpBrowserLastUrl());1661 // if (url.isEmpty())1662 // return;1663 // if (url.isValid())1664 // {1665 // if (m_pHelpEngine->findFile(url).isValid())1666 // {1667 // m_pContentViewer->setSource(url);1668 // m_pContentViewer->clearHistory();1669 // }1670 // else1671 // show404Error(url);1672 // }1673 // }1674 1685 } 1675 1686 … … 1753 1764 m_pTabWidget->setTabText(HelpBrowserTabs_Bookmarks, tr("Bookmarks")); 1754 1765 } 1766 1755 1767 if (m_pShowHideSideBarAction) 1756 m_pShowHideSideBarAction->setText(tr("Show/Hide Side Bar")); 1757 1768 m_pShowHideSideBarAction->setText(tr("Show Side Bar")); 1758 1769 if (m_pShowHideToolBarAction) 1759 m_pShowHideToolBarAction->setText(tr("Show /HideTool Bar"));1770 m_pShowHideToolBarAction->setText(tr("Show Tool Bar")); 1760 1771 if (m_pPrintDialogAction) 1761 1772 m_pPrintDialogAction->setText(tr("Print...")); 1773 1774 if (m_pFontSizeLargerAction) 1775 m_pFontSizeLargerAction->setText(tr("Increase Font Size")); 1776 if (m_pFontSizeSmallerAction) 1777 m_pFontSizeSmallerAction->setText(tr("Decrease Font Size")); 1778 if (m_pFontSizeResetAction) 1779 m_pFontSizeResetAction->setText(tr("Reset Font Size")); 1762 1780 } 1763 1781 … … 1766 1784 { 1767 1785 QWidget::showEvent(pEvent); 1768 1769 /* One may think that QWidget::polish() is the right place to do things 1770 * below, but apparently, by the time when QWidget::polish() is called, 1771 * the widget style & layout are not fully done, at least the minimum 1772 * size hint is not properly calculated. Since this is sometimes necessary, 1773 * we provide our own "polish" implementation: */ 1774 1775 if (m_fIsPolished) 1776 return; 1777 1786 if (m_fIsPolished) 1787 return; 1778 1788 m_fIsPolished = true; 1779 1789 } … … 1803 1813 QPrintDialog printDialog(&printer, this); 1804 1814 if (printDialog.exec() == QDialog::Accepted) 1805 {1806 1815 m_pTabManager->printCurrent(printer); 1807 // PrintWidget(this);1808 }1809 1816 } 1810 1817 … … 1855 1862 if (m_pSearchContainerWidget) 1856 1863 m_pSearchContainerWidget->setEnabled(false); 1857 printf("indexing started\n");1858 1864 } 1859 1865 … … 1862 1868 if (m_pSearchContainerWidget) 1863 1869 m_pSearchContainerWidget->setEnabled(true); 1864 1865 printf("indexing finished\n");1866 1870 } 1867 1871 1868 1872 void UIHelpBrowserWidget::sltHandleSearchingStarted() 1869 1873 { 1870 1871 1874 } 1872 1875 … … 1955 1958 } 1956 1959 1960 void UIHelpBrowserWidget::sltHandleFontSizeactions() 1961 { 1962 if (!sender() || !m_pTabManager) 1963 return; 1964 int iFontPointSize = m_pTabManager->fontPointSize(); 1965 if (sender() == m_pFontSizeResetAction) 1966 iFontPointSize = m_pTabManager->initialFontPointSize(); 1967 else if (sender() == m_pFontSizeLargerAction) 1968 iFontPointSize += iFontPointSizeChangeStep; 1969 else if (sender() == m_pFontSizeSmallerAction) 1970 iFontPointSize -= iFontPointSizeChangeStep; 1971 m_pTabManager->setFontPointSize(iFontPointSize); 1972 } 1973 1957 1974 #include "UIHelpBrowserWidget.moc" 1958 1975 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86844 r86866 101 101 void sltOpenLink(); 102 102 void sltAddNewBookmark(const QUrl &url, const QString &strTitle); 103 void sltHandleFontSizeactions(); 103 104 104 105 private: … … 167 168 QAction *m_pShowHideSideBarAction; 168 169 QAction *m_pShowHideToolBarAction; 170 QAction *m_pFontSizeLargerAction; 171 QAction *m_pFontSizeSmallerAction; 172 QAction *m_pFontSizeResetAction; 169 173 /* This is set t true when handling QHelpContentModel::contentsCreated signal. */ 170 174 bool m_fModelContentCreated;
Note:
See TracChangeset
for help on using the changeset viewer.