VirtualBox

Changeset 67109 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 26, 2017 9:53:10 AM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Tools pane: Simplify ToolType enum public access.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPane.cpp

    r67108 r67109  
    7373
    7474    /* Translate actions: */
    75     m_actions[ToolsType_SnapshotManager]->setText(tr("Snapshot Manager"));
    76     m_actions[ToolsType_VirtualMediaManager]->setText(tr("Virtual Media Manager"));
    77     m_actions[ToolsType_HostNetworkManager]->setText(tr("Host Network Manager"));
     75    m_actions[ToolType_SnapshotManager]->setText(tr("Snapshot Manager"));
     76    m_actions[ToolType_VirtualMediaManager]->setText(tr("Virtual Media Manager"));
     77    m_actions[ToolType_HostNetworkManager]->setText(tr("Host Network Manager"));
    7878
    7979    /* Translate tab-bar: */
    8080    for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    8181    {
    82         const ToolsType enmType = m_pTabBar->tabData(iTabIndex).value<ToolsType>();
     82        const ToolType enmType = m_pTabBar->tabData(iTabIndex).value<ToolType>();
    8383        m_pTabBar->setTabText(iTabIndex, m_actions.value(enmType)->text());
    8484    }
     
    9292
    9393    /* Acquire sender's type: */
    94     const ToolsType enmType = pAction->property("ToolsType").value<ToolsType>();
    95     AssertReturnVoid(enmType != ToolsType_Invalid);
     94    const ToolType enmType = pAction->property("ToolType").value<ToolType>();
     95    AssertReturnVoid(enmType != ToolType_Invalid);
    9696
    9797    /* Activate corresponding tab: */
     
    120120
    121121    /* Acquire sender's type: */
    122     const ToolsType enmType = pButton->property("ToolsType").value<ToolsType>();
    123     AssertReturnVoid(enmType != ToolsType_Invalid);
     122    const ToolType enmType = pButton->property("ToolType").value<ToolType>();
     123    AssertReturnVoid(enmType != ToolType_Invalid);
    124124
    125125    /* Search for the tab with such type: */
    126126    int iActualTabIndex = -1;
    127127    for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    128         if (m_pTabBar->tabData(iTabIndex).value<ToolsType>() == enmType)
     128        if (m_pTabBar->tabData(iTabIndex).value<ToolType>() == enmType)
    129129            iActualTabIndex = iTabIndex;
    130130    AssertReturnVoid(iActualTabIndex != -1);
     
    173173
    174174            /* Add and activate snapshots pane: */
    175             activateTabBarTab(ToolsType_SnapshotManager, false);
     175            activateTabBarTab(ToolType_SnapshotManager, false);
    176176
    177177            /* Add into layout: */
     
    252252
    253253        /* Create SnapShot manager action: */
    254         m_actions[ToolsType_SnapshotManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/snapshot_manager_22px.png",
     254        m_actions[ToolType_SnapshotManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/snapshot_manager_22px.png",
    255255                                                                                          ":/snapshot_manager_16px.png"),
    256256                                                                  QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    257257        {
    258             m_actions[ToolsType_SnapshotManager]->setCheckable(true);
    259             m_actions[ToolsType_SnapshotManager]->
    260                 setProperty("ToolsType", QVariant::fromValue(ToolsType_SnapshotManager));
     258            m_actions[ToolType_SnapshotManager]->setCheckable(true);
     259            m_actions[ToolType_SnapshotManager]->
     260                setProperty("ToolType", QVariant::fromValue(ToolType_SnapshotManager));
    261261        }
    262262
    263263        /* Create Virtual Media manager action: */
    264         m_actions[ToolsType_VirtualMediaManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/diskimage_22px.png",
     264        m_actions[ToolType_VirtualMediaManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/diskimage_22px.png",
    265265                                                                                              ":/diskimage_16px.png"),
    266266                                                                      QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    267267        {
    268             m_actions[ToolsType_VirtualMediaManager]->setCheckable(true);
    269             m_actions[ToolsType_VirtualMediaManager]->
    270                 setProperty("ToolsType", QVariant::fromValue(ToolsType_VirtualMediaManager));
     268            m_actions[ToolType_VirtualMediaManager]->setCheckable(true);
     269            m_actions[ToolType_VirtualMediaManager]->
     270                setProperty("ToolType", QVariant::fromValue(ToolType_VirtualMediaManager));
    271271        }
    272272
    273273        /* Create Host Network manager action: */
    274         m_actions[ToolsType_HostNetworkManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/host_iface_manager_22px.png",
     274        m_actions[ToolType_HostNetworkManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/host_iface_manager_22px.png",
    275275                                                                                             ":/host_iface_manager_16px.png"),
    276276                                                                     QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    277277        {
    278             m_actions[ToolsType_HostNetworkManager]->setCheckable(true);
    279             m_actions[ToolsType_HostNetworkManager]->
    280                 setProperty("ToolsType", QVariant::fromValue(ToolsType_HostNetworkManager));
     278            m_actions[ToolType_HostNetworkManager]->setCheckable(true);
     279            m_actions[ToolType_HostNetworkManager]->
     280                setProperty("ToolType", QVariant::fromValue(ToolType_HostNetworkManager));
    281281        }
    282282
     
    298298}
    299299
    300 void UIToolsPane::activateTabBarTab(ToolsType enmType, bool fCloseable)
     300void UIToolsPane::activateTabBarTab(ToolType enmType, bool fCloseable)
    301301{
    302302    /* Search for a tab with such type: */
    303303    int iActualTabIndex = -1;
    304304    for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    305         if (m_pTabBar->tabData(iTabIndex).value<ToolsType>() == enmType)
     305        if (m_pTabBar->tabData(iTabIndex).value<ToolType>() == enmType)
    306306            iActualTabIndex = iTabIndex;
    307307
     
    313313        switch (enmType)
    314314        {
    315             case ToolsType_SnapshotManager:
     315            case ToolType_SnapshotManager:
    316316                m_pPaneSnapshots = new UISnapshotPane;
    317317                m_pStackedLayout->addWidget(m_pPaneSnapshots);
    318318                break;
    319             case ToolsType_VirtualMediaManager:
     319            case ToolType_VirtualMediaManager:
    320320                m_pStackedLayout->addWidget(new UIMediumManagerWidget(EmbedTo_Stack));
    321321                break;
    322             case ToolsType_HostNetworkManager:
     322            case ToolType_HostNetworkManager:
    323323                m_pStackedLayout->addWidget(new UIHostNetworkManagerWidget(EmbedTo_Stack));
    324324                break;
     
    342342#endif
    343343                    pButtonClose->setIcon(UIIconPool::iconSet(":/close_16px.png"));
    344                     pButtonClose->setProperty("ToolsType", QVariant::fromValue(enmType));
     344                    pButtonClose->setProperty("ToolType", QVariant::fromValue(enmType));
    345345                    connect(pButtonClose, &QIToolButton::clicked, this, &UIToolsPane::sltHandleTabBarButtonClick);
    346346                    /* Add into tab-bar: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPane.h

    r67091 r67109  
    3737
    3838
     39/** Tool types. */
     40enum ToolType
     41{
     42    ToolType_Invalid,
     43    ToolType_SnapshotManager,
     44    ToolType_VirtualMediaManager,
     45    ToolType_HostNetworkManager,
     46};
     47
     48/* Make sure QVariant can eat ToolType: */
     49Q_DECLARE_METATYPE(ToolType);
     50
     51
    3952/** QWidget subclass representing container for tool panes. */
    4053class UIToolsPane : public QIWithRetranslateUI<QWidget>
     
    4356
    4457public:
    45 
    46     /** Tools types. */
    47     enum ToolsType
    48     {
    49         ToolsType_Invalid,
    50         ToolsType_SnapshotManager,
    51         ToolsType_VirtualMediaManager,
    52         ToolsType_HostNetworkManager,
    53     };
    5458
    5559    /** Constructs tools pane passing @a pParent to the base-class. */
     
    9498
    9599    /** Activates corresponding tab-bar tab, adds new if necessary. */
    96     void activateTabBarTab(ToolsType enmType, bool fCloseable);
     100    void activateTabBarTab(ToolType enmType, bool fCloseable);
    97101
    98102    /** Holds the main layout isntance. */
     
    111115    QMenu                     *m_pMenu;
    112116    /** Holds the menu action instances. */
    113     QMap<ToolsType, QAction*>  m_actions;
     117    QMap<ToolType, QAction*>  m_actions;
    114118};
    115 
    116 /* Make sure QVariant can eat UIToolsPane::ToolsType: */
    117 Q_DECLARE_METATYPE(UIToolsPane::ToolsType);
    118119
    119120#endif /* !___UIToolsPane_h___ */
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