Changeset 49465 in vbox
- Timestamp:
- Nov 13, 2013 1:27:44 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r49363 r49465 351 351 enum MachineCloseAction 352 352 { 353 MachineCloseAction_Invalid ,354 MachineCloseAction_SaveState ,355 MachineCloseAction_Shutdown ,356 MachineCloseAction_PowerOff ,357 MachineCloseAction_PowerOff_RestoringSnapshot ,358 MachineCloseAction_ Max353 MachineCloseAction_Invalid = 0, 354 MachineCloseAction_SaveState = RT_BIT(0), 355 MachineCloseAction_Shutdown = RT_BIT(1), 356 MachineCloseAction_PowerOff = RT_BIT(2), 357 MachineCloseAction_PowerOff_RestoringSnapshot = RT_BIT(3), 358 MachineCloseAction_All = 0xFF 359 359 }; 360 360 Q_DECLARE_METATYPE(MachineCloseAction); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r49363 r49465 3533 3533 } 3534 3534 3535 /** Returns default machine close action for passed @a machine. */ 3536 MachineCloseAction VBoxGlobal::defaultMachineCloseAction(CMachine &machine) 3537 { 3538 return gpConverter->fromInternalString<MachineCloseAction>(machine.GetExtraData(GUI_DefaultCloseAction)); 3539 } 3540 3535 3541 /* static */ 3536 3542 RuntimeMenuType VBoxGlobal::restrictedRuntimeMenuTypes(CMachine &machine) … … 3590 3596 } 3591 3597 3592 /* static*/3593 QList<MachineCloseAction>VBoxGlobal::restrictedMachineCloseActions(CMachine &machine)3598 /** Returns merged restricted machine close actions for passed @a machine. */ 3599 MachineCloseAction VBoxGlobal::restrictedMachineCloseActions(CMachine &machine) 3594 3600 { 3595 3601 /* Prepare result: */ 3596 QList<MachineCloseAction> result;3602 MachineCloseAction result = MachineCloseAction_Invalid; 3597 3603 /* Load restricted machine-close-actions: */ 3598 3604 QString strList(machine.GetExtraData(GUI_RestrictedCloseActions)); … … 3603 3609 MachineCloseAction value = gpConverter->fromInternalString<MachineCloseAction>(strValue); 3604 3610 if (value != MachineCloseAction_Invalid) 3605 result << value;3611 result = static_cast<MachineCloseAction>(result | value); 3606 3612 } 3607 3613 /* Return result: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r49363 r49465 359 359 static bool shouldWeAutoMountGuestScreens(CMachine &machine, bool fIncludingSanityCheck = true); 360 360 static bool shouldWeAllowSnapshotOperations(CMachine &machine, bool fIncludingSanityCheck = true); 361 static MachineCloseAction defaultMachineCloseAction(CMachine &machine); 361 362 static RuntimeMenuType restrictedRuntimeMenuTypes(CMachine &machine); 362 363 static UIVisualStateType restrictedVisualStateTypes(CMachine &machine); 363 364 static QList<IndicatorType> restrictedStatusBarIndicators(CMachine &machine); 364 static QList<MachineCloseAction>restrictedMachineCloseActions(CMachine &machine);365 static MachineCloseAction restrictedMachineCloseActions(CMachine &machine); 365 366 static QList<GlobalSettingsPageType> restrictedGlobalSettingsPages(CVirtualBox &vbox); 366 367 static QList<MachineSettingsPageType> restrictedMachineSettingsPages(CMachine &machine); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r49013 r49465 253 253 return; 254 254 255 /* Get machine: */ 256 CMachine m = machine(); 257 255 258 /* If there is a close hook script defined: */ 256 QString strScript = m achine().GetExtraData(GUI_CloseActionHook);259 QString strScript = m.GetExtraData(GUI_CloseActionHook); 257 260 if (!strScript.isEmpty()) 258 261 { 259 262 /* Execute asynchronously and leave: */ 260 QProcess::startDetached(strScript, QStringList() << m achine().GetId());263 QProcess::startDetached(strScript, QStringList() << m.GetId()); 261 264 return; 262 265 } … … 266 269 267 270 /* If there IS default close-action defined: */ 268 QString strDefaultAction = m achine().GetExtraData(GUI_DefaultCloseAction);271 QString strDefaultAction = m.GetExtraData(GUI_DefaultCloseAction); 269 272 if (!strDefaultAction.isEmpty()) 270 273 { … … 279 282 * we should check if its possible to discard machine-state: */ 280 283 if (closeAction == MachineCloseAction_PowerOff && 281 m achine().GetSnapshotCount() > 0)284 m.GetSnapshotCount() > 0) 282 285 closeAction = MachineCloseAction_PowerOff_RestoringSnapshot; 283 286 } … … 288 291 /* Prepare close-dialog: */ 289 292 QWidget *pParentDlg = windowManager().realParentWindow(this); 290 QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, m achine(), session());293 QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, m, session()); 291 294 292 295 /* Make sure close-dialog is valid: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r49462 r49465 132 132 , m_pWatchdogDisplayChange(0) 133 133 #endif /* Q_WS_MAC */ 134 , m_defaultCloseAction(MachineCloseAction_Invalid) 135 , m_restrictedCloseActions(MachineCloseAction_Invalid) 134 136 , m_fSnapshotOperationsAllowed(true) 135 137 /* Common flags: */ … … 1087 1089 updateSessionSettings(); 1088 1090 1091 /* What is the default close action and the restricted are? */ 1092 m_defaultCloseAction = vboxGlobal().defaultMachineCloseAction(machine); 1093 m_restrictedCloseActions = vboxGlobal().restrictedMachineCloseActions(machine); 1094 1089 1095 /* Should we allow snapshot operations? */ 1090 1096 m_fSnapshotOperationsAllowed = vboxGlobal().shouldWeAllowSnapshotOperations(machine); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r49462 r49465 105 105 QCursor cursor() const { return m_cursor; } 106 106 107 /** @name Application Close configuration stuff. 108 * @{ */ 109 /** Returns default close action. */ 110 MachineCloseAction defaultCloseAction() const { return m_defaultCloseAction; } 111 /** Returns merged restricted close actions. */ 112 MachineCloseAction restrictedCloseActions() const { return m_restrictedCloseActions; } 113 /** @} */ 114 107 115 /** @name Snapshot Operations configuration stuff. 108 116 * @{ */ … … 319 327 #endif /* Q_WS_MAC */ 320 328 329 /** @name Application Close configuration variables. 330 * @{ */ 331 /** Default close action. */ 332 MachineCloseAction m_defaultCloseAction; 333 /** Merged restricted close actions. */ 334 MachineCloseAction m_restrictedCloseActions; 335 /** @} */ 336 321 337 /** @name Snapshot Operations configuration variables. 322 338 * @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r47398 r49465 39 39 40 40 /* COM includes: */ 41 # include "CMachine.h" 41 42 # include "CSession.h" 42 43 # include "CConsole.h" … … 45 46 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 46 47 47 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, constCMachine &machine, const CSession &session)48 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine, const CSession &session) 48 49 : QIWithRetranslateUI<QIDialog>(pParent) 50 , m_machine(machine) 51 , m_session(session) 49 52 , m_fValid(false) 50 53 , m_fIsACPIEnabled(false) … … 55 58 56 59 /* Configure: */ 57 setSizeGripEnabled(false); 58 configure(machine, session); 59 60 /* Retranslate finally: */ 60 configure(); 61 62 /* Retranslate: */ 61 63 retranslateUi(); 62 64 } … … 270 272 pMainLayout->addWidget(pButtonBox); 271 273 } 272 } 273 274 void UIVMCloseDialog::configure(const CMachine &machine, const CSession &session) 275 { 276 /* Assign machine: */ 277 m_machine = machine; 278 279 /* Get machine-state: */ 274 /* Prepare size-grip token: */ 275 setSizeGripEnabled(false); 276 } 277 278 void UIVMCloseDialog::configure() 279 { 280 /* Get actual machine-state: */ 280 281 KMachineState machineState = m_machine.GetState(); 281 282 … … 284 285 285 286 /* Check which close-actions are resticted: */ 286 QList<MachineCloseAction>restictedCloseActions = vboxGlobal().restrictedMachineCloseActions(m_machine);287 bool fIsStateSavingAllowed = ! restictedCloseActions.contains(MachineCloseAction_SaveState);288 bool fIsACPIShutdownAllowed = ! restictedCloseActions.contains(MachineCloseAction_Shutdown);289 bool fIsPowerOffAllowed = ! restictedCloseActions.contains(MachineCloseAction_PowerOff);290 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && ! restictedCloseActions.contains(MachineCloseAction_PowerOff_RestoringSnapshot);287 MachineCloseAction restictedCloseActions = vboxGlobal().restrictedMachineCloseActions(m_machine); 288 bool fIsStateSavingAllowed = !(restictedCloseActions & MachineCloseAction_SaveState); 289 bool fIsACPIShutdownAllowed = !(restictedCloseActions & MachineCloseAction_Shutdown); 290 bool fIsPowerOffAllowed = !(restictedCloseActions & MachineCloseAction_PowerOff); 291 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot); 291 292 292 293 /* Make 'Save state' button visible/hidden depending on restriction: */ … … 297 298 setShutdownButtonVisible(fIsACPIShutdownAllowed); 298 299 /* Make 'Shutdown button' enabled/disabled depending on ACPI-state & machine-state: */ 299 m_fIsACPIEnabled = session.GetConsole().GetGuestEnteredACPIMode();300 m_fIsACPIEnabled = m_session.GetConsole().GetGuestEnteredACPIMode(); 300 301 setShutdownButtonEnabled(m_fIsACPIEnabled && machineState != KMachineState_Stuck); 301 302 /* Make 'Power off' button visible/hidden depending on restriction: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r47398 r49465 25 25 #include "UIDefs.h" 26 26 27 /* COM includes: */28 #include "COMEnums.h"29 #include "CMachine.h"30 31 27 /* Forward declarations: */ 28 class CMachine; 32 29 class CSession; 33 30 class QLabel; … … 43 40 44 41 /* Constructor: */ 45 UIVMCloseDialog(QWidget *pParent, constCMachine &machine, const CSession &session);42 UIVMCloseDialog(QWidget *pParent, CMachine &machine, const CSession &session); 46 43 47 44 /* API: Validation stuff: */ … … 75 72 /* Helpers: Prepare stuff: */ 76 73 void prepare(); 77 void configure( const CMachine &machine, const CSession &session);74 void configure(); 78 75 79 76 /* Helper: Translate stuff: */ … … 98 95 99 96 /* Variables: */ 97 CMachine &m_machine; 98 const CSession &m_session; 100 99 bool m_fValid; 101 CMachine m_machine;102 100 bool m_fIsACPIEnabled; 103 101 QString m_strDiscardCheckBoxText;
Note:
See TracChangeset
for help on using the changeset viewer.