VirtualBox

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


Ignore:
Timestamp:
Oct 31, 2019 6:20:11 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: Extra-data Manager stuff: A group of fixes for r134303.

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

Legend:

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

    r81573 r81612  
    8080template<> SHARED_LIBRARY_STUFF bool canConvert<SizeSuffix>();
    8181template<> SHARED_LIBRARY_STUFF bool canConvert<StorageSlot>();
     82template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::DialogType>();
    8283template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::MenuType>();
    8384template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::MenuApplicationActionType>();
     
    104105template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>();
    105106template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>();
    106 template<> SHARED_LIBRARY_STUFF bool canConvert<UIExtraDataMetaDefs::RestrictedDialogs>();
    107107template<> SHARED_LIBRARY_STUFF bool canConvert<UIToolType>();
    108108template<> SHARED_LIBRARY_STUFF bool canConvert<UIVisualStateType>();
     
    161161template<> SHARED_LIBRARY_STUFF QString toString(const StorageSlot &storageSlot);
    162162template<> SHARED_LIBRARY_STUFF StorageSlot fromString<StorageSlot>(const QString &strStorageSlot);
     163template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIExtraDataMetaDefs::DialogType &enmDialogType);
     164template<> SHARED_LIBRARY_STUFF UIExtraDataMetaDefs::DialogType fromInternalString<UIExtraDataMetaDefs::DialogType>(const QString &strDialogType);
    163165template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIExtraDataMetaDefs::MenuType &menuType);
    164166template<> SHARED_LIBRARY_STUFF UIExtraDataMetaDefs::MenuType fromInternalString<UIExtraDataMetaDefs::MenuType>(const QString &strMenuType);
     
    216218template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription &enmDetailsElementOptionTypeDescription);
    217219template<> SHARED_LIBRARY_STUFF UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(const QString &strDetailsElementOptionTypeDescription);
    218 template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIExtraDataMetaDefs::RestrictedDialogs &enmRestrictedDialogs);
    219 template<> SHARED_LIBRARY_STUFF UIExtraDataMetaDefs::RestrictedDialogs fromInternalString<UIExtraDataMetaDefs::RestrictedDialogs>(const QString &strRestrictedDialogs);
    220220template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIToolType &enmToolType);
    221221template<> SHARED_LIBRARY_STUFF UIToolType fromInternalString<UIToolType>(const QString &strToolType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r81563 r81612  
    3434template<> bool canConvert<SizeSuffix>() { return true; }
    3535template<> bool canConvert<StorageSlot>() { return true; }
     36template<> bool canConvert<UIExtraDataMetaDefs::DialogType>() { return true; }
    3637template<> bool canConvert<UIExtraDataMetaDefs::MenuType>() { return true; }
    3738template<> bool canConvert<UIExtraDataMetaDefs::MenuApplicationActionType>() { return true; }
     
    5859template<> bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>() { return true; }
    5960template<> bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>() { return true; }
    60 template<> bool canConvert<UIExtraDataMetaDefs::RestrictedDialogs>() { return true; }
    6161template<> bool canConvert<UIToolType>() { return true; }
    6262template<> bool canConvert<UIVisualStateType>() { return true; }
     
    380380    /* Return result: */
    381381    return result;
     382}
     383
     384/* QString <= UIExtraDataMetaDefs::DialogType: */
     385template<> QString toInternalString(const UIExtraDataMetaDefs::DialogType &enmDialogType)
     386{
     387    QString strResult;
     388    switch (enmDialogType)
     389    {
     390        case UIExtraDataMetaDefs::DialogType_VISOCreator: strResult = "VISOCreator"; break;
     391        case UIExtraDataMetaDefs::DialogType_All:         strResult = "All"; break;
     392        default:
     393        {
     394            AssertMsgFailed(("No text for dialog type=%d", enmDialogType));
     395            break;
     396        }
     397    }
     398    return strResult;
     399}
     400
     401/* UIExtraDataMetaDefs::DialogType <= QString: */
     402template<> UIExtraDataMetaDefs::DialogType fromInternalString<UIExtraDataMetaDefs::DialogType>(const QString &strDialogType)
     403{
     404    /* Here we have some fancy stuff allowing us
     405     * to search through the keys using 'case-insensitive' rule: */
     406    QStringList keys;      QList<UIExtraDataMetaDefs::DialogType> values;
     407    keys << "VISOCreator"; values << UIExtraDataMetaDefs::DialogType_VISOCreator;
     408    keys << "All";         values << UIExtraDataMetaDefs::DialogType_All;
     409    /* Invalid type for unknown words: */
     410    if (!keys.contains(strDialogType, Qt::CaseInsensitive))
     411        return UIExtraDataMetaDefs::DialogType_Invalid;
     412    /* Corresponding type for known words: */
     413    return values.at(keys.indexOf(QRegExp(strDialogType, Qt::CaseInsensitive)));
    382414}
    383415
     
    14551487}
    14561488
    1457 /* QString <= UIExtraDataMetaDefs::RestrictedDialogs: */
    1458 template<> QString toInternalString(const UIExtraDataMetaDefs::RestrictedDialogs &enmRestrictedDialogs)
    1459 {
    1460     QString strResult;
    1461     switch (enmRestrictedDialogs)
    1462     {
    1463         case UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator:     strResult = "VISOCreator"; break;
    1464         case UIExtraDataMetaDefs::RestrictedDialogs_All:   strResult = "All"; break;
    1465         default:
    1466         {
    1467             AssertMsgFailed(("No text for details element option type=%d", enmRestrictedDialogs));
    1468             break;
    1469         }
    1470     }
    1471     return strResult;
    1472 }
    1473 
    1474 /* UIExtraDataMetaDefs::RestrictedDialogs <= QString: */
    1475 template<> UIExtraDataMetaDefs::RestrictedDialogs fromInternalString<UIExtraDataMetaDefs::RestrictedDialogs>(const QString &strRestrictedDialogs)
    1476 {
    1477     /* Here we have some fancy stuff allowing us
    1478      * to search through the keys using 'case-insensitive' rule: */
    1479     QStringList keys;                        QList<UIExtraDataMetaDefs::RestrictedDialogs> values;
    1480     keys << "VISOCreator";                   values << UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator;
    1481     keys << "All";                           values << UIExtraDataMetaDefs::RestrictedDialogs_All;
    1482     /* Invalid type for unknown words: */
    1483     if (!keys.contains(strRestrictedDialogs, Qt::CaseInsensitive))
    1484         return UIExtraDataMetaDefs::RestrictedDialogs_Invalid;
    1485     /* Corresponding type for known words: */
    1486     return values.at(keys.indexOf(QRegExp(strRestrictedDialogs, Qt::CaseInsensitive)));
    1487 }
    1488 
    14891489/* UIExtraDataMetaDefs::DetailsElementOptionTypeDescription <= QString: */
    14901490template<> UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(const QString &strDetailsElementOptionTypeDescription)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r81563 r81612  
    2222/* General: */
    2323const char *UIExtraDataDefs::GUI_EventHandlingType = "GUI/EventHandlingType";
     24const char *UIExtraDataDefs::GUI_RestrictedDialogs = "GUI/RestrictedDialogs";
    2425
    2526
     
    239240const char *UIExtraDataDefs::GUI_GuestControl_LogViewerVisiblePanels = "GUI/LogViewerVisiblePanels";
    240241
    241 /* Restricted dialogs: */
    242 const char *UIExtraDataDefs::GUI_RestrictedDialogs = "GUI/RestrictedDialogs";
    243 
    244242/* Obsolete keys: */
    245243QMap<QString, QString> UIExtraDataDefs::prepareObsoleteKeysMap()
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r81563 r81612  
    4646        /** Holds event handling type. */
    4747        SHARED_LIBRARY_STUFF extern const char *GUI_EventHandlingType;
     48
     49        /** Holds restricted dialogs. */
     50        SHARED_LIBRARY_STUFF extern const char *GUI_RestrictedDialogs;
    4851    /** @} */
    4952
     
    436439    /** @} */
    437440
    438     /** @name Restricted dialogs
    439       * @{ */
    440         SHARED_LIBRARY_STUFF extern const char *GUI_RestrictedDialogs;
    441     /** @} */
    442 
    443441    /** @name Old key support stuff.
    444442      * @{ */
     
    473471
    474472public:
     473
     474    /** Common UI: Dialog types. */
     475    enum DialogType
     476    {
     477        DialogType_Invalid     = 0,
     478        DialogType_VISOCreator = RT_BIT(0),
     479        DialogType_All         = 0xFFFF
     480    };
     481    Q_ENUM(DialogType);
    475482
    476483    /** Common UI: Menu types. */
     
    778785    };
    779786    Q_ENUM(DetailsElementOptionTypeDescription);
    780 
    781     enum RestrictedDialogs
    782     {
    783         RestrictedDialogs_Invalid              = 0,
    784         RestrictedDialogs_VISOCreator          = RT_BIT(0),
    785         RestrictedDialogs_All                  = 0xFFFF
    786     };
    787     Q_ENUM(RestrictedDialogs);
    788787};
    789788
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r81563 r81612  
    19041904           << QString()
    19051905           << GUI_EventHandlingType
     1906           << GUI_RestrictedDialogs
    19061907           << GUI_SuppressMessages << GUI_InvertMessageOption
    19071908#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     
    19901991#endif /* VBOX_WITH_DEBUGGER_GUI */
    19911992           << GUI_ExtraDataManager_Geometry << GUI_ExtraDataManager_SplitterHints
    1992            << GUI_LogWindowGeometry
    1993            << GUI_RestrictedDialogs;
     1993           << GUI_LogWindowGeometry;
    19941994}
    19951995
     
    22772277}
    22782278
     2279UIExtraDataMetaDefs::DialogType UIExtraDataManager::restrictedDialogTypes(const QUuid &uID)
     2280{
     2281    /* Prepare result: */
     2282    UIExtraDataMetaDefs::DialogType result = UIExtraDataMetaDefs::DialogType_Invalid;
     2283    /* Get restricted runtime-menu-types: */
     2284    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedDialogs, uID))
     2285    {
     2286        UIExtraDataMetaDefs::DialogType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::DialogType>(strValue);
     2287        if (value != UIExtraDataMetaDefs::DialogType_Invalid)
     2288            result = static_cast<UIExtraDataMetaDefs::DialogType>(result | value);
     2289    }
     2290    /* Return result: */
     2291    return result;
     2292}
     2293
     2294void UIExtraDataManager::setRestrictedDialogTypes(UIExtraDataMetaDefs::DialogType dialogs, const QUuid &uID)
     2295{
     2296    /* We have MenuType enum registered, so we can enumerate it: */
     2297    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
     2298    const int iEnumIndex = smo.indexOfEnumerator("DialogType");
     2299    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
     2300
     2301    /* Prepare result: */
     2302    QStringList result;
     2303    /* Handle DialogType_All enum-value: */
     2304    if (dialogs == UIExtraDataMetaDefs::DialogType_All)
     2305        result << gpConverter->toInternalString(dialogs);
     2306    else
     2307    {
     2308        /* Handle other enum-values: */
     2309        for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
     2310        {
     2311            /* Get iterated enum-value: */
     2312            const UIExtraDataMetaDefs::DialogType enumValue =
     2313                static_cast<UIExtraDataMetaDefs::DialogType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     2314            /* Skip DialogType_Invalid & DialogType_All enum-values: */
     2315            if (enumValue == UIExtraDataMetaDefs::DialogType_Invalid ||
     2316                enumValue == UIExtraDataMetaDefs::DialogType_All)
     2317                continue;
     2318            if (dialogs & enumValue)
     2319                result << gpConverter->toInternalString(enumValue);
     2320        }
     2321    }
     2322    /* Save result: */
     2323    setExtraDataStringList(GUI_RestrictedDialogs, result, uID);
     2324}
     2325
    22792326QStringList UIExtraDataManager::suppressedMessages(const QUuid &uID /* = GlobalID */)
    22802327{
     
    45184565{
    45194566    return extraDataStringList(GUI_GuestControl_LogViewerVisiblePanels);
    4520 }
    4521 
    4522 UIExtraDataMetaDefs::RestrictedDialogs UIExtraDataManager::restrictedDialogs(const QUuid &uID)
    4523 {
    4524     UIExtraDataMetaDefs::RestrictedDialogs result = UIExtraDataMetaDefs::RestrictedDialogs_Invalid;
    4525     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedDialogs, uID))
    4526     {
    4527         UIExtraDataMetaDefs::RestrictedDialogs value =
    4528             gpConverter->fromInternalString<UIExtraDataMetaDefs::RestrictedDialogs>(strValue);
    4529         if (value != UIExtraDataMetaDefs::RestrictedDialogs_Invalid)
    4530             result = static_cast<UIExtraDataMetaDefs::RestrictedDialogs>(result | value);
    4531     }
    4532     return result;
    4533 }
    4534 
    4535 void UIExtraDataManager::setRestrictedDialogs(UIExtraDataMetaDefs::RestrictedDialogs dialogs, const QUuid &uID)
    4536 {
    4537     const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
    4538     const int iEnumIndex = smo.indexOfEnumerator("RestrictedDialogs");
    4539     QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
    4540 
    4541     QStringList result;
    4542     if (dialogs == UIExtraDataMetaDefs::RestrictedDialogs_All)
    4543         result << gpConverter->toInternalString(dialogs);
    4544     else
    4545     {
    4546         for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
    4547         {
    4548             const UIExtraDataMetaDefs::RestrictedDialogs enumValue =
    4549                 static_cast<UIExtraDataMetaDefs::RestrictedDialogs>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
    4550             if (enumValue == UIExtraDataMetaDefs::RestrictedDialogs_Invalid ||
    4551                 enumValue == UIExtraDataMetaDefs::RestrictedDialogs_All)
    4552                 continue;
    4553             if (dialogs & enumValue)
    4554                 result << gpConverter->toInternalString(enumValue);
    4555         }
    4556     }
    4557     setExtraDataStringList(GUI_RestrictedDialogs, result, uID);
    45584567}
    45594568
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r81563 r81612  
    149149        /** Returns event handling type. */
    150150        EventHandlingType eventHandlingType();
     151
     152        /** Returns a list of restricted dialogs. */
     153        UIExtraDataMetaDefs::DialogType restrictedDialogTypes(const QUuid &uID);
     154        /** Defines a list of restricted dialogs. */
     155        void setRestrictedDialogTypes(UIExtraDataMetaDefs::DialogType enmTypes, const QUuid &uID);
    151156    /** @} */
    152157
     
    750755        void setLogViewerVisiblePanels(const QStringList &panelNameList);
    751756        QStringList logViewerVisiblePanels();
    752     /** @} */
    753 
    754     /** @name Restricted Dialogs
    755       * @{ */
    756         /** Returns a list of restricted dialogs. */
    757         UIExtraDataMetaDefs::RestrictedDialogs restrictedDialogs(const QUuid &uID);
    758         /** Defines restricted Runtime UI menu types. */
    759         void setRestrictedDialogs(UIExtraDataMetaDefs::RestrictedDialogs types, const QUuid &uID);
    760757    /** @} */
    761758
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r81563 r81612  
    225225
    226226    m_pToolBar->addAction(m_pActionAdd);
    227     if (!(gEDataManager->restrictedDialogs(m_uMachineID) & UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator))
     227    if (!(gEDataManager->restrictedDialogTypes(m_uMachineID) & UIExtraDataMetaDefs::DialogType_VISOCreator))
    228228        m_pToolBar->addAction(m_pActionCreate);
    229229    m_pToolBar->addSeparator();
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