VirtualBox

Changeset 56751 in vbox


Ignore:
Timestamp:
Jul 2, 2015 11:56:11 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: Interface page: Do not apply status-bar restrictions/order changes on-the-fly, use common approach instead.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIStatusBarEditorWindow.cpp

    r56736 r56751  
    303303}
    304304
     305void UIStatusBarEditorWidget::setStatusBarConfiguration(const QList<IndicatorType> &restrictions,
     306                                                        const QList<IndicatorType> &order)
     307{
     308    /* Cache passed restrictions: */
     309    m_restrictions = restrictions;
     310
     311    /* Cache passed order: */
     312    m_order = order;
     313    /* Append order with missed indicators: */
     314    for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType)
     315        if (iType != IndicatorType_Invalid && iType != IndicatorType_KeyboardExtension &&
     316            !m_order.contains((IndicatorType)iType))
     317            m_order << (IndicatorType)iType;
     318
     319    /* Update configuration for all existing buttons: */
     320    foreach (const IndicatorType &type, m_order)
     321    {
     322        /* Get button: */
     323        UIStatusBarEditorButton *pButton = m_buttons.value(type);
     324        /* Make sure button exists: */
     325        if (!pButton)
     326            continue;
     327        /* Update button 'checked' state: */
     328        pButton->setChecked(!m_restrictions.contains(type));
     329        /* Make sure it have valid position: */
     330        const int iWantedIndex = position(type);
     331        const int iActualIndex = m_pButtonLayout->indexOf(pButton);
     332        if (iActualIndex != iWantedIndex)
     333        {
     334            /* Re-inject button into main-layout at proper position: */
     335            m_pButtonLayout->removeWidget(pButton);
     336            m_pButtonLayout->insertWidget(iWantedIndex, pButton);
     337        }
     338    }
     339}
     340
    305341void UIStatusBarEditorWidget::sltHandleConfigurationChange(const QString &strMachineID)
    306342{
     
    309345        return;
    310346
    311     /* Update status buttons: */
    312     updateStatusButtons();
     347    /* Recache status-bar configuration: */
     348    setStatusBarConfiguration(gEDataManager->restrictedStatusBarIndicators(machineID()),
     349                              gEDataManager->statusBarIndicatorOrder(machineID()));
    313350}
    314351
     
    322359    const IndicatorType type = pButton->type();
    323360
    324     /* Load current status-bar indicator restrictions: */
    325     QList<IndicatorType> restrictions =
    326         gEDataManager->restrictedStatusBarIndicators(machineID());
    327 
    328361    /* Invert restriction for sender type: */
    329     if (restrictions.contains(type))
    330         restrictions.removeAll(type);
     362    if (m_restrictions.contains(type))
     363        m_restrictions.removeAll(type);
    331364    else
    332         restrictions.append(type);
    333 
    334     /* Save updated status-bar indicator restrictions: */
    335     gEDataManager->setRestrictedStatusBarIndicators(restrictions, machineID());
     365        m_restrictions.append(type);
     366
     367    if (m_fStartedFromVMSettings)
     368    {
     369        /* Reapply status-bar configuration from cache: */
     370        setStatusBarConfiguration(m_restrictions, m_order);
     371    }
     372    else
     373    {
     374        /* Save updated status-bar indicator restrictions: */
     375        gEDataManager->setRestrictedStatusBarIndicators(m_restrictions, machineID());
     376    }
    336377}
    337378
     
    443484    }
    444485
    445     /* Listen for the status-bar configuration changes if necessary: */
    446486    if (!m_fStartedFromVMSettings)
    447487    {
     488        /* Cache status-bar configuration: */
     489        setStatusBarConfiguration(gEDataManager->restrictedStatusBarIndicators(machineID()),
     490                                  gEDataManager->statusBarIndicatorOrder(machineID()));
     491        /* And listen for the status-bar configuration changes after that: */
    448492        connect(gEDataManager, SIGNAL(sigStatusBarConfigurationChange(const QString&)),
    449493                this, SLOT(sltHandleConfigurationChange(const QString&)));
    450494    }
    451 
    452     /* Update status buttons: */
    453     updateStatusButtons();
    454495}
    455496
     
    467508        /* Insert status button into map: */
    468509        m_buttons.insert(type, pButton);
    469     }
    470 }
    471 
    472 void UIStatusBarEditorWidget::updateStatusButtons()
    473 {
    474     /* Recache status-bar configuration: */
    475     m_restrictions = gEDataManager->restrictedStatusBarIndicators(machineID());
    476     m_order = gEDataManager->statusBarIndicatorOrder(machineID());
    477     for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType)
    478         if (iType != IndicatorType_Invalid && iType != IndicatorType_KeyboardExtension &&
    479             !m_order.contains((IndicatorType)iType))
    480             m_order << (IndicatorType)iType;
    481 
    482     /* Update configuration for all the status buttons: */
    483     foreach (const IndicatorType &type, m_order)
    484     {
    485         /* Get button: */
    486         UIStatusBarEditorButton *pButton = m_buttons.value(type);
    487         /* Update button 'checked' state: */
    488         pButton->setChecked(!m_restrictions.contains(type));
    489         /* Make sure it have valid position: */
    490         const int iWantedIndex = position(type);
    491         const int iActualIndex = m_pButtonLayout->indexOf(pButton);
    492         if (iActualIndex != iWantedIndex)
    493         {
    494             /* Re-inject button into main-layout at proper position: */
    495             m_pButtonLayout->removeWidget(pButton);
    496             m_pButtonLayout->insertWidget(iWantedIndex, pButton);
    497         }
    498510    }
    499511}
     
    673685        return;
    674686
    675     /* Load current status-bar indicator order and make sure it's complete: */
    676     QList<IndicatorType> order =
    677         gEDataManager->statusBarIndicatorOrder(machineID());
    678     for (int iType = IndicatorType_Invalid; iType < IndicatorType_Max; ++iType)
    679         if (iType != IndicatorType_Invalid && iType != IndicatorType_KeyboardExtension &&
    680             !order.contains((IndicatorType)iType))
    681             order << (IndicatorType)iType;
    682 
    683687    /* Remove type of dropped-button: */
    684     order.removeAll(droppedType);
     688    m_order.removeAll(droppedType);
    685689    /* Insert type of dropped-button into position of token-button: */
    686     int iPosition = order.indexOf(tokenType);
     690    int iPosition = m_order.indexOf(tokenType);
    687691    if (m_fDropAfterTokenButton)
    688692        ++iPosition;
    689     order.insert(iPosition, droppedType);
    690 
    691     /* Save updated status-bar indicator order: */
    692     gEDataManager->setStatusBarIndicatorOrder(order, machineID());
     693    m_order.insert(iPosition, droppedType);
     694
     695    if (m_fStartedFromVMSettings)
     696    {
     697        /* Reapply status-bar configuration from cache: */
     698        setStatusBarConfiguration(m_restrictions, m_order);
     699    }
     700    else
     701    {
     702        /* Save updated status-bar indicator order: */
     703        gEDataManager->setStatusBarIndicatorOrder(m_order, machineID());
     704    }
    693705}
    694706
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIStatusBarEditorWindow.h

    r56736 r56751  
    7878    void setStatusBarEnabled(bool fEnabled);
    7979
     80    /** Returns status-bar indicator restrictions. */
     81    const QList<IndicatorType>& statusBarIndicatorRestrictions() const { return m_restrictions; }
     82    /** Returns status-bar indicator order. */
     83    const QList<IndicatorType>& statusBarIndicatorOrder() const { return m_order; }
     84    /** Defines status-bar indicator @a restrictions and @a order. */
     85    void setStatusBarConfiguration(const QList<IndicatorType> &restrictions, const QList<IndicatorType> &order);
     86
    8087private slots:
    8188
     
    97104    /** Prepare status button routine. */
    98105    void prepareStatusButton(IndicatorType type);
    99 
    100     /** Update status buttons routine. */
    101     void updateStatusButtons();
    102106
    103107    /** Retranslation routine. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r56736 r56751  
    5656    /* Cache interface data: */
    5757    interfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
     58    interfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
     59    interfaceData.m_statusBarOrder = gEDataManager->statusBarIndicatorOrder(m_machine.GetId());
    5860#ifndef Q_WS_MAC
    5961    interfaceData.m_fMenuBarEnabled = gEDataManager->menuBarEnabled(m_machine.GetId());
     
    7880    /* Prepare interface data: */
    7981    m_pStatusBarEditor->setStatusBarEnabled(interfaceData.m_fStatusBarEnabled);
     82    m_pStatusBarEditor->setStatusBarConfiguration(interfaceData.m_statusBarRestrictions,
     83                                                  interfaceData.m_statusBarOrder);
    8084#ifndef Q_WS_MAC
    8185    m_pMenuBarEditor->setMenuBarEnabled(interfaceData.m_fMenuBarEnabled);
     
    100104    /* Gather interface data from page: */
    101105    interfaceData.m_fStatusBarEnabled = m_pStatusBarEditor->isStatusBarEnabled();
     106    interfaceData.m_statusBarRestrictions = m_pStatusBarEditor->statusBarIndicatorRestrictions();
     107    interfaceData.m_statusBarOrder = m_pStatusBarEditor->statusBarIndicatorOrder();
    102108#ifndef Q_WS_MAC
    103109    interfaceData.m_fMenuBarEnabled = m_pMenuBarEditor->isMenuBarEnabled();
     
    127133        {
    128134            gEDataManager->setStatusBarEnabled(interfaceData.m_fStatusBarEnabled, m_machine.GetId());
     135            gEDataManager->setRestrictedStatusBarIndicators(interfaceData.m_statusBarRestrictions, m_machine.GetId());
     136            gEDataManager->setStatusBarIndicatorOrder(interfaceData.m_statusBarOrder, m_machine.GetId());
    129137#ifndef Q_WS_MAC
    130138            gEDataManager->setMenuBarEnabled(interfaceData.m_fMenuBarEnabled, m_machine.GetId());
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.h

    r56736 r56751  
    4343    {
    4444        return    (m_fStatusBarEnabled == other.m_fStatusBarEnabled)
     45               && (m_statusBarRestrictions == other.m_statusBarRestrictions)
     46               && (m_statusBarOrder == other.m_statusBarOrder)
    4547#ifndef Q_WS_MAC
    4648               && (m_fMenuBarEnabled == other.m_fMenuBarEnabled)
     
    5759    /* Variables: */
    5860    bool m_fStatusBarEnabled;
     61    QList<IndicatorType> m_statusBarRestrictions;
     62    QList<IndicatorType> m_statusBarOrder;
    5963#ifndef Q_WS_MAC
    6064    bool m_fMenuBarEnabled;
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