Changeset 98524 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 10, 2023 12:27:24 PM (2 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r98335 r98524 2403 2403 switch (machineCloseAction) 2404 2404 { 2405 case MachineCloseAction_Detach: strResult = "Detach"; break; 2406 case MachineCloseAction_SaveState: strResult = "SaveState"; break; 2407 case MachineCloseAction_Shutdown: strResult = "Shutdown"; break; 2408 case MachineCloseAction_PowerOff: strResult = "PowerOff"; break; 2405 case MachineCloseAction_Detach: strResult = "Detach"; break; 2406 case MachineCloseAction_SaveState: strResult = "SaveState"; break; 2407 case MachineCloseAction_Shutdown: strResult = "Shutdown"; break; 2408 case MachineCloseAction_PowerOff: strResult = "PowerOff"; break; 2409 case MachineCloseAction_PowerOff_RestoringSnapshot: strResult = "PowerOffRestoringSnapshot"; break; 2409 2410 default: 2410 2411 { … … 2427 2428 if (strMachineCloseAction.compare("PowerOff", Qt::CaseInsensitive) == 0) 2428 2429 return MachineCloseAction_PowerOff; 2430 if (strMachineCloseAction.compare("PowerOffRestoringSnapshot", Qt::CaseInsensitive) == 0) 2431 return MachineCloseAction_PowerOff_RestoringSnapshot; 2429 2432 return MachineCloseAction_Invalid; 2430 2433 } -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r98103 r98524 1075 1075 enum MachineCloseAction 1076 1076 { 1077 MachineCloseAction_Invalid = 0, 1078 MachineCloseAction_Detach = RT_BIT(0), 1079 MachineCloseAction_SaveState = RT_BIT(1), 1080 MachineCloseAction_Shutdown = RT_BIT(2), 1081 MachineCloseAction_PowerOff = RT_BIT(3), 1082 MachineCloseAction_All = 0xFF 1077 MachineCloseAction_Invalid = 0, 1078 MachineCloseAction_Detach = RT_BIT(0), 1079 MachineCloseAction_SaveState = RT_BIT(1), 1080 MachineCloseAction_Shutdown = RT_BIT(2), 1081 MachineCloseAction_PowerOff = RT_BIT(3), 1082 MachineCloseAction_PowerOff_RestoringSnapshot = RT_BIT(4), 1083 MachineCloseAction_All = 0xFF 1083 1084 }; 1084 1085 Q_DECLARE_METATYPE(MachineCloseAction); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r98517 r98524 529 529 } 530 530 case MachineCloseAction_PowerOff: 531 case MachineCloseAction_PowerOff_RestoringSnapshot: 531 532 { 532 533 /* Power VM off: */ 533 534 LogRel(("GUI: Request for close-action to power VM off.\n")); 534 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()); 535 const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid()) 536 || closeAction == MachineCloseAction_PowerOff_RestoringSnapshot; 535 537 uimachine()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff); 536 538 break; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r98103 r98524 27 27 28 28 /* Qt includes: */ 29 #include <QButtonGroup> 29 30 #include <QCheckBox> 30 31 #include <QGridLayout> … … 69 70 , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0) 70 71 , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0) 72 , m_pCheckBoxDiscard(0) 71 73 , m_enmLastCloseAction(MachineCloseAction_Invalid) 72 74 { … … 182 184 "Selecting this action is recommended only if the virtual machine does not respond " 183 185 "to the <b>Send the shutdown signal</b> action.</p>")); 186 187 /* Translate check-box: */ 188 m_pCheckBoxDiscard->setText(tr("&Restore current snapshot '%1'").arg(m_strDiscardCheckBoxText)); 189 m_pCheckBoxDiscard->setWhatsThis(tr("<p>When checked, the machine will be returned to the state stored in the current " 190 "snapshot after it is turned off. This is useful if you are sure that you want to " 191 "discard the results of your last sessions and start again at that snapshot.</p>")); 192 } 193 194 void UIVMCloseDialog::sltUpdateWidgetAvailability() 195 { 196 /* Discard option should be enabled only on power-off action: */ 197 m_pCheckBoxDiscard->setEnabled(m_pRadioButtonPowerOff->isChecked()); 184 198 } 185 199 … … 194 208 setResult(MachineCloseAction_Shutdown); 195 209 else if (m_pRadioButtonPowerOff->isChecked()) 196 setResult(MachineCloseAction_PowerOff); 210 { 211 if (!m_pCheckBoxDiscard->isChecked() || !m_pCheckBoxDiscard->isVisible()) 212 setResult(MachineCloseAction_PowerOff); 213 else 214 setResult(MachineCloseAction_PowerOff_RestoringSnapshot); 215 } 197 216 198 217 /* Memorize the last user's choice for the given VM: */ … … 256 275 } 257 276 277 void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible) 278 { 279 m_pCheckBoxDiscard->setVisible(fVisible); 280 } 281 258 282 void UIVMCloseDialog::prepare() 259 283 { … … 392 416 #endif 393 417 418 /* Create button-group: */ 419 QButtonGroup *pButtonGroup = new QButtonGroup(this); 420 if (pButtonGroup) 421 { 422 connect(pButtonGroup, static_cast<void (QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), 423 this, &UIVMCloseDialog::sltUpdateWidgetAvailability); 424 } 425 394 426 /* Create 'detach' icon label: */ 395 427 m_pLabelIconDetach = new QLabel; … … 407 439 /* Configure button: */ 408 440 m_pRadioButtonDetach->installEventFilter(this); 409 /* Add into layout: */ 441 /* Add into group/layout: */ 442 pButtonGroup->addButton(m_pRadioButtonDetach); 410 443 m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1); 411 444 } … … 426 459 /* Configure button: */ 427 460 m_pRadioButtonSave->installEventFilter(this); 428 /* Add into layout: */ 461 /* Add into group/layout: */ 462 pButtonGroup->addButton(m_pRadioButtonSave); 429 463 m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1); 430 464 } … … 445 479 /* Configure button: */ 446 480 m_pRadioButtonShutdown->installEventFilter(this); 447 /* Add into layout: */ 481 /* Add into group/layout: */ 482 pButtonGroup->addButton(m_pRadioButtonShutdown); 448 483 m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1); 449 484 } … … 464 499 /* Configure button: */ 465 500 m_pRadioButtonPowerOff->installEventFilter(this); 501 /* Add into group/layout: */ 502 pButtonGroup->addButton(m_pRadioButtonPowerOff); 503 m_pChoiceLayout->addWidget(m_pRadioButtonPowerOff, 3, 1); 504 } 505 506 /* Create 'discard' check-box: */ 507 m_pCheckBoxDiscard = new QCheckBox; 508 if (m_pCheckBoxDiscard) 509 { 466 510 /* Add into layout: */ 467 m_pChoiceLayout->addWidget(m_p RadioButtonPowerOff, 3, 1);511 m_pChoiceLayout->addWidget(m_pCheckBoxDiscard, 4, 1); 468 512 } 469 513 … … 506 550 bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown); 507 551 bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff); 552 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot); 508 553 509 554 /* Make 'Detach' button visible/hidden depending on restriction: */ … … 524 569 /* Make 'Power off' button visible/hidden depending on restriction: */ 525 570 setButtonVisiblePowerOff(fIsPowerOffAllowed); 571 /* Make the Restore Snapshot checkbox visible/hidden depending on snapshot count & restrictions: */ 572 setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && m_comMachine.GetSnapshotCount() > 0); 573 /* Assign Restore Snapshot checkbox text: */ 574 if (!m_comMachine.GetCurrentSnapshot().isNull()) 575 m_strDiscardCheckBoxText = m_comMachine.GetCurrentSnapshot().GetName(); 526 576 527 577 /* Check which radio-button should be initially chosen: */ … … 542 592 } 543 593 else if (m_enmLastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed) 594 { 595 pRadioButtonToChoose = m_pRadioButtonPowerOff; 596 } 597 else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed) 544 598 { 545 599 pRadioButtonToChoose = m_pRadioButtonPowerOff; … … 564 618 pRadioButtonToChoose->setChecked(true); 565 619 pRadioButtonToChoose->setFocus(); 620 sltUpdateWidgetAvailability(); 566 621 m_fValid = true; 567 622 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
r98103 r98524 85 85 private slots: 86 86 87 /** Updates widgets availability. */ 88 void sltUpdateWidgetAvailability(); 89 87 90 /** Accepts the dialog. */ 88 91 void accept(); … … 109 112 /** Defines whether 'PowerOff' button is visible. */ 110 113 void setButtonVisiblePowerOff(bool fVisible); 114 115 /** Defines whether 'Discard' check-box is visible. */ 116 void setCheckBoxVisibleDiscard(bool fVisible); 111 117 112 118 /** Prepares all. */ … … 177 183 QRadioButton *m_pRadioButtonPowerOff; 178 184 185 /** Holds the 'Discard' check-box instance. */ 186 QCheckBox *m_pCheckBoxDiscard; 187 /** Holds the 'Discard' check-box text. */ 188 QString m_strDiscardCheckBoxText; 189 179 190 /** Holds the last close action. */ 180 191 MachineCloseAction m_enmLastCloseAction;
Note:
See TracChangeset
for help on using the changeset viewer.