VirtualBox

Changeset 90083 in vbox for trunk/src


Ignore:
Timestamp:
Jul 8, 2021 7:38:43 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145582
Message:

FE/Qt: bugref:5117: Removing Restore current snapshot check-box from Close VM dialog; It's too dangerous for unprepared user; Old behavior still can be invoked by declaring GUI/DiscardStateOnPowerOff extra-data flag on per-machine basis or globally.

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  
    22092209    switch (machineCloseAction)
    22102210    {
    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;
    22162215        default:
    22172216        {
     
    22282227    /* Here we have some fancy stuff allowing us
    22292228     * 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;
    22362234    /* Invalid type for unknown words: */
    22372235    if (!keys.contains(strMachineCloseAction, Qt::CaseInsensitive))
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r89688 r90083  
    225225const char *UIExtraDataDefs::GUI_LastCloseAction = "GUI/LastCloseAction";
    226226const char *UIExtraDataDefs::GUI_CloseActionHook = "GUI/CloseActionHook";
     227const char *UIExtraDataDefs::GUI_DiscardStateOnPowerOff = "GUI/DiscardStateOnPowerOff";
    227228
    228229#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r89688 r90083  
    414414        /** Holds machine close hook script name as simple string. */
    415415        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;
    416418    /** @} */
    417419
     
    10061008enum MachineCloseAction
    10071009{
    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
    10151016};
    10161017Q_DECLARE_METATYPE(MachineCloseAction);
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r89950 r90083  
    19771977           << GUI_GuestControl_ProcessControlDialogGeometry
    19781978           << GUI_DefaultCloseAction << GUI_RestrictedCloseActions
    1979            << GUI_LastCloseAction << GUI_CloseActionHook
     1979           << GUI_LastCloseAction << GUI_CloseActionHook << GUI_DiscardStateOnPowerOff
    19801980#ifdef VBOX_WITH_DEBUGGER_GUI
    19811981           << GUI_Dbg_Enabled << GUI_Dbg_AutoShow
     
    44424442{
    44434443    return extraDataString(GUI_CloseActionHook, uID);
     4444}
     4445
     4446bool UIExtraDataManager::discardStateOnPowerOff(const QUuid &uID)
     4447{
     4448    /* 'False' unless feature allowed: */
     4449    return isFeatureAllowed(GUI_DiscardStateOnPowerOff, uID);
    44444450}
    44454451
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r89740 r90083  
    749749        /** Returns machine close hook script name as simple string. */
    750750        QString machineCloseHookScript(const QUuid &uID);
     751
     752        /** Returns whether machine should discard state on power off. */
     753        bool discardStateOnPowerOff(const QUuid &uID);
    751754    /** @} */
    752755
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp

    r87251 r90083  
    34573457                                      && (restrictedCloseActions & MachineCloseAction_Shutdown)
    34583458                                      && (restrictedCloseActions & MachineCloseAction_PowerOff);
    3459                                       // Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..
    3460                                       // && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    34613459    if (fAllCloseActionsRestricted)
    34623460    {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r90024 r90083  
    514514    /* Power VM off: */
    515515    LogRel(("GUI: Request to power VM off due to VBoxSVC is unavailable.\n"));
    516     powerOff(false);
     516    powerOff(false /* do NOT restore current snapshot */);
    517517}
    518518
     
    19351935    }
    19361936
     1937    LogRel(("GUI: User requested to detach GUI.\n"));
    19371938    detach();
    19381939}
     
    19471948    }
    19481949
     1950    LogRel(("GUI: User requested to save VM state.\n"));
    19491951    saveState();
    19501952}
     
    19591961    }
    19601962
     1963    LogRel(("GUI: User requested to shutdown VM.\n"));
    19611964    shutdown();
    19621965}
     
    19711974    }
    19721975
    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);
    19761979}
    19771980
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r88244 r90083  
    440440        case MachineCloseAction_Detach:
    441441        {
    442             /* Just close Runtime UI: */
     442            /* Detach GUI: */
    443443            LogRel(("GUI: Request for close-action to detach GUI.\n"));
    444444            machineLogic()->detach();
     
    460460        }
    461461        case MachineCloseAction_PowerOff:
    462         case MachineCloseAction_PowerOff_RestoringSnapshot:
    463462        {
    464463            /* Power VM off: */
    465464            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);
    467467            break;
    468468        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r89867 r90083  
    13651365                                     && (m_restrictedCloseActions & MachineCloseAction_Shutdown)
    13661366                                     && (m_restrictedCloseActions & MachineCloseAction_PowerOff);
    1367                                      // Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..
    1368                                      // && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    13691367    }
    13701368}
     
    20202018            bool fServerCrashed = false;
    20212019            LogRel(("GUI: Aborting startup due to postprocess initialization issue detected...\n"));
    2022             powerOff(false, fServerCrashed);
     2020            powerOff(false /* do NOT restore current snapshot */, fServerCrashed);
    20232021            return false;
    20242022        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r87001 r90083  
    5959    , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0)
    6060    , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0)
    61     , m_pCheckBoxDiscard(0)
    6261    , m_enmLastCloseAction(MachineCloseAction_Invalid)
    6362{
     
    173172                                            "Selecting this action is recommended only if the virtual machine does not respond "
    174173                                            "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());
    188174}
    189175
     
    198184        setResult(MachineCloseAction_Shutdown);
    199185    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);
    206187
    207188    /* Memorize the last user's choice for the given VM: */
     
    265246}
    266247
    267 void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible)
    268 {
    269     m_pCheckBoxDiscard->setVisible(fVisible);
    270 }
    271 
    272248void UIVMCloseDialog::prepare()
    273249{
     
    421397            /* Configure button: */
    422398            m_pRadioButtonDetach->installEventFilter(this);
    423             connect(m_pRadioButtonDetach, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
    424399            /* Add into layout: */
    425400            m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1);
     
    441416            /* Configure button: */
    442417            m_pRadioButtonSave->installEventFilter(this);
    443             connect(m_pRadioButtonSave, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
    444418            /* Add into layout: */
    445419            m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1);
     
    461435            /* Configure button: */
    462436            m_pRadioButtonShutdown->installEventFilter(this);
    463             connect(m_pRadioButtonShutdown, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
    464437            /* Add into layout: */
    465438            m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1);
     
    481454            /* Configure button: */
    482455            m_pRadioButtonPowerOff->installEventFilter(this);
    483             connect(m_pRadioButtonPowerOff, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
    484456            /* Add into layout: */
    485457            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);
    494458        }
    495459
     
    532496    bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown);
    533497    bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff);
    534     bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    535498
    536499    /* Make 'Detach' button visible/hidden depending on restriction: */
     
    551514    /* Make 'Power off' button visible/hidden depending on restriction: */
    552515    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();
    558516
    559517    /* Check which radio-button should be initially chosen: */
     
    576534    {
    577535        pRadioButtonToChoose = m_pRadioButtonPowerOff;
    578     }
    579     else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
    580     {
    581         pRadioButtonToChoose = m_pRadioButtonPowerOff;
    582         m_pCheckBoxDiscard->setChecked(true);
    583536    }
    584537    /* Else 'default choice' will be used: */
     
    601554        pRadioButtonToChoose->setChecked(true);
    602555        pRadioButtonToChoose->setFocus();
    603         sltUpdateWidgetAvailability();
    604556        m_fValid = true;
    605557    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r82968 r90083  
    7575private slots:
    7676
    77     /** Updates widgets availability. */
    78     void sltUpdateWidgetAvailability();
    79 
    8077    /** Accepts the dialog. */
    8178    void accept();
     
    10299    /** Defines whether 'PowerOff' button is visible. */
    103100    void setButtonVisiblePowerOff(bool fVisible);
    104 
    105     /** Defines whether 'Discard' check-box is visible. */
    106     void setCheckBoxVisibleDiscard(bool fVisible);
    107101
    108102    /** Prepares all. */
     
    173167    QRadioButton *m_pRadioButtonPowerOff;
    174168
    175     /** Holds the 'Discard' check-box instance.  */
    176     QCheckBox *m_pCheckBoxDiscard;
    177     /** Holds the 'Discard' check-box text. */
    178     QString    m_strDiscardCheckBoxText;
    179 
    180169    /** Holds the last close action. */
    181170    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