- Timestamp:
- Jul 8, 2021 7:38:43 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145582
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r89324 r90083 2209 2209 switch (machineCloseAction) 2210 2210 { 2211 case MachineCloseAction_Detach: strResult = "Detach"; break; 2212 case MachineCloseAction_SaveState: strResult = "SaveState"; break; 2213 case MachineCloseAction_Shutdown: strResult = "Shutdown"; break; 2214 case MachineCloseAction_PowerOff: strResult = "PowerOff"; break; 2215 case MachineCloseAction_PowerOff_RestoringSnapshot: strResult = "PowerOffRestoringSnapshot"; break; 2211 case MachineCloseAction_Detach: strResult = "Detach"; break; 2212 case MachineCloseAction_SaveState: strResult = "SaveState"; break; 2213 case MachineCloseAction_Shutdown: strResult = "Shutdown"; break; 2214 case MachineCloseAction_PowerOff: strResult = "PowerOff"; break; 2216 2215 default: 2217 2216 { … … 2228 2227 /* Here we have some fancy stuff allowing us 2229 2228 * to search through the keys using 'case-insensitive' rule: */ 2230 QStringList keys; QList<MachineCloseAction> values; 2231 keys << "Detach"; values << MachineCloseAction_Detach; 2232 keys << "SaveState"; values << MachineCloseAction_SaveState; 2233 keys << "Shutdown"; values << MachineCloseAction_Shutdown; 2234 keys << "PowerOff"; values << MachineCloseAction_PowerOff; 2235 keys << "PowerOffRestoringSnapshot"; values << MachineCloseAction_PowerOff_RestoringSnapshot; 2229 QStringList keys; QList<MachineCloseAction> values; 2230 keys << "Detach"; values << MachineCloseAction_Detach; 2231 keys << "SaveState"; values << MachineCloseAction_SaveState; 2232 keys << "Shutdown"; values << MachineCloseAction_Shutdown; 2233 keys << "PowerOff"; values << MachineCloseAction_PowerOff; 2236 2234 /* Invalid type for unknown words: */ 2237 2235 if (!keys.contains(strMachineCloseAction, Qt::CaseInsensitive)) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r89688 r90083 225 225 const char *UIExtraDataDefs::GUI_LastCloseAction = "GUI/LastCloseAction"; 226 226 const char *UIExtraDataDefs::GUI_CloseActionHook = "GUI/CloseActionHook"; 227 const char *UIExtraDataDefs::GUI_DiscardStateOnPowerOff = "GUI/DiscardStateOnPowerOff"; 227 228 228 229 #ifdef VBOX_WITH_DEBUGGER_GUI -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r89688 r90083 414 414 /** Holds machine close hook script name as simple string. */ 415 415 SHARED_LIBRARY_STUFF extern const char *GUI_CloseActionHook; 416 /** Holds whether machine should discard state on power off. */ 417 SHARED_LIBRARY_STUFF extern const char *GUI_DiscardStateOnPowerOff; 416 418 /** @} */ 417 419 … … 1006 1008 enum MachineCloseAction 1007 1009 { 1008 MachineCloseAction_Invalid = 0, 1009 MachineCloseAction_Detach = RT_BIT(0), 1010 MachineCloseAction_SaveState = RT_BIT(1), 1011 MachineCloseAction_Shutdown = RT_BIT(2), 1012 MachineCloseAction_PowerOff = RT_BIT(3), 1013 MachineCloseAction_PowerOff_RestoringSnapshot = RT_BIT(4), 1014 MachineCloseAction_All = 0xFF 1010 MachineCloseAction_Invalid = 0, 1011 MachineCloseAction_Detach = RT_BIT(0), 1012 MachineCloseAction_SaveState = RT_BIT(1), 1013 MachineCloseAction_Shutdown = RT_BIT(2), 1014 MachineCloseAction_PowerOff = RT_BIT(3), 1015 MachineCloseAction_All = 0xFF 1015 1016 }; 1016 1017 Q_DECLARE_METATYPE(MachineCloseAction); -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r89950 r90083 1977 1977 << GUI_GuestControl_ProcessControlDialogGeometry 1978 1978 << GUI_DefaultCloseAction << GUI_RestrictedCloseActions 1979 << GUI_LastCloseAction << GUI_CloseActionHook 1979 << GUI_LastCloseAction << GUI_CloseActionHook << GUI_DiscardStateOnPowerOff 1980 1980 #ifdef VBOX_WITH_DEBUGGER_GUI 1981 1981 << GUI_Dbg_Enabled << GUI_Dbg_AutoShow … … 4442 4442 { 4443 4443 return extraDataString(GUI_CloseActionHook, uID); 4444 } 4445 4446 bool UIExtraDataManager::discardStateOnPowerOff(const QUuid &uID) 4447 { 4448 /* 'False' unless feature allowed: */ 4449 return isFeatureAllowed(GUI_DiscardStateOnPowerOff, uID); 4444 4450 } 4445 4451 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r89740 r90083 749 749 /** Returns machine close hook script name as simple string. */ 750 750 QString machineCloseHookScript(const QUuid &uID); 751 752 /** Returns whether machine should discard state on power off. */ 753 bool discardStateOnPowerOff(const QUuid &uID); 751 754 /** @} */ 752 755 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp
r87251 r90083 3457 3457 && (restrictedCloseActions & MachineCloseAction_Shutdown) 3458 3458 && (restrictedCloseActions & MachineCloseAction_PowerOff); 3459 // Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..3460 // && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);3461 3459 if (fAllCloseActionsRestricted) 3462 3460 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r90024 r90083 514 514 /* Power VM off: */ 515 515 LogRel(("GUI: Request to power VM off due to VBoxSVC is unavailable.\n")); 516 powerOff(false );516 powerOff(false /* do NOT restore current snapshot */); 517 517 } 518 518 … … 1935 1935 } 1936 1936 1937 LogRel(("GUI: User requested to detach GUI.\n")); 1937 1938 detach(); 1938 1939 } … … 1947 1948 } 1948 1949 1950 LogRel(("GUI: User requested to save VM state.\n")); 1949 1951 saveState(); 1950 1952 } … … 1959 1961 } 1960 1962 1963 LogRel(("GUI: User requested to shutdown VM.\n")); 1961 1964 shutdown(); 1962 1965 } … … 1971 1974 } 1972 1975 1973 LogRel(("GUI: User request to power VM off.\n"));1974 MachineCloseAction enmLastCloseAction = gEDataManager->lastMachineCloseAction(uiCommon().managedVMUuid());1975 powerOff(machine().GetSnapshotCount() > 0 && enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot);1976 LogRel(("GUI: User requested to power VM off.\n")); 1977 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()); 1978 powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff); 1976 1979 } 1977 1980 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r88244 r90083 440 440 case MachineCloseAction_Detach: 441 441 { 442 /* Just close RuntimeUI: */442 /* Detach GUI: */ 443 443 LogRel(("GUI: Request for close-action to detach GUI.\n")); 444 444 machineLogic()->detach(); … … 460 460 } 461 461 case MachineCloseAction_PowerOff: 462 case MachineCloseAction_PowerOff_RestoringSnapshot:463 462 { 464 463 /* Power VM off: */ 465 464 LogRel(("GUI: Request for close-action to power VM off.\n")); 466 machineLogic()->powerOff(closeAction == MachineCloseAction_PowerOff_RestoringSnapshot); 465 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()); 466 machineLogic()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff); 467 467 break; 468 468 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r89867 r90083 1365 1365 && (m_restrictedCloseActions & MachineCloseAction_Shutdown) 1366 1366 && (m_restrictedCloseActions & MachineCloseAction_PowerOff); 1367 // Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..1368 // && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);1369 1367 } 1370 1368 } … … 2020 2018 bool fServerCrashed = false; 2021 2019 LogRel(("GUI: Aborting startup due to postprocess initialization issue detected...\n")); 2022 powerOff(false , fServerCrashed);2020 powerOff(false /* do NOT restore current snapshot */, fServerCrashed); 2023 2021 return false; 2024 2022 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r87001 r90083 59 59 , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0) 60 60 , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0) 61 , m_pCheckBoxDiscard(0)62 61 , m_enmLastCloseAction(MachineCloseAction_Invalid) 63 62 { … … 173 172 "Selecting this action is recommended only if the virtual machine does not respond " 174 173 "to the <b>Send the shutdown signal</b> action.</p>")); 175 176 /* Translate check-box: */177 m_pCheckBoxDiscard->setText(tr("&Restore current snapshot '%1'").arg(m_strDiscardCheckBoxText));178 m_pCheckBoxDiscard->setToolTip(tr("Restore the machine state stored in the current snapshot"));179 m_pCheckBoxDiscard->setWhatsThis(tr("<p>When checked, the machine will be returned to the state stored in the current "180 "snapshot after it is turned off. This is useful if you are sure that you want to "181 "discard the results of your last sessions and start again at that snapshot.</p>"));182 }183 184 void UIVMCloseDialog::sltUpdateWidgetAvailability()185 {186 /* Discard option should be enabled only on power-off action: */187 m_pCheckBoxDiscard->setEnabled(m_pRadioButtonPowerOff->isChecked());188 174 } 189 175 … … 198 184 setResult(MachineCloseAction_Shutdown); 199 185 else if (m_pRadioButtonPowerOff->isChecked()) 200 { 201 if (!m_pCheckBoxDiscard->isChecked() || !m_pCheckBoxDiscard->isVisible()) 202 setResult(MachineCloseAction_PowerOff); 203 else 204 setResult(MachineCloseAction_PowerOff_RestoringSnapshot); 205 } 186 setResult(MachineCloseAction_PowerOff); 206 187 207 188 /* Memorize the last user's choice for the given VM: */ … … 265 246 } 266 247 267 void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible)268 {269 m_pCheckBoxDiscard->setVisible(fVisible);270 }271 272 248 void UIVMCloseDialog::prepare() 273 249 { … … 421 397 /* Configure button: */ 422 398 m_pRadioButtonDetach->installEventFilter(this); 423 connect(m_pRadioButtonDetach, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);424 399 /* Add into layout: */ 425 400 m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1); … … 441 416 /* Configure button: */ 442 417 m_pRadioButtonSave->installEventFilter(this); 443 connect(m_pRadioButtonSave, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);444 418 /* Add into layout: */ 445 419 m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1); … … 461 435 /* Configure button: */ 462 436 m_pRadioButtonShutdown->installEventFilter(this); 463 connect(m_pRadioButtonShutdown, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);464 437 /* Add into layout: */ 465 438 m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1); … … 481 454 /* Configure button: */ 482 455 m_pRadioButtonPowerOff->installEventFilter(this); 483 connect(m_pRadioButtonPowerOff, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);484 456 /* Add into layout: */ 485 457 m_pChoiceLayout->addWidget(m_pRadioButtonPowerOff, 3, 1); 486 }487 488 /* Create 'discard' check-box: */489 m_pCheckBoxDiscard = new QCheckBox;490 if (m_pCheckBoxDiscard)491 {492 /* Add into layout: */493 m_pChoiceLayout->addWidget(m_pCheckBoxDiscard, 4, 1);494 458 } 495 459 … … 532 496 bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown); 533 497 bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff); 534 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);535 498 536 499 /* Make 'Detach' button visible/hidden depending on restriction: */ … … 551 514 /* Make 'Power off' button visible/hidden depending on restriction: */ 552 515 setButtonVisiblePowerOff(fIsPowerOffAllowed); 553 /* Make the Restore Snapshot checkbox visible/hidden depending on snapshot count & restrictions: */554 setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && m_comMachine.GetSnapshotCount() > 0);555 /* Assign Restore Snapshot checkbox text: */556 if (!m_comMachine.GetCurrentSnapshot().isNull())557 m_strDiscardCheckBoxText = m_comMachine.GetCurrentSnapshot().GetName();558 516 559 517 /* Check which radio-button should be initially chosen: */ … … 576 534 { 577 535 pRadioButtonToChoose = m_pRadioButtonPowerOff; 578 }579 else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)580 {581 pRadioButtonToChoose = m_pRadioButtonPowerOff;582 m_pCheckBoxDiscard->setChecked(true);583 536 } 584 537 /* Else 'default choice' will be used: */ … … 601 554 pRadioButtonToChoose->setChecked(true); 602 555 pRadioButtonToChoose->setFocus(); 603 sltUpdateWidgetAvailability();604 556 m_fValid = true; 605 557 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r82968 r90083 75 75 private slots: 76 76 77 /** Updates widgets availability. */78 void sltUpdateWidgetAvailability();79 80 77 /** Accepts the dialog. */ 81 78 void accept(); … … 102 99 /** Defines whether 'PowerOff' button is visible. */ 103 100 void setButtonVisiblePowerOff(bool fVisible); 104 105 /** Defines whether 'Discard' check-box is visible. */106 void setCheckBoxVisibleDiscard(bool fVisible);107 101 108 102 /** Prepares all. */ … … 173 167 QRadioButton *m_pRadioButtonPowerOff; 174 168 175 /** Holds the 'Discard' check-box instance. */176 QCheckBox *m_pCheckBoxDiscard;177 /** Holds the 'Discard' check-box text. */178 QString m_strDiscardCheckBoxText;179 180 169 /** Holds the last close action. */ 181 170 MachineCloseAction m_enmLastCloseAction;
Note:
See TracChangeset
for help on using the changeset viewer.