Changeset 86925 in vbox
- Timestamp:
- Nov 19, 2020 6:19:19 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141407
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r86922 r86925 1507 1507 setName(QApplication::translate("UIActionPool", "&Save State")); 1508 1508 setStatusTip(QApplication::translate("UIActionPool", "Save state of selected virtual machines")); 1509 } 1510 }; 1511 1512 /** Simple action extension, used as 'Perform Terminate' action class. */ 1513 class UIActionSimpleManagerClosePerformTerminate : public UIActionSimple 1514 { 1515 Q_OBJECT; 1516 1517 public: 1518 1519 /** Constructs action passing @a pParent to the base-class. */ 1520 UIActionSimpleManagerClosePerformTerminate(UIActionPool *pParent) 1521 : UIActionSimple(pParent, ":/vm_discard_16px.png", ":/vm_discard_disabled_16px.png") 1522 {} 1523 1524 protected: 1525 1526 /** Returns shortcut extra-data ID. */ 1527 virtual QString shortcutExtraDataID() const /* override */ 1528 { 1529 return QString("TerminateVM"); 1530 } 1531 1532 /** Handles translation event. */ 1533 virtual void retranslateUi() /* override */ 1534 { 1535 setIconText(QApplication::translate("UIActionPool", "Terminate")); 1536 setName(QApplication::translate("UIActionPool", "&Terminate Cloud Instance...")); 1537 setStatusTip(QApplication::translate("UIActionPool", "Terminate cloud instance of selected virtual machines")); 1538 setToolTip(simplifyText(text()) + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 1509 1539 } 1510 1540 }; … … 3388 3418 m_pool[UIActionIndexMN_M_Group_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this); 3389 3419 m_pool[UIActionIndexMN_M_Group_M_Close_S_SaveState] = new UIActionSimpleManagerClosePerformSave(this); 3420 m_pool[UIActionIndexMN_M_Group_M_Close_S_Terminate] = new UIActionSimpleManagerClosePerformTerminate(this); 3390 3421 m_pool[UIActionIndexMN_M_Group_M_Close_S_Shutdown] = new UIActionSimpleManagerClosePerformShutdown(this); 3391 3422 m_pool[UIActionIndexMN_M_Group_M_Close_S_PowerOff] = new UIActionSimpleManagerClosePerformPowerOff(this); … … 3432 3463 m_pool[UIActionIndexMN_M_Machine_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this); 3433 3464 m_pool[UIActionIndexMN_M_Machine_M_Close_S_SaveState] = new UIActionSimpleManagerClosePerformSave(this); 3465 m_pool[UIActionIndexMN_M_Machine_M_Close_S_Terminate] = new UIActionSimpleManagerClosePerformTerminate(this); 3434 3466 m_pool[UIActionIndexMN_M_Machine_M_Close_S_Shutdown] = new UIActionSimpleManagerClosePerformShutdown(this); 3435 3467 m_pool[UIActionIndexMN_M_Machine_M_Close_S_PowerOff] = new UIActionSimpleManagerClosePerformPowerOff(this); … … 3680 3712 // << action(UIActionIndexMN_M_Group_M_Close_S_Detach) 3681 3713 << action(UIActionIndexMN_M_Group_M_Close_S_SaveState) 3714 << action(UIActionIndexMN_M_Group_M_Close_S_Terminate) 3682 3715 << action(UIActionIndexMN_M_Group_M_Close_S_Shutdown) 3683 3716 << action(UIActionIndexMN_M_Group_M_Close_S_PowerOff) … … 3720 3753 // << action(UIActionIndexMN_M_Machine_M_Close_S_Detach) 3721 3754 << action(UIActionIndexMN_M_Machine_M_Close_S_SaveState) 3755 << action(UIActionIndexMN_M_Machine_M_Close_S_Terminate) 3722 3756 << action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown) 3723 3757 << action(UIActionIndexMN_M_Machine_M_Close_S_PowerOff) … … 3981 4015 pMenu->clear(); 3982 4016 3983 /* Populate 'Group' / 'Close' menu: */ 3984 // pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_Detach)); 3985 pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_SaveState)); 3986 pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_Shutdown)); 4017 #ifdef VBOX_WS_MAC 4018 // WORKAROUND: 4019 // On macOS you can't leave menu empty and still have it in 4020 // the menu-bar, you have to leave there at least something. 4021 // Remaining stuff will be appended from UIVirtualBoxManager. 3987 4022 pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_PowerOff)); 3988 3989 /* Mark menu as valid: */ 3990 m_invalidations.remove(UIActionIndexMN_M_Group_M_Close);4023 #endif 4024 4025 /* This menu always remains invalid.. */ 3991 4026 } 3992 4027 … … 3999 4034 pMenu->clear(); 4000 4035 4001 /* Populate 'Machine' / 'Close' menu: */ 4002 // pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_Detach)); 4003 pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)); 4004 pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown)); 4036 #ifdef VBOX_WS_MAC 4037 // WORKAROUND: 4038 // On macOS you can't leave menu empty and still have it in 4039 // the menu-bar, you have to leave there at least something. 4040 // Remaining stuff will be appended from UIVirtualBoxManager. 4005 4041 pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_PowerOff)); 4006 4007 /* Mark menu as valid: */ 4008 m_invalidations.remove(UIActionIndexMN_M_Machine_M_Close);4042 #endif 4043 4044 /* This menu always remains invalid.. */ 4009 4045 } 4010 4046 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r86344 r86925 72 72 UIActionIndexMN_M_Group_M_Close_S_Detach, 73 73 UIActionIndexMN_M_Group_M_Close_S_SaveState, 74 UIActionIndexMN_M_Group_M_Close_S_Terminate, 74 75 UIActionIndexMN_M_Group_M_Close_S_Shutdown, 75 76 UIActionIndexMN_M_Group_M_Close_S_PowerOff, … … 115 116 UIActionIndexMN_M_Machine_M_Close_S_Detach, 116 117 UIActionIndexMN_M_Machine_M_Close_S_SaveState, 118 UIActionIndexMN_M_Machine_M_Close_S_Terminate, 117 119 UIActionIndexMN_M_Machine_M_Close_S_Shutdown, 118 120 UIActionIndexMN_M_Machine_M_Close_S_PowerOff, -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r86922 r86925 1776 1776 } 1777 1777 1778 void UIVirtualBoxManager::sltPerformTerminateMachine() 1779 { 1780 /* Get selected items: */ 1781 QList<UIVirtualMachineItem*> items = currentItems(); 1782 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1783 1784 /* Prepare the list of the machines to be terminated: */ 1785 QStringList machinesToTerminate; 1786 QList<UIVirtualMachineItem*> itemsToTerminate; 1787 foreach (UIVirtualMachineItem *pItem, items) 1788 { 1789 if (isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Terminate, QList<UIVirtualMachineItem*>() << pItem)) 1790 { 1791 machinesToTerminate << pItem->name(); 1792 itemsToTerminate << pItem; 1793 } 1794 } 1795 AssertMsg(!machinesToTerminate.isEmpty(), ("This action should not be allowed!")); 1796 1797 /* Confirm terminating: */ 1798 if ( machinesToTerminate.isEmpty() 1799 || !msgCenter().confirmTerminateCloudInstance(machinesToTerminate.join(", "))) 1800 return; 1801 1802 /* For every confirmed item to terminate: */ 1803 foreach (UIVirtualMachineItem *pItem, itemsToTerminate) 1804 { 1805 /* Get cloud machine: */ 1806 AssertPtrReturnVoid(pItem); 1807 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1808 AssertPtrReturnVoid(pCloudItem); 1809 CCloudMachine comMachine = pCloudItem->machine(); 1810 1811 /* Acquire machine name: */ 1812 QString strName; 1813 if (!cloudMachineName(comMachine, strName)) 1814 continue; 1815 1816 /* Prepare terminate cloud instance progress: */ 1817 CProgress comProgress = comMachine.Terminate(); 1818 if (!comMachine.isOk()) 1819 { 1820 msgCenter().cannotTerminateCloudInstance(comMachine); 1821 continue; 1822 } 1823 1824 /* Show terminate cloud instance progress: */ 1825 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1826 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1827 msgCenter().cannotTerminateCloudInstance(comProgress, strName); 1828 } 1829 } 1830 1778 1831 void UIVirtualBoxManager::sltPerformShutdownMachine() 1779 1832 { … … 2397 2450 connect(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState), &UIAction::triggered, 2398 2451 this, &UIVirtualBoxManager::sltPerformSaveMachineState); 2452 connect(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Terminate), &UIAction::triggered, 2453 this, &UIVirtualBoxManager::sltPerformTerminateMachine); 2399 2454 connect(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown), &UIAction::triggered, 2400 2455 this, &UIVirtualBoxManager::sltPerformShutdownMachine); … … 2407 2462 connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState), &UIAction::triggered, 2408 2463 this, &UIVirtualBoxManager::sltPerformSaveMachineState); 2464 connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Terminate), &UIAction::triggered, 2465 this, &UIVirtualBoxManager::sltPerformTerminateMachine); 2409 2466 connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown), &UIAction::triggered, 2410 2467 this, &UIVirtualBoxManager::sltPerformShutdownMachine); … … 2879 2936 } 2880 2937 2881 void UIVirtualBoxManager::updateMenuGroupClose(QMenu *) 2882 { 2938 void UIVirtualBoxManager::updateMenuGroupClose(QMenu *pMenu) 2939 { 2940 /* Get first selected item: */ 2941 UIVirtualMachineItem *pItem = currentItem(); 2942 AssertPtrReturnVoid(pItem); 2883 2943 /* Get selected items: */ 2884 2944 QList<UIVirtualMachineItem*> items = currentItems(); 2885 2945 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 2886 2946 2947 /* For local machine: */ 2948 if (pItem->itemType() == UIVirtualMachineItemType_Local) 2949 { 2950 // pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_Detach)); 2951 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState)); 2952 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown)); 2953 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_PowerOff)); 2954 } 2955 else 2956 { 2957 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Terminate)); 2958 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown)); 2959 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_PowerOff)); 2960 } 2961 2962 /* Configure 'Group' / 'Close' menu: */ 2887 2963 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Shutdown, items)); 2888 2964 } … … 3002 3078 } 3003 3079 3004 void UIVirtualBoxManager::updateMenuMachineClose(QMenu *) 3005 { 3080 void UIVirtualBoxManager::updateMenuMachineClose(QMenu *pMenu) 3081 { 3082 /* Get first selected item: */ 3083 UIVirtualMachineItem *pItem = currentItem(); 3084 AssertPtrReturnVoid(pItem); 3006 3085 /* Get selected items: */ 3007 3086 QList<UIVirtualMachineItem*> items = currentItems(); 3008 3087 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 3009 3088 3089 /* For local machine: */ 3090 if (pItem->itemType() == UIVirtualMachineItemType_Local) 3091 { 3092 // pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_Detach)); 3093 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)); 3094 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown)); 3095 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_PowerOff)); 3096 } 3097 else 3098 { 3099 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Terminate)); 3100 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown)); 3101 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_PowerOff)); 3102 } 3103 3104 /* Configure 'Machine' / 'Close' menu: */ 3010 3105 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Shutdown, items)); 3011 3106 } … … 3144 3239 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Detach, items)); 3145 3240 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_SaveState, items)); 3241 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Terminate)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Terminate, items)); 3146 3242 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Shutdown, items)); 3147 3243 actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_PowerOff)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_PowerOff, items)); … … 3151 3247 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Detach, items)); 3152 3248 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_SaveState, items)); 3249 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Terminate)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Terminate, items)); 3153 3250 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Shutdown, items)); 3154 3251 actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_PowerOff)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_PowerOff, items)); … … 3408 3505 case UIActionIndexMN_M_Machine_M_Close: 3409 3506 { 3410 return isAtLeastOneItemStarted(items); 3507 return (isItemsLocal(items) && isAtLeastOneItemStarted(items)) 3508 || (isItemsCloud(items) && isAtLeastOneItemDiscardable(items)); 3411 3509 } 3412 3510 case UIActionIndexMN_M_Group_M_Close_S_Detach: … … 3418 3516 && isItemsLocal(items); 3419 3517 } 3518 case UIActionIndexMN_M_Group_M_Close_S_Terminate: 3519 case UIActionIndexMN_M_Machine_M_Close_S_Terminate: 3520 { 3521 return isActionEnabled(UIActionIndexMN_M_Machine_M_Close, items) 3522 && isAtLeastOneItemDiscardable(items); 3523 } 3420 3524 case UIActionIndexMN_M_Group_M_Close_S_Shutdown: 3421 3525 case UIActionIndexMN_M_Machine_M_Close_S_Shutdown: … … 3443 3547 foreach (UIVirtualMachineItem *pItem, items) 3444 3548 if (!pItem->toLocal()) 3549 return false; 3550 return true; 3551 } 3552 3553 /* static */ 3554 bool UIVirtualBoxManager::isItemsCloud(const QList<UIVirtualMachineItem*> &items) 3555 { 3556 foreach (UIVirtualMachineItem *pItem, items) 3557 if (!pItem->toCloud()) 3445 3558 return false; 3446 3559 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r86734 r86925 274 274 /** Handles call to save machine state. */ 275 275 void sltPerformSaveMachineState(); 276 /** Handles call to terminate machine. */ 277 void sltPerformTerminateMachine(); 276 278 /** Handles call to ask machine for shutdown. */ 277 279 void sltPerformShutdownMachine(); … … 411 413 /** Returns whether all passed @a items are local. */ 412 414 static bool isItemsLocal(const QList<UIVirtualMachineItem*> &items); 415 /** Returns whether all passed @a items are cloud. */ 416 static bool isItemsCloud(const QList<UIVirtualMachineItem*> &items); 413 417 /** Returns whether all passed @a items are powered off. */ 414 418 static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r86923 r86925 838 838 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Add)); 839 839 m_pToolBar->addSeparator(); 840 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Discard)); 840 if (isSingleLocalGroupSelected()) 841 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Discard)); 842 else if ( isSingleCloudProviderGroupSelected() 843 || isSingleCloudProfileGroupSelected()) 844 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Terminate)); 841 845 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)); 842 846 } … … 847 851 m_pToolBar->addSeparator(); 848 852 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 849 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 853 if (isLocalMachineItemSelected()) 854 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 855 else if (isCloudMachineItemSelected()) 856 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Terminate)); 850 857 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 851 858 }
Note:
See TracChangeset
for help on using the changeset viewer.