Changeset 86961 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 23, 2020 5:26:14 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r86861 r86961 390 390 <file alias="help_browser_home_32px.png">images/help_browser_home_32px.png</file> 391 391 <file alias="help_browser_search.png">images/help_browser_search.png</file> 392 <file alias="help_browser_star_16px.png">images/help_browser_star_16px.png</file> 392 393 <file alias="help_16px.png">images/help_16px.png</file> 393 394 <file alias="help_button_normal_mac_24px.png">images/help_button_normal_mac_24px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86958 r86961 400 400 void sigSourceChanged(const QUrl &url); 401 401 void sigAddBookmark(const QUrl &url, const QString &strTitle); 402 /** list.first is tab title and list.second is tab's index. */ 403 void sigTabsListChanged(const QStringList &titleList); 402 404 403 405 public: … … 405 407 UIHelpBrowserTabManager(const QHelpEngine *pHelpEngine, const QUrl &homeUrl, 406 408 const QStringList &urlList, QWidget *pParent = 0); 409 /* Return the list of urls of all open tabs as QStringList. */ 407 410 QStringList tabUrlList() const; 411 QStringList tabTitleList() const; 412 408 413 /** Either start with a single tab showin the home url or saved tab(s). Depending on the params. passed to ctor. */ 409 414 void initializeTabs(); … … 411 416 QUrl currentSource() const; 412 417 void setSource(const QUrl &url, bool fNewTab = false); 413 /* Return the list of urls of all open tabs as QStringList. */414 QStringList tabUrlList();415 418 void setToolBarVisible(bool fVisible); 416 419 void printCurrent(QPrinter &printer); … … 419 422 int fontPointSize() const; 420 423 void setFontScaleWidgetVisible(bool fToggled); 424 void switchToTab(int iIndex); 421 425 422 426 protected: … … 441 445 void clearAndDeleteTabs(); 442 446 void addNewTab(const QUrl &initialUrl); 447 /** Check if lists of tab url/title has changed. if so emit a signal. */ 448 void updateTabUrlTitleList(); 443 449 const QHelpEngine* m_pHelpEngine; 444 450 UIFontScaleWidget *m_pFontScaleWidget; … … 448 454 bool m_fSwitchToNewTab; 449 455 bool m_fToolBarVisible; 456 QStringList m_tabTitleList; 450 457 }; 451 458 … … 1490 1497 } 1491 1498 1499 void UIHelpBrowserTabManager::updateTabUrlTitleList() 1500 { 1501 QList<QPair<QString, int> > newList; 1502 1503 QStringList titles = tabTitleList(); 1504 1505 if (titles == m_tabTitleList) 1506 return; 1507 1508 m_tabTitleList = titles; 1509 1510 emit sigTabsListChanged(m_tabTitleList); 1511 } 1512 1492 1513 void UIHelpBrowserTabManager::initializeTabs() 1493 1514 { … … 1500 1521 for (int i = 0; i < m_savedUrlList.size(); ++i) 1501 1522 addNewTab(m_savedUrlList[i]); 1523 updateTabUrlTitleList(); 1502 1524 } 1503 1525 … … 1521 1543 else 1522 1544 addNewTab(url); 1523 } 1524 1525 QStringList UIHelpBrowserTabManager::tabUrlList() 1545 1546 updateTabUrlTitleList(); 1547 } 1548 1549 QStringList UIHelpBrowserTabManager::tabUrlList() const 1526 1550 { 1527 1551 QStringList list; … … 1536 1560 } 1537 1561 1562 QStringList UIHelpBrowserTabManager::tabTitleList() const 1563 { 1564 QStringList list; 1565 for (int i = 0; i < count(); ++i) 1566 { 1567 UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i)); 1568 if (!pTab || !pTab->source().isValid()) 1569 continue; 1570 list << pTab->documentTitle(); 1571 } 1572 return list; 1573 } 1574 1575 1538 1576 void UIHelpBrowserTabManager::setToolBarVisible(bool fVisible) 1539 1577 { … … 1602 1640 if (m_pFontScaleWidget) 1603 1641 m_pFontScaleWidget->setVisible(fToggled); 1642 } 1643 1644 void UIHelpBrowserTabManager::switchToTab(int iIndex) 1645 { 1646 if (iIndex == currentIndex()) 1647 return; 1648 setCurrentIndex(iIndex); 1604 1649 } 1605 1650 … … 1615 1660 } 1616 1661 } 1662 updateTabUrlTitleList(); 1617 1663 } 1618 1664 … … 1621 1667 if (url.isValid()) 1622 1668 addNewTab(url); 1669 updateTabUrlTitleList(); 1623 1670 } 1624 1671 … … 1632 1679 removeTab(iTabIndex); 1633 1680 delete pWidget; 1681 updateTabUrlTitleList(); 1634 1682 } 1635 1683 … … 1664 1712 } 1665 1713 addTab(widgetList[iTabIndex], strTitle); 1714 updateTabUrlTitleList(); 1666 1715 } 1667 1716 … … 1735 1784 , m_pFileMenu(0) 1736 1785 , m_pViewMenu(0) 1786 , m_pTabsMenu(0) 1737 1787 , m_pContentWidget(0) 1738 1788 , m_pIndexWidget(0) … … 1769 1819 menuList 1770 1820 << m_pFileMenu 1771 << m_pViewMenu; 1821 << m_pViewMenu 1822 << m_pTabsMenu; 1772 1823 return menuList; 1773 1824 } … … 1797 1848 1798 1849 prepareActions(); 1850 prepareMenu(); 1799 1851 prepareWidgets(); 1800 1852 prepareSearchWidgets(); 1801 prepareMenu();1802 1853 loadBookmarks(); 1803 1854 retranslateUi(); … … 1838 1889 1839 1890 connect(m_pFontSizeLargerAction, &QAction::triggered, 1840 this, &UIHelpBrowserWidget::sltHandleFontSize actions);1891 this, &UIHelpBrowserWidget::sltHandleFontSizeActions); 1841 1892 connect(m_pFontSizeSmallerAction, &QAction::triggered, 1842 this, &UIHelpBrowserWidget::sltHandleFontSize actions);1893 this, &UIHelpBrowserWidget::sltHandleFontSizeActions); 1843 1894 connect(m_pFontSizeResetAction, &QAction::triggered, 1844 this, &UIHelpBrowserWidget::sltHandleFontSize actions);1895 this, &UIHelpBrowserWidget::sltHandleFontSizeActions); 1845 1896 } 1846 1897 … … 1883 1934 connect(m_pTabManager, &UIHelpBrowserTabManager::sigAddBookmark, 1884 1935 this, &UIHelpBrowserWidget::sltAddNewBookmark); 1936 connect(m_pTabManager, &UIHelpBrowserTabManager::sigTabsListChanged, 1937 this, &UIHelpBrowserWidget::sltHandleTabListChanged); 1938 connect(m_pTabManager, &UIHelpBrowserTabManager::currentChanged, 1939 this, &UIHelpBrowserWidget::sltHandleCurrentTabChanged); 1885 1940 connect(m_pHelpEngine, &QHelpEngine::setupFinished, 1886 1941 this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished); … … 1969 2024 m_pFileMenu = new QMenu(tr("File"), this); 1970 2025 m_pViewMenu = new QMenu(tr("View"), this); 1971 AssertReturnVoid(m_pViewMenu); 2026 m_pTabsMenu = new QMenu(tr("Tabs"), this); 2027 2028 AssertReturnVoid(m_pFileMenu && m_pViewMenu && m_pTabsMenu); 1972 2029 1973 2030 if (m_pPrintDialogAction) … … 2012 2069 ++i; 2013 2070 const QString &strTitle = bookmarks[i]; 2014 printf("%s %s\n", qPrintable(url), qPrintable(strTitle));2015 2071 m_pBookmarksWidget->addBookmark(url, strTitle); 2016 2072 } … … 2333 2389 } 2334 2390 2391 void UIHelpBrowserWidget::updateTabsMenu(const QStringList &titles) 2392 { 2393 if (!m_pTabsMenu) 2394 return; 2395 m_pTabsMenu->clear(); 2396 for (int i = 0; i < titles.size(); ++i) 2397 { 2398 QAction *pAction = m_pTabsMenu->addAction(titles[i]); 2399 pAction->setData(i); 2400 connect(pAction, &QAction::triggered, this, &UIHelpBrowserWidget::sltHandleTabChoose); 2401 } 2402 if (m_pTabManager) 2403 sltHandleCurrentTabChanged(m_pTabManager->currentIndex()); 2404 } 2405 2335 2406 void UIHelpBrowserWidget::sltOpenLinkWithUrl(const QUrl &url) 2336 2407 { … … 2339 2410 } 2340 2411 2341 void UIHelpBrowserWidget::sltHandleFontSize actions()2412 void UIHelpBrowserWidget::sltHandleFontSizeActions() 2342 2413 { 2343 2414 if (!sender() || !m_pTabManager) … … 2357 2428 } 2358 2429 2430 void UIHelpBrowserWidget::sltHandleTabListChanged(const QStringList &titleList) 2431 { 2432 updateTabsMenu(titleList); 2433 } 2434 2435 void UIHelpBrowserWidget::sltHandleTabChoose() 2436 { 2437 QAction *pAction = qobject_cast<QAction*>(sender()); 2438 if (!pAction) 2439 return; 2440 int iIndex = pAction->data().toInt(); 2441 if (m_pTabManager) 2442 m_pTabManager->switchToTab(iIndex); 2443 } 2444 2445 void UIHelpBrowserWidget::sltHandleCurrentTabChanged(int iIndex) 2446 { 2447 Q_UNUSED(iIndex); 2448 if (!m_pTabsMenu) 2449 return; 2450 QList<QAction*> list = m_pTabsMenu->actions(); 2451 if (iIndex >= list.size()) 2452 return; 2453 2454 for (int i = 0; i < list.size(); ++i) 2455 { 2456 if (i == iIndex) 2457 list[i]->setIcon(UIIconPool::iconSet(":/help_browser_star_16px.png")); 2458 else 2459 list[i]->setIcon(QIcon()); 2460 } 2461 } 2462 2359 2463 #include "UIHelpBrowserWidget.moc" 2360 2464 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86958 r86961 100 100 void sltCopyLink(); 101 101 void sltAddNewBookmark(const QUrl &url, const QString &strTitle); 102 void sltHandleFontSizeactions(); 102 void sltHandleFontSizeActions(); 103 void sltHandleTabListChanged(const QStringList &titleList); 104 void sltHandleTabChoose(); 105 void sltHandleCurrentTabChanged(int iIndex); 103 106 104 107 private: … … 121 124 QUrl contentWidgetUrl(const QModelIndex &itemIndex); 122 125 void openLinkSlotHandler(QObject *pSenderObject, bool fOpenInNewTab); 126 void updateTabsMenu(const QStringList &titleList); 123 127 124 128 /** @name Event handling stuff. … … 156 160 QMenu *m_pFileMenu; 157 161 QMenu *m_pViewMenu; 162 QMenu *m_pTabsMenu; 158 163 QHelpContentWidget *m_pContentWidget; 159 164 QHelpIndexWidget *m_pIndexWidget;
Note:
See TracChangeset
for help on using the changeset viewer.