Changeset 94362 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 24, 2022 7:03:55 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r94361 r94362 909 909 src/settings/editors/UIMachineDisplayScreenFeaturesEditor.h \ 910 910 src/settings/editors/UIMaximumGuestScreenSizeEditor.h \ 911 src/settings/editors/UIMonitorCountEditor.h \ 911 912 src/settings/editors/UINameAndSystemEditor.h \ 912 913 src/settings/editors/UINetworkAttachmentEditor.h \ … … 1466 1467 src/settings/editors/UIMachineDisplayScreenFeaturesEditor.cpp \ 1467 1468 src/settings/editors/UIMaximumGuestScreenSizeEditor.cpp \ 1469 src/settings/editors/UIMonitorCountEditor.cpp \ 1468 1470 src/settings/editors/UINameAndSystemEditor.cpp \ 1469 1471 src/settings/editors/UINetworkAttachmentEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMonitorCountEditor.cpp
r94361 r94362 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI VideoMemoryEditor class implementation.3 * VBox Qt GUI - UIMonitorCountEditor class implementation. 4 4 */ 5 5 … … 18 18 /* Qt includes: */ 19 19 #include <QGridLayout> 20 #include <QHBoxLayout>21 20 #include <QLabel> 22 21 #include <QSpinBox> 23 #include <QVBoxLayout>24 22 25 23 /* GUI includes: */ 26 24 #include "QIAdvancedSlider.h" 27 25 #include "UICommon.h" 28 #include "UIVideoMemoryEditor.h" 26 #include "UIDesktopWidgetWatchdog.h" 27 #include "UIMonitorCountEditor.h" 29 28 30 29 /* COM includes: */ 30 #include "COMEnums.h" 31 31 #include "CSystemProperties.h" 32 32 33 33 34 UI VideoMemoryEditor::UIVideoMemoryEditor(QWidget *pParent /* = 0 */)34 UIMonitorCountEditor::UIMonitorCountEditor(QWidget *pParent /* = 0 */) 35 35 : QIWithRetranslateUI<QWidget>(pParent) 36 , m_comGuestOSType(CGuestOSType()) 37 , m_cGuestScreenCount(1) 38 , m_enmGraphicsControllerType(KGraphicsControllerType_Null) 39 #ifdef VBOX_WITH_3D_ACCELERATION 40 , m_f3DAccelerationSupported(false) 41 , m_f3DAccelerationEnabled(false) 42 #endif 43 , m_iMinVRAM(0) 44 , m_iMaxVRAM(0) 45 , m_iMaxVRAMVisible(0) 46 , m_iInitialVRAM(0) 36 , m_iValue(1) 47 37 , m_pLayout(0) 48 , m_pLabel Memory(0)38 , m_pLabel(0) 49 39 , m_pSlider(0) 50 , m_pLabelMemoryMin(0)51 , m_pLabelMemoryMax(0)52 40 , m_pSpinBox(0) 41 , m_pLabelMin(0) 42 , m_pLabelMax(0) 53 43 { 54 44 prepare(); 55 45 } 56 46 57 void UI VideoMemoryEditor::setValue(int iValue)47 void UIMonitorCountEditor::setValue(int iValue) 58 48 { 59 if (m_ pSlider)49 if (m_iValue != iValue) 60 50 { 61 m_iInitialVRAM = RT_MIN(iValue, m_iMaxVRAM); 62 m_pSlider->setValue(m_iInitialVRAM); 51 m_iValue = iValue; 52 if (m_pSlider) 53 m_pSlider->setValue(m_iValue); 54 if (m_pSpinBox) 55 m_pSpinBox->setValue(m_iValue); 63 56 } 64 57 } 65 58 66 int UI VideoMemoryEditor::value() const59 int UIMonitorCountEditor::value() const 67 60 { 68 return m_pS lider ? m_pSlider->value() : 0;61 return m_pSpinBox ? m_pSpinBox->value() : m_iValue; 69 62 } 70 63 71 void UIVideoMemoryEditor::setGuestOSType(const CGuestOSType &comGuestOSType) 64 int UIMonitorCountEditor::minimumLabelHorizontalHint() const 72 65 { 73 /* Check if guest OS type really changed: */ 74 if (m_comGuestOSType == comGuestOSType) 75 return; 76 77 /* Remember new guest OS type: */ 78 m_comGuestOSType = comGuestOSType; 79 80 /* Update requirements: */ 81 updateRequirements(); 66 return m_pLabel->minimumSizeHint().width(); 82 67 } 83 68 84 void UIVideoMemoryEditor::setGuestScreenCount(int cGuestScreenCount) 85 { 86 /* Check if guest screen count really changed: */ 87 if (m_cGuestScreenCount == cGuestScreenCount) 88 return; 89 90 /* Remember new guest screen count: */ 91 m_cGuestScreenCount = cGuestScreenCount; 92 93 /* Update requirements: */ 94 updateRequirements(); 95 } 96 97 void UIVideoMemoryEditor::setGraphicsControllerType(const KGraphicsControllerType &enmGraphicsControllerType) 98 { 99 /* Check if graphics controller type really changed: */ 100 if (m_enmGraphicsControllerType == enmGraphicsControllerType) 101 return; 102 103 /* Remember new graphics controller type: */ 104 m_enmGraphicsControllerType = enmGraphicsControllerType; 105 106 /* Update requirements: */ 107 updateRequirements(); 108 } 109 110 #ifdef VBOX_WITH_3D_ACCELERATION 111 void UIVideoMemoryEditor::set3DAccelerationSupported(bool fSupported) 112 { 113 /* Check if 3D acceleration really changed: */ 114 if (m_f3DAccelerationSupported == fSupported) 115 return; 116 117 /* Remember new 3D acceleration: */ 118 m_f3DAccelerationSupported = fSupported; 119 120 /* Update requirements: */ 121 updateRequirements(); 122 } 123 124 void UIVideoMemoryEditor::set3DAccelerationEnabled(bool fEnabled) 125 { 126 /* Check if 3D acceleration really changed: */ 127 if (m_f3DAccelerationEnabled == fEnabled) 128 return; 129 130 /* Remember new 3D acceleration: */ 131 m_f3DAccelerationEnabled = fEnabled; 132 133 /* Update requirements: */ 134 updateRequirements(); 135 } 136 #endif /* VBOX_WITH_3D_ACCELERATION */ 137 138 int UIVideoMemoryEditor::minimumLabelHorizontalHint() const 139 { 140 return m_pLabelMemory->minimumSizeHint().width(); 141 } 142 143 void UIVideoMemoryEditor::setMinimumLayoutIndent(int iIndent) 69 void UIMonitorCountEditor::setMinimumLayoutIndent(int iIndent) 144 70 { 145 71 if (m_pLayout) … … 147 73 } 148 74 149 void UI VideoMemoryEditor::retranslateUi()75 void UIMonitorCountEditor::retranslateUi() 150 76 { 151 if (m_pLabel Memory)152 m_pLabel Memory->setText(tr("Video &Memory:"));77 if (m_pLabel) 78 m_pLabel->setText(tr("Mo&nitor Count:")); 153 79 154 80 if (m_pSlider) 155 m_pSlider->setToolTip(tr("Holds the amount of vi deo memoryprovided to the virtual machine."));81 m_pSlider->setToolTip(tr("Holds the amount of virtual monitors provided to the virtual machine.")); 156 82 if (m_pSpinBox) 157 m_pSpinBox->setToolTip(tr("Holds the amount of vi deo memoryprovided to the virtual machine."));83 m_pSpinBox->setToolTip(tr("Holds the amount of virtual monitors provided to the virtual machine.")); 158 84 159 if (m_pLabelMemoryMin) 160 { 161 m_pLabelMemoryMin->setText(tr("%1 MB").arg(m_iMinVRAM)); 162 m_pLabelMemoryMin->setToolTip(tr("Minimum possible video memory size.")); 163 } 164 if (m_pLabelMemoryMax) 165 { 166 m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible)); 167 m_pLabelMemoryMax->setToolTip(tr("Maximum possible video memory size.")); 168 } 169 170 if (m_pSpinBox) 171 m_pSpinBox->setSuffix(QString(" %1").arg(tr("MB"))); 85 if (m_pLabelMin) 86 m_pLabelMin->setToolTip(tr("Minimum possible monitor count.")); 87 if (m_pLabelMax) 88 m_pLabelMax->setToolTip(tr("Maximum possible monitor count.")); 172 89 } 173 90 174 void UI VideoMemoryEditor::sltHandleSliderChange()91 void UIMonitorCountEditor::sltHandleSliderChange() 175 92 { 176 /* Apply spin-box value keeping it'ssignals disabled: */93 /* Apply spin-box value keeping signals disabled: */ 177 94 if (m_pSpinBox && m_pSlider) 178 95 { … … 182 99 } 183 100 184 /* Revalidate to send signal to listener: */185 revalidate();101 /* Notify listeners about value changed: */ 102 emit sigValidChanged(); 186 103 } 187 104 188 void UI VideoMemoryEditor::sltHandleSpinBoxChange()105 void UIMonitorCountEditor::sltHandleSpinBoxChange() 189 106 { 190 /* Apply slider value keeping it'ssignals disabled: */191 if (m_pS pinBox && m_pSlider)107 /* Apply slider value keeping signals disabled: */ 108 if (m_pSlider && m_pSpinBox) 192 109 { 193 110 m_pSlider->blockSignals(true); … … 196 113 } 197 114 198 /* Revalidate to send signal to listener: */199 revalidate();115 /* Notify listeners about value changed: */ 116 emit sigValidChanged(); 200 117 } 201 118 202 void UI VideoMemoryEditor::prepare()119 void UIMonitorCountEditor::prepare() 203 120 { 204 121 /* Prepare common variables: */ 205 122 const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 206 m_iMinVRAM = comProperties.GetMinGuestVRAM();207 m_iMaxVRAM = comProperties.GetMaxGuestVRAM();208 m_iMaxVRAMVisible = m_iMaxVRAM;209 123 210 /* Create main layout: */124 /* Prepare main layout: */ 211 125 m_pLayout = new QGridLayout(this); 212 126 if (m_pLayout) 213 127 { 214 128 m_pLayout->setContentsMargins(0, 0, 0, 0); 129 m_pLayout->setColumnStretch(2, 1); // spacer between min&max labels 215 130 216 /* Create memorylabel: */217 m_pLabel Memory= new QLabel(this);218 if (m_pLabel Memory)131 /* Prepare main label: */ 132 m_pLabel = new QLabel(this); 133 if (m_pLabel) 219 134 { 220 m_pLabel Memory->setAlignment(Qt::AlignRight | Qt::AlignVCenter);221 m_pLayout->addWidget(m_pLabel Memory, 0, 0);135 m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 136 m_pLayout->addWidget(m_pLabel, 0, 0); 222 137 } 223 138 224 /* Create slider layout: */225 QVBoxLayout *pSliderLayout = new QVBoxLayout;226 if ( pSliderLayout)139 /* Prepare slider: */ 140 m_pSlider = new QIAdvancedSlider(this); 141 if (m_pSlider) 227 142 { 228 pSliderLayout->setContentsMargins(0, 0, 0, 0); 143 const uint cHostScreens = gpDesktop->screenCount(); 144 const uint cMinGuestScreens = 1; 145 const uint cMaxGuestScreens = comProperties.GetMaxGuestMonitors(); 146 const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8); 147 m_pSlider->setOrientation(Qt::Horizontal); 148 m_pSlider->setMinimum(cMinGuestScreens); 149 m_pSlider->setMaximum(cMaxGuestScreensForSlider); 150 m_pSlider->setPageStep(1); 151 m_pSlider->setSingleStep(1); 152 m_pSlider->setTickInterval(1); 153 m_pSlider->setOptimalHint(cMinGuestScreens, cHostScreens); 154 m_pSlider->setWarningHint(cHostScreens, cMaxGuestScreensForSlider); 229 155 230 /* Create memory slider: */ 231 m_pSlider = new QIAdvancedSlider(this); 232 if (m_pSlider) 233 { 234 m_pSlider->setMinimum(m_iMinVRAM); 235 m_pSlider->setMaximum(m_iMaxVRAMVisible); 236 m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible)); 237 m_pSlider->setSingleStep(m_pSlider->pageStep() / 4); 238 m_pSlider->setTickInterval(m_pSlider->pageStep()); 239 m_pSlider->setSnappingEnabled(true); 240 m_pSlider->setErrorHint(0, 1); 241 m_pSlider->setMinimumWidth(150); 242 connect(m_pSlider, &QIAdvancedSlider::valueChanged, 243 this, &UIVideoMemoryEditor::sltHandleSliderChange); 244 pSliderLayout->addWidget(m_pSlider); 245 } 246 247 /* Create legend layout: */ 248 QHBoxLayout *pLegendLayout = new QHBoxLayout; 249 if (pLegendLayout) 250 { 251 pLegendLayout->setContentsMargins(0, 0, 0, 0); 252 253 /* Create min label: */ 254 m_pLabelMemoryMin = new QLabel(this); 255 if (m_pLabelMemoryMin) 256 pLegendLayout->addWidget(m_pLabelMemoryMin); 257 258 /* Push labels from each other: */ 259 pLegendLayout->addStretch(); 260 261 /* Create max label: */ 262 m_pLabelMemoryMax = new QLabel(this); 263 if (m_pLabelMemoryMax) 264 pLegendLayout->addWidget(m_pLabelMemoryMax); 265 266 /* Add legend layout to slider layout: */ 267 pSliderLayout->addLayout(pLegendLayout); 268 } 269 270 /* Add slider layout to main layout: */ 271 m_pLayout->addLayout(pSliderLayout, 0, 1, 2, 1); 156 m_pLayout->addWidget(m_pSlider, 0, 1, 1, 3); 272 157 } 273 158 274 /* Create memoryspin-box: */159 /* Prepare spin-box: */ 275 160 m_pSpinBox = new QSpinBox(this); 276 161 if (m_pSpinBox) 277 162 { 278 setFocusProxy(m_pSpinBox); 279 if (m_pLabelMemory) 280 m_pLabelMemory->setBuddy(m_pSpinBox); 281 m_pSpinBox->setMinimum(m_iMinVRAM); 282 m_pSpinBox->setMaximum(m_iMaxVRAMVisible); 283 connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 284 this, &UIVideoMemoryEditor::sltHandleSpinBoxChange); 285 m_pLayout->addWidget(m_pSpinBox, 0, 2); 163 if (m_pLabel) 164 m_pLabel->setBuddy(m_pSpinBox); 165 m_pSpinBox->setMinimum(1); 166 m_pSpinBox->setMaximum(comProperties.GetMaxGuestMonitors()); 167 168 m_pLayout->addWidget(m_pSpinBox, 0, 4); 169 } 170 171 /* Prepare min label: */ 172 m_pLabelMin = new QLabel(this); 173 if (m_pLabelMin) 174 { 175 m_pLabelMin->setText(QString::number(1)); 176 m_pLayout->addWidget(m_pLabelMin, 1, 1); 177 } 178 179 /* Prepare max label: */ 180 m_pLabelMax = new QLabel(this); 181 if (m_pLabelMax) 182 { 183 m_pLabelMax->setText(QString::number(qMin(comProperties.GetMaxGuestMonitors(), (ULONG)8))); 184 m_pLayout->addWidget(m_pLabelMax, 1, 3); 286 185 } 287 186 } 187 188 /* Prepare connections: */ 189 if (m_pSlider) 190 connect(m_pSlider, &QIAdvancedSlider::valueChanged, 191 this, &UIMonitorCountEditor::sltHandleSliderChange); 192 if (m_pSpinBox) 193 connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 194 this, &UIMonitorCountEditor::sltHandleSpinBoxChange); 288 195 289 196 /* Apply language settings: */ 290 197 retranslateUi(); 291 198 } 292 293 void UIVideoMemoryEditor::updateRequirements()294 {295 /* Make sure guest OS type is set: */296 if (m_comGuestOSType.isNull())297 return;298 299 /* Init visible maximum VRAM: */300 m_iMaxVRAMVisible = m_cGuestScreenCount * 32;301 302 /* Get monitors count and recommended VRAM: */303 int iNeedMBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_cGuestScreenCount) / _1M;304 /* Adjust visible maximum VRAM to be no less than 128MB (if possible): */305 if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128)306 m_iMaxVRAMVisible = 128;307 308 #ifdef VBOX_WITH_3D_ACCELERATION309 if (m_f3DAccelerationEnabled && m_f3DAccelerationSupported)310 {311 /* Adjust recommended VRAM to be no less than 128MB: */312 iNeedMBytes = qMax(iNeedMBytes, 128);313 /* Adjust visible maximum VRAM to be no less than 256MB (if possible): */314 if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256)315 m_iMaxVRAMVisible = 256;316 }317 #endif318 319 /* Adjust visible maximum VRAM to be no less than initial VRAM: */320 m_iMaxVRAMVisible = qMax(m_iMaxVRAMVisible, m_iInitialVRAM);321 /* Adjust visible maximum VRAM to be no less than recommended VRAM: */322 m_iMaxVRAMVisible = qMax(m_iMaxVRAMVisible, iNeedMBytes);323 324 /* Adjust recommended VRAM to be no more than actual maximum VRAM: */325 iNeedMBytes = qMin(iNeedMBytes, m_iMaxVRAM);326 /* Adjust visible maximum VRAM to be no more than actual maximum VRAM: */327 m_iMaxVRAMVisible = qMin(m_iMaxVRAMVisible, m_iMaxVRAM);328 329 if (m_pSpinBox)330 m_pSpinBox->setMaximum(m_iMaxVRAMVisible);331 if (m_pSlider)332 {333 m_pSlider->setMaximum(m_iMaxVRAMVisible);334 m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible));335 m_pSlider->setWarningHint(1, qMin(iNeedMBytes, m_iMaxVRAMVisible));336 m_pSlider->setOptimalHint(qMin(iNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible);337 }338 if (m_pLabelMemoryMax)339 m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible));340 }341 342 void UIVideoMemoryEditor::revalidate()343 {344 if (m_pSlider)345 emit sigValidChanged( m_enmGraphicsControllerType == KGraphicsControllerType_Null346 || m_pSlider->value() > 0);347 }348 349 /* static */350 int UIVideoMemoryEditor::calculatePageStep(int iMax)351 {352 /* Reasonable max. number of page steps is 32. */353 const uint uPage = ((uint)iMax + 31) / 32;354 /* Make it a power of 2: */355 uint uP = uPage, p2 = 0x1;356 while ((uP >>= 1))357 p2 <<= 1;358 if (uPage != p2)359 p2 <<= 1;360 if (p2 < 4)361 p2 = 4;362 return (int)p2;363 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMonitorCountEditor.h
r94361 r94362 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI VideoMemoryEditor class declaration.3 * VBox Qt GUI - UIMonitorCountEditor class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UI VideoMemoryEditor_h19 #define FEQT_INCLUDED_SRC_settings_editors_UI VideoMemoryEditor_h18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_h 19 #define FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_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 #include "CGuestOSType.h"34 35 31 /* Forward declarations: */ 36 32 class QGridLayout; … … 39 35 class QIAdvancedSlider; 40 36 41 /** QWidget subclass used as a video memoryeditor. */42 class SHARED_LIBRARY_STUFF UI VideoMemoryEditor : public QIWithRetranslateUI<QWidget>37 /** QWidget subclass used as a monitor count editor. */ 38 class SHARED_LIBRARY_STUFF UIMonitorCountEditor : public QIWithRetranslateUI<QWidget> 43 39 { 44 40 Q_OBJECT; … … 46 42 signals: 47 43 48 /** Notifies listeners about value has became @a fValid. */49 void sigValidChanged( bool fValid);44 /** Notifies listeners about value changed. */ 45 void sigValidChanged(); 50 46 51 47 public: 52 48 53 /** Constructs video-memoryeditor passing @a pParent to the base-class. */54 UI VideoMemoryEditor(QWidget *pParent = 0);49 /** Constructs monitor count editor passing @a pParent to the base-class. */ 50 UIMonitorCountEditor(QWidget *pParent = 0); 55 51 56 52 /** Defines editor @a iValue. */ … … 58 54 /** Returns editor value. */ 59 55 int value() const; 60 61 /** Defines @a comGuestOSType. */62 void setGuestOSType(const CGuestOSType &comGuestOSType);63 64 /** Defines @a cGuestScreenCount. */65 void setGuestScreenCount(int cGuestScreenCount);66 67 /** Defines @a enmGraphicsControllerType. */68 void setGraphicsControllerType(const KGraphicsControllerType &enmGraphicsControllerType);69 70 #ifdef VBOX_WITH_3D_ACCELERATION71 /** Defines whether 3D acceleration is @a fSupported. */72 void set3DAccelerationSupported(bool fSupported);73 /** Defines whether 3D acceleration is @a fEnabled. */74 void set3DAccelerationEnabled(bool fEnabled);75 #endif76 56 77 57 /** Returns minimum layout hint. */ … … 97 77 void prepare(); 98 78 99 /** Update requirements. */100 void updateRequirements();101 102 79 /** Revalidates and emits validity change signal. */ 103 80 void revalidate(); 104 81 105 /** Calculates the reasonably sane slider page step. */ 106 static int calculatePageStep(int iMax); 107 108 /** Holds the guest OS type ID. */ 109 CGuestOSType m_comGuestOSType; 110 /** Holds the guest screen count. */ 111 int m_cGuestScreenCount; 112 /** Holds the graphics controller type. */ 113 KGraphicsControllerType m_enmGraphicsControllerType; 114 #ifdef VBOX_WITH_3D_ACCELERATION 115 /** Holds whether 3D acceleration is supported. */ 116 bool m_f3DAccelerationSupported; 117 /** Holds whether 3D acceleration is enabled. */ 118 bool m_f3DAccelerationEnabled; 119 #endif 120 121 /** Holds the minimum lower limit of VRAM (MiB). */ 122 int m_iMinVRAM; 123 /** Holds the maximum upper limit of VRAM (MiB). */ 124 int m_iMaxVRAM; 125 /** Holds the upper limit of VRAM (MiB) for this dialog. 126 * @note This value is lower than m_iMaxVRAM to save 127 * careless users from setting useless big values. */ 128 int m_iMaxVRAMVisible; 129 /** Holds the initial VRAM value when the dialog is opened. */ 130 int m_iInitialVRAM; 82 /** Holds the value to be selected. */ 83 int m_iValue; 131 84 132 85 /** Holds the main layout instance. */ 133 86 QGridLayout *m_pLayout; 134 /** Holds the m emorylabel instance. */135 QLabel *m_pLabel Memory;136 /** Holds the memoryslider instance. */87 /** Holds the main label instance. */ 88 QLabel *m_pLabel; 89 /** Holds the slider instance. */ 137 90 QIAdvancedSlider *m_pSlider; 138 /** Holds minimum memory label instance. */ 139 QLabel *m_pLabelMemoryMin; 140 /** Holds maximum memory label instance. */ 141 QLabel *m_pLabelMemoryMax; 142 /** Holds the memory spin-box instance. */ 91 /** Holds the spin-box instance. */ 143 92 QSpinBox *m_pSpinBox; 93 /** Holds minimum label instance. */ 94 QLabel *m_pLabelMin; 95 /** Holds maximum label instance. */ 96 QLabel *m_pLabelMax; 144 97 }; 145 98 146 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UI VideoMemoryEditor_h */99 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIMonitorCountEditor_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r94361 r94362 33 33 #include "UICommon.h" 34 34 #include "UIConverter.h" 35 #include "UIDesktopWidgetWatchdog.h"36 35 #include "UIErrorString.h" 37 36 #include "UIExtraDataManager.h" … … 43 42 #endif 44 43 #include "UIMachineSettingsDisplay.h" 44 #include "UIMonitorCountEditor.h" 45 45 #include "UIScaleFactorEditor.h" 46 46 #include "UITranslator.h" … … 306 306 , m_pTabWidget(0) 307 307 , m_pTabScreen(0) 308 , m_pLayoutScreen(0)309 308 , m_pEditorVideoMemorySize(0) 310 , m_pLabelMonitorCount(0) 311 , m_pSliderMonitorCount(0) 312 , m_pSpinboxMonitorCount(0) 313 , m_pLabelMonitorCountMin(0) 314 , m_pLabelMonitorCountMax(0) 309 , m_pEditorMonitorCount(0) 315 310 , m_pEditorScaleFactor(0) 316 311 , m_pEditorGraphicsController(0) … … 500 495 501 496 /* Load old 'Screen' data from cache: */ 502 m_p SpinboxMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount);497 m_pEditorMonitorCount->setValue(oldDisplayData.m_cGuestScreenCount); 503 498 m_pEditorScaleFactor->setScaleFactors(oldDisplayData.m_scaleFactors); 504 499 m_pEditorScaleFactor->setMonitorCount(oldDisplayData.m_cGuestScreenCount); … … 508 503 #endif 509 504 /* Push required value to m_pEditorVideoMemorySize: */ 510 sltHandle GuestScreenCountEditorChange();505 sltHandleMonitorCountChange(); 511 506 sltHandleGraphicsControllerComboChange(); 512 507 #ifdef VBOX_WITH_3D_ACCELERATION … … 566 561 /* Gather new 'Screen' data: */ 567 562 newDisplayData.m_iCurrentVRAM = m_pEditorVideoMemorySize->value(); 568 newDisplayData.m_cGuestScreenCount = m_p SpinboxMonitorCount->value();563 newDisplayData.m_cGuestScreenCount = m_pEditorMonitorCount->value(); 569 564 newDisplayData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors(); 570 565 newDisplayData.m_graphicsControllerType = m_pEditorGraphicsController->value(); … … 653 648 if (shouldWeWarnAboutLowVRAM() && !m_comGuestOSType.isNull()) 654 649 { 655 quint64 uNeedBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_p SpinboxMonitorCount->value());650 quint64 uNeedBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_pEditorMonitorCount->value()); 656 651 657 652 /* Basic video RAM amount test: */ … … 752 747 setTabOrder(pWidget, m_pTabWidget->focusProxy()); 753 748 setTabOrder(m_pTabWidget->focusProxy(), m_pEditorVideoMemorySize); 754 setTabOrder(m_pEditorVideoMemorySize, m_pSliderMonitorCount); 755 setTabOrder(m_pSliderMonitorCount, m_pSpinboxMonitorCount); 756 setTabOrder(m_pSpinboxMonitorCount, m_pEditorScaleFactor); 749 setTabOrder(m_pEditorVideoMemorySize, m_pEditorMonitorCount); 750 setTabOrder(m_pEditorMonitorCount, m_pEditorScaleFactor); 757 751 setTabOrder(m_pEditorScaleFactor, m_pEditorGraphicsController); 758 752 … … 777 771 void UIMachineSettingsDisplay::retranslateUi() 778 772 { 779 m_pLabelMonitorCount->setText(tr("Mo&nitor Count:"));780 m_pSliderMonitorCount->setToolTip(tr("Controls the amount of virtual monitors provided to the virtual machine."));781 m_pSpinboxMonitorCount->setToolTip(tr("Controls the amount of virtual monitors provided to the virtual machine."));782 m_pEditorScaleFactor->setToolTip(tr("Controls the guest screen scale factor."));783 773 m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabScreen), tr("&Screen")); 784 774 m_pCheckboxRemoteDisplay->setToolTip(tr("When checked, the VM will act as a Remote Desktop Protocol (RDP) server, allowing " … … 826 816 m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabRecording), tr("Re&cording")); 827 817 828 /* Screen stuff: */829 CSystemProperties sys = uiCommon().virtualBox().GetSystemProperties();830 m_pLabelMonitorCountMin->setText(QString::number(1));831 m_pLabelMonitorCountMax->setText(QString::number(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));832 833 818 /* Translate Remote Display auth method combo: */ 834 819 AssertPtrReturnVoid(m_pComboRemoteDisplayAuthMethod); … … 859 844 int iMinimumLayoutHint = 0; 860 845 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorVideoMemorySize->minimumLabelHorizontalHint()); 861 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_p LabelMonitorCount->minimumSizeHint().width());846 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorMonitorCount->minimumLabelHorizontalHint()); 862 847 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorScaleFactor->minimumLabelHorizontalHint()); 863 848 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorGraphicsController->minimumLabelHorizontalHint()); … … 866 851 #endif 867 852 m_pEditorVideoMemorySize->setMinimumLayoutIndent(iMinimumLayoutHint); 853 m_pEditorMonitorCount->setMinimumLayoutIndent(iMinimumLayoutHint); 868 854 m_pEditorScaleFactor->setMinimumLayoutIndent(iMinimumLayoutHint); 869 855 m_pEditorGraphicsController->setMinimumLayoutIndent(iMinimumLayoutHint); … … 871 857 m_pEditorDisplayScreenFeatures->setMinimumLayoutIndent(iMinimumLayoutHint); 872 858 #endif 873 m_pLayoutScreen->setColumnMinimumWidth(0, iMinimumLayoutHint);874 859 875 860 updateRecordingFileSizeHint(); … … 883 868 /* Polish 'Screen' availability: */ 884 869 m_pEditorVideoMemorySize->setEnabled(isMachineOffline()); 885 m_pLabelMonitorCount->setEnabled(isMachineOffline()); 886 m_pSliderMonitorCount->setEnabled(isMachineOffline()); 887 m_pLabelMonitorCountMin->setEnabled(isMachineOffline()); 888 m_pLabelMonitorCountMax->setEnabled(isMachineOffline()); 889 m_pSpinboxMonitorCount->setEnabled(isMachineOffline()); 870 m_pEditorMonitorCount->setEnabled(isMachineOffline()); 890 871 m_pEditorScaleFactor->setEnabled(isMachineInValidMode()); 891 872 m_pEditorGraphicsController->setEnabled(isMachineOffline()); … … 906 887 } 907 888 908 void UIMachineSettingsDisplay::sltHandleGuestScreenCountSliderChange() 909 { 910 /* Apply proposed screen-count: */ 911 m_pSpinboxMonitorCount->blockSignals(true); 912 m_pSpinboxMonitorCount->setValue(m_pSliderMonitorCount->value()); 913 m_pSpinboxMonitorCount->blockSignals(false); 914 915 /* Update Video RAM requirements: */ 916 m_pEditorVideoMemorySize->setGuestScreenCount(m_pSliderMonitorCount->value()); 917 918 /* Update recording tab screen count: */ 919 updateGuestScreenCount(); 920 921 /* Revalidate: */ 922 revalidate(); 923 } 924 925 void UIMachineSettingsDisplay::sltHandleGuestScreenCountEditorChange() 926 { 927 /* Apply proposed screen-count: */ 928 m_pSliderMonitorCount->blockSignals(true); 929 m_pSliderMonitorCount->setValue(m_pSpinboxMonitorCount->value()); 930 m_pSliderMonitorCount->blockSignals(false); 931 932 /* Update Video RAM requirements: */ 933 m_pEditorVideoMemorySize->setGuestScreenCount(m_pSpinboxMonitorCount->value()); 934 889 void UIMachineSettingsDisplay::sltHandleMonitorCountChange() 890 { 935 891 /* Update recording tab screen count: */ 936 892 updateGuestScreenCount(); … … 1093 1049 void UIMachineSettingsDisplay::prepareTabScreen() 1094 1050 { 1095 /* Prepare common variables: */1096 const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();1097 1098 1051 /* Prepare 'Screen' tab: */ 1099 1052 m_pTabScreen = new QWidget; … … 1101 1054 { 1102 1055 /* Prepare 'Screen' tab layout: */ 1103 m_pLayoutScreen = new QGridLayout(m_pTabScreen);1104 if ( m_pLayoutScreen)1056 QVBoxLayout *pLayoutScreen = new QVBoxLayout(m_pTabScreen); 1057 if (pLayoutScreen) 1105 1058 { 1106 m_pLayoutScreen->setRowStretch(8, 1);1107 1108 1059 /* Prepare video memory editor: */ 1109 1060 m_pEditorVideoMemorySize = new UIVideoMemoryEditor(m_pTabScreen); 1110 1061 if (m_pEditorVideoMemorySize) 1111 m_pLayoutScreen->addWidget(m_pEditorVideoMemorySize, 0, 0, 1, 3); 1112 1113 /* Prepare monitor count label: */ 1114 m_pLabelMonitorCount = new QLabel(m_pTabScreen); 1115 if (m_pLabelMonitorCount) 1116 { 1117 m_pLabelMonitorCount->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 1118 m_pLayoutScreen->addWidget(m_pLabelMonitorCount, 1, 0); 1119 } 1120 /* Prepare monitor count layout: */ 1121 QVBoxLayout *pLayoutMonitorCount = new QVBoxLayout; 1122 if (pLayoutMonitorCount) 1123 { 1124 pLayoutMonitorCount->setContentsMargins(0, 0, 0, 0); 1125 1126 /* Prepare monitor count slider: */ 1127 m_pSliderMonitorCount = new QIAdvancedSlider(m_pTabScreen); 1128 if (m_pSliderMonitorCount) 1129 { 1130 const uint cHostScreens = gpDesktop->screenCount(); 1131 const uint cMinGuestScreens = 1; 1132 const uint cMaxGuestScreens = comProperties.GetMaxGuestMonitors(); 1133 const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8); 1134 m_pSliderMonitorCount->setOrientation(Qt::Horizontal); 1135 m_pSliderMonitorCount->setMinimum(cMinGuestScreens); 1136 m_pSliderMonitorCount->setMaximum(cMaxGuestScreensForSlider); 1137 m_pSliderMonitorCount->setPageStep(1); 1138 m_pSliderMonitorCount->setSingleStep(1); 1139 m_pSliderMonitorCount->setTickInterval(1); 1140 m_pSliderMonitorCount->setOptimalHint(cMinGuestScreens, cHostScreens); 1141 m_pSliderMonitorCount->setWarningHint(cHostScreens, cMaxGuestScreensForSlider); 1142 1143 pLayoutMonitorCount->addWidget(m_pSliderMonitorCount); 1144 } 1145 /* Prepare monitor count scale layout: */ 1146 QHBoxLayout *pLayoutMonitorCountScale = new QHBoxLayout; 1147 if (pLayoutMonitorCountScale) 1148 { 1149 pLayoutMonitorCountScale->setContentsMargins(0, 0, 0, 0); 1150 1151 /* Prepare monitor count min label: */ 1152 m_pLabelMonitorCountMin = new QLabel(m_pTabScreen); 1153 if (m_pLabelMonitorCountMin) 1154 pLayoutMonitorCountScale->addWidget(m_pLabelMonitorCountMin); 1155 pLayoutMonitorCountScale->addStretch(); 1156 /* Prepare monitor count max label: */ 1157 m_pLabelMonitorCountMax = new QLabel(m_pTabScreen); 1158 if (m_pLabelMonitorCountMax) 1159 pLayoutMonitorCountScale->addWidget(m_pLabelMonitorCountMax); 1160 1161 pLayoutMonitorCount->addLayout(pLayoutMonitorCountScale); 1162 } 1163 1164 m_pLayoutScreen->addLayout(pLayoutMonitorCount, 1, 1, 2, 1); 1165 } 1166 /* Prepare monitor count spinbox: */ 1167 m_pSpinboxMonitorCount = new QSpinBox(m_pTabScreen); 1168 if (m_pSpinboxMonitorCount) 1169 { 1170 if (m_pLabelMonitorCount) 1171 m_pLabelMonitorCount->setBuddy(m_pSpinboxMonitorCount); 1172 m_pSpinboxMonitorCount->setMinimum(1); 1173 m_pSpinboxMonitorCount->setMaximum(comProperties.GetMaxGuestMonitors()); 1174 1175 m_pLayoutScreen->addWidget(m_pSpinboxMonitorCount, 1, 2); 1176 } 1062 pLayoutScreen->addWidget(m_pEditorVideoMemorySize); 1063 1064 /* Prepare monitor count editor: */ 1065 m_pEditorMonitorCount = new UIMonitorCountEditor(m_pTabScreen); 1066 if (m_pEditorMonitorCount) 1067 pLayoutScreen->addWidget(m_pEditorMonitorCount); 1177 1068 1178 1069 /* Prepare scale factor editor: */ 1179 1070 m_pEditorScaleFactor = new UIScaleFactorEditor(m_pTabScreen); 1180 1071 if (m_pEditorScaleFactor) 1181 m_pLayoutScreen->addWidget(m_pEditorScaleFactor, 3, 0, 1, 3);1072 pLayoutScreen->addWidget(m_pEditorScaleFactor); 1182 1073 1183 1074 /* Prepare graphics controller editor: */ 1184 1075 m_pEditorGraphicsController = new UIGraphicsControllerEditor(m_pTabScreen); 1185 1076 if (m_pEditorGraphicsController) 1186 m_pLayoutScreen->addWidget(m_pEditorGraphicsController, 4, 0, 1, 3);1077 pLayoutScreen->addWidget(m_pEditorGraphicsController); 1187 1078 1188 1079 #ifdef VBOX_WITH_3D_ACCELERATION … … 1190 1081 m_pEditorDisplayScreenFeatures = new UIMachineDisplayScreenFeaturesEditor(m_pTabScreen); 1191 1082 if (m_pEditorDisplayScreenFeatures) 1192 m_pLayoutScreen->addWidget(m_pEditorDisplayScreenFeatures, 5, 0, 1, 2);1083 pLayoutScreen->addWidget(m_pEditorDisplayScreenFeatures); 1193 1084 #endif /* VBOX_WITH_3D_ACCELERATION */ 1085 1086 pLayoutScreen->addStretch(); 1194 1087 } 1195 1088 … … 1677 1570 connect(m_pEditorVideoMemorySize, &UIVideoMemoryEditor::sigValidChanged, 1678 1571 this, &UIMachineSettingsDisplay::revalidate); 1679 connect(m_pSliderMonitorCount, &QIAdvancedSlider::valueChanged, 1680 this, &UIMachineSettingsDisplay::sltHandleGuestScreenCountSliderChange); 1681 connect(m_pSpinboxMonitorCount, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 1682 this, &UIMachineSettingsDisplay::sltHandleGuestScreenCountEditorChange); 1572 connect(m_pEditorMonitorCount, &UIMonitorCountEditor::sigValidChanged, 1573 this, &UIMachineSettingsDisplay::sltHandleMonitorCountChange); 1683 1574 connect(m_pEditorGraphicsController, &UIGraphicsControllerEditor::sigValueChanged, 1684 1575 this, &UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange); … … 1769 1660 /* Update copy of the cached item to get the desired result: */ 1770 1661 QVector<BOOL> screens = m_pCache->base().m_vecRecordingScreens; 1771 screens.resize(m_p SpinboxMonitorCount->value());1662 screens.resize(m_pEditorMonitorCount->value()); 1772 1663 m_pScrollerRecordingScreens->setValue(screens); 1773 m_pEditorScaleFactor->setMonitorCount(m_p SpinboxMonitorCount->value());1664 m_pEditorScaleFactor->setMonitorCount(m_pEditorMonitorCount->value()); 1774 1665 } 1775 1666 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h
r94361 r94362 33 33 class QLabel; 34 34 class QLineEdit; 35 class QGridLayout;36 35 class QSpinBox; 37 36 class QStackedLayout; … … 46 45 class UIMachineDisplayScreenFeaturesEditor; 47 46 #endif 47 class UIMonitorCountEditor; 48 48 class UIScaleFactorEditor; 49 49 class UIVideoMemoryEditor; … … 108 108 private slots: 109 109 110 /** Handles Guest Screen count slider change. */ 111 void sltHandleGuestScreenCountSliderChange(); 112 /** Handles Guest Screen count editor change. */ 113 void sltHandleGuestScreenCountEditorChange(); 110 /** Handles monitor count change. */ 111 void sltHandleMonitorCountChange(); 114 112 /** Handles Graphics Controller combo change. */ 115 113 void sltHandleGraphicsControllerComboChange(); … … 202 200 /** Holds the 'Screen' tab instance. */ 203 201 QWidget *m_pTabScreen; 204 /** Holds the 'Screen' layout instance. */205 QGridLayout *m_pLayoutScreen;206 202 /** Holds the video memory size editor instance. */ 207 203 UIVideoMemoryEditor *m_pEditorVideoMemorySize; 208 /** Holds the monitor count label instance. */209 QLabel *m_pLabelMonitorCount;210 /** Holds the monitor count slider instance. */211 QIAdvancedSlider *m_pSliderMonitorCount;212 204 /** Holds the monitor count spinbox instance. */ 213 QSpinBox *m_pSpinboxMonitorCount; 214 /** Holds the monitor count min label instance. */ 215 QLabel *m_pLabelMonitorCountMin; 216 /** Holds the monitor count max label instance. */ 217 QLabel *m_pLabelMonitorCountMax; 205 UIMonitorCountEditor *m_pEditorMonitorCount; 218 206 /** Holds the scale factor editor instance. */ 219 207 UIScaleFactorEditor *m_pEditorScaleFactor;
Note:
See TracChangeset
for help on using the changeset viewer.