- Timestamp:
- Jun 20, 2013 12:04:30 PM (12 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
r46703 r46704 268 268 { 269 269 /* Parse the close-action which was defined: */ 270 closeAction = UIVMCloseDialog::parseResultCode(strDefaultAction);270 closeAction = gpConverter->fromInternalString<MachineCloseAction>(strDefaultAction); 271 271 /* If VM is stuck, and the default close-action is not 'power-off', 272 272 * we should ask the user about what to do: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r46703 r46704 36 36 # include "VBoxGlobal.h" 37 37 # include "QIDialogButtonBox.h" 38 # include "UIConverter.h" 38 39 39 40 /* COM includes: */ … … 46 47 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, const CMachine &machine, const CSession &session) 47 48 : QIWithRetranslateUI<QIDialog>(pParent) 48 , m_strExtraDataOptionSave("save")49 , m_strExtraDataOptionShutdown("shutdown")50 , m_strExtraDataOptionPowerOff("powerOff")51 , m_strExtraDataOptionDiscard("discardCurState")52 49 , m_fValid(false) 53 50 , m_fIsACPIEnabled(false) 51 , m_lastCloseAction(MachineCloseAction_Invalid) 54 52 { 55 53 /* Prepare: */ … … 62 60 /* Retranslate finally: */ 63 61 retranslateUi(); 64 }65 66 /* static */67 MachineCloseAction UIVMCloseDialog::parseResultCode(const QString &strCloseAction)68 {69 MachineCloseAction closeAction = MachineCloseAction_Invalid;70 if (!strCloseAction.compare("Save", Qt::CaseInsensitive))71 closeAction = MachineCloseAction_Save;72 else if (!strCloseAction.compare("Shutdown", Qt::CaseInsensitive))73 closeAction = MachineCloseAction_Shutdown;74 else if (!strCloseAction.compare("PowerOff", Qt::CaseInsensitive))75 closeAction = MachineCloseAction_PowerOff;76 return closeAction;77 62 } 78 63 … … 98 83 } 99 84 100 /* Read the last user's choice for the given VM: */101 QStringList previousChoice = m_machine.GetExtraData(GUI_LastCloseAction).split(',');102 85 /* Memorize the last user's choice for the given VM: */ 103 QString strLastAction = m_strExtraDataOptionPowerOff; 104 switch (result()) 105 { 106 case MachineCloseAction_Save: 107 { 108 strLastAction = m_strExtraDataOptionSave; 109 break; 110 } 111 case MachineCloseAction_Shutdown: 112 { 113 strLastAction = m_strExtraDataOptionShutdown; 114 break; 115 } 116 case MachineCloseAction_PowerOff: 117 { 118 if (previousChoice[0] == m_strExtraDataOptionShutdown && !m_fIsACPIEnabled) 119 strLastAction = m_strExtraDataOptionShutdown; 120 else 121 strLastAction = m_strExtraDataOptionPowerOff; 122 break; 123 } 124 case MachineCloseAction_PowerOff_RestoringSnapshot: 125 { 126 strLastAction = m_strExtraDataOptionPowerOff + "," + 127 m_strExtraDataOptionDiscard; 128 } 129 default: break; 130 } 131 m_machine.SetExtraData(GUI_LastCloseAction, strLastAction); 86 MachineCloseAction newCloseAction = static_cast<MachineCloseAction>(result()); 87 /* But make sure 'Shutdown' is preserved if temporary unavailable: */ 88 if (newCloseAction == MachineCloseAction_PowerOff && 89 m_lastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled) 90 newCloseAction = MachineCloseAction_Shutdown; 91 m_machine.SetExtraData(GUI_LastCloseAction, gpConverter->toInternalString(newCloseAction)); 132 92 133 93 /* Hide the dialog: */ … … 344 304 m_strDiscardCheckBoxText = m_machine.GetCurrentSnapshot().GetName(); 345 305 346 /* Read the last user's choice for the given VM: */347 QStringList lastAction = m_machine.GetExtraData(GUI_LastCloseAction).split(',');348 349 306 /* Check which radio-button should be initially chosen: */ 350 307 QRadioButton *pRadioButtonToChoose = 0; 351 308 /* If choosing 'last choice' is possible: */ 352 if (lastAction[0] == m_strExtraDataOptionSave && fIsStateSavingAllowed) 309 m_lastCloseAction = gpConverter->fromInternalString<MachineCloseAction>(m_machine.GetExtraData(GUI_LastCloseAction)); 310 if (m_lastCloseAction == MachineCloseAction_Save && fIsStateSavingAllowed) 353 311 { 354 312 pRadioButtonToChoose = m_pSaveRadio; 355 313 } 356 else if ( lastAction[0] == m_strExtraDataOptionShutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)314 else if (m_lastCloseAction == MachineCloseAction_Shutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled) 357 315 { 358 316 pRadioButtonToChoose = m_pShutdownRadio; 359 317 } 360 else if ( lastAction[0] == m_strExtraDataOptionPowerOff && fIsPowerOffAllowed)318 else if (m_lastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed) 361 319 { 362 320 pRadioButtonToChoose = m_pPowerOffRadio; 363 if (fIsPowerOffAndRestoreAllowed) 364 m_pDiscardCheckBox->setChecked(lastAction.count() > 1 && lastAction[1] == m_strExtraDataOptionDiscard); 321 } 322 else if (m_lastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed) 323 { 324 pRadioButtonToChoose = m_pPowerOffRadio; 325 m_pDiscardCheckBox->setChecked(true); 365 326 } 366 327 /* Else 'default choice' will be used: */ 367 328 else 368 329 { 369 if (fIsACPIShutdownAllowed && m_fIsACPIEnabled) 330 if (fIsStateSavingAllowed) 331 pRadioButtonToChoose = m_pSaveRadio; 332 else if (fIsACPIShutdownAllowed && m_fIsACPIEnabled) 370 333 pRadioButtonToChoose = m_pShutdownRadio; 371 else if (fIsStateSavingAllowed)372 pRadioButtonToChoose = m_pSaveRadio;373 334 else if (fIsPowerOffAllowed) 374 335 pRadioButtonToChoose = m_pPowerOffRadio; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r46698 r46704 48 48 bool isValid() const { return m_fValid; } 49 49 50 /* Static API: Parse string containing result-code: */51 static MachineCloseAction parseResultCode(const QString &strCloseAction);52 53 50 private slots: 54 51 … … 98 95 99 96 /* Variables: */ 100 const QString m_strExtraDataOptionSave;101 const QString m_strExtraDataOptionShutdown;102 const QString m_strExtraDataOptionPowerOff;103 const QString m_strExtraDataOptionDiscard;104 97 bool m_fValid; 105 98 CMachine m_machine; 106 99 bool m_fIsACPIEnabled; 107 100 QString m_strDiscardCheckBoxText; 101 MachineCloseAction m_lastCloseAction; 108 102 }; 109 103
Note:
See TracChangeset
for help on using the changeset viewer.