VirtualBox

Changeset 80068 in vbox


Ignore:
Timestamp:
Jul 31, 2019 11:20:37 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132507
Message:

FE/Qt: bugref:7720: VM settings / Display page: Replace heavily distributed across display page widgets related to graphics controller editing functionality with single UIGraphicsControllerEditor.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r80043 r80068  
    893893        src/widgets/UIFilePathSelector.h \
    894894        src/widgets/UIFilmContainer.h \
     895        src/widgets/UIGraphicsControllerEditor.h \
    895896        src/widgets/UIHostComboEditor.h \
    896897        src/widgets/UIHotKeyEditor.h \
     
    13861387        src/widgets/UIFilePathSelector.cpp \
    13871388        src/widgets/UIFilmContainer.cpp \
     1389        src/widgets/UIGraphicsControllerEditor.cpp \
    13881390        src/widgets/UIHostComboEditor.cpp \
    13891391        src/widgets/UIHotKeyEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r80043 r80068  
    422422    m_pScaleFactorEditor->setScaleFactors(oldDisplayData.m_scaleFactors);
    423423    m_pScaleFactorEditor->setMonitorCount(oldDisplayData.m_cGuestScreenCount);
    424     m_pComboGraphicsControllerType->setCurrentIndex(m_pComboGraphicsControllerType->findText(gpConverter->toString(oldDisplayData.m_graphicsControllerType)));
     424    m_pGraphicsControllerEditor->setValue(oldDisplayData.m_graphicsControllerType);
    425425#ifdef VBOX_WITH_CRHGSMI
    426426    m_pCheckbox3D->setChecked(oldDisplayData.m_f3dAccelerationEnabled);
     
    492492    newDisplayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value();
    493493    newDisplayData.m_scaleFactors = m_pScaleFactorEditor->scaleFactors();
    494     newDisplayData.m_graphicsControllerType = gpConverter->fromString<KGraphicsControllerType>(m_pComboGraphicsControllerType->currentText());
     494    newDisplayData.m_graphicsControllerType = m_pGraphicsControllerEditor->value();
    495495#ifdef VBOX_WITH_CRHGSMI
    496496    newDisplayData.m_f3dAccelerationEnabled = m_pCheckbox3D->isChecked();
     
    692692    setTabOrder(m_pSliderVideoScreenCount, m_pEditorVideoScreenCount);
    693693    setTabOrder(m_pEditorVideoScreenCount, m_pScaleFactorEditor);
    694     setTabOrder(m_pScaleFactorEditor, m_pComboGraphicsControllerType);
     694    setTabOrder(m_pScaleFactorEditor, m_pGraphicsControllerEditor);
    695695
    696696    /* Remote Display tab-order: */
     
    721721    m_pLabelVideoScreenCountMin->setText(QString::number(1));
    722722    m_pLabelVideoScreenCountMax->setText(QString::number(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));
    723     m_pComboGraphicsControllerType->setItemText(0, gpConverter->toString(KGraphicsControllerType_Null));
    724     m_pComboGraphicsControllerType->setItemText(1, gpConverter->toString(KGraphicsControllerType_VBoxVGA));
    725     m_pComboGraphicsControllerType->setItemText(2, gpConverter->toString(KGraphicsControllerType_VMSVGA));
    726     m_pComboGraphicsControllerType->setItemText(3, gpConverter->toString(KGraphicsControllerType_VBoxSVGA));
    727723
    728724    /* Remote Display stuff: */
     
    765761    m_pEditorVideoScreenCount->setEnabled(isMachineOffline());
    766762    m_pScaleFactorEditor->setEnabled(isMachineInValidMode());
     763    m_pGraphicsControllerLabel->setEnabled(isMachineOffline());
     764    m_pGraphicsControllerEditor->setEnabled(isMachineOffline());
    767765    m_pLabelVideoOptions->setEnabled(isMachineOffline());
    768766#ifdef VBOX_WITH_CRHGSMI
     
    776774    m_pCheckbox2DVideo->hide();
    777775#endif
    778     m_pComboGraphicsControllerType->setEnabled(isMachineOffline());
    779776
    780777    /* Polish 'Remote Display' availability: */
     
    827824{
    828825    /* Update Video RAM requirements: */
    829     m_pVideoMemoryEditor->setGraphicsControllerType(gpConverter->fromString<KGraphicsControllerType>(m_pComboGraphicsControllerType->currentText()));
     826    m_pVideoMemoryEditor->setGraphicsControllerType(m_pGraphicsControllerEditor->value());
    830827
    831828    /* Revalidate: */
     
    10181015        }
    10191016
    1020         /* Graphics controller combo-box created in the .ui file. */
    1021         AssertPtrReturnVoid(m_pComboGraphicsControllerType);
    1022         {
    1023             /* Configure combo-box: */
    1024             m_pComboGraphicsControllerType->insertItem(0, ""); /* KGraphicsControllerType_Null */
    1025             m_pComboGraphicsControllerType->insertItem(1, ""); /* KGraphicsControllerType_VBoxVGA */
    1026             m_pComboGraphicsControllerType->insertItem(2, ""); /* KGraphicsControllerType_VMSVGA */
    1027             m_pComboGraphicsControllerType->insertItem(3, ""); /* KGraphicsControllerType_VBoxSVGA */
     1017        /* Graphics controller label & editor created in the .ui file. */
     1018        AssertPtrReturnVoid(m_pGraphicsControllerEditor);
     1019        {
     1020            /* Configure label & editor: */
     1021            m_pGraphicsControllerLabel->setBuddy(m_pGraphicsControllerEditor->focusProxy());
    10281022        }
    10291023    }
     
    11981192    connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountSliderChange()));
    11991193    connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountEditorChange()));
    1200     connect(m_pComboGraphicsControllerType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     1194    connect(m_pGraphicsControllerEditor, &UIGraphicsControllerEditor::sigValueChanged,
    12011195            this, &UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange);
    12021196#ifdef VBOX_WITH_CRHGSMI
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui

    r80043 r80068  
    132132          </item>
    133133          <item row="6" column="0">
    134            <widget class="QLabel" name="m_pLabelGraphicsControllerType">
     134           <widget class="QLabel" name="m_pGraphicsControllerLabel">
    135135            <property name="text">
    136136             <string>&amp;Graphics Controller:</string>
     
    139139             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    140140            </property>
    141             <property name="buddy">
    142              <cstring>m_pComboGraphicsControllerType</cstring>
    143             </property>
    144141           </widget>
    145142          </item>
    146143          <item row="6" column="1" colspan="2">
    147            <layout class="QHBoxLayout">
    148             <item>
    149              <widget class="QComboBox" name="m_pComboGraphicsControllerType" >
    150               <property name="sizePolicy" >
    151                <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
    152                 <horstretch>0</horstretch>
    153                 <verstretch>0</verstretch>
    154                </sizepolicy>
    155               </property>
    156               <property name="whatsThis" >
    157                <string>Selects the graphics adapter type the virtual machine will use.</string>
    158               </property>
    159              </widget>
    160             </item>
    161             <item>
    162              <spacer name="m_pSpacerHorizontalGraphicsAdapterType">
    163               <property name="orientation">
    164                <enum>Qt::Horizontal</enum>
    165               </property>
    166               <property name="sizeHint" stdset="0">
    167                <size>
    168                 <width>0</width>
    169                 <height>0</height>
    170                </size>
    171               </property>
    172              </spacer>
    173             </item>
    174            </layout>
     144           <widget class="UIGraphicsControllerEditor" name="m_pGraphicsControllerEditor" >
     145            <property name="whatsThis" >
     146             <string>Selects the graphics adapter type the virtual machine will use.</string>
     147            </property>
     148           </widget>
    175149          </item>
    176150          <item row="7" column="0">
     
    774748  </customwidget>
    775749  <customwidget>
     750   <class>UIGraphicsControllerEditor</class>
     751   <extends>QWidget</extends>
     752   <header>UIGraphicsControllerEditor.h</header>
     753  </customwidget>
     754  <customwidget>
    776755   <class>UIScaleFactorEditor</class>
    777756   <extends>QWidget</extends>
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.cpp

    r80063 r80068  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIBaseMemoryEditor class implementation.
     3 * VBox Qt GUI - UIGraphicsControllerEditor class implementation.
    44 */
    55
     
    2020#include <QHBoxLayout>
    2121#include <QLabel>
    22 #include <QSpinBox>
    23 #include <QVBoxLayout>
    2422
    2523/* GUI includes: */
    26 #include "UIBaseMemoryEditor.h"
    27 #include "UIBaseMemorySlider.h"
     24#include "QIComboBox.h"
     25#include "UIConverter.h"
     26#include "UIGraphicsControllerEditor.h"
    2827
    2928
    30 UIBaseMemoryEditor::UIBaseMemoryEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     29UIGraphicsControllerEditor::UIGraphicsControllerEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
    3130    : QIWithRetranslateUI<QWidget>(pParent)
    3231    , m_fWithLabel(fWithLabel)
    33     , m_pLabelMemory(0)
    34     , m_pSlider(0)
    35     , m_pLabelMemoryMin(0)
    36     , m_pLabelMemoryMax(0)
    37     , m_pSpinBox(0)
     32    , m_pLabel(0)
     33    , m_pCombo(0)
    3834{
    3935    prepare();
    4036}
    4137
    42 void UIBaseMemoryEditor::setValue(int iValue)
     38void UIGraphicsControllerEditor::setValue(KGraphicsControllerType enmValue)
    4339{
    44     if (m_pSlider)
    45         m_pSlider->setValue(iValue);
     40    if (m_pCombo)
     41    {
     42        int iIndex = m_pCombo->findData(QVariant::fromValue(enmValue));
     43        if (iIndex != -1)
     44            m_pCombo->setCurrentIndex(iIndex);
     45    }
    4646}
    4747
    48 int UIBaseMemoryEditor::value() const
     48KGraphicsControllerType UIGraphicsControllerEditor::value() const
    4949{
    50     return m_pSlider ? m_pSlider->value() : 0;
     50    return m_pCombo ? m_pCombo->itemData(m_pCombo->currentIndex()).value<KGraphicsControllerType>() : KGraphicsControllerType_Null;
    5151}
    5252
    53 uint UIBaseMemoryEditor::maxRAMOpt() const
     53void UIGraphicsControllerEditor::retranslateUi()
    5454{
    55     return m_pSlider ? m_pSlider->maxRAMOpt() : 0;
     55    if (m_pLabel)
     56        m_pLabel->setText(tr("&Graphics Controller:"));
     57    if (m_pCombo)
     58    {
     59        for (int i = 0; i < m_pCombo->count(); ++i)
     60        {
     61            const KGraphicsControllerType enmType = m_pCombo->itemData(i).value<KGraphicsControllerType>();
     62            m_pCombo->setItemText(i, gpConverter->toString(enmType));
     63        }
     64    }
    5665}
    5766
    58 uint UIBaseMemoryEditor::maxRAMAlw() const
     67void UIGraphicsControllerEditor::sltHandleCurrentIndexChanged()
    5968{
    60     return m_pSlider ? m_pSlider->maxRAMAlw() : 0;
     69    if (m_pCombo)
     70        emit sigValueChanged(m_pCombo->itemData(m_pCombo->currentIndex()).value<KGraphicsControllerType>());
    6171}
    6272
    63 void UIBaseMemoryEditor::retranslateUi()
    64 {
    65     if (m_pLabelMemory)
    66         m_pLabelMemory->setText(tr("Base &Memory:"));
    67     if (m_pLabelMemoryMin)
    68         m_pLabelMemoryMin->setText(tr("%1 MB").arg(m_pSlider->minRAM()));
    69     if (m_pLabelMemoryMax)
    70         m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_pSlider->maxRAM()));
    71     if (m_pSpinBox)
    72         m_pSpinBox->setSuffix(QString(" %1").arg(tr("MB")));
    73 }
    74 
    75 void UIBaseMemoryEditor::sltHandleSliderChange()
    76 {
    77     /* Apply spin-box value keeping it's signals disabled: */
    78     if (m_pSpinBox && m_pSlider)
    79     {
    80         m_pSpinBox->blockSignals(true);
    81         m_pSpinBox->setValue(m_pSlider->value());
    82         m_pSpinBox->blockSignals(false);
    83     }
    84 
    85     /* Revalidate to send signal to listener: */
    86     revalidate();
    87 }
    88 
    89 void UIBaseMemoryEditor::sltHandleSpinBoxChange()
    90 {
    91     /* Apply slider value keeping it's signals disabled: */
    92     if (m_pSpinBox && m_pSlider)
    93     {
    94         m_pSlider->blockSignals(true);
    95         m_pSlider->setValue(m_pSpinBox->value());
    96         m_pSlider->blockSignals(false);
    97     }
    98 
    99     /* Revalidate to send signal to listener: */
    100     revalidate();
    101 }
    102 
    103 void UIBaseMemoryEditor::prepare()
     73void UIGraphicsControllerEditor::prepare()
    10474{
    10575    /* Create main layout: */
     
    11080        int iRow = 0;
    11181
    112         /* Create memory label: */
     82        /* Create label: */
    11383        if (m_fWithLabel)
    114             m_pLabelMemory = new QLabel(this);
    115         if (m_pLabelMemory)
    116             pMainLayout->addWidget(m_pLabelMemory, 0, iRow++, 1, 1);
     84            m_pLabel = new QLabel(this);
     85        if (m_pLabel)
     86            pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
    11787
    118         /* Create slider layout: */
    119         QVBoxLayout *pSliderLayout = new QVBoxLayout;
    120         if (pSliderLayout)
     88        /* Create combo layout: */
     89        QHBoxLayout *pComboLayout = new QHBoxLayout;
     90        if (pComboLayout)
    12191        {
    122             pSliderLayout->setContentsMargins(0, 0, 0, 0);
    123 
    124             /* Create memory slider: */
    125             m_pSlider = new UIBaseMemorySlider(this);
    126             if (m_pSlider)
     92            /* Create combo: */
     93            m_pCombo = new QIComboBox(this);
     94            if (m_pCombo)
    12795            {
    128                 m_pSlider->setMinimumWidth(150);
    129                 connect(m_pSlider, &UIBaseMemorySlider::valueChanged,
    130                         this, &UIBaseMemoryEditor::sltHandleSliderChange);
    131                 pSliderLayout->addWidget(m_pSlider);
     96                setFocusProxy(m_pCombo->focusProxy());
     97                connect(m_pCombo, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
     98                        this, &UIGraphicsControllerEditor::sltHandleCurrentIndexChanged);
     99                pComboLayout->addWidget(m_pCombo);
    132100            }
    133101
    134             /* Create legend layout: */
    135             QHBoxLayout *pLegendLayout = new QHBoxLayout;
    136             if (pLegendLayout)
    137             {
    138                 pLegendLayout->setContentsMargins(0, 0, 0, 0);
     102            /* Add stretch: */
     103            pComboLayout->addStretch();
    139104
    140                 /* Create min label: */
    141                 m_pLabelMemoryMin = new QLabel(this);
    142                 if (m_pLabelMemoryMin)
    143                     pLegendLayout->addWidget(m_pLabelMemoryMin);
    144 
    145                 /* Push labels from each other: */
    146                 pLegendLayout->addStretch();
    147 
    148                 /* Create max label: */
    149                 m_pLabelMemoryMax = new QLabel(this);
    150                 if (m_pLabelMemoryMax)
    151                     pLegendLayout->addWidget(m_pLabelMemoryMax);
    152 
    153                 /* Add legend layout to slider layout: */
    154                 pSliderLayout->addLayout(pLegendLayout);
    155             }
    156 
    157             /* Add slider layout to main layout: */
    158             pMainLayout->addLayout(pSliderLayout, 0, iRow++, 2, 1);
    159         }
    160 
    161         /* Create memory spin-box: */
    162         m_pSpinBox = new QSpinBox(this);
    163         if (m_pSpinBox)
    164         {
    165             setFocusProxy(m_pSpinBox);
    166             if (m_pLabelMemory)
    167                 m_pLabelMemory->setBuddy(m_pSpinBox);
    168             m_pSpinBox->setMinimum(m_pSlider->minRAM());
    169             m_pSpinBox->setMaximum(m_pSlider->maxRAM());
    170             connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
    171                     this, &UIBaseMemoryEditor::sltHandleSpinBoxChange);
    172             pMainLayout->addWidget(m_pSpinBox, 0, iRow++, 1, 1);
     105            /* Add combo-layout into main-layout: */
     106            pMainLayout->addLayout(pComboLayout, 0, iRow++, 1, 1);
    173107        }
    174108    }
     109
     110    /* Populate combo: */
     111    populateCombo();
    175112
    176113    /* Apply language settings: */
     
    178115}
    179116
    180 void UIBaseMemoryEditor::revalidate()
     117void UIGraphicsControllerEditor::populateCombo()
    181118{
    182     if (m_pSlider)
    183         emit sigValidChanged(m_pSlider->value() < (int)m_pSlider->maxRAMAlw());
     119    for (int i = 0; i < KGraphicsControllerType_Max; ++i)
     120        m_pCombo->addItem(QString(), QVariant::fromValue(static_cast<KGraphicsControllerType>(i)));
    184121}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.h

    r80063 r80068  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIBaseMemoryEditor class declaration.
     3 * VBox Qt GUI - UIGraphicsControllerEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_widgets_UIBaseMemoryEditor_h
    19 #define FEQT_INCLUDED_SRC_widgets_UIBaseMemoryEditor_h
     18#ifndef FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h
     19#define FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2929#include "UILibraryDefs.h"
    3030
     31/* COM includes: */
     32#include "COMEnums.h"
     33
    3134/* Forward declarations: */
    3235class QLabel;
    33 class QSpinBox;
    34 class UIBaseMemorySlider;
     36class QIComboBox;
    3537
    36 /** QWidget subclass used as a base memory editor. */
    37 class SHARED_LIBRARY_STUFF UIBaseMemoryEditor : public QIWithRetranslateUI<QWidget>
     38/** QWidget subclass used as a graphics controller editor. */
     39class SHARED_LIBRARY_STUFF UIGraphicsControllerEditor : public QIWithRetranslateUI<QWidget>
    3840{
    3941    Q_OBJECT;
     
    4143signals:
    4244
    43     /** Notifies listeners about value has became @a fValid. */
    44     void sigValidChanged(bool fValid);
     45    /** Notifies listeners about @a enmValue change. */
     46    void sigValueChanged(KGraphicsControllerType enmValue);
    4547
    4648public:
    4749
    48     /** Constructs base-memory editor passing @a pParent to the base-class.
     50    /** Constructs graphics controller editor passing @a pParent to the base-class.
    4951      * @param  fWithLabel  Brings whether we should add label ourselves. */
    50     UIBaseMemoryEditor(QWidget *pParent = 0, bool fWithLabel = false);
     52    UIGraphicsControllerEditor(QWidget *pParent = 0, bool fWithLabel = false);
    5153
    52     /** Defines editor @a iValue. */
    53     void setValue(int iValue);
     54    /** Defines editor @a enmValue. */
     55    void setValue(KGraphicsControllerType enmValue);
    5456    /** Returns editor value. */
    55     int value() const;
    56 
    57     /** Returns the maximum optimal RAM. */
    58     uint maxRAMOpt() const;
    59     /** Returns the maximum allowed RAM. */
    60     uint maxRAMAlw() const;
     57    KGraphicsControllerType value() const;
    6158
    6259protected:
     
    6764private slots:
    6865
    69     /** Handles slider value changes. */
    70     void sltHandleSliderChange();
    71     /** Handles spin-box value changes. */
    72     void sltHandleSpinBoxChange();
     66    /** Handles current index change. */
     67    void sltHandleCurrentIndexChanged();
    7368
    7469private:
     
    7671    /** Prepares all. */
    7772    void prepare();
    78 
    79     /** Revalidates and emits validity change signal. */
    80     void revalidate();
     73    /** Populates combo. */
     74    void populateCombo();
    8175
    8276    /** Holds whether descriptive label should be created. */
    8377    bool  m_fWithLabel;
    8478
    85     /** Holds the memory label instance. */
    86     QLabel             *m_pLabelMemory;
    87     /** Holds the memory slider instance. */
    88     UIBaseMemorySlider *m_pSlider;
    89     /** Holds minimum memory label instance. */
    90     QLabel             *m_pLabelMemoryMin;
    91     /** Holds maximum memory label instance. */
    92     QLabel             *m_pLabelMemoryMax;
    93     /** Holds the memory spin-box instance. */
    94     QSpinBox           *m_pSpinBox;
     79    /** Holds the label instance. */
     80    QLabel     *m_pLabel;
     81    /** Holds the combo instance. */
     82    QIComboBox *m_pCombo;
    9583};
    9684
    97 #endif /* !FEQT_INCLUDED_SRC_widgets_UIBaseMemoryEditor_h */
     85#endif /* !FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h */
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