VirtualBox

Changeset 49468 in vbox


Ignore:
Timestamp:
Nov 13, 2013 2:04:55 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Close actions handling rework (step 4): Make sure DefaultCloseAction takes into account RestrictedCloseActions; Also some change in Close VM dialog initialization.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r49467 r49468  
    268268    MachineCloseAction closeAction = MachineCloseAction_Invalid;
    269269
    270     /* If there IS default close-action defined: */
    271     QString strDefaultAction = m.GetExtraData(GUI_DefaultCloseAction);
    272     if (!strDefaultAction.isEmpty())
    273     {
    274         /* Parse the close-action which was defined: */
    275         closeAction = gpConverter->fromInternalString<MachineCloseAction>(strDefaultAction);
    276         /* If VM is stuck, and the default close-action is not 'power-off',
    277          * we should ask the user about what to do: */
    278         if (uisession()->isStuck() &&
    279             closeAction != MachineCloseAction_PowerOff)
    280             closeAction = MachineCloseAction_Invalid;
    281         /* If the default-action is 'power-off',
    282          * we should check if its possible to discard machine-state: */
    283         if (closeAction == MachineCloseAction_PowerOff &&
    284             m.GetSnapshotCount() > 0)
    285             closeAction = MachineCloseAction_PowerOff_RestoringSnapshot;
     270    /* If default close-action defined and not restricted: */
     271    MachineCloseAction defaultCloseAction = uisession()->defaultCloseAction();
     272    MachineCloseAction restrictedCloseActions = uisession()->restrictedCloseActions();
     273    if ((defaultCloseAction != MachineCloseAction_Invalid) &&
     274        !(restrictedCloseActions & defaultCloseAction))
     275    {
     276        switch (defaultCloseAction)
     277        {
     278            /* If VM is stuck, and the default close-action is 'save-state' or 'shutdown',
     279             * we should ask the user about what to do: */
     280            case MachineCloseAction_SaveState:
     281            case MachineCloseAction_Shutdown:
     282                closeAction = uisession()->isStuck() ? MachineCloseAction_Invalid : defaultCloseAction;
     283                break;
     284            /* Otherwise we just use what we have: */
     285            default:
     286                closeAction = defaultCloseAction;
     287                break;
     288        }
    286289    }
    287290
     
    292295        QWidget *pParentDlg = windowManager().realParentWindow(this);
    293296        QPointer<UIVMCloseDialog> pCloseDlg = new UIVMCloseDialog(pParentDlg, m,
    294                                                                   session().GetConsole().GetGuestEnteredACPIMode());
     297                                                                  session().GetConsole().GetGuestEnteredACPIMode(),
     298                                                                  restrictedCloseActions);
    295299
    296300        /* Make sure close-dialog is valid: */
     
    323327        else
    324328        {
    325             /* Else user misconfigured .vbox file, 'power-off' will be the action: */
    326             closeAction = MachineCloseAction_PowerOff;
     329            /* Else user misconfigured .vbox file, we will reject closing UI: */
     330            closeAction = MachineCloseAction_Invalid;
    327331        }
    328332
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r49467 r49468  
    4646#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4747
    48 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine, bool fIsACPIEnabled)
     48UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine,
     49                                 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions)
    4950    : QIWithRetranslateUI<QIDialog>(pParent)
    5051    , m_machine(machine)
     52    , m_restictedCloseActions(restictedCloseActions)
    5153    , m_fIsACPIEnabled(fIsACPIEnabled)
    5254    , m_fValid(false)
     
    284286
    285287    /* Check which close-actions are resticted: */
    286     MachineCloseAction restictedCloseActions = vboxGlobal().restrictedMachineCloseActions(m_machine);
    287     bool fIsStateSavingAllowed = !(restictedCloseActions & MachineCloseAction_SaveState);
    288     bool fIsACPIShutdownAllowed = !(restictedCloseActions & MachineCloseAction_Shutdown);
    289     bool fIsPowerOffAllowed = !(restictedCloseActions & MachineCloseAction_PowerOff);
    290     bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
     288    bool fIsStateSavingAllowed = !(m_restictedCloseActions & MachineCloseAction_SaveState);
     289    bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown);
     290    bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff);
     291    bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    291292
    292293    /* Make 'Save state' button visible/hidden depending on restriction: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r49467 r49468  
    2626
    2727/* Forward declarations: */
     28enum MachineCloseAction;
    2829class CMachine;
    2930class QLabel;
     
    3940
    4041    /* Constructor: */
    41     UIVMCloseDialog(QWidget *pParent, CMachine &machine, bool fIsACPIEnabled);
     42    UIVMCloseDialog(QWidget *pParent, CMachine &machine,
     43                    bool fIsACPIEnabled, MachineCloseAction restictedCloseActions);
    4244
    4345    /* API: Validation stuff: */
     
    9597    /* Variables: */
    9698    CMachine &m_machine;
     99    const MachineCloseAction m_restictedCloseActions;
    97100    bool m_fIsACPIEnabled;
    98101    bool m_fValid;
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