VirtualBox

Changeset 46698 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 20, 2013 10:18:39 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Moving machine-close type enum to global UI defs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46686 r46698  
    258258Q_DECLARE_METATYPE(IndicatorType);
    259259
     260/* Machine close action: */
     261enum MachineCloseAction
     262{
     263    MachineCloseAction_Cancel,
     264    MachineCloseAction_Save,
     265    MachineCloseAction_Shutdown,
     266    MachineCloseAction_PowerOff,
     267    MachineCloseAction_PowerOff_Restoring_Snapshot,
     268    MachineCloseAction_Max
     269};
     270Q_DECLARE_METATYPE(MachineCloseAction);
     271
    260272#endif // __UIDefs_h__
    261273
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r46244 r46698  
    261261
    262262    /* Choose the close action: */
    263     UIVMCloseDialog::ResultCode closeAction = UIVMCloseDialog::ResultCode_Cancel;
     263    MachineCloseAction closeAction = MachineCloseAction_Cancel;
    264264
    265265    /* If there IS default close-action defined: */
     
    272272         * we should ask the user about what to do: */
    273273        if (uisession()->isStuck() &&
    274             closeAction != UIVMCloseDialog::ResultCode_PowerOff)
    275             closeAction = UIVMCloseDialog::ResultCode_Cancel;
     274            closeAction != MachineCloseAction_PowerOff)
     275            closeAction = MachineCloseAction_Cancel;
    276276        /* If the default-action is 'power-off',
    277277         * we should check if its possible to discard machine-state: */
    278         if (closeAction == UIVMCloseDialog::ResultCode_PowerOff &&
     278        if (closeAction == MachineCloseAction_PowerOff &&
    279279            machine().GetSnapshotCount() > 0)
    280             closeAction = UIVMCloseDialog::ResultCode_PowerOff_With_Discarding;
     280            closeAction = MachineCloseAction_PowerOff_Restoring_Snapshot;
    281281    }
    282282
    283283    /* If the close-action still undefined: */
    284     if (closeAction == UIVMCloseDialog::ResultCode_Cancel)
     284    if (closeAction == MachineCloseAction_Cancel)
    285285    {
    286286        /* Prepare close-dialog: */
     
    297297                /* Show close-dialog to let the user make the choice: */
    298298                windowManager().registerNewParent(pCloseDlg, pParentDlg);
    299                 closeAction = (UIVMCloseDialog::ResultCode)pCloseDlg->exec();
     299                closeAction = static_cast<MachineCloseAction>(pCloseDlg->exec());
    300300
    301301                /* Make sure the dialog still valid: */
     
    306306                 * we should resume it if user canceled dialog or chosen shutdown: */
    307307                if (!fWasPaused && uisession()->isPaused() &&
    308                     (closeAction == UIVMCloseDialog::ResultCode_Cancel ||
    309                      closeAction == UIVMCloseDialog::ResultCode_Shutdown))
     308                    (closeAction == MachineCloseAction_Cancel ||
     309                     closeAction == MachineCloseAction_Shutdown))
    310310                {
    311311                    /* If we unable to resume VM, cancel closing: */
    312312                    if (!uisession()->unpause())
    313                         closeAction = UIVMCloseDialog::ResultCode_Cancel;
     313                        closeAction = MachineCloseAction_Cancel;
    314314                }
    315315            }
     
    318318        {
    319319            /* Else user misconfigured .vbox file, 'power-off' will be the action: */
    320             closeAction = UIVMCloseDialog::ResultCode_PowerOff;
     320            closeAction = MachineCloseAction_PowerOff;
    321321        }
    322322
     
    328328    switch (closeAction)
    329329    {
    330         case UIVMCloseDialog::ResultCode_Save:
     330        case MachineCloseAction_Save:
    331331        {
    332332            /* Save VM state: */
     
    334334            break;
    335335        }
    336         case UIVMCloseDialog::ResultCode_Shutdown:
     336        case MachineCloseAction_Shutdown:
    337337        {
    338338            /* Shutdown VM: */
     
    340340            break;
    341341        }
    342         case UIVMCloseDialog::ResultCode_PowerOff:
    343         case UIVMCloseDialog::ResultCode_PowerOff_With_Discarding:
     342        case MachineCloseAction_PowerOff:
     343        case MachineCloseAction_PowerOff_Restoring_Snapshot:
    344344        {
    345345            /* Power VM off: */
    346             machineLogic()->powerOff(closeAction == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding);
     346            machineLogic()->powerOff(closeAction == MachineCloseAction_PowerOff_Restoring_Snapshot);
    347347            break;
    348348        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r45736 r46698  
    6565
    6666/* static */
    67 UIVMCloseDialog::ResultCode UIVMCloseDialog::parseResultCode(const QString &strCloseAction)
    68 {
    69     ResultCode resultCode = ResultCode_Cancel;
     67MachineCloseAction UIVMCloseDialog::parseResultCode(const QString &strCloseAction)
     68{
     69    MachineCloseAction closeAction = MachineCloseAction_Cancel;
    7070    if (!strCloseAction.compare("Save", Qt::CaseInsensitive))
    71         resultCode = ResultCode_Save;
     71        closeAction = MachineCloseAction_Save;
    7272    else if (!strCloseAction.compare("Shutdown", Qt::CaseInsensitive))
    73         resultCode = ResultCode_Shutdown;
     73        closeAction = MachineCloseAction_Shutdown;
    7474    else if (!strCloseAction.compare("PowerOff", Qt::CaseInsensitive))
    75         resultCode = ResultCode_PowerOff;
    76     return resultCode;
     75        closeAction = MachineCloseAction_PowerOff;
     76    return closeAction;
    7777}
    7878
     
    8787    /* Calculate result: */
    8888    if (m_pSaveRadio->isChecked())
    89         setResult(ResultCode_Save);
     89        setResult(MachineCloseAction_Save);
    9090    else if (m_pShutdownRadio->isChecked())
    91         setResult(ResultCode_Shutdown);
     91        setResult(MachineCloseAction_Shutdown);
    9292    else if (m_pPowerOffRadio->isChecked())
    9393    {
    9494        if (!m_pDiscardCheckBox->isChecked() || !m_pDiscardCheckBox->isVisible())
    95             setResult(ResultCode_PowerOff);
     95            setResult(MachineCloseAction_PowerOff);
    9696        else
    97             setResult(ResultCode_PowerOff_With_Discarding);
     97            setResult(MachineCloseAction_PowerOff_Restoring_Snapshot);
    9898    }
    9999
     
    104104    switch (result())
    105105    {
    106         case ResultCode_Save:
     106        case MachineCloseAction_Save:
    107107        {
    108108            strLastAction = m_strExtraDataOptionSave;
    109109            break;
    110110        }
    111         case ResultCode_Shutdown:
     111        case MachineCloseAction_Shutdown:
    112112        {
    113113            strLastAction = m_strExtraDataOptionShutdown;
    114114            break;
    115115        }
    116         case ResultCode_PowerOff:
     116        case MachineCloseAction_PowerOff:
    117117        {
    118118            if (previousChoice[0] == m_strExtraDataOptionShutdown && !m_fIsACPIEnabled)
     
    122122            break;
    123123        }
    124         case ResultCode_PowerOff_With_Discarding:
     124        case MachineCloseAction_PowerOff_Restoring_Snapshot:
    125125        {
    126126            strLastAction = m_strExtraDataOptionPowerOff + "," +
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r45736 r46698  
    2121
    2222/* GUI includes: */
     23#include "QIWithRetranslateUI.h"
    2324#include "QIDialog.h"
    24 #include "QIWithRetranslateUI.h"
     25#include "UIDefs.h"
    2526
    2627/* COM includes: */
     
    4142public:
    4243
    43     /* Dialog result-code enumerator: */
    44     enum ResultCode
    45     {
    46         ResultCode_Cancel = 0,
    47         ResultCode_Save,
    48         ResultCode_Shutdown,
    49         ResultCode_PowerOff,
    50         ResultCode_PowerOff_With_Discarding
    51     };
    52 
    5344    /* Constructor: */
    5445    UIVMCloseDialog(QWidget *pParent, const CMachine &machine, const CSession &session);
     
    5849
    5950    /* Static API: Parse string containing result-code: */
    60     static ResultCode parseResultCode(const QString &strCloseAction);
     51    static MachineCloseAction parseResultCode(const QString &strCloseAction);
    6152
    6253private slots:
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