VirtualBox

Ignore:
Timestamp:
Dec 5, 2019 5:48:54 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9390: UIGraphicsControllerEditor: Get rid of hardcoded graphics controller types, instead acquire these types through CSystemProperties interface; Besides that, adjust machine settings to advice recommended controller only if it's among supported.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r82008 r82436  
    350350#endif /* VBOX_WITH_VIDEOHWACCEL */
    351351
     352KGraphicsControllerType UIMachineSettingsDisplay::graphicsControllerTypeRecommended() const
     353{
     354    return   m_pGraphicsControllerEditor->supportedValues().contains(m_enmGraphicsControllerTypeRecommended)
     355           ? m_enmGraphicsControllerTypeRecommended
     356           : graphicsControllerTypeCurrent();
     357}
     358
    352359KGraphicsControllerType UIMachineSettingsDisplay::graphicsControllerTypeCurrent() const
    353360{
     
    662669        if (!m_comGuestOSType.isNull())
    663670        {
    664             if (m_pGraphicsControllerEditor->value() != m_enmGraphicsControllerTypeRecommended)
     671            if (graphicsControllerTypeCurrent() != graphicsControllerTypeRecommended())
    665672            {
    666673#ifdef VBOX_WITH_3D_ACCELERATION
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r81457 r82436  
    6060
    6161    /** Returns recommended graphics controller type. */
    62     KGraphicsControllerType graphicsControllerTypeRecommended() const { return m_enmGraphicsControllerTypeRecommended; }
     62    KGraphicsControllerType graphicsControllerTypeRecommended() const;
    6363    /** Returns current graphics controller type. */
    6464    KGraphicsControllerType graphicsControllerTypeCurrent() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.cpp

    r82430 r82436  
    2323/* GUI includes: */
    2424#include "QIComboBox.h"
     25#include "UICommon.h"
    2526#include "UIConverter.h"
    2627#include "UIGraphicsControllerEditor.h"
     28
     29/* COM includes: */
     30#include "CSystemProperties.h"
    2731
    2832
     
    4145    if (m_pCombo)
    4246    {
    43         /* Update cached value: */
    44         m_enmValue = enmValue;
     47        /* Update cached value and
     48         * combo if value has changed: */
     49        if (m_enmValue != enmValue)
     50        {
     51            m_enmValue = enmValue;
     52            populateCombo();
     53        }
    4554
    4655        /* Look for proper index to choose: */
     
    100109            {
    101110                setFocusProxy(m_pCombo->focusProxy());
     111                /* This is necessary since contents is dynamical now: */
     112                m_pCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    102113                if (m_pLabel)
    103114                    m_pLabel->setBuddy(m_pCombo->focusProxy());
     
    124135void UIGraphicsControllerEditor::populateCombo()
    125136{
    126     for (int i = 0; i < KGraphicsControllerType_Max; ++i)
    127         m_pCombo->addItem(QString(), QVariant::fromValue(static_cast<KGraphicsControllerType>(i)));
     137    if (m_pCombo)
     138    {
     139        /* Clear combo first of all: */
     140        m_pCombo->clear();
     141
     142        /* Load currently supported graphics controller types: */
     143        CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     144        m_supportedValues = comProperties.GetSupportedGraphicsControllerTypes();
     145
     146        /* Make sure requested value if sane is present as well: */
     147        if (   m_enmValue != KGraphicsControllerType_Max
     148            && !m_supportedValues.contains(m_enmValue))
     149            m_supportedValues.prepend(m_enmValue);
     150
     151        /* Update combo with all the supported values: */
     152        foreach (const KGraphicsControllerType &enmType, m_supportedValues)
     153            m_pCombo->addItem(QString(), QVariant::fromValue(enmType));
     154
     155        /* Retranslate finally: */
     156        retranslateUi();
     157    }
    128158}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.h

    r82430 r82436  
    5757    KGraphicsControllerType value() const;
    5858
     59    /** Returns the vector of supported values. */
     60    QVector<KGraphicsControllerType> supportedValues() const { return m_supportedValues; }
     61
    5962protected:
    6063
     
    8083    KGraphicsControllerType  m_enmValue;
    8184
     85    /** Holds the vector of supported values. */
     86    QVector<KGraphicsControllerType>  m_supportedValues;
     87
    8288    /** Holds the label instance. */
    8389    QLabel     *m_pLabel;
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