- Timestamp:
- Feb 6, 2020 6:07:29 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136029
- 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 1709 1709 1710 1710 /* 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)); 1711 1713 actionPool()->action(UIActionIndexST_M_Group_S_Rename)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Rename, items)); 1712 1714 actionPool()->action(UIActionIndexST_M_Group_S_Remove)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Remove, items)); … … 1721 1723 1722 1724 /* 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)); 1723 1727 actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Settings, items)); 1724 1728 actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Clone, items)); … … 1862 1866 switch (iActionIndex) 1863 1867 { 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 } 1864 1876 case UIActionIndexST_M_Group_S_Rename: 1865 1877 case UIActionIndexST_M_Group_S_Remove: 1866 1878 { 1867 1879 return !isGroupSavingInProgress() && 1880 isSingleGroupSelected() && 1881 isItemsLocal(items) && 1868 1882 isItemsPoweredOff(items); 1869 1883 } 1870 case UIActionIndexST_M_Group_S_Sort: 1884 case UIActionIndexST_M_Machine_S_New: 1885 case UIActionIndexST_M_Machine_S_Add: 1871 1886 { 1872 1887 return !isGroupSavingInProgress() && 1873 is SingleGroupSelected();1888 isItemsLocal(items); 1874 1889 } 1875 1890 case UIActionIndexST_M_Machine_S_Settings: … … 1878 1893 !isGroupSavingInProgress() && 1879 1894 items.size() == 1 && 1895 pItem->toLocal() && 1880 1896 pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null && 1881 1897 (m_pWidget->currentMachineTool() != UIToolType_Snapshots || … … 1887 1903 return !isGroupSavingInProgress() && 1888 1904 items.size() == 1 && 1905 pItem->toLocal() && 1889 1906 pItem->isItemEditable(); 1890 1907 } … … 1892 1909 { 1893 1910 return !actionPool()->action(iActionIndex)->property("opened").toBool() && 1894 items.size() == 1; 1911 items.size() == 1 && 1912 pItem->toLocal(); 1895 1913 } 1896 1914 case UIActionIndexST_M_Machine_S_Remove: 1897 1915 { 1898 1916 return !isGroupSavingInProgress() && 1899 isAtLeastOneItemRemovable(items); 1917 isAtLeastOneItemRemovable(items) && 1918 isItemsLocal(items); 1900 1919 } 1901 1920 case UIActionIndexST_M_Machine_S_AddGroup: … … 1903 1922 return !isGroupSavingInProgress() && 1904 1923 !isAllItemsOfOneGroupSelected() && 1924 isItemsLocal(items) && 1905 1925 isItemsPoweredOff(items); 1906 1926 } … … 1930 1950 case UIActionIndexST_M_Machine_S_ShowLogDialog: 1931 1951 { 1932 return isAtLeastOneItemAccessible(items); 1952 return isItemsLocal(items) && 1953 isAtLeastOneItemAccessible(items); 1933 1954 } 1934 1955 case UIActionIndexST_M_Group_T_Pause: 1935 1956 case UIActionIndexST_M_Machine_T_Pause: 1936 1957 { 1937 return isAtLeastOneItemStarted(items); 1958 return isItemsLocal(items) && 1959 isAtLeastOneItemStarted(items); 1938 1960 } 1939 1961 case UIActionIndexST_M_Group_S_Reset: 1940 1962 case UIActionIndexST_M_Machine_S_Reset: 1941 1963 { 1942 return isAtLeastOneItemRunning(items); 1964 return isItemsLocal(items) && 1965 isAtLeastOneItemRunning(items); 1943 1966 } 1944 1967 case UIActionIndexST_M_Group_S_Refresh: 1945 1968 case UIActionIndexST_M_Machine_S_Refresh: 1946 1969 { 1947 return isAtLeastOneItemInaccessible(items); 1970 return isItemsLocal(items) && 1971 isAtLeastOneItemInaccessible(items); 1948 1972 } 1949 1973 case UIActionIndexST_M_Group_S_ShowInFileManager: 1950 1974 case UIActionIndexST_M_Machine_S_ShowInFileManager: 1951 1975 { 1952 return isAtLeastOneItemAccessible(items); 1976 return isItemsLocal(items) && 1977 isAtLeastOneItemAccessible(items); 1953 1978 } 1954 1979 case UIActionIndexST_M_Machine_S_SortParent: 1955 1980 { 1956 return !isGroupSavingInProgress(); 1981 return !isGroupSavingInProgress() && 1982 isItemsLocal(items); 1957 1983 } 1958 1984 case UIActionIndexST_M_Group_S_CreateShortcut: … … 1964 1990 case UIActionIndexST_M_Machine_M_Close: 1965 1991 { 1966 return isAtLeastOneItemStarted(items); 1992 return isItemsLocal(items) && 1993 isAtLeastOneItemStarted(items); 1967 1994 } 1968 1995 case UIActionIndexST_M_Group_M_Close_S_Detach: 1969 1996 case UIActionIndexST_M_Machine_M_Close_S_Detach: 1970 1997 { 1971 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 1998 return isItemsLocal(items) && 1999 isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 1972 2000 } 1973 2001 case UIActionIndexST_M_Group_M_Close_S_SaveState: 1974 2002 case UIActionIndexST_M_Machine_M_Close_S_SaveState: 1975 2003 { 1976 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 2004 return isItemsLocal(items) && 2005 isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 1977 2006 } 1978 2007 case UIActionIndexST_M_Group_M_Close_S_Shutdown: 1979 2008 case UIActionIndexST_M_Machine_M_Close_S_Shutdown: 1980 2009 { 1981 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items) && 2010 return isItemsLocal(items) && 2011 isActionEnabled(UIActionIndexST_M_Machine_M_Close, items) && 1982 2012 isAtLeastOneItemAbleToShutdown(items); 1983 2013 } … … 1985 2015 case UIActionIndexST_M_Machine_M_Close_S_PowerOff: 1986 2016 { 1987 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 2017 return isItemsLocal(items) && 2018 isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 1988 2019 } 1989 2020 default: … … 1993 2024 /* Unknown actions are disabled: */ 1994 2025 return false; 2026 } 2027 2028 /* static */ 2029 bool UIVirtualBoxManager::isItemsLocal(const QList<UIVirtualMachineItem*> &items) 2030 { 2031 foreach (UIVirtualMachineItem *pItem, items) 2032 if (!pItem->toLocal()) 2033 return false; 2034 return true; 1995 2035 } 1996 2036 … … 2043 2083 { 2044 2084 if ( pItem->accessible() 2085 && pItem->toLocal() 2045 2086 #ifdef VBOX_WS_MAC 2046 2087 /* On Mac OS X this are real alias files, which don't work with the old legacy xml files. */ 2047 && pItem->toLocal()2048 2088 && pItem->toLocal()->settingsFile().endsWith(".vbox", Qt::CaseInsensitive) 2049 2089 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r82968 r83011 313 313 bool isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items); 314 314 315 /** Returns whether all passed @a items are local. */ 316 static bool isItemsLocal(const QList<UIVirtualMachineItem*> &items); 315 317 /** Returns whether all passed @a items are powered off. */ 316 318 static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items);
Note:
See TracChangeset
for help on using the changeset viewer.