VirtualBox

Changeset 46703 in vbox for trunk/src


Ignore:
Timestamp:
Jun 20, 2013 11:54:22 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86617
Message:

FE/Qt: UI converter: Support string conversions for the machine-close-action enum.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r46684 r46703  
    5858template<> bool canConvert<DetailsElementType>();
    5959template<> bool canConvert<IndicatorType>();
     60template<> bool canConvert<MachineCloseAction>();
    6061
    6162/* Declare COM canConvert specializations: */
     
    9091template<> QString toInternalString(const IndicatorType &indicatorType);
    9192template<> IndicatorType fromInternalString<IndicatorType>(const QString &strIndicatorType);
     93template<> QString toInternalString(const MachineCloseAction &machineCloseAction);
     94template<> MachineCloseAction fromInternalString<MachineCloseAction>(const QString &strMachineCloseAction);
    9295
    9396/* Declare COM conversion specializations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r46699 r46703  
    3434template<> bool canConvert<DetailsElementType>() { return true; }
    3535template<> bool canConvert<IndicatorType>() { return true; }
     36template<> bool canConvert<MachineCloseAction>() { return true; }
    3637
    3738/* QString <= StorageSlot: */
     
    417418}
    418419
     420/* QString <= MachineCloseAction: */
     421template<> QString toInternalString(const MachineCloseAction &machineCloseAction)
     422{
     423    QString strResult;
     424    switch (machineCloseAction)
     425    {
     426        case MachineCloseAction_Save:                       strResult = "Save"; break;
     427        case MachineCloseAction_Shutdown:                   strResult = "Shutdown"; break;
     428        case MachineCloseAction_PowerOff:                   strResult = "PowerOff"; break;
     429        case MachineCloseAction_PowerOff_RestoringSnapshot: strResult = "PowerOffRestoringSnapshot"; break;
     430        default:
     431        {
     432            AssertMsgFailed(("No text for indicator type=%d", machineCloseAction));
     433            break;
     434        }
     435    }
     436    return strResult;
     437}
     438
     439/* MachineCloseAction <= QString: */
     440template<> MachineCloseAction fromInternalString<MachineCloseAction>(const QString &strMachineCloseAction)
     441{
     442    QHash<QString, MachineCloseAction> list;
     443    list.insert("Save",                      MachineCloseAction_Save);
     444    list.insert("Shutdown",                  MachineCloseAction_Shutdown);
     445    list.insert("PowerOff",                  MachineCloseAction_PowerOff);
     446    list.insert("PowerOffRestoringSnapshot", MachineCloseAction_PowerOff_RestoringSnapshot);
     447    if (!list.contains(strMachineCloseAction))
     448        return MachineCloseAction_Invalid;
     449    return list.value(strMachineCloseAction);
     450}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46698 r46703  
    261261enum MachineCloseAction
    262262{
    263     MachineCloseAction_Cancel,
     263    MachineCloseAction_Invalid,
    264264    MachineCloseAction_Save,
    265265    MachineCloseAction_Shutdown,
    266266    MachineCloseAction_PowerOff,
    267     MachineCloseAction_PowerOff_Restoring_Snapshot,
     267    MachineCloseAction_PowerOff_RestoringSnapshot,
    268268    MachineCloseAction_Max
    269269};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r46698 r46703  
    261261
    262262    /* Choose the close action: */
    263     MachineCloseAction closeAction = MachineCloseAction_Cancel;
     263    MachineCloseAction closeAction = MachineCloseAction_Invalid;
    264264
    265265    /* If there IS default close-action defined: */
     
    273273        if (uisession()->isStuck() &&
    274274            closeAction != MachineCloseAction_PowerOff)
    275             closeAction = MachineCloseAction_Cancel;
     275            closeAction = MachineCloseAction_Invalid;
    276276        /* If the default-action is 'power-off',
    277277         * we should check if its possible to discard machine-state: */
    278278        if (closeAction == MachineCloseAction_PowerOff &&
    279279            machine().GetSnapshotCount() > 0)
    280             closeAction = MachineCloseAction_PowerOff_Restoring_Snapshot;
     280            closeAction = MachineCloseAction_PowerOff_RestoringSnapshot;
    281281    }
    282282
    283283    /* If the close-action still undefined: */
    284     if (closeAction == MachineCloseAction_Cancel)
     284    if (closeAction == MachineCloseAction_Invalid)
    285285    {
    286286        /* Prepare close-dialog: */
     
    306306                 * we should resume it if user canceled dialog or chosen shutdown: */
    307307                if (!fWasPaused && uisession()->isPaused() &&
    308                     (closeAction == MachineCloseAction_Cancel ||
     308                    (closeAction == MachineCloseAction_Invalid ||
    309309                     closeAction == MachineCloseAction_Shutdown))
    310310                {
    311311                    /* If we unable to resume VM, cancel closing: */
    312312                    if (!uisession()->unpause())
    313                         closeAction = MachineCloseAction_Cancel;
     313                        closeAction = MachineCloseAction_Invalid;
    314314                }
    315315            }
     
    341341        }
    342342        case MachineCloseAction_PowerOff:
    343         case MachineCloseAction_PowerOff_Restoring_Snapshot:
     343        case MachineCloseAction_PowerOff_RestoringSnapshot:
    344344        {
    345345            /* Power VM off: */
    346             machineLogic()->powerOff(closeAction == MachineCloseAction_PowerOff_Restoring_Snapshot);
     346            machineLogic()->powerOff(closeAction == MachineCloseAction_PowerOff_RestoringSnapshot);
    347347            break;
    348348        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r46698 r46703  
    6767MachineCloseAction UIVMCloseDialog::parseResultCode(const QString &strCloseAction)
    6868{
    69     MachineCloseAction closeAction = MachineCloseAction_Cancel;
     69    MachineCloseAction closeAction = MachineCloseAction_Invalid;
    7070    if (!strCloseAction.compare("Save", Qt::CaseInsensitive))
    7171        closeAction = MachineCloseAction_Save;
     
    9595            setResult(MachineCloseAction_PowerOff);
    9696        else
    97             setResult(MachineCloseAction_PowerOff_Restoring_Snapshot);
     97            setResult(MachineCloseAction_PowerOff_RestoringSnapshot);
    9898    }
    9999
     
    122122            break;
    123123        }
    124         case MachineCloseAction_PowerOff_Restoring_Snapshot:
     124        case MachineCloseAction_PowerOff_RestoringSnapshot:
    125125        {
    126126            strLastAction = m_strExtraDataOptionPowerOff + "," +
Note: See TracChangeset for help on using the changeset viewer.

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