VirtualBox

Ignore:
Timestamp:
Feb 10, 2023 12:27:24 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:5117: Runtime UI: Bring back Restore current snapshot checkbox of Close VM dialog; Just don't restore whether it was selected before.

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  
    24032403    switch (machineCloseAction)
    24042404    {
    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;
    24092410        default:
    24102411        {
     
    24272428    if (strMachineCloseAction.compare("PowerOff", Qt::CaseInsensitive) == 0)
    24282429        return MachineCloseAction_PowerOff;
     2430    if (strMachineCloseAction.compare("PowerOffRestoringSnapshot", Qt::CaseInsensitive) == 0)
     2431        return MachineCloseAction_PowerOff_RestoringSnapshot;
    24292432    return MachineCloseAction_Invalid;
    24302433}
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r98103 r98524  
    10751075enum MachineCloseAction
    10761076{
    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
    10831084};
    10841085Q_DECLARE_METATYPE(MachineCloseAction);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r98517 r98524  
    529529        }
    530530        case MachineCloseAction_PowerOff:
     531        case MachineCloseAction_PowerOff_RestoringSnapshot:
    531532        {
    532533            /* Power VM off: */
    533534            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;
    535537            uimachine()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
    536538            break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r98103 r98524  
    2727
    2828/* Qt includes: */
     29#include <QButtonGroup>
    2930#include <QCheckBox>
    3031#include <QGridLayout>
     
    6970    , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0)
    7071    , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0)
     72    , m_pCheckBoxDiscard(0)
    7173    , m_enmLastCloseAction(MachineCloseAction_Invalid)
    7274{
     
    182184                                            "Selecting this action is recommended only if the virtual machine does not respond "
    183185                                            "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
     194void UIVMCloseDialog::sltUpdateWidgetAvailability()
     195{
     196    /* Discard option should be enabled only on power-off action: */
     197    m_pCheckBoxDiscard->setEnabled(m_pRadioButtonPowerOff->isChecked());
    184198}
    185199
     
    194208        setResult(MachineCloseAction_Shutdown);
    195209    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    }
    197216
    198217    /* Memorize the last user's choice for the given VM: */
     
    256275}
    257276
     277void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible)
     278{
     279    m_pCheckBoxDiscard->setVisible(fVisible);
     280}
     281
    258282void UIVMCloseDialog::prepare()
    259283{
     
    392416#endif
    393417
     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
    394426        /* Create 'detach' icon label: */
    395427        m_pLabelIconDetach = new QLabel;
     
    407439            /* Configure button: */
    408440            m_pRadioButtonDetach->installEventFilter(this);
    409             /* Add into layout: */
     441            /* Add into group/layout: */
     442            pButtonGroup->addButton(m_pRadioButtonDetach);
    410443            m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1);
    411444        }
     
    426459            /* Configure button: */
    427460            m_pRadioButtonSave->installEventFilter(this);
    428             /* Add into layout: */
     461            /* Add into group/layout: */
     462            pButtonGroup->addButton(m_pRadioButtonSave);
    429463            m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1);
    430464        }
     
    445479            /* Configure button: */
    446480            m_pRadioButtonShutdown->installEventFilter(this);
    447             /* Add into layout: */
     481            /* Add into group/layout: */
     482            pButtonGroup->addButton(m_pRadioButtonShutdown);
    448483            m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1);
    449484        }
     
    464499            /* Configure button: */
    465500            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        {
    466510            /* Add into layout: */
    467             m_pChoiceLayout->addWidget(m_pRadioButtonPowerOff, 3, 1);
     511            m_pChoiceLayout->addWidget(m_pCheckBoxDiscard, 4, 1);
    468512        }
    469513
     
    506550    bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown);
    507551    bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff);
     552    bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    508553
    509554    /* Make 'Detach' button visible/hidden depending on restriction: */
     
    524569    /* Make 'Power off' button visible/hidden depending on restriction: */
    525570    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();
    526576
    527577    /* Check which radio-button should be initially chosen: */
     
    542592    }
    543593    else if (m_enmLastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed)
     594    {
     595        pRadioButtonToChoose = m_pRadioButtonPowerOff;
     596    }
     597    else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
    544598    {
    545599        pRadioButtonToChoose = m_pRadioButtonPowerOff;
     
    564618        pRadioButtonToChoose->setChecked(true);
    565619        pRadioButtonToChoose->setFocus();
     620        sltUpdateWidgetAvailability();
    566621        m_fValid = true;
    567622    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r98103 r98524  
    8585private slots:
    8686
     87    /** Updates widgets availability. */
     88    void sltUpdateWidgetAvailability();
     89
    8790    /** Accepts the dialog. */
    8891    void accept();
     
    109112    /** Defines whether 'PowerOff' button is visible. */
    110113    void setButtonVisiblePowerOff(bool fVisible);
     114
     115    /** Defines whether 'Discard' check-box is visible. */
     116    void setCheckBoxVisibleDiscard(bool fVisible);
    111117
    112118    /** Prepares all. */
     
    177183    QRadioButton *m_pRadioButtonPowerOff;
    178184
     185    /** Holds the 'Discard' check-box instance.  */
     186    QCheckBox *m_pCheckBoxDiscard;
     187    /** Holds the 'Discard' check-box text. */
     188    QString    m_strDiscardCheckBoxText;
     189
    179190    /** Holds the last close action. */
    180191    MachineCloseAction  m_enmLastCloseAction;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette