VirtualBox

Changeset 86921 in vbox


Ignore:
Timestamp:
Nov 19, 2020 2:33:34 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Adding 'Close other tabs' action to the bar bar

File:
1 edited

Legend:

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

    r86913 r86921  
    426426    void sltHandleOpenLinkInNewTab(const QUrl &url);
    427427    void sltHandleTabClose(int iTabIndex);
     428    /** Closes/deletes all tabs other than the one with tab index @iTabIndex. */
     429    void sltHandleOtherTabs();
    428430    void sltHandleCurrentChanged(int iTabIndex);
    429431    void sltHandleFontSizeChange(int iFontPointSize);
     432    void sltShowTabBarContextMenu(const QPoint &pos);
    430433
    431434private:
     
    15911594}
    15921595
     1596void UIHelpBrowserTabManager::sltHandleOtherTabs()
     1597{
     1598    QAction *pAction = qobject_cast<QAction*>(sender());
     1599    if (!pAction)
     1600        return;
     1601    int iTabIndex = pAction->data().toInt();
     1602    if (iTabIndex < 0 || iTabIndex >= count())
     1603        return;
     1604    QString strTitle = tabText(iTabIndex);
     1605    QList<QWidget*> widgetList;
     1606    for (int i = 0; i < count(); ++i)
     1607        widgetList.append(widget(i));
     1608    clear();
     1609    for (int i = 0; i < widgetList.size(); ++i)
     1610    {
     1611        if (i != iTabIndex)
     1612            delete widgetList[i];
     1613    }
     1614    addTab(widgetList[iTabIndex], strTitle);
     1615}
     1616
    15931617void UIHelpBrowserTabManager::sltHandleCurrentChanged(int iTabIndex)
    15941618{
     
    16001624{
    16011625    setFontPointSize(iFontPointSize);
     1626}
     1627
     1628void UIHelpBrowserTabManager::sltShowTabBarContextMenu(const QPoint &pos)
     1629{
     1630    if (!tabBar())
     1631        return;
     1632    QMenu menu;
     1633    QAction *pCloseAll = menu.addAction(UIHelpBrowserWidget::tr("Close other tabs"));
     1634    connect(pCloseAll, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleOtherTabs);
     1635    pCloseAll->setData(tabBar()->tabAt(pos));
     1636    menu.exec(tabBar()->mapToGlobal(pos));
    16021637}
    16031638
     
    16081643    connect(this, &UIHelpBrowserTabManager::tabCloseRequested, this, &UIHelpBrowserTabManager::sltHandleTabClose);
    16091644    connect(this, &UIHelpBrowserTabManager::currentChanged, this, &UIHelpBrowserTabManager::sltHandleCurrentChanged);
     1645    if (tabBar())
     1646    {
     1647        tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
     1648        connect(tabBar(), &QTabBar::customContextMenuRequested, this, &UIHelpBrowserTabManager::sltShowTabBarContextMenu);
     1649    }
    16101650}
    16111651
     
    21352175        if (!browser)
    21362176            return;
    2137         // if (!browser->rect().contains(pos, true))
    2138         //     return;
    21392177        QPoint browserPos = browser->mapFromGlobal(m_pSearchResultWidget->mapToGlobal(pos));
    21402178        url = browser->anchorAt(browserPos);
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