VirtualBox

Changeset 76776 in vbox


Ignore:
Timestamp:
Jan 11, 2019 1:21:59 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: Reworking VirtualBox Manager tools menu to have mutually exclusive togglable actions (s.a. r128074).

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r76757 r76776  
    12941294
    12951295/** Simple action extension, used as 'Show Machine Details' action class. */
    1296 class UIActionSimpleSelectorToolsMachineShowDetails : public UIActionSimple
    1297 {
    1298     Q_OBJECT;
    1299 
    1300 public:
    1301 
    1302     /** Constructs action passing @a pParent to the base-class. */
    1303     UIActionSimpleSelectorToolsMachineShowDetails(UIActionPool *pParent)
    1304         : UIActionSimple(pParent,
    1305                          ":/machine_details_manager_24px.png", ":/machine_details_manager_16px.png",
    1306                          ":/machine_details_manager_disabled_24px.png", ":/machine_details_manager_disabled_16px.png")
    1307     {}
     1296class UIActionToggleSelectorToolsMachineShowDetails : public UIActionToggle
     1297{
     1298    Q_OBJECT;
     1299
     1300public:
     1301
     1302    /** Constructs action passing @a pParent to the base-class. */
     1303    UIActionToggleSelectorToolsMachineShowDetails(UIActionPool *pParent)
     1304        : UIActionToggle(pParent)
     1305    {
     1306        setProperty("UIToolType", QVariant::fromValue(UIToolType_Details));
     1307        /// @todo use icons with check-boxes
     1308        setIcon(UIIconPool::iconSetFull(":/machine_details_manager_24px.png", ":/machine_details_manager_16px.png",
     1309                                        ":/machine_details_manager_disabled_24px.png", ":/machine_details_manager_disabled_16px.png"));
     1310    }
    13081311
    13091312protected:
     
    13241327
    13251328/** Simple action extension, used as 'Show Machine Snapshots' action class. */
    1326 class UIActionSimpleSelectorToolsMachineShowSnapshots : public UIActionSimple
    1327 {
    1328     Q_OBJECT;
    1329 
    1330 public:
    1331 
    1332     /** Constructs action passing @a pParent to the base-class. */
    1333     UIActionSimpleSelectorToolsMachineShowSnapshots(UIActionPool *pParent)
    1334         : UIActionSimple(pParent,
    1335                          ":/snapshot_manager_24px.png", ":/snapshot_manager_16px.png",
    1336                          ":/snapshot_manager_disabled_24px.png", ":/snapshot_manager_disabled_16px.png")
    1337     {}
     1329class UIActionToggleSelectorToolsMachineShowSnapshots : public UIActionToggle
     1330{
     1331    Q_OBJECT;
     1332
     1333public:
     1334
     1335    /** Constructs action passing @a pParent to the base-class. */
     1336    UIActionToggleSelectorToolsMachineShowSnapshots(UIActionPool *pParent)
     1337        : UIActionToggle(pParent)
     1338    {
     1339        setProperty("UIToolType", QVariant::fromValue(UIToolType_Snapshots));
     1340        /// @todo use icons with check-boxes
     1341        setIcon(UIIconPool::iconSetFull(":/snapshot_manager_24px.png", ":/snapshot_manager_16px.png",
     1342                                        ":/snapshot_manager_disabled_24px.png", ":/snapshot_manager_disabled_16px.png"));
     1343    }
    13381344
    13391345protected:
     
    13541360
    13551361/** Simple action extension, used as 'Show Machine Logs' action class. */
    1356 class UIActionSimpleSelectorToolsMachineShowLogs : public UIActionSimple
    1357 {
    1358     Q_OBJECT;
    1359 
    1360 public:
    1361 
    1362     /** Constructs action passing @a pParent to the base-class. */
    1363     UIActionSimpleSelectorToolsMachineShowLogs(UIActionPool *pParent)
    1364         : UIActionSimple(pParent,
    1365                          ":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png",
    1366                          ":/vm_show_logs_disabled_32px.png", ":/vm_show_logs_disabled_16px.png")
    1367     {}
     1362class UIActionToggleSelectorToolsMachineShowLogs : public UIActionToggle
     1363{
     1364    Q_OBJECT;
     1365
     1366public:
     1367
     1368    /** Constructs action passing @a pParent to the base-class. */
     1369    UIActionToggleSelectorToolsMachineShowLogs(UIActionPool *pParent)
     1370        : UIActionToggle(pParent)
     1371    {
     1372        setProperty("UIToolType", QVariant::fromValue(UIToolType_Logs));
     1373        /// @todo use icons with check-boxes
     1374        setIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png",
     1375                                        ":/vm_show_logs_disabled_32px.png", ":/vm_show_logs_disabled_16px.png"));
     1376    }
    13681377
    13691378protected:
     
    25342543    m_pool[UIActionIndexST_M_Group_M_Close_S_PowerOff] = new UIActionSimpleSelectorClosePerformPowerOff(this);
    25352544    m_pool[UIActionIndexST_M_Group_M_Tools] = new UIActionMenuSelectorToolsMachine(this);
    2536     m_pool[UIActionIndexST_M_Group_M_Tools_S_Details] = new UIActionSimpleSelectorToolsMachineShowDetails(this);
    2537     m_pool[UIActionIndexST_M_Group_M_Tools_S_Snapshots] = new UIActionSimpleSelectorToolsMachineShowSnapshots(this);
    2538     m_pool[UIActionIndexST_M_Group_M_Tools_S_Logs] = new UIActionSimpleSelectorToolsMachineShowLogs(this);
     2545    m_pool[UIActionIndexST_M_Group_M_Tools_T_Details] = new UIActionToggleSelectorToolsMachineShowDetails(this);
     2546    m_pool[UIActionIndexST_M_Group_M_Tools_T_Snapshots] = new UIActionToggleSelectorToolsMachineShowSnapshots(this);
     2547    m_pool[UIActionIndexST_M_Group_M_Tools_T_Logs] = new UIActionToggleSelectorToolsMachineShowLogs(this);
    25392548    m_pool[UIActionIndexST_M_Group_S_Discard] = new UIActionSimpleSelectorCommonPerformDiscard(this);
    25402549    m_pool[UIActionIndexST_M_Group_S_ShowLogDialog] = new UIActionSimpleSelectorCommonShowMachineLogs(this);
     
    25652574    m_pool[UIActionIndexST_M_Machine_M_Close_S_PowerOff] = new UIActionSimpleSelectorClosePerformPowerOff(this);
    25662575    m_pool[UIActionIndexST_M_Machine_M_Tools] = new UIActionMenuSelectorToolsMachine(this);
    2567     m_pool[UIActionIndexST_M_Machine_M_Tools_S_Details] = new UIActionSimpleSelectorToolsMachineShowDetails(this);
    2568     m_pool[UIActionIndexST_M_Machine_M_Tools_S_Snapshots] = new UIActionSimpleSelectorToolsMachineShowSnapshots(this);
    2569     m_pool[UIActionIndexST_M_Machine_M_Tools_S_Logs] = new UIActionSimpleSelectorToolsMachineShowLogs(this);
     2576    m_pool[UIActionIndexST_M_Machine_M_Tools_T_Details] = new UIActionToggleSelectorToolsMachineShowDetails(this);
     2577    m_pool[UIActionIndexST_M_Machine_M_Tools_T_Snapshots] = new UIActionToggleSelectorToolsMachineShowSnapshots(this);
     2578    m_pool[UIActionIndexST_M_Machine_M_Tools_T_Logs] = new UIActionToggleSelectorToolsMachineShowLogs(this);
    25702579    m_pool[UIActionIndexST_M_Machine_S_Discard] = new UIActionSimpleSelectorCommonPerformDiscard(this);
    25712580    m_pool[UIActionIndexST_M_Machine_S_ShowLogDialog] = new UIActionSimpleSelectorCommonShowMachineLogs(this);
     
    26162625    m_pool[UIActionIndexST_M_Cloud_T_Details] = new UIActionMenuSelectorCloudToggleProperties(this);
    26172626    m_pool[UIActionIndexST_M_Cloud_S_Help] = new UIActionMenuSelectorCloudShowHelp(this);
     2627
     2628    /* 'Group' action groups: */
     2629    m_groupPool[UIActionIndexST_M_Group_M_Tools] = new QActionGroup(m_pool.value(UIActionIndexST_M_Group_M_Tools));
     2630    m_groupPool[UIActionIndexST_M_Group_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Group_M_Tools_T_Details));
     2631    m_groupPool[UIActionIndexST_M_Group_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Group_M_Tools_T_Snapshots));
     2632    m_groupPool[UIActionIndexST_M_Group_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Group_M_Tools_T_Logs));
     2633
     2634    /* 'Machine' action groups: */
     2635    m_groupPool[UIActionIndexST_M_Machine_M_Tools] = new QActionGroup(m_pool.value(UIActionIndexST_M_Machine_M_Tools));
     2636    m_groupPool[UIActionIndexST_M_Machine_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Machine_M_Tools_T_Details));
     2637    m_groupPool[UIActionIndexST_M_Machine_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Machine_M_Tools_T_Snapshots));
     2638    m_groupPool[UIActionIndexST_M_Machine_M_Tools]->addAction(m_pool.value(UIActionIndexST_M_Machine_M_Tools_T_Logs));
    26182639
    26192640    /* Prepare update-handlers for known menus: */
     
    29833004
    29843005    /* Populate 'Group' / 'Tools' menu: */
    2985     pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_S_Details));
    2986     pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_S_Snapshots));
    2987     pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_S_Logs));
     3006    pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_T_Details));
     3007    pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_T_Snapshots));
     3008    pMenu->addAction(action(UIActionIndexST_M_Group_M_Tools_T_Logs));
    29883009
    29893010    /* Mark menu as valid: */
     
    30003021
    30013022    /* Populate 'Machine' / 'Tools' menu: */
    3002     pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_S_Details));
    3003     pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_S_Snapshots));
    3004     pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_S_Logs));
     3023    pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_T_Details));
     3024    pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_T_Snapshots));
     3025    pMenu->addAction(action(UIActionIndexST_M_Machine_M_Tools_T_Logs));
    30053026
    30063027    /* Mark menu as valid: */
     
    32363257                    << action(UIActionIndexST_M_Group_M_Close_S_Shutdown)
    32373258                    << action(UIActionIndexST_M_Group_M_Close_S_PowerOff)
    3238                     << action(UIActionIndexST_M_Group_M_Tools_S_Details)
    3239                     << action(UIActionIndexST_M_Group_M_Tools_S_Snapshots)
    3240                     << action(UIActionIndexST_M_Group_M_Tools_S_Logs);
     3259                    << action(UIActionIndexST_M_Group_M_Tools_T_Details)
     3260                    << action(UIActionIndexST_M_Group_M_Tools_T_Snapshots)
     3261                    << action(UIActionIndexST_M_Group_M_Tools_T_Logs);
    32413262            break;
    32423263        }
     
    32673288                    << action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)
    32683289                    << action(UIActionIndexST_M_Machine_M_Close_S_PowerOff)
    3269                     << action(UIActionIndexST_M_Machine_M_Tools_S_Details)
    3270                     << action(UIActionIndexST_M_Machine_M_Tools_S_Snapshots)
    3271                     << action(UIActionIndexST_M_Machine_M_Tools_S_Logs);
     3290                    << action(UIActionIndexST_M_Machine_M_Tools_T_Details)
     3291                    << action(UIActionIndexST_M_Machine_M_Tools_T_Snapshots)
     3292                    << action(UIActionIndexST_M_Machine_M_Tools_T_Logs);
    32723293            break;
    32733294        }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r76757 r76776  
    7474    UIActionIndexST_M_Group_M_Close_S_PowerOff,
    7575    UIActionIndexST_M_Group_M_Tools,
    76     UIActionIndexST_M_Group_M_Tools_S_Details,
    77     UIActionIndexST_M_Group_M_Tools_S_Snapshots,
    78     UIActionIndexST_M_Group_M_Tools_S_Logs,
     76    UIActionIndexST_M_Group_M_Tools_T_Details,
     77    UIActionIndexST_M_Group_M_Tools_T_Snapshots,
     78    UIActionIndexST_M_Group_M_Tools_T_Logs,
    7979    UIActionIndexST_M_Group_S_Discard,
    8080    UIActionIndexST_M_Group_S_ShowLogDialog,
     
    105105    UIActionIndexST_M_Machine_M_Close_S_PowerOff,
    106106    UIActionIndexST_M_Machine_M_Tools,
    107     UIActionIndexST_M_Machine_M_Tools_S_Details,
    108     UIActionIndexST_M_Machine_M_Tools_S_Snapshots,
    109     UIActionIndexST_M_Machine_M_Tools_S_Logs,
     107    UIActionIndexST_M_Machine_M_Tools_T_Details,
     108    UIActionIndexST_M_Machine_M_Tools_T_Snapshots,
     109    UIActionIndexST_M_Machine_M_Tools_T_Logs,
    110110    UIActionIndexST_M_Machine_S_Discard,
    111111    UIActionIndexST_M_Machine_S_ShowLogDialog,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r76757 r76776  
    10481048}
    10491049
    1050 void UIVirtualBoxManager::sltPerformShowMachineToolDetails()
    1051 {
    1052     m_pWidget->setToolsType(UIToolType_Details);
    1053 }
    1054 
    1055 void UIVirtualBoxManager::sltPerformShowMachineToolSnapshots()
    1056 {
    1057     m_pWidget->setToolsType(UIToolType_Snapshots);
    1058 }
    1059 
    1060 void UIVirtualBoxManager::sltPerformShowMachineToolLogs()
    1061 {
    1062     m_pWidget->setToolsType(UIToolType_Logs);
     1050void UIVirtualBoxManager::sltPerformShowMachineTool(QAction *pAction)
     1051{
     1052    AssertPtrReturnVoid(pAction);
     1053    AssertPtrReturnVoid(m_pWidget);
     1054    m_pWidget->setToolsType(pAction->property("UIToolType").value<UIToolType>());
    10631055}
    10641056
     
    14611453
    14621454    /* 'Group/Tools' menu connections: */
    1463     connect(actionPool()->action(UIActionIndexST_M_Group_M_Tools_S_Details), &UIAction::triggered,
    1464             this, &UIVirtualBoxManager::sltPerformShowMachineToolDetails);
    1465     connect(actionPool()->action(UIActionIndexST_M_Group_M_Tools_S_Snapshots), &UIAction::triggered,
    1466             this, &UIVirtualBoxManager::sltPerformShowMachineToolSnapshots);
    1467     connect(actionPool()->action(UIActionIndexST_M_Group_M_Tools_S_Logs), &UIAction::triggered,
    1468             this, &UIVirtualBoxManager::sltPerformShowMachineToolLogs);
     1455    connect(actionPool()->actionGroup(UIActionIndexST_M_Group_M_Tools), &QActionGroup::triggered,
     1456            this, &UIVirtualBoxManager::sltPerformShowMachineTool);
    14691457
    14701458    /* 'Machine/Tools' menu connections: */
    1471     connect(actionPool()->action(UIActionIndexST_M_Machine_M_Tools_S_Details), &UIAction::triggered,
    1472             this, &UIVirtualBoxManager::sltPerformShowMachineToolDetails);
    1473     connect(actionPool()->action(UIActionIndexST_M_Machine_M_Tools_S_Snapshots), &UIAction::triggered,
    1474             this, &UIVirtualBoxManager::sltPerformShowMachineToolSnapshots);
    1475     connect(actionPool()->action(UIActionIndexST_M_Machine_M_Tools_S_Logs), &UIAction::triggered,
    1476             this, &UIVirtualBoxManager::sltPerformShowMachineToolLogs);
     1459    connect(actionPool()->actionGroup(UIActionIndexST_M_Machine_M_Tools), &QActionGroup::triggered,
     1460            this, &UIVirtualBoxManager::sltPerformShowMachineTool);
    14771461}
    14781462
     
    17581742    actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->retranslateUi();
    17591743    actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->blockSignals(false);
     1744
     1745    /* Update action toggle states: */
     1746    if (m_pWidget)
     1747    {
     1748        switch (m_pWidget->currentMachineTool())
     1749        {
     1750            case UIToolType_Details:
     1751            {
     1752                actionPool()->action(UIActionIndexST_M_Group_M_Tools_T_Details)->setChecked(true);
     1753                actionPool()->action(UIActionIndexST_M_Machine_M_Tools_T_Details)->setChecked(true);
     1754                break;
     1755            }
     1756            case UIToolType_Snapshots:
     1757            {
     1758                actionPool()->action(UIActionIndexST_M_Group_M_Tools_T_Snapshots)->setChecked(true);
     1759                actionPool()->action(UIActionIndexST_M_Machine_M_Tools_T_Snapshots)->setChecked(true);
     1760                break;
     1761            }
     1762            case UIToolType_Logs:
     1763            {
     1764                actionPool()->action(UIActionIndexST_M_Group_M_Tools_T_Logs)->setChecked(true);
     1765                actionPool()->action(UIActionIndexST_M_Machine_M_Tools_T_Logs)->setChecked(true);
     1766                break;
     1767            }
     1768            default:
     1769                break;
     1770        }
     1771    }
    17601772}
    17611773
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r76757 r76776  
    223223        void sltPerformPowerOffMachine();
    224224
    225         /** Handles call to show machine Details tool. */
    226         void sltPerformShowMachineToolDetails();
    227         /** Handles call to show machine Snapshots tool. */
    228         void sltPerformShowMachineToolSnapshots();
    229         /** Handles call to show machine Logs tool. */
    230         void sltPerformShowMachineToolLogs();
     225        /** Handles call to show machine tool corresponding to passed @a pAction. */
     226        void sltPerformShowMachineTool(QAction *pAction);
    231227
    232228        /** Handles call to open machine Log Viewer window. */
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