VirtualBox

Ignore:
Timestamp:
Apr 30, 2014 2:18:14 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93539
Message:

FE/Qt: 6660: Advanced extra-data management framework: Moving key/value handling logic from UIExtraDataEventHandler to UIExtraDataManager.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extradata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r51174 r51177  
    4242signals:
    4343
    44     /** Notifies about GUI language change. */
    45     void sigLanguageChange(QString strLanguage);
    46 
    47     /** Notifies about Selector UI keyboard shortcut change. */
    48     void sigSelectorUIShortcutChange();
    49     /** Notifies about Runtime UI keyboard shortcut change. */
    50     void sigRuntimeUIShortcutChange();
    51 
    52     /** Notifies about HID LED sync state change. */
    53     void sigHIDLedsSyncStateChange(bool fEnabled);
    54 
    55 #ifdef RT_OS_DARWIN
    56     /** Mac OS X: Notifies about 'presentation mode' status change. */
    57     void sigPresentationModeChange(bool fEnabled);
    58     /** Mac OS X: Notifies about 'dock icon' appearance change. */
    59     void sigDockIconAppearanceChange(bool fEnabled);
    60 #endif /* RT_OS_DARWIN */
     44    /** Notifies about 'extra-data change' event: */
     45    void sigExtraDataChange(QString strMachineID, QString strKey, QString strValue);
    6146
    6247public:
     
    6752public slots:
    6853
    69     /** Handles extra-data 'can change' event: */
    70     void sltExtraDataCanChange(QString strMachineID, QString strKey, QString strValue, bool &fVeto, QString &strVetoReason);
    71     /** Handles extra-data 'change' event: */
    72     void sltExtraDataChange(QString strMachineID, QString strKey, QString strValue);
     54    /** Preprocess 'extra-data can change' event: */
     55    void sltPreprocessExtraDataCanChange(QString strMachineID, QString strKey, QString strValue, bool &fVeto, QString &strVetoReason);
     56    /** Preprocess 'extra-data change' event: */
     57    void sltPreprocessExtraDataChange(QString strMachineID, QString strKey, QString strValue);
    7358
    7459private:
    7560
    76     /** Protects sltExtraDataChange. */
     61    /** Protects sltPreprocessExtraDataChange. */
    7762    QMutex m_mutex;
    7863};
     
    8065UIExtraDataEventHandler::UIExtraDataEventHandler(QObject *pParent)
    8166    : QObject(pParent)
    82 {}
    83 
    84 void UIExtraDataEventHandler::sltExtraDataCanChange(QString strMachineID, QString strKey, QString strValue, bool &fVeto, QString &strVetoReason)
    85 {
    86     /* Global extra-data 'can change' event: */
     67{
     68}
     69
     70void UIExtraDataEventHandler::sltPreprocessExtraDataCanChange(QString strMachineID, QString strKey, QString strValue, bool &fVeto, QString &strVetoReason)
     71{
     72    /* Preprocess global 'extra-data can change' event: */
    8773    if (QUuid(strMachineID).isNull())
    8874    {
    89         /* It's a global extra-data key someone wants to change: */
    9075        if (strKey.startsWith("GUI/"))
    9176        {
     
    10388                    fVeto = true;
    10489                }
    105                 return;
    10690            }
    10791        }
     
    10993}
    11094
    111 void UIExtraDataEventHandler::sltExtraDataChange(QString strMachineID, QString strKey, QString strValue)
     95void UIExtraDataEventHandler::sltPreprocessExtraDataChange(QString strMachineID, QString strKey, QString strValue)
     96{
     97    /* Preprocess global 'extra-data change' event: */
     98    if (QUuid(strMachineID).isNull())
     99    {
     100        if (strKey.startsWith("GUI/"))
     101        {
     102            /* Apply global property: */
     103            m_mutex.lock();
     104            vboxGlobal().settings().setPublicProperty(strKey, strValue);
     105            m_mutex.unlock();
     106            AssertMsgReturnVoid(!!vboxGlobal().settings(), ("Failed to apply global property.\n"));
     107        }
     108    }
     109
     110    /* Motify listener about 'extra-data change' event: */
     111    emit sigExtraDataChange(strMachineID, strKey, strValue);
     112}
     113
     114
     115/* static */
     116UIExtraDataManager *UIExtraDataManager::m_pInstance = 0;
     117
     118/* static */
     119UIExtraDataManager* UIExtraDataManager::instance()
     120{
     121    /* Create/prepare instance if not yet exists: */
     122    if (!m_pInstance)
     123    {
     124        new UIExtraDataManager;
     125        m_pInstance->prepare();
     126    }
     127    /* Return instance: */
     128    return m_pInstance;
     129}
     130
     131/* static */
     132void UIExtraDataManager::destroy()
     133{
     134    /* Destroy/cleanup instance if still exists: */
     135    if (m_pInstance)
     136    {
     137        m_pInstance->cleanup();
     138        delete m_pInstance;
     139    }
     140}
     141
     142UIExtraDataManager::UIExtraDataManager()
     143    : m_pHandler(0)
     144{
     145    /* Connect to static instance: */
     146    m_pInstance = this;
     147}
     148
     149UIExtraDataManager::~UIExtraDataManager()
     150{
     151    /* Disconnect from static instance: */
     152    m_pInstance = 0;
     153}
     154
     155#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     156bool UIExtraDataManager::shouldWeAllowApplicationUpdate() const
     157{
     158    /* Allow unless 'forbidden' flag is set: */
     159    return !isFeatureAllowed(GUI_PreventApplicationUpdate);
     160}
     161#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     162
     163bool UIExtraDataManager::shouldWeShowMachine(const QString &strID) const
     164{
     165    /* Show unless 'forbidden' flag is set: */
     166    return !isFeatureAllowed(GUI_HideFromManager, strID);
     167}
     168
     169bool UIExtraDataManager::shouldWeShowMachineDetails(const QString &strID) const
     170{
     171    /* Show unless 'forbidden' flag is set: */
     172    return !isFeatureAllowed(GUI_HideDetails, strID);
     173}
     174
     175bool UIExtraDataManager::shouldWeAllowMachineReconfiguration(const QString &strID) const
     176{
     177    /* Show unless 'forbidden' flag is set: */
     178    return !isFeatureAllowed(GUI_PreventReconfiguration, strID);
     179}
     180
     181bool UIExtraDataManager::shouldWeAllowMachineSnapshotOperations(const QString &strID) const
     182{
     183    /* Show unless 'forbidden' flag is set: */
     184    return !isFeatureAllowed(GUI_PreventSnapshotOperations, strID);
     185}
     186
     187bool UIExtraDataManager::shouldWeAutoMountGuestScreens(const QString &strID) const
     188{
     189    /* Show only if 'allowed' flag is set: */
     190    return isFeatureAllowed(GUI_AutomountGuestScreens, strID);
     191}
     192
     193RuntimeMenuType UIExtraDataManager::restrictedRuntimeMenuTypes(const QString &strID) const
     194{
     195    /* Prepare result: */
     196    RuntimeMenuType result = RuntimeMenuType_Invalid;
     197    /* Load restricted runtime-menu-types: */
     198    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeMenus, strID))
     199    {
     200        RuntimeMenuType value = gpConverter->fromInternalString<RuntimeMenuType>(strValue);
     201        if (value != RuntimeMenuType_Invalid)
     202            result = static_cast<RuntimeMenuType>(result | value);
     203    }
     204    /* Return result: */
     205    return result;
     206}
     207
     208#ifdef Q_WS_MAC
     209RuntimeMenuApplicationActionType UIExtraDataManager::restrictedRuntimeMenuApplicationActionTypes(const QString &strID) const
     210{
     211    /* Prepare result: */
     212    RuntimeMenuApplicationActionType result = RuntimeMenuApplicationActionType_Invalid;
     213    /* Load restricted runtime-application-menu action-types: */
     214    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeApplicationMenuActions, strID))
     215    {
     216        RuntimeMenuApplicationActionType value = gpConverter->fromInternalString<RuntimeMenuApplicationActionType>(strValue);
     217        if (value != RuntimeMenuApplicationActionType_Invalid)
     218            result = static_cast<RuntimeMenuApplicationActionType>(result | value);
     219    }
     220    /* Return result: */
     221    return result;
     222}
     223#endif /* Q_WS_MAC */
     224
     225RuntimeMenuMachineActionType UIExtraDataManager::restrictedRuntimeMenuMachineActionTypes(const QString &strID) const
     226{
     227    /* Prepare result: */
     228    RuntimeMenuMachineActionType result = RuntimeMenuMachineActionType_Invalid;
     229    /* Load restricted runtime-machine-menu action-types: */
     230    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeMachineMenuActions, strID))
     231    {
     232        RuntimeMenuMachineActionType value = gpConverter->fromInternalString<RuntimeMenuMachineActionType>(strValue);
     233        if (value != RuntimeMenuMachineActionType_Invalid)
     234            result = static_cast<RuntimeMenuMachineActionType>(result | value);
     235    }
     236    /* Return result: */
     237    return result;
     238}
     239
     240RuntimeMenuViewActionType UIExtraDataManager::restrictedRuntimeMenuViewActionTypes(const QString &strID) const
     241{
     242    /* Prepare result: */
     243    RuntimeMenuViewActionType result = RuntimeMenuViewActionType_Invalid;
     244    /* Load restricted runtime-view-menu action-types: */
     245    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeViewMenuActions, strID))
     246    {
     247        RuntimeMenuViewActionType value = gpConverter->fromInternalString<RuntimeMenuViewActionType>(strValue);
     248        if (value != RuntimeMenuViewActionType_Invalid)
     249            result = static_cast<RuntimeMenuViewActionType>(result | value);
     250    }
     251    /* Return result: */
     252    return result;
     253}
     254
     255RuntimeMenuDevicesActionType UIExtraDataManager::restrictedRuntimeMenuDevicesActionTypes(const QString &strID) const
     256{
     257    /* Prepare result: */
     258    RuntimeMenuDevicesActionType result = RuntimeMenuDevicesActionType_Invalid;
     259    /* Load restricted runtime-devices-menu action-types: */
     260    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeDevicesMenuActions, strID))
     261    {
     262        RuntimeMenuDevicesActionType value = gpConverter->fromInternalString<RuntimeMenuDevicesActionType>(strValue);
     263        if (value != RuntimeMenuDevicesActionType_Invalid)
     264            result = static_cast<RuntimeMenuDevicesActionType>(result | value);
     265    }
     266    /* Return result: */
     267    return result;
     268}
     269
     270#ifdef VBOX_WITH_DEBUGGER_GUI
     271RuntimeMenuDebuggerActionType UIExtraDataManager::restrictedRuntimeMenuDebuggerActionTypes(const QString &strID) const
     272{
     273    /* Prepare result: */
     274    RuntimeMenuDebuggerActionType result = RuntimeMenuDebuggerActionType_Invalid;
     275    /* Load restricted runtime-debugger-menu action-types: */
     276    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeDebuggerMenuActions, strID))
     277    {
     278        RuntimeMenuDebuggerActionType value = gpConverter->fromInternalString<RuntimeMenuDebuggerActionType>(strValue);
     279        if (value != RuntimeMenuDebuggerActionType_Invalid)
     280            result = static_cast<RuntimeMenuDebuggerActionType>(result | value);
     281    }
     282    /* Return result: */
     283    return result;
     284}
     285#endif /* VBOX_WITH_DEBUGGER_GUI */
     286
     287RuntimeMenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID) const
     288{
     289    /* Prepare result: */
     290    RuntimeMenuHelpActionType result = RuntimeMenuHelpActionType_Invalid;
     291    /* Load restricted runtime-help-menu action-types: */
     292    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeHelpMenuActions, strID))
     293    {
     294        RuntimeMenuHelpActionType value = gpConverter->fromInternalString<RuntimeMenuHelpActionType>(strValue);
     295        if (value != RuntimeMenuHelpActionType_Invalid)
     296            result = static_cast<RuntimeMenuHelpActionType>(result | value);
     297    }
     298    /* Return result: */
     299    return result;
     300}
     301
     302UIVisualStateType UIExtraDataManager::restrictedVisualStateTypes(const QString &strID) const
     303{
     304    /* Prepare result: */
     305    UIVisualStateType result = UIVisualStateType_Invalid;
     306    /* Load restricted visual-state-types: */
     307    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedVisualStates, strID))
     308    {
     309        UIVisualStateType value = gpConverter->fromInternalString<UIVisualStateType>(strValue);
     310        if (value != UIVisualStateType_Invalid)
     311            result = static_cast<UIVisualStateType>(result | value);
     312    }
     313    /* Return result: */
     314    return result;
     315}
     316
     317MachineCloseAction UIExtraDataManager::defaultMachineCloseAction(const QString &strID) const
     318{
     319    return gpConverter->fromInternalString<MachineCloseAction>(extraDataString(GUI_DefaultCloseAction, strID));
     320}
     321
     322MachineCloseAction UIExtraDataManager::restrictedMachineCloseActions(const QString &strID) const
     323{
     324    /* Prepare result: */
     325    MachineCloseAction result = MachineCloseAction_Invalid;
     326    /* Load restricted machine-close-actions: */
     327    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedCloseActions, strID))
     328    {
     329        MachineCloseAction value = gpConverter->fromInternalString<MachineCloseAction>(strValue);
     330        if (value != MachineCloseAction_Invalid)
     331            result = static_cast<MachineCloseAction>(result | value);
     332    }
     333    /* Return result: */
     334    return result;
     335}
     336
     337QList<IndicatorType> UIExtraDataManager::restrictedStatusBarIndicators(const QString &strID) const
     338{
     339    /* Prepare result: */
     340    QList<IndicatorType> result;
     341    /* Load restricted status-bar-indicators: */
     342    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedStatusBarIndicators, strID))
     343    {
     344        IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
     345        if (value != IndicatorType_Invalid)
     346            result << value;
     347    }
     348    /* Return result: */
     349    return result;
     350}
     351
     352QList<GlobalSettingsPageType> UIExtraDataManager::restrictedGlobalSettingsPages() const
     353{
     354    /* Prepare result: */
     355    QList<GlobalSettingsPageType> result;
     356    /* Load restricted global-settings-pages: */
     357    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedGlobalSettingsPages))
     358    {
     359        GlobalSettingsPageType value = gpConverter->fromInternalString<GlobalSettingsPageType>(strValue);
     360        if (value != GlobalSettingsPageType_Invalid)
     361            result << value;
     362    }
     363    /* Return result: */
     364    return result;
     365}
     366
     367QList<MachineSettingsPageType> UIExtraDataManager::restrictedMachineSettingsPages(const QString &strID) const
     368{
     369    /* Prepare result: */
     370    QList<MachineSettingsPageType> result;
     371    /* Load restricted machine-settings-pages: */
     372    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedMachineSettingsPages, strID))
     373    {
     374        MachineSettingsPageType value = gpConverter->fromInternalString<MachineSettingsPageType>(strValue);
     375        if (value != MachineSettingsPageType_Invalid)
     376            result << value;
     377    }
     378    /* Return result: */
     379    return result;
     380}
     381
     382#ifndef Q_WS_MAC
     383QStringList UIExtraDataManager::machineWindowIconNames(const QString &strID) const
     384{
     385    return extraDataStringList(GUI_MachineWindowIcons, strID);
     386}
     387
     388QString UIExtraDataManager::machineWindowNamePostfix(const QString &strID) const
     389{
     390    return extraDataString(GUI_MachineWindowNamePostfix, strID);
     391}
     392#endif /* !Q_WS_MAC */
     393
     394GuruMeditationHandlerType UIExtraDataManager::guruMeditationHandlerType(const QString &strID) const
     395{
     396    return gpConverter->fromInternalString<GuruMeditationHandlerType>(extraDataString(GUI_GuruMeditationHandler, strID));
     397}
     398
     399HiDPIOptimizationType UIExtraDataManager::hiDPIOptimizationType(const QString &strID) const
     400{
     401    return gpConverter->fromInternalString<HiDPIOptimizationType>(extraDataString(GUI_HiDPIOptimization, strID));
     402}
     403
     404void UIExtraDataManager::sltExtraDataChange(QString strMachineID, QString strKey, QString strValue)
    112405{
    113406    /* Global extra-data 'change' event: */
     
    135428            }
    136429#endif /* Q_WS_MAC */
    137 
    138             /* Apply global property: */
    139             m_mutex.lock();
    140             vboxGlobal().settings().setPublicProperty(strKey, strValue);
    141             m_mutex.unlock();
    142             AssertMsgReturnVoid(!!vboxGlobal().settings(), ("Failed to apply global property.\n"));
    143430        }
    144431    }
     
    169456}
    170457
    171 
    172 /* static */
    173 UIExtraDataManager *UIExtraDataManager::m_pInstance = 0;
    174 
    175 /* static */
    176 UIExtraDataManager* UIExtraDataManager::instance()
    177 {
    178     /* Create/prepare instance if not yet exists: */
    179     if (!m_pInstance)
    180     {
    181         new UIExtraDataManager;
    182         m_pInstance->prepare();
    183     }
    184     /* Return instance: */
    185     return m_pInstance;
    186 }
    187 
    188 /* static */
    189 void UIExtraDataManager::destroy()
    190 {
    191     /* Destroy/cleanup instance if still exists: */
    192     if (m_pInstance)
    193     {
    194         m_pInstance->cleanup();
    195         delete m_pInstance;
    196     }
    197 }
    198 
    199 UIExtraDataManager::UIExtraDataManager()
    200     : m_pHandler(0)
    201 {
    202     /* Connect to static instance: */
    203     m_pInstance = this;
    204 }
    205 
    206 UIExtraDataManager::~UIExtraDataManager()
    207 {
    208     /* Disconnect from static instance: */
    209     m_pInstance = 0;
    210 }
    211 
    212 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    213 bool UIExtraDataManager::shouldWeAllowApplicationUpdate() const
    214 {
    215     /* Allow unless 'forbidden' flag is set: */
    216     return !isFeatureAllowed(GUI_PreventApplicationUpdate);
    217 }
    218 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    219 
    220 bool UIExtraDataManager::shouldWeShowMachine(const QString &strID) const
    221 {
    222     /* Show unless 'forbidden' flag is set: */
    223     return !isFeatureAllowed(GUI_HideFromManager, strID);
    224 }
    225 
    226 bool UIExtraDataManager::shouldWeShowMachineDetails(const QString &strID) const
    227 {
    228     /* Show unless 'forbidden' flag is set: */
    229     return !isFeatureAllowed(GUI_HideDetails, strID);
    230 }
    231 
    232 bool UIExtraDataManager::shouldWeAllowMachineReconfiguration(const QString &strID) const
    233 {
    234     /* Show unless 'forbidden' flag is set: */
    235     return !isFeatureAllowed(GUI_PreventReconfiguration, strID);
    236 }
    237 
    238 bool UIExtraDataManager::shouldWeAllowMachineSnapshotOperations(const QString &strID) const
    239 {
    240     /* Show unless 'forbidden' flag is set: */
    241     return !isFeatureAllowed(GUI_PreventSnapshotOperations, strID);
    242 }
    243 
    244 bool UIExtraDataManager::shouldWeAutoMountGuestScreens(const QString &strID) const
    245 {
    246     /* Show only if 'allowed' flag is set: */
    247     return isFeatureAllowed(GUI_AutomountGuestScreens, strID);
    248 }
    249 
    250 RuntimeMenuType UIExtraDataManager::restrictedRuntimeMenuTypes(const QString &strID) const
    251 {
    252     /* Prepare result: */
    253     RuntimeMenuType result = RuntimeMenuType_Invalid;
    254     /* Load restricted runtime-menu-types: */
    255     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeMenus, strID))
    256     {
    257         RuntimeMenuType value = gpConverter->fromInternalString<RuntimeMenuType>(strValue);
    258         if (value != RuntimeMenuType_Invalid)
    259             result = static_cast<RuntimeMenuType>(result | value);
    260     }
    261     /* Return result: */
    262     return result;
    263 }
    264 
    265 #ifdef Q_WS_MAC
    266 RuntimeMenuApplicationActionType UIExtraDataManager::restrictedRuntimeMenuApplicationActionTypes(const QString &strID) const
    267 {
    268     /* Prepare result: */
    269     RuntimeMenuApplicationActionType result = RuntimeMenuApplicationActionType_Invalid;
    270     /* Load restricted runtime-application-menu action-types: */
    271     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeApplicationMenuActions, strID))
    272     {
    273         RuntimeMenuApplicationActionType value = gpConverter->fromInternalString<RuntimeMenuApplicationActionType>(strValue);
    274         if (value != RuntimeMenuApplicationActionType_Invalid)
    275             result = static_cast<RuntimeMenuApplicationActionType>(result | value);
    276     }
    277     /* Return result: */
    278     return result;
    279 }
    280 #endif /* Q_WS_MAC */
    281 
    282 RuntimeMenuMachineActionType UIExtraDataManager::restrictedRuntimeMenuMachineActionTypes(const QString &strID) const
    283 {
    284     /* Prepare result: */
    285     RuntimeMenuMachineActionType result = RuntimeMenuMachineActionType_Invalid;
    286     /* Load restricted runtime-machine-menu action-types: */
    287     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeMachineMenuActions, strID))
    288     {
    289         RuntimeMenuMachineActionType value = gpConverter->fromInternalString<RuntimeMenuMachineActionType>(strValue);
    290         if (value != RuntimeMenuMachineActionType_Invalid)
    291             result = static_cast<RuntimeMenuMachineActionType>(result | value);
    292     }
    293     /* Return result: */
    294     return result;
    295 }
    296 
    297 RuntimeMenuViewActionType UIExtraDataManager::restrictedRuntimeMenuViewActionTypes(const QString &strID) const
    298 {
    299     /* Prepare result: */
    300     RuntimeMenuViewActionType result = RuntimeMenuViewActionType_Invalid;
    301     /* Load restricted runtime-view-menu action-types: */
    302     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeViewMenuActions, strID))
    303     {
    304         RuntimeMenuViewActionType value = gpConverter->fromInternalString<RuntimeMenuViewActionType>(strValue);
    305         if (value != RuntimeMenuViewActionType_Invalid)
    306             result = static_cast<RuntimeMenuViewActionType>(result | value);
    307     }
    308     /* Return result: */
    309     return result;
    310 }
    311 
    312 RuntimeMenuDevicesActionType UIExtraDataManager::restrictedRuntimeMenuDevicesActionTypes(const QString &strID) const
    313 {
    314     /* Prepare result: */
    315     RuntimeMenuDevicesActionType result = RuntimeMenuDevicesActionType_Invalid;
    316     /* Load restricted runtime-devices-menu action-types: */
    317     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeDevicesMenuActions, strID))
    318     {
    319         RuntimeMenuDevicesActionType value = gpConverter->fromInternalString<RuntimeMenuDevicesActionType>(strValue);
    320         if (value != RuntimeMenuDevicesActionType_Invalid)
    321             result = static_cast<RuntimeMenuDevicesActionType>(result | value);
    322     }
    323     /* Return result: */
    324     return result;
    325 }
    326 
    327 #ifdef VBOX_WITH_DEBUGGER_GUI
    328 RuntimeMenuDebuggerActionType UIExtraDataManager::restrictedRuntimeMenuDebuggerActionTypes(const QString &strID) const
    329 {
    330     /* Prepare result: */
    331     RuntimeMenuDebuggerActionType result = RuntimeMenuDebuggerActionType_Invalid;
    332     /* Load restricted runtime-debugger-menu action-types: */
    333     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeDebuggerMenuActions, strID))
    334     {
    335         RuntimeMenuDebuggerActionType value = gpConverter->fromInternalString<RuntimeMenuDebuggerActionType>(strValue);
    336         if (value != RuntimeMenuDebuggerActionType_Invalid)
    337             result = static_cast<RuntimeMenuDebuggerActionType>(result | value);
    338     }
    339     /* Return result: */
    340     return result;
    341 }
    342 #endif /* VBOX_WITH_DEBUGGER_GUI */
    343 
    344 RuntimeMenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID) const
    345 {
    346     /* Prepare result: */
    347     RuntimeMenuHelpActionType result = RuntimeMenuHelpActionType_Invalid;
    348     /* Load restricted runtime-help-menu action-types: */
    349     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeHelpMenuActions, strID))
    350     {
    351         RuntimeMenuHelpActionType value = gpConverter->fromInternalString<RuntimeMenuHelpActionType>(strValue);
    352         if (value != RuntimeMenuHelpActionType_Invalid)
    353             result = static_cast<RuntimeMenuHelpActionType>(result | value);
    354     }
    355     /* Return result: */
    356     return result;
    357 }
    358 
    359 UIVisualStateType UIExtraDataManager::restrictedVisualStateTypes(const QString &strID) const
    360 {
    361     /* Prepare result: */
    362     UIVisualStateType result = UIVisualStateType_Invalid;
    363     /* Load restricted visual-state-types: */
    364     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedVisualStates, strID))
    365     {
    366         UIVisualStateType value = gpConverter->fromInternalString<UIVisualStateType>(strValue);
    367         if (value != UIVisualStateType_Invalid)
    368             result = static_cast<UIVisualStateType>(result | value);
    369     }
    370     /* Return result: */
    371     return result;
    372 }
    373 
    374 MachineCloseAction UIExtraDataManager::defaultMachineCloseAction(const QString &strID) const
    375 {
    376     return gpConverter->fromInternalString<MachineCloseAction>(extraDataString(GUI_DefaultCloseAction, strID));
    377 }
    378 
    379 MachineCloseAction UIExtraDataManager::restrictedMachineCloseActions(const QString &strID) const
    380 {
    381     /* Prepare result: */
    382     MachineCloseAction result = MachineCloseAction_Invalid;
    383     /* Load restricted machine-close-actions: */
    384     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedCloseActions, strID))
    385     {
    386         MachineCloseAction value = gpConverter->fromInternalString<MachineCloseAction>(strValue);
    387         if (value != MachineCloseAction_Invalid)
    388             result = static_cast<MachineCloseAction>(result | value);
    389     }
    390     /* Return result: */
    391     return result;
    392 }
    393 
    394 QList<IndicatorType> UIExtraDataManager::restrictedStatusBarIndicators(const QString &strID) const
    395 {
    396     /* Prepare result: */
    397     QList<IndicatorType> result;
    398     /* Load restricted status-bar-indicators: */
    399     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedStatusBarIndicators, strID))
    400     {
    401         IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
    402         if (value != IndicatorType_Invalid)
    403             result << value;
    404     }
    405     /* Return result: */
    406     return result;
    407 }
    408 
    409 QList<GlobalSettingsPageType> UIExtraDataManager::restrictedGlobalSettingsPages() const
    410 {
    411     /* Prepare result: */
    412     QList<GlobalSettingsPageType> result;
    413     /* Load restricted global-settings-pages: */
    414     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedGlobalSettingsPages))
    415     {
    416         GlobalSettingsPageType value = gpConverter->fromInternalString<GlobalSettingsPageType>(strValue);
    417         if (value != GlobalSettingsPageType_Invalid)
    418             result << value;
    419     }
    420     /* Return result: */
    421     return result;
    422 }
    423 
    424 QList<MachineSettingsPageType> UIExtraDataManager::restrictedMachineSettingsPages(const QString &strID) const
    425 {
    426     /* Prepare result: */
    427     QList<MachineSettingsPageType> result;
    428     /* Load restricted machine-settings-pages: */
    429     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedMachineSettingsPages, strID))
    430     {
    431         MachineSettingsPageType value = gpConverter->fromInternalString<MachineSettingsPageType>(strValue);
    432         if (value != MachineSettingsPageType_Invalid)
    433             result << value;
    434     }
    435     /* Return result: */
    436     return result;
    437 }
    438 
    439 #ifndef Q_WS_MAC
    440 QStringList UIExtraDataManager::machineWindowIconNames(const QString &strID) const
    441 {
    442     return extraDataStringList(GUI_MachineWindowIcons, strID);
    443 }
    444 
    445 QString UIExtraDataManager::machineWindowNamePostfix(const QString &strID) const
    446 {
    447     return extraDataString(GUI_MachineWindowNamePostfix, strID);
    448 }
    449 #endif /* !Q_WS_MAC */
    450 
    451 GuruMeditationHandlerType UIExtraDataManager::guruMeditationHandlerType(const QString &strID) const
    452 {
    453     return gpConverter->fromInternalString<GuruMeditationHandlerType>(extraDataString(GUI_GuruMeditationHandler, strID));
    454 }
    455 
    456 HiDPIOptimizationType UIExtraDataManager::hiDPIOptimizationType(const QString &strID) const
    457 {
    458     return gpConverter->fromInternalString<HiDPIOptimizationType>(extraDataString(GUI_HiDPIOptimization, strID));
    459 }
    460 
    461458void UIExtraDataManager::prepare()
    462459{
     
    487484    AssertPtrReturnVoid(m_pHandler);
    488485    {
    489         /* Language change signal: */
    490         connect(m_pHandler, SIGNAL(sigLanguageChange(QString)),
    491                 this, SIGNAL(sigLanguageChange(QString)),
     486        /* Extra-data change signal: */
     487        connect(m_pHandler, SIGNAL(sigExtraDataChange(QString, QString, QString)),
     488                this, SIGNAL(sltExtraDataChange(QString, QString, QString)),
    492489                Qt::QueuedConnection);
    493 
    494         /* Selector/Runtime UI shortcut change signals: */
    495         connect(m_pHandler, SIGNAL(sigSelectorUIShortcutChange()),
    496                 this, SIGNAL(sigSelectorUIShortcutChange()),
    497                 Qt::QueuedConnection);
    498         connect(m_pHandler, SIGNAL(sigRuntimeUIShortcutChange()),
    499                 this, SIGNAL(sigRuntimeUIShortcutChange()),
    500                 Qt::QueuedConnection);
    501 
    502         /* HID LED sync state change signal: */
    503         connect(m_pHandler, SIGNAL(sigHIDLedsSyncStateChange(bool)),
    504                 this, SIGNAL(sigHIDLedsSyncStateChange(bool)),
    505                 Qt::QueuedConnection);
    506 
    507 #ifdef Q_WS_MAC
    508         /* 'Presentation mode' status change signal: */
    509         connect(m_pHandler, SIGNAL(sigPresentationModeChange(bool)),
    510                 this, SIGNAL(sigPresentationModeChange(bool)),
    511                 Qt::QueuedConnection);
    512 
    513         /* 'Dock icon' appearance change signal: */
    514         connect(m_pHandler, SIGNAL(sigDockIconAppearanceChange(bool)),
    515                 this, SIGNAL(sigDockIconAppearanceChange(bool)),
    516                 Qt::QueuedConnection);
    517 #endif /* Q_WS_MAC */
    518490
    519491        /* Prepare Main event-listener: */
     
    539511    /* This is a vetoable event, so we have to respond to the event and have to use a direct connection therefor: */
    540512    connect(pListener->getWrapped(), SIGNAL(sigExtraDataCanChange(QString, QString, QString, bool&, QString&)),
    541             m_pHandler, SLOT(sltExtraDataCanChange(QString, QString, QString, bool&, QString&)),
     513            m_pHandler, SLOT(sltPreprocessExtraDataCanChange(QString, QString, QString, bool&, QString&)),
    542514            Qt::DirectConnection);
    543515    /* Use a direct connection to the helper class: */
    544516    connect(pListener->getWrapped(), SIGNAL(sigExtraDataChange(QString, QString, QString)),
    545             m_pHandler, SLOT(sltExtraDataChange(QString, QString, QString)),
     517            m_pHandler, SLOT(sltPreprocessExtraDataChange(QString, QString, QString)),
    546518            Qt::DirectConnection);
    547519}
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51174 r51177  
    139139    HiDPIOptimizationType hiDPIOptimizationType(const QString &strID) const;
    140140
     141private slots:
     142
     143    /** Handles 'extra-data change' event: */
     144    void sltExtraDataChange(QString strMachineID, QString strKey, QString strValue);
     145
    141146private:
    142147
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