VirtualBox

Changeset 83011 in vbox for trunk


Ignore:
Timestamp:
Feb 6, 2020 6:07:29 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136029
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Actions validation for cloud VM groups and items; Everything is restricted for now.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r83009 r83011  
    17091709
    17101710    /* Enable/disable group actions: */
     1711    actionPool()->action(UIActionIndexST_M_Group_S_New)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_New, items));
     1712    actionPool()->action(UIActionIndexST_M_Group_S_Add)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Add, items));
    17111713    actionPool()->action(UIActionIndexST_M_Group_S_Rename)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Rename, items));
    17121714    actionPool()->action(UIActionIndexST_M_Group_S_Remove)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Remove, items));
     
    17211723
    17221724    /* Enable/disable machine actions: */
     1725    actionPool()->action(UIActionIndexST_M_Machine_S_New)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_New, items));
     1726    actionPool()->action(UIActionIndexST_M_Machine_S_Add)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Add, items));
    17231727    actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Settings, items));
    17241728    actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Clone, items));
     
    18621866    switch (iActionIndex)
    18631867    {
     1868        case UIActionIndexST_M_Group_S_New:
     1869        case UIActionIndexST_M_Group_S_Add:
     1870        case UIActionIndexST_M_Group_S_Sort:
     1871        {
     1872            return !isGroupSavingInProgress() &&
     1873                   isSingleGroupSelected() &&
     1874                   isItemsLocal(items);
     1875        }
    18641876        case UIActionIndexST_M_Group_S_Rename:
    18651877        case UIActionIndexST_M_Group_S_Remove:
    18661878        {
    18671879            return !isGroupSavingInProgress() &&
     1880                   isSingleGroupSelected() &&
     1881                   isItemsLocal(items) &&
    18681882                   isItemsPoweredOff(items);
    18691883        }
    1870         case UIActionIndexST_M_Group_S_Sort:
     1884        case UIActionIndexST_M_Machine_S_New:
     1885        case UIActionIndexST_M_Machine_S_Add:
    18711886        {
    18721887            return !isGroupSavingInProgress() &&
    1873                    isSingleGroupSelected();
     1888                   isItemsLocal(items);
    18741889        }
    18751890        case UIActionIndexST_M_Machine_S_Settings:
     
    18781893                   !isGroupSavingInProgress() &&
    18791894                   items.size() == 1 &&
     1895                   pItem->toLocal() &&
    18801896                   pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null &&
    18811897                   (m_pWidget->currentMachineTool() != UIToolType_Snapshots ||
     
    18871903            return !isGroupSavingInProgress() &&
    18881904                   items.size() == 1 &&
     1905                   pItem->toLocal() &&
    18891906                   pItem->isItemEditable();
    18901907        }
     
    18921909        {
    18931910            return !actionPool()->action(iActionIndex)->property("opened").toBool() &&
    1894                    items.size() == 1;
     1911                   items.size() == 1 &&
     1912                   pItem->toLocal();
    18951913        }
    18961914        case UIActionIndexST_M_Machine_S_Remove:
    18971915        {
    18981916            return !isGroupSavingInProgress() &&
    1899                    isAtLeastOneItemRemovable(items);
     1917                   isAtLeastOneItemRemovable(items) &&
     1918                   isItemsLocal(items);
    19001919        }
    19011920        case UIActionIndexST_M_Machine_S_AddGroup:
     
    19031922            return !isGroupSavingInProgress() &&
    19041923                   !isAllItemsOfOneGroupSelected() &&
     1924                   isItemsLocal(items) &&
    19051925                   isItemsPoweredOff(items);
    19061926        }
     
    19301950        case UIActionIndexST_M_Machine_S_ShowLogDialog:
    19311951        {
    1932             return isAtLeastOneItemAccessible(items);
     1952            return isItemsLocal(items) &&
     1953                   isAtLeastOneItemAccessible(items);
    19331954        }
    19341955        case UIActionIndexST_M_Group_T_Pause:
    19351956        case UIActionIndexST_M_Machine_T_Pause:
    19361957        {
    1937             return isAtLeastOneItemStarted(items);
     1958            return isItemsLocal(items) &&
     1959                   isAtLeastOneItemStarted(items);
    19381960        }
    19391961        case UIActionIndexST_M_Group_S_Reset:
    19401962        case UIActionIndexST_M_Machine_S_Reset:
    19411963        {
    1942             return isAtLeastOneItemRunning(items);
     1964            return isItemsLocal(items) &&
     1965                   isAtLeastOneItemRunning(items);
    19431966        }
    19441967        case UIActionIndexST_M_Group_S_Refresh:
    19451968        case UIActionIndexST_M_Machine_S_Refresh:
    19461969        {
    1947             return isAtLeastOneItemInaccessible(items);
     1970            return isItemsLocal(items) &&
     1971                   isAtLeastOneItemInaccessible(items);
    19481972        }
    19491973        case UIActionIndexST_M_Group_S_ShowInFileManager:
    19501974        case UIActionIndexST_M_Machine_S_ShowInFileManager:
    19511975        {
    1952             return isAtLeastOneItemAccessible(items);
     1976            return isItemsLocal(items) &&
     1977                   isAtLeastOneItemAccessible(items);
    19531978        }
    19541979        case UIActionIndexST_M_Machine_S_SortParent:
    19551980        {
    1956             return !isGroupSavingInProgress();
     1981            return !isGroupSavingInProgress() &&
     1982                   isItemsLocal(items);
    19571983        }
    19581984        case UIActionIndexST_M_Group_S_CreateShortcut:
     
    19641990        case UIActionIndexST_M_Machine_M_Close:
    19651991        {
    1966             return isAtLeastOneItemStarted(items);
     1992            return isItemsLocal(items) &&
     1993                   isAtLeastOneItemStarted(items);
    19671994        }
    19681995        case UIActionIndexST_M_Group_M_Close_S_Detach:
    19691996        case UIActionIndexST_M_Machine_M_Close_S_Detach:
    19701997        {
    1971             return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
     1998            return isItemsLocal(items) &&
     1999                   isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
    19722000        }
    19732001        case UIActionIndexST_M_Group_M_Close_S_SaveState:
    19742002        case UIActionIndexST_M_Machine_M_Close_S_SaveState:
    19752003        {
    1976             return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
     2004            return isItemsLocal(items) &&
     2005                   isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
    19772006        }
    19782007        case UIActionIndexST_M_Group_M_Close_S_Shutdown:
    19792008        case UIActionIndexST_M_Machine_M_Close_S_Shutdown:
    19802009        {
    1981             return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items) &&
     2010            return isItemsLocal(items) &&
     2011                   isActionEnabled(UIActionIndexST_M_Machine_M_Close, items) &&
    19822012                   isAtLeastOneItemAbleToShutdown(items);
    19832013        }
     
    19852015        case UIActionIndexST_M_Machine_M_Close_S_PowerOff:
    19862016        {
    1987             return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
     2017            return isItemsLocal(items) &&
     2018                   isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
    19882019        }
    19892020        default:
     
    19932024    /* Unknown actions are disabled: */
    19942025    return false;
     2026}
     2027
     2028/* static */
     2029bool UIVirtualBoxManager::isItemsLocal(const QList<UIVirtualMachineItem*> &items)
     2030{
     2031    foreach (UIVirtualMachineItem *pItem, items)
     2032        if (!pItem->toLocal())
     2033            return false;
     2034    return true;
    19952035}
    19962036
     
    20432083    {
    20442084        if (   pItem->accessible()
     2085            && pItem->toLocal()
    20452086#ifdef VBOX_WS_MAC
    20462087            /* On Mac OS X this are real alias files, which don't work with the old legacy xml files. */
    2047             && pItem->toLocal()
    20482088            && pItem->toLocal()->settingsFile().endsWith(".vbox", Qt::CaseInsensitive)
    20492089#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r82968 r83011  
    313313        bool isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items);
    314314
     315        /** Returns whether all passed @a items are local. */
     316        static bool isItemsLocal(const QList<UIVirtualMachineItem*> &items);
    315317        /** Returns whether all passed @a items are powered off. */
    316318        static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items);
Note: See TracChangeset for help on using the changeset viewer.

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