VirtualBox

Changeset 51021 in vbox


Ignore:
Timestamp:
Apr 9, 2014 4:48:49 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: New GUI/GuruMeditationHandler per-VM extra-data flag allowing to predefine Guru Meditation handling behavior.

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

Legend:

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

    r50041 r51021  
    7777template<> bool canConvert<IndicatorType>();
    7878template<> bool canConvert<MachineCloseAction>();
     79template<> bool canConvert<GuruMeditationHandlerType>();
    7980
    8081/* Declare COM canConvert specializations: */
     
    140141template<> QString toInternalString(const MachineCloseAction &machineCloseAction);
    141142template<> MachineCloseAction fromInternalString<MachineCloseAction>(const QString &strMachineCloseAction);
     143template<> QString toInternalString(const GuruMeditationHandlerType &guruMeditationHandlerType);
     144template<> GuruMeditationHandlerType fromInternalString<GuruMeditationHandlerType>(const QString &strGuruMeditationHandlerType);
    142145
    143146/* Declare COM conversion specializations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r50849 r51021  
    5050template<> bool canConvert<IndicatorType>() { return true; }
    5151template<> bool canConvert<MachineCloseAction>() { return true; }
     52template<> bool canConvert<GuruMeditationHandlerType>() { return true; }
    5253
    5354/* QString <= SizeSuffix: */
     
    10451046}
    10461047
     1048/* QString <= GuruMeditationHandlerType: */
     1049template<> QString toInternalString(const GuruMeditationHandlerType &guruMeditationHandlerType)
     1050{
     1051    QString strResult;
     1052    switch (guruMeditationHandlerType)
     1053    {
     1054        case GuruMeditationHandlerType_Default:  strResult = "Default"; break;
     1055        case GuruMeditationHandlerType_PowerOff: strResult = "PowerOff"; break;
     1056        case GuruMeditationHandlerType_Ignore:   strResult = "Ignore"; break;
     1057        default:
     1058        {
     1059            AssertMsgFailed(("No text for indicator type=%d", guruMeditationHandlerType));
     1060            break;
     1061        }
     1062    }
     1063    return strResult;
     1064}
     1065
     1066/* GuruMeditationHandlerType <= QString: */
     1067template<> GuruMeditationHandlerType fromInternalString<GuruMeditationHandlerType>(const QString &strGuruMeditationHandlerType)
     1068{
     1069    /* Here we have some fancy stuff allowing us
     1070     * to search through the keys using 'case-insensitive' rule: */
     1071    QStringList keys;   QList<GuruMeditationHandlerType> values;
     1072    keys << "Default";  values << GuruMeditationHandlerType_Default;
     1073    keys << "PowerOff"; values << GuruMeditationHandlerType_PowerOff;
     1074    keys << "Ignore";   values << GuruMeditationHandlerType_Ignore;
     1075    /* Default type for unknown words: */
     1076    if (!keys.contains(strGuruMeditationHandlerType, Qt::CaseInsensitive))
     1077        return GuruMeditationHandlerType_Default;
     1078    /* Corresponding type for known words: */
     1079    return values.at(keys.indexOf(QRegExp(strGuruMeditationHandlerType, Qt::CaseInsensitive)));
     1080}
     1081
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r51004 r51021  
    8383const char* UIDefs::GUI_RestrictedStatusBarIndicators = "GUI/RestrictedStatusBarIndicators";
    8484const char* UIDefs::GUI_HidLedsSync = "GUI/HidLedsSync";
     85const char* UIDefs::GUI_GuruMeditationHandler = "GUI/GuruMeditationHandler";
    8586
    8687/* Settings dialogs stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r51004 r51021  
    152152    extern const char* GUI_RestrictedStatusBarIndicators;
    153153    extern const char* GUI_HidLedsSync;
     154    extern const char* GUI_GuruMeditationHandler;
    154155
    155156    /* Settings dialogs stuff: */
     
    473474Q_DECLARE_METATYPE(MachineCloseAction);
    474475
     476/** Guru Meditation handler types. */
     477enum GuruMeditationHandlerType
     478{
     479    GuruMeditationHandlerType_Default,
     480    GuruMeditationHandlerType_PowerOff,
     481    GuruMeditationHandlerType_Ignore
     482};
     483
    475484#endif /* !___UIDefs_h___ */
    476485
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r51004 r51021  
    40934093#endif /* !Q_WS_MAC */
    40944094
     4095/* static */
     4096GuruMeditationHandlerType VBoxGlobal::guruMeditationHandlerType(CMachine &machine)
     4097{
     4098    /* Return result: */
     4099    return gpConverter->fromInternalString<GuruMeditationHandlerType>(machine.GetExtraData(GUI_GuruMeditationHandler));
     4100}
     4101
    40954102#ifdef RT_OS_LINUX
    40964103/* static */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r51004 r51021  
    401401    static QStringList machineWindowIconNames(CMachine &machine);
    402402#endif /* !Q_WS_MAC */
     403    /** Loads redefined guru-meditation handler type. */
     404    static GuruMeditationHandlerType guruMeditationHandlerType(CMachine &machine);
    403405
    404406#ifdef RT_OS_LINUX
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r50943 r51021  
    414414            /* Take the screenshot for debugging purposes: */
    415415            takeScreenshot(strLogFolder + "/VBox.png", "png");
    416             /* Warn the user about GURU meditation: */
    417             if (msgCenter().remindAboutGuruMeditation(QDir::toNativeSeparators(strLogFolder)))
    418                 powerOff(false /* do NOT restore current snapshot */);
     416            /* How should we handle Guru Meditation? */
     417            switch (uisession()->guruMeditationHandlerType())
     418            {
     419                /* Ask how to proceed; Power off VM if proposal accepted: */
     420                case GuruMeditationHandlerType_Default:
     421                {
     422                    if (msgCenter().remindAboutGuruMeditation(QDir::toNativeSeparators(strLogFolder)))
     423                        powerOff(false /* do NOT restore current snapshot */);
     424                    break;
     425                }
     426                /* Power off VM silently: */
     427                case GuruMeditationHandlerType_PowerOff:
     428                {
     429                    powerOff(false /* do NOT restore current snapshot */);
     430                    break;
     431                }
     432                /* Just ignore it: */
     433                case GuruMeditationHandlerType_Ignore:
     434                default:
     435                    break;
     436            }
    419437            break;
    420438        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r51004 r51021  
    133133    , m_pMachineWindowIcon(0)
    134134#endif /* !Q_WS_MAC */
     135    , m_guruMeditationHandlerType(GuruMeditationHandlerType_Default)
    135136    , m_fIsExtensionPackUsable(false)
    136137    , m_requestedVisualStateType(UIVisualStateType_Invalid)
     
    11301131#endif /* !Q_WS_MAC */
    11311132
     1133        /* Determine Guru Meditation handler type: */
     1134        m_guruMeditationHandlerType = VBoxGlobal::guruMeditationHandlerType(machine);
     1135
    11321136        /* Is there should be First RUN Wizard? */
    11331137        strSettings = machine.GetExtraData(GUI_FirstRun);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r51004 r51021  
    105105#endif /* !Q_WS_MAC */
    106106
     107    /** @name Runtime workflow stuff.
     108     ** @{ */
     109    /** Returns Guru Meditation handler type. */
     110    GuruMeditationHandlerType guruMeditationHandlerType() const { return m_guruMeditationHandlerType; }
     111    /** @} */
     112
    107113    /** @name Extension Pack stuff.
    108114     ** @{ */
     
    349355#endif /* !Q_WS_MAC */
    350356
     357    /** @name Runtime workflow variables.
     358     ** @{ */
     359    /** Holds Guru Meditation handler type. */
     360    GuruMeditationHandlerType m_guruMeditationHandlerType;
     361    /** @} */
     362
    351363    /** @name Extension Pack variables.
    352364     ** @{ */
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