VirtualBox

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


Ignore:
Timestamp:
Dec 14, 2011 9:48:17 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 5804: Allow one operation on several VMs: Disable 'settings', 'clone' and 'discard' actions for more than one VM selected.

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

Legend:

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

    r39326 r39601  
    419419        {
    420420            /* Check if current item could be removed: */
    421             if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items[i]))
     421            if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items[i], items))
    422422                continue;
    423423
     
    468468    {
    469469        /* Check if current item could be started/showed: */
    470         if (!isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items[i]))
     470        if (!isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items[i], items))
    471471            continue;
    472472
     
    521521
    522522        /* Check if current item could be paused/resumed: */
    523         if (!isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem))
     523        if (!isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem, items))
    524524            continue;
    525525
     
    580580
    581581        /* Check if current item could be reseted: */
    582         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem))
     582        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem, items))
    583583            continue;
    584584
     
    618618
    619619        /* Check if current item could be shutdowned: */
    620         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem))
     620        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem, items))
    621621            continue;
    622622
     
    656656
    657657        /* Check if current item could be powered off: */
    658         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem))
     658        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem, items))
    659659            continue;
    660660
     
    690690
    691691        /* Check if current item could be refreshed: */
    692         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem))
     692        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem, items))
    693693            continue;
    694694
     
    711711
    712712        /* Check if log could be show for the current item: */
    713         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem))
     713        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem, items))
    714714            continue;
    715715
     
    732732
    733733        /* Check if that item could be shown in file-browser: */
    734         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem))
     734        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem, items))
    735735            continue;
    736736
     
    753753
    754754        /* Check if shortcuts could be created for this item: */
    755         if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem))
     755        if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem, items))
    756756            continue;
    757757
     
    781781    /* Get current item: */
    782782    UIVMItem *pItem = m_pVMListView->currentItem();
     783    /* Get selected items: */
     784    QList<UIVMItem*> items = m_pVMListView->currentItems();
    783785    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    784786
    785     m_pMachineCloseMenuAction->setEnabled(isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem));
     787    m_pMachineCloseMenuAction->setEnabled(isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem, items));
    786788}
    787789
     
    790792    /* Get current item: */
    791793    UIVMItem *pItem = m_pVMListView->currentItem();
     794    /* Get selected items: */
     795    QList<UIVMItem*> items = m_pVMListView->currentItems();
    792796    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    793797
    794     m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem));
     798    m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem, items));
    795799}
    796800
     
    849853
    850854    /* Enable/disable actions: */
    851     m_pSettingsDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, pItem));
    852     m_pCloneWizardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, pItem));
    853     m_pRemoveDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, pItem));
    854     m_pStartOrShowAction->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, pItem));
    855     m_pDiscardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, pItem));
    856     m_pPauseAndResumeAction->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem));
    857     m_pResetAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem));
    858     m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem));
    859     m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem));
    860     m_pRefreshAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem));
    861     m_pLogDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem));
    862     m_pShowInFileManagerAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem));
    863     m_pCreateShortcutAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem));
    864     m_pSortAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, pItem));
     855    m_pSettingsDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, pItem, items));
     856    m_pCloneWizardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, pItem, items));
     857    m_pRemoveDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, pItem, items));
     858    m_pStartOrShowAction->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, pItem, items));
     859    m_pDiscardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, pItem, items));
     860    m_pPauseAndResumeAction->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem, items));
     861    m_pResetAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem, items));
     862    m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem, items));
     863    m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem, items));
     864    m_pRefreshAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem, items));
     865    m_pLogDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem, items));
     866    m_pShowInFileManagerAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem, items));
     867    m_pCreateShortcutAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem, items));
     868    m_pSortAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, pItem, items));
    865869
    866870    /* If currently selected VM item is accessible: */
     
    18001804}
    18011805
    1802 bool UISelectorWindow::isActionEnabled(int iActionIndex, UIVMItem *pItem)
     1806bool UISelectorWindow::isActionEnabled(int iActionIndex, UIVMItem *pItem, const QList<UIVMItem*> &items)
    18031807{
    18041808    switch (iActionIndex)
     
    18061810        case UIActionIndexSelector_Simple_Machine_SettingsDialog:
    18071811        {
    1808             /* Check that item is present and accessible
     1812            /* Check that there is only one item, its accessible
    18091813             * and machine is not in 'stuck' or 'saved' state.
    18101814             * Modifying VM settings in 'saved' state will be available later. */
    1811             return pItem && pItem->accessible() &&
     1815            return items.size() == 1 &&
     1816                   pItem && pItem->accessible() &&
    18121817                   pItem->machineState() != KMachineState_Stuck &&
    18131818                   pItem->machineState() != KMachineState_Saved;
     
    18151820        case UIActionIndexSelector_Simple_Machine_CloneWizard:
    18161821        {
    1817             /* Check that item is present and accessible
     1822            /* Check that there is only one item, its accessible
    18181823             * and session state is unlocked. */
    1819             return pItem && pItem->accessible() &&
     1824            return items.size() == 1 &&
     1825                   pItem && pItem->accessible() &&
    18201826                   pItem->sessionState() == KSessionState_Unlocked;
    18211827        }
     
    18471853        case UIActionIndexSelector_Simple_Machine_Discard:
    18481854        {
    1849             /* Check that item present and accessible
     1855            /* Check that there is only one item, its accessible
    18501856             * and machine is in 'saved' state and session state is unlocked. */
    1851             return pItem && pItem->accessible() &&
     1857            return items.size() == 1 &&
     1858                   pItem && pItem->accessible() &&
    18521859                   pItem->machineState() == KMachineState_Saved &&
    18531860                   pItem->sessionState() == KSessionState_Unlocked;
     
    18841891        {
    18851892            /* Check that 'Machine/Close' menu is enabled: */
    1886             if (!isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem))
     1893            if (!isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem, items))
    18871894                return false;
    18881895
     
    19061913        {
    19071914            /* The same as 'Machine/Close' menu is enabled: */
    1908             return isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem);
     1915            return isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem, items);
    19091916        }
    19101917        case UIActionIndexSelector_Simple_Machine_Refresh:
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r39326 r39601  
    158158
    159159    /* Static helping stuff: */
    160     static bool isActionEnabled(int iActionIndex, UIVMItem *pItem);
     160    static bool isActionEnabled(int iActionIndex, UIVMItem *pItem, const QList<UIVMItem*> &items);
    161161
    162162    /* Central splitter 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