Changeset 80068 in vbox
- Timestamp:
- Jul 31, 2019 11:20:37 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132507
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r80043 r80068 893 893 src/widgets/UIFilePathSelector.h \ 894 894 src/widgets/UIFilmContainer.h \ 895 src/widgets/UIGraphicsControllerEditor.h \ 895 896 src/widgets/UIHostComboEditor.h \ 896 897 src/widgets/UIHotKeyEditor.h \ … … 1386 1387 src/widgets/UIFilePathSelector.cpp \ 1387 1388 src/widgets/UIFilmContainer.cpp \ 1389 src/widgets/UIGraphicsControllerEditor.cpp \ 1388 1390 src/widgets/UIHostComboEditor.cpp \ 1389 1391 src/widgets/UIHotKeyEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r80043 r80068 422 422 m_pScaleFactorEditor->setScaleFactors(oldDisplayData.m_scaleFactors); 423 423 m_pScaleFactorEditor->setMonitorCount(oldDisplayData.m_cGuestScreenCount); 424 m_p ComboGraphicsControllerType->setCurrentIndex(m_pComboGraphicsControllerType->findText(gpConverter->toString(oldDisplayData.m_graphicsControllerType)));424 m_pGraphicsControllerEditor->setValue(oldDisplayData.m_graphicsControllerType); 425 425 #ifdef VBOX_WITH_CRHGSMI 426 426 m_pCheckbox3D->setChecked(oldDisplayData.m_f3dAccelerationEnabled); … … 492 492 newDisplayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value(); 493 493 newDisplayData.m_scaleFactors = m_pScaleFactorEditor->scaleFactors(); 494 newDisplayData.m_graphicsControllerType = gpConverter->fromString<KGraphicsControllerType>(m_pComboGraphicsControllerType->currentText());494 newDisplayData.m_graphicsControllerType = m_pGraphicsControllerEditor->value(); 495 495 #ifdef VBOX_WITH_CRHGSMI 496 496 newDisplayData.m_f3dAccelerationEnabled = m_pCheckbox3D->isChecked(); … … 692 692 setTabOrder(m_pSliderVideoScreenCount, m_pEditorVideoScreenCount); 693 693 setTabOrder(m_pEditorVideoScreenCount, m_pScaleFactorEditor); 694 setTabOrder(m_pScaleFactorEditor, m_p ComboGraphicsControllerType);694 setTabOrder(m_pScaleFactorEditor, m_pGraphicsControllerEditor); 695 695 696 696 /* Remote Display tab-order: */ … … 721 721 m_pLabelVideoScreenCountMin->setText(QString::number(1)); 722 722 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));727 723 728 724 /* Remote Display stuff: */ … … 765 761 m_pEditorVideoScreenCount->setEnabled(isMachineOffline()); 766 762 m_pScaleFactorEditor->setEnabled(isMachineInValidMode()); 763 m_pGraphicsControllerLabel->setEnabled(isMachineOffline()); 764 m_pGraphicsControllerEditor->setEnabled(isMachineOffline()); 767 765 m_pLabelVideoOptions->setEnabled(isMachineOffline()); 768 766 #ifdef VBOX_WITH_CRHGSMI … … 776 774 m_pCheckbox2DVideo->hide(); 777 775 #endif 778 m_pComboGraphicsControllerType->setEnabled(isMachineOffline());779 776 780 777 /* Polish 'Remote Display' availability: */ … … 827 824 { 828 825 /* Update Video RAM requirements: */ 829 m_pVideoMemoryEditor->setGraphicsControllerType( gpConverter->fromString<KGraphicsControllerType>(m_pComboGraphicsControllerType->currentText()));826 m_pVideoMemoryEditor->setGraphicsControllerType(m_pGraphicsControllerEditor->value()); 830 827 831 828 /* Revalidate: */ … … 1018 1015 } 1019 1016 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()); 1028 1022 } 1029 1023 } … … 1198 1192 connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountSliderChange())); 1199 1193 connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountEditorChange())); 1200 connect(m_p ComboGraphicsControllerType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),1194 connect(m_pGraphicsControllerEditor, &UIGraphicsControllerEditor::sigValueChanged, 1201 1195 this, &UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange); 1202 1196 #ifdef VBOX_WITH_CRHGSMI -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui
r80043 r80068 132 132 </item> 133 133 <item row="6" column="0"> 134 <widget class="QLabel" name="m_p LabelGraphicsControllerType">134 <widget class="QLabel" name="m_pGraphicsControllerLabel"> 135 135 <property name="text"> 136 136 <string>&Graphics Controller:</string> … … 139 139 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 140 140 </property> 141 <property name="buddy">142 <cstring>m_pComboGraphicsControllerType</cstring>143 </property>144 141 </widget> 145 142 </item> 146 143 <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> 175 149 </item> 176 150 <item row="7" column="0"> … … 774 748 </customwidget> 775 749 <customwidget> 750 <class>UIGraphicsControllerEditor</class> 751 <extends>QWidget</extends> 752 <header>UIGraphicsControllerEditor.h</header> 753 </customwidget> 754 <customwidget> 776 755 <class>UIScaleFactorEditor</class> 777 756 <extends>QWidget</extends> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.cpp
r80063 r80068 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI BaseMemoryEditor class implementation.3 * VBox Qt GUI - UIGraphicsControllerEditor class implementation. 4 4 */ 5 5 … … 20 20 #include <QHBoxLayout> 21 21 #include <QLabel> 22 #include <QSpinBox>23 #include <QVBoxLayout>24 22 25 23 /* GUI includes: */ 26 #include "UIBaseMemoryEditor.h" 27 #include "UIBaseMemorySlider.h" 24 #include "QIComboBox.h" 25 #include "UIConverter.h" 26 #include "UIGraphicsControllerEditor.h" 28 27 29 28 30 UI BaseMemoryEditor::UIBaseMemoryEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)29 UIGraphicsControllerEditor::UIGraphicsControllerEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */) 31 30 : QIWithRetranslateUI<QWidget>(pParent) 32 31 , 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) 38 34 { 39 35 prepare(); 40 36 } 41 37 42 void UI BaseMemoryEditor::setValue(int iValue)38 void UIGraphicsControllerEditor::setValue(KGraphicsControllerType enmValue) 43 39 { 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 } 46 46 } 47 47 48 int UIBaseMemoryEditor::value() const48 KGraphicsControllerType UIGraphicsControllerEditor::value() const 49 49 { 50 return m_p Slider ? m_pSlider->value() : 0;50 return m_pCombo ? m_pCombo->itemData(m_pCombo->currentIndex()).value<KGraphicsControllerType>() : KGraphicsControllerType_Null; 51 51 } 52 52 53 uint UIBaseMemoryEditor::maxRAMOpt() const 53 void UIGraphicsControllerEditor::retranslateUi() 54 54 { 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 } 56 65 } 57 66 58 uint UIBaseMemoryEditor::maxRAMAlw() const 67 void UIGraphicsControllerEditor::sltHandleCurrentIndexChanged() 59 68 { 60 return m_pSlider ? m_pSlider->maxRAMAlw() : 0; 69 if (m_pCombo) 70 emit sigValueChanged(m_pCombo->itemData(m_pCombo->currentIndex()).value<KGraphicsControllerType>()); 61 71 } 62 72 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() 73 void UIGraphicsControllerEditor::prepare() 104 74 { 105 75 /* Create main layout: */ … … 110 80 int iRow = 0; 111 81 112 /* Create memorylabel: */82 /* Create label: */ 113 83 if (m_fWithLabel) 114 m_pLabel Memory= new QLabel(this);115 if (m_pLabel Memory)116 pMainLayout->addWidget(m_pLabel Memory, 0, iRow++, 1, 1);84 m_pLabel = new QLabel(this); 85 if (m_pLabel) 86 pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1); 117 87 118 /* Create sliderlayout: */119 Q VBoxLayout *pSliderLayout = new QVBoxLayout;120 if (p SliderLayout)88 /* Create combo layout: */ 89 QHBoxLayout *pComboLayout = new QHBoxLayout; 90 if (pComboLayout) 121 91 { 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) 127 95 { 128 m_pSlider->setMinimumWidth(150);129 connect(m_p Slider, &UIBaseMemorySlider::valueChanged,130 this, &UI BaseMemoryEditor::sltHandleSliderChange);131 p SliderLayout->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); 132 100 } 133 101 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(); 139 104 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); 173 107 } 174 108 } 109 110 /* Populate combo: */ 111 populateCombo(); 175 112 176 113 /* Apply language settings: */ … … 178 115 } 179 116 180 void UI BaseMemoryEditor::revalidate()117 void UIGraphicsControllerEditor::populateCombo() 181 118 { 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))); 184 121 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGraphicsControllerEditor.h
r80063 r80068 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI BaseMemoryEditor class declaration.3 * VBox Qt GUI - UIGraphicsControllerEditor class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_widgets_UI BaseMemoryEditor_h19 #define FEQT_INCLUDED_SRC_widgets_UI BaseMemoryEditor_h18 #ifndef FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h 19 #define FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 29 29 #include "UILibraryDefs.h" 30 30 31 /* COM includes: */ 32 #include "COMEnums.h" 33 31 34 /* Forward declarations: */ 32 35 class QLabel; 33 class QSpinBox; 34 class UIBaseMemorySlider; 36 class QIComboBox; 35 37 36 /** QWidget subclass used as a base memoryeditor. */37 class SHARED_LIBRARY_STUFF UI BaseMemoryEditor : public QIWithRetranslateUI<QWidget>38 /** QWidget subclass used as a graphics controller editor. */ 39 class SHARED_LIBRARY_STUFF UIGraphicsControllerEditor : public QIWithRetranslateUI<QWidget> 38 40 { 39 41 Q_OBJECT; … … 41 43 signals: 42 44 43 /** Notifies listeners about value has became @a fValid. */44 void sigVal idChanged(bool fValid);45 /** Notifies listeners about @a enmValue change. */ 46 void sigValueChanged(KGraphicsControllerType enmValue); 45 47 46 48 public: 47 49 48 /** Constructs base-memoryeditor passing @a pParent to the base-class.50 /** Constructs graphics controller editor passing @a pParent to the base-class. 49 51 * @param fWithLabel Brings whether we should add label ourselves. */ 50 UI BaseMemoryEditor(QWidget *pParent = 0, bool fWithLabel = false);52 UIGraphicsControllerEditor(QWidget *pParent = 0, bool fWithLabel = false); 51 53 52 /** Defines editor @a iValue. */53 void setValue( int iValue);54 /** Defines editor @a enmValue. */ 55 void setValue(KGraphicsControllerType enmValue); 54 56 /** 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; 61 58 62 59 protected: … … 67 64 private slots: 68 65 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(); 73 68 74 69 private: … … 76 71 /** Prepares all. */ 77 72 void prepare(); 78 79 /** Revalidates and emits validity change signal. */ 80 void revalidate(); 73 /** Populates combo. */ 74 void populateCombo(); 81 75 82 76 /** Holds whether descriptive label should be created. */ 83 77 bool m_fWithLabel; 84 78 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; 95 83 }; 96 84 97 #endif /* !FEQT_INCLUDED_SRC_widgets_UI BaseMemoryEditor_h */85 #endif /* !FEQT_INCLUDED_SRC_widgets_UIGraphicsControllerEditor_h */
Note:
See TracChangeset
for help on using the changeset viewer.