VirtualBox

Changeset 86946 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 20, 2020 6:13:28 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Adding Close tab context menu action to the tabbar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp

    r86945 r86946  
    427427    void sltHandleOpenLinkInNewTab(const QUrl &url);
    428428    void sltHandleTabClose(int iTabIndex);
     429    void sltHandleContextMenuTabClose();
    429430    /** Closes/deletes all tabs other than the one with tab index @iTabIndex. */
    430     void sltHandleOtherTabs();
     431    void sltHandleCloseOtherTabs();
    431432    void sltHandleCurrentChanged(int iTabIndex);
    432433    void sltHandleFontSizeChange(int iFontPointSize);
     
    16141615}
    16151616
    1616 void UIHelpBrowserTabManager::sltHandleOtherTabs()
     1617void UIHelpBrowserTabManager::sltHandleContextMenuTabClose()
     1618{
     1619    QAction *pAction = qobject_cast<QAction*>(sender());
     1620    if (!pAction)
     1621        return;
     1622    int iTabIndex = pAction->data().toInt();
     1623    if (iTabIndex < 0 || iTabIndex >= count())
     1624        return;
     1625    sltHandleTabClose(iTabIndex);
     1626}
     1627
     1628void UIHelpBrowserTabManager::sltHandleCloseOtherTabs()
    16171629{
    16181630    QAction *pAction = qobject_cast<QAction*>(sender());
     
    16521664    QMenu menu;
    16531665    QAction *pCloseAll = menu.addAction(UIHelpBrowserWidget::tr("Close other tabs"));
    1654     connect(pCloseAll, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleOtherTabs);
     1666    connect(pCloseAll, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleCloseOtherTabs);
    16551667    pCloseAll->setData(tabBar()->tabAt(pos));
     1668
     1669    QAction *pClose = menu.addAction(UIHelpBrowserWidget::tr("Close tab"));
     1670    connect(pClose, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleContextMenuTabClose);
     1671    pClose->setData(tabBar()->tabAt(pos));
     1672
    16561673    menu.exec(tabBar()->mapToGlobal(pos));
    16571674}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette