Changeset 49468 in vbox
- Timestamp:
- Nov 13, 2013 2:04:55 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r49467 r49468 268 268 MachineCloseAction closeAction = MachineCloseAction_Invalid; 269 269 270 /* If there IS default close-action defined: */ 271 QString strDefaultAction = m.GetExtraData(GUI_DefaultCloseAction); 272 if (!strDefaultAction.isEmpty()) 273 { 274 /* Parse the close-action which was defined: */ 275 closeAction = gpConverter->fromInternalString<MachineCloseAction>(strDefaultAction); 276 /* If VM is stuck, and the default close-action is not 'power-off', 277 * we should ask the user about what to do: */ 278 if (uisession()->isStuck() && 279 closeAction != MachineCloseAction_PowerOff) 280 closeAction = MachineCloseAction_Invalid; 281 /* If the default-action is 'power-off', 282 * we should check if its possible to discard machine-state: */ 283 if (closeAction == MachineCloseAction_PowerOff && 284 m.GetSnapshotCount() > 0) 285 closeAction = MachineCloseAction_PowerOff_RestoringSnapshot; 270 /* If default close-action defined and not restricted: */ 271 MachineCloseAction defaultCloseAction = uisession()->defaultCloseAction(); 272 MachineCloseAction restrictedCloseActions = uisession()->restrictedCloseActions(); 273 if ((defaultCloseAction != MachineCloseAction_Invalid) && 274 !(restrictedCloseActions & defaultCloseAction)) 275 { 276 switch (defaultCloseAction) 277 { 278 /* If VM is stuck, and the default close-action is 'save-state' or 'shutdown', 279 * we should ask the user about what to do: */ 280 case MachineCloseAction_SaveState: 281 case MachineCloseAction_Shutdown: 282 closeAction = uisession()->isStuck() ? MachineCloseAction_Invalid : defaultCloseAction; 283 break; 284 /* Otherwise we just use what we have: */ 285 default: 286 closeAction = defaultCloseAction; 287 break; 288 } 286 289 } 287 290 … … 292 295 QWidget *pParentDlg = windowManager().realParentWindow(this); 293 296 QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, m, 294 session().GetConsole().GetGuestEnteredACPIMode()); 297 session().GetConsole().GetGuestEnteredACPIMode(), 298 restrictedCloseActions); 295 299 296 300 /* Make sure close-dialog is valid: */ … … 323 327 else 324 328 { 325 /* Else user misconfigured .vbox file, 'power-off' will be the action: */326 closeAction = MachineCloseAction_ PowerOff;329 /* Else user misconfigured .vbox file, we will reject closing UI: */ 330 closeAction = MachineCloseAction_Invalid; 327 331 } 328 332 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r49467 r49468 46 46 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 47 47 48 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine, bool fIsACPIEnabled) 48 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine, 49 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions) 49 50 : QIWithRetranslateUI<QIDialog>(pParent) 50 51 , m_machine(machine) 52 , m_restictedCloseActions(restictedCloseActions) 51 53 , m_fIsACPIEnabled(fIsACPIEnabled) 52 54 , m_fValid(false) … … 284 286 285 287 /* Check which close-actions are resticted: */ 286 MachineCloseAction restictedCloseActions = vboxGlobal().restrictedMachineCloseActions(m_machine); 287 bool fIsStateSavingAllowed = !(restictedCloseActions & MachineCloseAction_SaveState); 288 bool fIsACPIShutdownAllowed = !(restictedCloseActions & MachineCloseAction_Shutdown); 289 bool fIsPowerOffAllowed = !(restictedCloseActions & MachineCloseAction_PowerOff); 290 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot); 288 bool fIsStateSavingAllowed = !(m_restictedCloseActions & MachineCloseAction_SaveState); 289 bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown); 290 bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff); 291 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot); 291 292 292 293 /* Make 'Save state' button visible/hidden depending on restriction: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r49467 r49468 26 26 27 27 /* Forward declarations: */ 28 enum MachineCloseAction; 28 29 class CMachine; 29 30 class QLabel; … … 39 40 40 41 /* Constructor: */ 41 UIVMCloseDialog(QWidget *pParent, CMachine &machine, bool fIsACPIEnabled); 42 UIVMCloseDialog(QWidget *pParent, CMachine &machine, 43 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions); 42 44 43 45 /* API: Validation stuff: */ … … 95 97 /* Variables: */ 96 98 CMachine &m_machine; 99 const MachineCloseAction m_restictedCloseActions; 97 100 bool m_fIsACPIEnabled; 98 101 bool m_fValid;
Note:
See TracChangeset
for help on using the changeset viewer.