VirtualBox

Changeset 52035 in vbox for trunk/src


Ignore:
Timestamp:
Jul 15, 2014 12:15:46 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 3646: Extra-data Manager: Allow to change status-bar order at runtime; Indicators Pool: Handle runtime order change.

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

Legend:

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

    r51931 r52035  
    110110const char* UIExtraDataDefs::GUI_MiniToolBarAlignment = "GUI/MiniToolBarAlignment";
    111111const char* UIExtraDataDefs::GUI_RestrictedStatusBarIndicators = "GUI/RestrictedStatusBarIndicators";
     112const char* UIExtraDataDefs::GUI_StatusBar_IndicatorOrder = "GUI/StatusBar/IndicatorOrder";
    112113#ifdef Q_WS_MAC
    113114const char* UIExtraDataDefs::GUI_PresentationModeEnabled = "GUI/PresentationModeEnabled";
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r51992 r52035  
    203203        /** Holds restricted Runtime UI status-bar indicators. */
    204204        extern const char* GUI_RestrictedStatusBarIndicators;
     205        /** Holds Runtime UI status-bar indicator order. */
     206        extern const char* GUI_StatusBar_IndicatorOrder;
    205207#ifdef Q_WS_MAC
    206208        /** Mac OS X: Holds whether 'presentation mode' enabled. */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r52013 r52035  
    17831783           << GUI_HiDPI_Optimization
    17841784           << GUI_ShowMiniToolBar << GUI_MiniToolBarAutoHide << GUI_MiniToolBarAlignment
    1785            << GUI_RestrictedStatusBarIndicators
     1785           << GUI_RestrictedStatusBarIndicators << GUI_StatusBar_IndicatorOrder
    17861786#ifdef Q_WS_MAC
    17871787           << GUI_PresentationModeEnabled
     
    28102810    /* Prepare result: */
    28112811    QList<IndicatorType> result;
    2812     /* Get restricted status-bar-indicators: */
     2812    /* Get restricted status-bar indicators: */
    28132813    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedStatusBarIndicators, strID))
    28142814    {
    2815         IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
    2816         if (value != IndicatorType_Invalid)
     2815        const IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
     2816        if (value != IndicatorType_Invalid && !result.contains(value))
    28172817            result << value;
    28182818    }
     
    28302830    /* Re-cache corresponding extra-data: */
    28312831    setExtraDataStringList(GUI_RestrictedStatusBarIndicators, data, strID);
     2832}
     2833
     2834QList<IndicatorType> UIExtraDataManager::statusBarIndicatorOrder(const QString &strID)
     2835{
     2836    /* Prepare result: */
     2837    QList<IndicatorType> result;
     2838    /* Get status-bar indicator order: */
     2839    foreach (const QString &strValue, extraDataStringList(GUI_StatusBar_IndicatorOrder, strID))
     2840    {
     2841        const IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
     2842        if (value != IndicatorType_Invalid && !result.contains(value))
     2843            result << value;
     2844    }
     2845    /* Return result: */
     2846    return result;
     2847}
     2848
     2849void UIExtraDataManager::setStatusBarIndicatorOrder(const QList<IndicatorType> &list, const QString &strID)
     2850{
     2851    /* Parse passed list: */
     2852    QStringList data;
     2853    foreach (const IndicatorType &indicatorType, list)
     2854        data << gpConverter->toInternalString(indicatorType);
     2855
     2856    /* Re-cache corresponding extra-data: */
     2857    setExtraDataStringList(GUI_StatusBar_IndicatorOrder, data, strID);
    28322858}
    28332859
     
    31393165    {
    31403166        /* Status-bar configuration change: */
    3141         if (strKey == GUI_RestrictedStatusBarIndicators)
     3167        if (strKey == GUI_RestrictedStatusBarIndicators ||
     3168            strKey == GUI_StatusBar_IndicatorOrder)
    31423169            emit sigStatusBarConfigurationChange();
    31433170        /* HID LEDs sync state changed (allowed if not restricted)? */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r52013 r52035  
    369369        void setRestrictedStatusBarIndicators(const QList<IndicatorType> &list, const QString &strID);
    370370
     371        /** Returns Runtime UI status-bar indicator order list. */
     372        QList<IndicatorType> statusBarIndicatorOrder(const QString &strID);
     373        /** Defines Runtime UI status-bar indicator order @a list. */
     374        void setStatusBarIndicatorOrder(const QList<IndicatorType> &list, const QString &strID);
     375
    371376#ifdef Q_WS_MAC
    372377        /** Mac OS X: Returns whether 'presentation mode' enabled. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r52014 r52035  
    10401040void UIIndicatorsPool::updatePool()
    10411041{
    1042     /* Recache the list of restricted indicators: */
    1043     m_configuration = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid());
    1044 
    1045     /* Update indicators: */
     1042    /* Recache status-bar configuration: */
     1043    m_restrictions = gEDataManager->restrictedStatusBarIndicators(vboxGlobal().managedVMUuid());
     1044    m_order = gEDataManager->statusBarIndicatorOrder(vboxGlobal().managedVMUuid());
     1045
     1046    /* Make sure the order is complete taking restrictions into account: */
    10461047    for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType)
    10471048    {
    1048         /* Determine indicator presence: */
    1049         const IndicatorType indicatorType = static_cast<IndicatorType>(iType);
    1050         bool fPresenceAllowed = !m_configuration.contains(indicatorType);
    1051 
    1052         /* If presence restricted: */
    1053         if (!fPresenceAllowed && m_pool.contains(indicatorType))
    1054         {
    1055             /* Cleanup indicator: */
     1049        /* Get iterated type: */
     1050        IndicatorType type = (IndicatorType)iType;
     1051        /* Skip invalid type: */
     1052        if (type == IndicatorType_Invalid)
     1053            continue;
     1054        /* Take restriction/presence into account: */
     1055        bool fRestricted = m_restrictions.contains(type);
     1056        bool fPresent = m_order.contains(type);
     1057        if (fRestricted && fPresent)
     1058            m_order.removeAll(type);
     1059        else if (!fRestricted && !fPresent)
     1060            m_order << type;
     1061    }
     1062
     1063    /* Remove restricted indicators: */
     1064    foreach (const IndicatorType &indicatorType, m_restrictions)
     1065        if (m_pool.contains(indicatorType))
     1066        {
    10561067            delete m_pool.value(indicatorType);
    10571068            m_pool.remove(indicatorType);
    10581069        }
    1059         /* If presence allowed: */
    1060         else if (fPresenceAllowed && !m_pool.contains(indicatorType))
     1070
     1071    /* Add/Update allowed indicators: */
     1072    foreach (const IndicatorType &indicatorType, m_order)
     1073    {
     1074        /* Indicator exists: */
     1075        if (m_pool.contains(indicatorType))
     1076        {
     1077            /* Get indicator: */
     1078            QIStatusBarIndicator *pIndicator = m_pool.value(indicatorType);
     1079            /* Make sure it have valid position: */
     1080            const int iWantedIndex = indicatorPosition(indicatorType);
     1081            const int iActualIndex = m_pMainLayout->indexOf(pIndicator);
     1082            if (iActualIndex != iWantedIndex)
     1083            {
     1084                /* Re-inject indicator into main-layout at proper position: */
     1085                m_pMainLayout->removeWidget(pIndicator);
     1086                m_pMainLayout->insertWidget(iWantedIndex, pIndicator);
     1087            }
     1088        }
     1089        /* Indicator missed: */
     1090        else
    10611091        {
    10621092            /* Create indicator: */
     
    10791109            connect(m_pool.value(indicatorType), SIGNAL(sigContextMenuRequest(QIStatusBarIndicator*, QContextMenuEvent*)),
    10801110                    this, SLOT(sltContextMenuRequest(QIStatusBarIndicator*, QContextMenuEvent*)));
    1081             /* Insert indicator into main-layout: */
     1111            /* Insert indicator into main-layout at proper position: */
    10821112            m_pMainLayout->insertWidget(indicatorPosition(indicatorType), m_pool.value(indicatorType));
    10831113        }
     
    11181148{
    11191149    int iPosition = 0;
    1120     foreach (const IndicatorType &iteratedIndicatorType, m_pool.keys())
     1150    foreach (const IndicatorType &iteratedIndicatorType, m_order)
    11211151        if (iteratedIndicatorType == indicatorType)
    11221152            return iPosition;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h

    r51995 r52035  
    5757    ~UIIndicatorsPool();
    5858
    59     /** Returns indicator corresponding to passed @a indicatorType. */
    60     QIStatusBarIndicator* indicator(IndicatorType indicatorType) const { return m_pool.value(indicatorType); }
    61 
    6259    /** Updates appearance for passed @a indicatorType. */
    6360    void updateAppearance(IndicatorType indicatorType);
     
    108105    /** Holds the session reference. */
    109106    CSession &m_session;
    110     /** Holds the cached configuration. */
    111     QList<IndicatorType> m_configuration;
     107    /** Holds the cached restrictions. */
     108    QList<IndicatorType> m_restrictions;
     109    /** Holds the cached order. */
     110    QList<IndicatorType> m_order;
    112111    /** Holds cached indicator instances. */
    113112    QMap<IndicatorType, QIStatusBarIndicator*> m_pool;
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