Changeset 80043 in vbox
- Timestamp:
- Jul 29, 2019 12:16:59 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132479
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r79979 r80043 915 915 src/widgets/UISearchLineEdit.h \ 916 916 src/widgets/UIToolBar.h \ 917 src/widgets/UIVideoMemoryEditor.h \ 917 918 src/widgets/UIWarningPane.h \ 918 919 src/wizards/UIWizard.h \ … … 1407 1408 src/widgets/UIStatusBarEditorWindow.cpp \ 1408 1409 src/widgets/UIToolBar.cpp \ 1410 src/widgets/UIVideoMemoryEditor.cpp \ 1409 1411 src/widgets/UIWarningPane.cpp \ 1410 1412 src/wizards/UIWizard.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r80042 r80043 287 287 UIMachineSettingsDisplay::UIMachineSettingsDisplay() 288 288 : m_comGuestOSType(CGuestOSType()) 289 , m_iMinVRAM(0)290 , m_iMaxVRAM(0)291 , m_iMaxVRAMVisible(0)292 , m_iInitialVRAM(0)293 289 #ifdef VBOX_WITH_CRHGSMI 294 290 , m_fWddmModeSupported(false) … … 317 313 /* Remember new guest OS type: */ 318 314 m_comGuestOSType = comGuestOSType; 315 m_pVideoMemoryEditor->setGuestOSType(m_comGuestOSType); 319 316 320 317 #ifdef VBOX_WITH_CRHGSMI … … 322 319 const QString strGuestOSTypeId = m_comGuestOSType.isNotNull() ? m_comGuestOSType.GetId() : QString(); 323 320 m_fWddmModeSupported = UICommon::isWddmCompatibleOsType(strGuestOSTypeId); 321 m_pVideoMemoryEditor->set3DAccelerationSupported(m_fWddmModeSupported); 324 322 #endif 325 323 #ifdef VBOX_WITH_VIDEOHWACCEL … … 327 325 const QString strGuestOSTypeFamily = m_comGuestOSType.isNotNull() ? m_comGuestOSType.GetFamilyId() : QString(); 328 326 m_f2DVideoAccelerationSupported = strGuestOSTypeFamily == "Windows"; 329 #endif 330 331 /* Recheck video RAM requirement: */ 332 checkVRAMRequirements(); 327 m_pVideoMemoryEditor->set2DVideoAccelerationSupported(m_f2DVideoAccelerationSupported); 328 #endif 333 329 334 330 /* Revalidate: */ … … 410 406 } 411 407 412 /* Gather other old display data: */413 m_iInitialVRAM = RT_MIN(oldDisplayData.m_iCurrentVRAM, m_iMaxVRAM);414 415 408 /* Cache old display data: */ 416 409 m_pCache->cacheInitialData(oldDisplayData); … … 436 429 m_pCheckbox2DVideo->setChecked(oldDisplayData.m_f2dVideoAccelerationEnabled); 437 430 #endif 431 /* Push required value to m_pVideoMemoryEditor: */ 432 sltHandleGuestScreenCountEditorChange(); 433 sltHandleGraphicsControllerComboChange(); 434 #ifdef VBOX_WITH_CRHGSMI 435 sltHandle3DAccelerationCheckboxChange(); 436 #endif 437 #ifdef VBOX_WITH_VIDEOHWACCEL 438 sltHandle2DVideoAccelerationCheckboxChange(); 439 #endif 438 440 // Should be the last one for this tab, since it depends on some of others: 439 m_p EditorVideoMemorySize->setValue(oldDisplayData.m_iCurrentVRAM);441 m_pVideoMemoryEditor->setValue(oldDisplayData.m_iCurrentVRAM); 440 442 441 443 /* If remote display server is supported: */ … … 487 489 488 490 /* Gather new 'Screen' data: */ 489 newDisplayData.m_iCurrentVRAM = m_p EditorVideoMemorySize->value();491 newDisplayData.m_iCurrentVRAM = m_pVideoMemoryEditor->value(); 490 492 newDisplayData.m_cGuestScreenCount = m_pEditorVideoScreenCount->value(); 491 493 newDisplayData.m_scaleFactors = m_pScaleFactorEditor->scaleFactors(); … … 566 568 bool UIMachineSettingsDisplay::validate(QList<UIValidationMessage> &messages) 567 569 { 568 /* Check if video RAM requirement changed first: */569 checkVRAMRequirements();570 571 570 /* Pass by default: */ 572 571 bool fPass = true; … … 584 583 585 584 /* Basic video RAM amount test: */ 586 if ((quint64)m_p EditorVideoMemorySize->value() * _1M < uNeedBytes)585 if ((quint64)m_pVideoMemoryEditor->value() * _1M < uNeedBytes) 587 586 { 588 587 message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory " … … 595 594 { 596 595 uNeedBytes = qMax(uNeedBytes, (quint64) 128 * _1M); 597 if ((quint64)m_p EditorVideoMemorySize->value() * _1M < uNeedBytes)596 if ((quint64)m_pVideoMemoryEditor->value() * _1M < uNeedBytes) 598 597 { 599 598 message.second << tr("The virtual machine is set up to use hardware graphics acceleration " … … 609 608 { 610 609 uNeedBytes += VBox2DHelpers::required2DOffscreenVideoMemory(); 611 if ((quint64)m_p EditorVideoMemorySize->value() * _1M < uNeedBytes)610 if ((quint64)m_pVideoMemoryEditor->value() * _1M < uNeedBytes) 612 611 { 613 612 message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory " … … 689 688 /* Screen tab-order: */ 690 689 setTabOrder(pWidget, m_pTabWidget->focusProxy()); 691 setTabOrder(m_pTabWidget->focusProxy(), m_pSliderVideoMemorySize); 692 setTabOrder(m_pSliderVideoMemorySize, m_pEditorVideoMemorySize); 693 setTabOrder(m_pEditorVideoMemorySize, m_pSliderVideoScreenCount); 690 setTabOrder(m_pTabWidget->focusProxy(), m_pVideoMemoryEditor); 691 setTabOrder(m_pVideoMemoryEditor, m_pSliderVideoScreenCount); 694 692 setTabOrder(m_pSliderVideoScreenCount, m_pEditorVideoScreenCount); 695 693 setTabOrder(m_pEditorVideoScreenCount, m_pScaleFactorEditor); … … 721 719 /* Screen stuff: */ 722 720 CSystemProperties sys = uiCommon().virtualBox().GetSystemProperties(); 723 m_pEditorVideoMemorySize->setSuffix(QString(" %1").arg(tr("MB")));724 m_pLabelVideoMemorySizeMin->setText(tr("%1 MB").arg(m_iMinVRAM));725 m_pLabelVideoMemorySizeMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible));726 721 m_pLabelVideoScreenCountMin->setText(QString::number(1)); 727 722 m_pLabelVideoScreenCountMax->setText(QString::number(qMin(sys.GetMaxGuestMonitors(), (ULONG)8))); … … 762 757 763 758 /* Polish 'Screen' availability: */ 764 m_pLabelVideoMemorySize->setEnabled(isMachineOffline()); 765 m_pSliderVideoMemorySize->setEnabled(isMachineOffline()); 766 m_pLabelVideoMemorySizeMin->setEnabled(isMachineOffline()); 767 m_pLabelVideoMemorySizeMax->setEnabled(isMachineOffline()); 768 m_pEditorVideoMemorySize->setEnabled(isMachineOffline()); 759 m_pVideoMemoryLabel->setEnabled(isMachineOffline()); 760 m_pVideoMemoryEditor->setEnabled(isMachineOffline()); 769 761 m_pLabelVideoScreenCount->setEnabled(isMachineOffline()); 770 762 m_pSliderVideoScreenCount->setEnabled(isMachineOffline()); … … 798 790 } 799 791 800 void UIMachineSettingsDisplay::sltHandleVideoMemorySizeSliderChange()801 {802 /* Apply proposed memory-size: */803 m_pEditorVideoMemorySize->blockSignals(true);804 m_pEditorVideoMemorySize->setValue(m_pSliderVideoMemorySize->value());805 m_pEditorVideoMemorySize->blockSignals(false);806 807 /* Revalidate: */808 revalidate();809 }810 811 void UIMachineSettingsDisplay::sltHandleVideoMemorySizeEditorChange()812 {813 /* Apply proposed memory-size: */814 m_pSliderVideoMemorySize->blockSignals(true);815 m_pSliderVideoMemorySize->setValue(m_pEditorVideoMemorySize->value());816 m_pSliderVideoMemorySize->blockSignals(false);817 818 /* Revalidate: */819 revalidate();820 }821 822 792 void UIMachineSettingsDisplay::sltHandleGuestScreenCountSliderChange() 823 793 { … … 828 798 829 799 /* Update Video RAM requirements: */ 830 checkVRAMRequirements();800 m_pVideoMemoryEditor->setGuestScreenCount(m_pSliderVideoScreenCount->value()); 831 801 832 802 /* Update recording tab screen count: */ … … 845 815 846 816 /* Update Video RAM requirements: */ 847 checkVRAMRequirements();817 m_pVideoMemoryEditor->setGuestScreenCount(m_pEditorVideoScreenCount->value()); 848 818 849 819 /* Update recording tab screen count: */ … … 853 823 revalidate(); 854 824 } 825 826 void UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange() 827 { 828 /* Update Video RAM requirements: */ 829 m_pVideoMemoryEditor->setGraphicsControllerType(gpConverter->fromString<KGraphicsControllerType>(m_pComboGraphicsControllerType->currentText())); 830 831 /* Revalidate: */ 832 revalidate(); 833 } 834 835 #ifdef VBOX_WITH_CRHGSMI 836 void UIMachineSettingsDisplay::sltHandle3DAccelerationCheckboxChange() 837 { 838 /* Update Video RAM requirements: */ 839 m_pVideoMemoryEditor->set3DAccelerationEnabled(m_pCheckbox3D->isChecked()); 840 841 /* Revalidate: */ 842 revalidate(); 843 } 844 #endif /* VBOX_WITH_CRHGSMI */ 845 846 #ifdef VBOX_WITH_VIDEOHWACCEL 847 void UIMachineSettingsDisplay::sltHandle2DVideoAccelerationCheckboxChange() 848 { 849 /* Update Video RAM requirements: */ 850 m_pVideoMemoryEditor->set2DVideoAccelerationEnabled(m_pCheckbox2DVideo->isChecked()); 851 852 /* Revalidate: */ 853 revalidate(); 854 } 855 #endif /* VBOX_WITH_VIDEOHWACCEL */ 855 856 856 857 void UIMachineSettingsDisplay::sltHandleRecordingCheckboxToggle() … … 980 981 /* Prepare common variables: */ 981 982 const CSystemProperties sys = uiCommon().virtualBox().GetSystemProperties(); 982 m_iMinVRAM = sys.GetMinGuestVRAM();983 m_iMaxVRAM = sys.GetMaxGuestVRAM();984 m_iMaxVRAMVisible = m_iMaxVRAM;985 983 986 984 /* Tab and it's layout created in the .ui file. */ 987 985 { 988 /* Memory-size slider created in the .ui file. */ 989 AssertPtrReturnVoid(m_pSliderVideoMemorySize); 990 { 991 /* Configure slider: */ 992 m_pSliderVideoMemorySize->setMinimum(m_iMinVRAM); 993 m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible); 994 m_pSliderVideoMemorySize->setPageStep(calculatePageStep(m_iMaxVRAMVisible)); 995 m_pSliderVideoMemorySize->setSingleStep(m_pSliderVideoMemorySize->pageStep() / 4); 996 m_pSliderVideoMemorySize->setTickInterval(m_pSliderVideoMemorySize->pageStep()); 997 m_pSliderVideoMemorySize->setSnappingEnabled(true); 998 m_pSliderVideoMemorySize->setErrorHint(0, 1); 999 } 1000 1001 /* Memory-size editor created in the .ui file. */ 1002 AssertPtrReturnVoid(m_pEditorVideoMemorySize); 1003 { 1004 /* Configure editor: */ 1005 uiCommon().setMinimumWidthAccordingSymbolCount(m_pEditorVideoMemorySize, 7); 1006 m_pEditorVideoMemorySize->setMinimum(m_iMinVRAM); 1007 m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible); 986 /* Video-memory label and editor created in the .ui file. */ 987 AssertPtrReturnVoid(m_pVideoMemoryLabel); 988 AssertPtrReturnVoid(m_pVideoMemoryEditor); 989 { 990 /* Configure label & editor: */ 991 m_pVideoMemoryLabel->setBuddy(m_pVideoMemoryEditor->focusProxy()); 1008 992 } 1009 993 … … 1032 1016 m_pEditorVideoScreenCount->setMinimum(1); 1033 1017 m_pEditorVideoScreenCount->setMaximum(cMaxGuestScreens); 1034 }1035 1036 /* Scale-factor editor created in the .ui file. */1037 AssertPtrReturnVoid(m_pScaleFactorEditor);1038 {1039 /* Configure editor: */1040 m_pScaleFactorEditor->setSpinBoxWidthHint(m_pEditorVideoMemorySize->minimumWidth());1041 1018 } 1042 1019 … … 1218 1195 { 1219 1196 /* Configure 'Screen' connections: */ 1220 connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeSliderChange())); 1221 connect(m_pEditorVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeEditorChange())); 1197 connect(m_pVideoMemoryEditor, &UIVideoMemoryEditor::sigValidChanged, this, &UIMachineSettingsDisplay::revalidate); 1222 1198 connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountSliderChange())); 1223 1199 connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenCountEditorChange())); 1200 connect(m_pComboGraphicsControllerType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 1201 this, &UIMachineSettingsDisplay::sltHandleGraphicsControllerComboChange); 1224 1202 #ifdef VBOX_WITH_CRHGSMI 1225 1203 connect(m_pCheckbox3D, &QCheckBox::stateChanged, 1226 this, &UIMachineSettingsDisplay:: revalidate);1204 this, &UIMachineSettingsDisplay::sltHandle3DAccelerationCheckboxChange); 1227 1205 #endif 1228 1206 #ifdef VBOX_WITH_VIDEOHWACCEL 1229 1207 connect(m_pCheckbox2DVideo, &QCheckBox::stateChanged, 1230 this, &UIMachineSettingsDisplay:: revalidate);1208 this, &UIMachineSettingsDisplay::sltHandle2DVideoAccelerationCheckboxChange); 1231 1209 #endif 1232 1210 … … 1257 1235 } 1258 1236 1259 void UIMachineSettingsDisplay::checkVRAMRequirements()1260 {1261 /* Make sure guest OS type is set: */1262 if (m_comGuestOSType.isNull())1263 return;1264 1265 /* Get monitors count and base video memory requirements: */1266 const int cGuestScreenCount = m_pEditorVideoScreenCount->value();1267 quint64 uNeedMBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), cGuestScreenCount) / _1M;1268 1269 /* Initial value: */1270 m_iMaxVRAMVisible = cGuestScreenCount * 32;1271 1272 /* No more than m_iMaxVRAM: */1273 if (m_iMaxVRAMVisible > m_iMaxVRAM)1274 m_iMaxVRAMVisible = m_iMaxVRAM;1275 1276 /* No less than 128MB (if possible): */1277 if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128)1278 m_iMaxVRAMVisible = 128;1279 1280 /* No less than initial VRAM size (wtf?): */1281 if (m_iMaxVRAMVisible < m_iInitialVRAM)1282 m_iMaxVRAMVisible = m_iInitialVRAM;1283 1284 #ifdef VBOX_WITH_VIDEOHWACCEL1285 if (m_pCheckbox2DVideo->isChecked() && m_f2DVideoAccelerationSupported)1286 {1287 uNeedMBytes += VBox2DHelpers::required2DOffscreenVideoMemory() / _1M;1288 }1289 #endif1290 1291 #ifdef VBOX_WITH_CRHGSMI1292 if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported)1293 {1294 uNeedMBytes = qMax(uNeedMBytes, (quint64) 128);1295 /* No less than 256MB (if possible): */1296 if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256)1297 m_iMaxVRAMVisible = 256;1298 }1299 #endif1300 1301 m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible);1302 m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible);1303 m_pSliderVideoMemorySize->setPageStep(calculatePageStep(m_iMaxVRAMVisible));1304 m_pSliderVideoMemorySize->setWarningHint(1, qMin((int)uNeedMBytes, m_iMaxVRAMVisible));1305 m_pSliderVideoMemorySize->setOptimalHint(qMin((int)uNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible);1306 m_pLabelVideoMemorySizeMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible));1307 }1308 1309 1237 bool UIMachineSettingsDisplay::shouldWeWarnAboutLowVRAM() 1310 1238 { … … 1317 1245 1318 1246 return fResult; 1319 }1320 1321 /* static */1322 int UIMachineSettingsDisplay::calculatePageStep(int iMax)1323 {1324 /* Reasonable max. number of page steps is 32. */1325 uint uPage = ((uint)iMax + 31) / 32;1326 /* Make it a power of 2: */1327 uint uP = uPage, p2 = 0x1;1328 while ((uP >>= 1))1329 p2 <<= 1;1330 if (uPage != p2)1331 p2 <<= 1;1332 if (p2 < 4)1333 p2 = 4;1334 return (int)p2;1335 1247 } 1336 1248 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h
r80042 r80043 88 88 private slots: 89 89 90 /** Handles Video Memory size slider change. */91 void sltHandleVideoMemorySizeSliderChange();92 /** Handles Video Memory size editor change. */93 void sltHandleVideoMemorySizeEditorChange();94 90 /** Handles Guest Screen count slider change. */ 95 91 void sltHandleGuestScreenCountSliderChange(); 96 92 /** Handles Guest Screen count editor change. */ 97 93 void sltHandleGuestScreenCountEditorChange(); 94 /** Handles Graphics Controller combo change. */ 95 void sltHandleGraphicsControllerComboChange(); 96 #ifdef VBOX_WITH_CRHGSMI 97 /** Handles 3D Acceleration check-box change. */ 98 void sltHandle3DAccelerationCheckboxChange(); 99 #endif 100 #ifdef VBOX_WITH_VIDEOHWACCEL 101 /** Handles 2D Video Acceleration check-box change. */ 102 void sltHandle2DVideoAccelerationCheckboxChange(); 103 #endif 98 104 99 105 /** Handles recording toggle. */ … … 130 136 void cleanup(); 131 137 132 /** Checks the VRAM requirements. */133 void checkVRAMRequirements();134 138 /** Returns whether the VRAM requirements are important. */ 135 139 bool shouldWeWarnAboutLowVRAM(); 136 /** Calculates the reasonably sane slider page step. */137 static int calculatePageStep(int iMax);138 140 139 141 /** Searches for corresponding frame size preset. */ … … 162 164 /** Holds the guest OS type ID. */ 163 165 CGuestOSType m_comGuestOSType; 164 /** Holds the minimum lower limit of VRAM (MiB). */165 int m_iMinVRAM;166 /** Holds the maximum upper limit of VRAM (MiB). */167 int m_iMaxVRAM;168 /** Holds the upper limit of VRAM (MiB) for this dialog.169 * This value is lower than m_iMaxVRAM to save careless170 * users from setting useless big values. */171 int m_iMaxVRAMVisible;172 /** Holds the initial VRAM value when the dialog is opened. */173 int m_iInitialVRAM;174 166 #ifdef VBOX_WITH_CRHGSMI 175 167 /** Holds whether the guest OS supports WDDM. */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.ui
r76184 r80043 35 35 <layout class="QGridLayout" name="m_pLayoutContainerVideo"> 36 36 <item row="0" column="0"> 37 <widget class="QLabel" name="m_p LabelVideoMemorySize">37 <widget class="QLabel" name="m_pVideoMemoryLabel"> 38 38 <property name="text"> 39 39 <string>Video &Memory:</string> … … 42 42 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 43 43 </property> 44 <property name="buddy"> 45 <cstring>m_pEditorVideoMemorySize</cstring> 46 </property> 47 </widget> 48 </item> 49 <item row="0" column="1" rowspan="2"> 50 <layout class="QGridLayout" name="m_pLayoutVideoMemorySizeSlider"> 51 <property name="spacing"> 52 <number>0</number> 53 </property> 54 <item row="0" column="0" colspan="3"> 55 <widget class="QIAdvancedSlider" name="m_pSliderVideoMemorySize"> 56 <property name="whatsThis"> 57 <string>Controls the amount of video memory provided to the virtual machine.</string> 58 </property> 59 <property name="orientation"> 60 <enum>Qt::Horizontal</enum> 61 </property> 62 </widget> 63 </item> 64 <item row="1" column="0"> 65 <widget class="QLabel" name="m_pLabelVideoMemorySizeMin"/> 66 </item> 67 <item row="1" column="1"> 68 <spacer name="m_pSpacerVideoMemorySize"> 69 <property name="orientation"> 70 <enum>Qt::Horizontal</enum> 71 </property> 72 <property name="sizeHint" stdset="0"> 73 <size> 74 <width>0</width> 75 <height>0</height> 76 </size> 77 </property> 78 </spacer> 79 </item> 80 <item row="1" column="2"> 81 <widget class="QLabel" name="m_pLabelVideoMemorySizeMax"/> 82 </item> 83 </layout> 84 </item> 85 <item row="0" column="2"> 86 <widget class="QSpinBox" name="m_pEditorVideoMemorySize"> 44 </widget> 45 </item> 46 <item row="0" column="1" rowspan="2" colspan="2"> 47 <widget class="UIVideoMemoryEditor" name="m_pVideoMemoryEditor"> 87 48 <property name="whatsThis"> 88 49 <string>Controls the amount of video memory provided to the virtual machine.</string> … … 817 778 <header>UIScaleFactorEditor.h</header> 818 779 </customwidget> 780 <customwidget> 781 <class>UIVideoMemoryEditor</class> 782 <extends>QWidget</extends> 783 <header>UIVideoMemoryEditor.h</header> 784 </customwidget> 819 785 </customwidgets> 820 786 <resources/> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVideoMemoryEditor.cpp
r79996 r80043 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI BaseMemoryEditor class implementation.3 * VBox Qt GUI - UIVideoMemoryEditor class implementation. 4 4 */ 5 5 … … 24 24 25 25 /* GUI includes: */ 26 #include "UIBaseMemoryEditor.h" 27 #include "UIBaseMemorySlider.h" 28 29 30 UIBaseMemoryEditor::UIBaseMemoryEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */) 26 #include "QIAdvancedSlider.h" 27 #include "UICommon.h" 28 #include "UIVideoMemoryEditor.h" 29 #include "VBox2DHelpers.h" 30 31 /* COM includes: */ 32 #include "CSystemProperties.h" 33 34 35 UIVideoMemoryEditor::UIVideoMemoryEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */) 31 36 : QIWithRetranslateUI<QWidget>(pParent) 32 37 , m_fWithLabel(fWithLabel) 38 , m_comGuestOSType(CGuestOSType()) 39 , m_cGuestScreenCount(1) 40 , m_enmGraphicsControllerType(KGraphicsControllerType_Null) 41 #ifdef VBOX_WITH_CRHGSMI 42 , m_f3DAccelerationSupported(false) 43 , m_f3DAccelerationEnabled(false) 44 #endif 45 #ifdef VBOX_WITH_VIDEOHWACCEL 46 , m_f2DVideoAccelerationSupported(false) 47 , m_f2DVideoAccelerationEnabled(false) 48 #endif 49 , m_iMinVRAM(0) 50 , m_iMaxVRAM(0) 51 , m_iMaxVRAMVisible(0) 52 , m_iInitialVRAM(0) 33 53 , m_pLabelMemory(0) 34 54 , m_pSlider(0) … … 40 60 } 41 61 42 void UI BaseMemoryEditor::setValue(int iValue)62 void UIVideoMemoryEditor::setValue(int iValue) 43 63 { 44 64 if (m_pSlider) 45 m_pSlider->setValue(iValue); 46 } 47 48 int UIBaseMemoryEditor::value() const 65 { 66 m_iInitialVRAM = RT_MIN(iValue, m_iMaxVRAM); 67 m_pSlider->setValue(m_iInitialVRAM); 68 } 69 } 70 71 int UIVideoMemoryEditor::value() const 49 72 { 50 73 return m_pSlider ? m_pSlider->value() : 0; 51 74 } 52 75 53 uint UIBaseMemoryEditor::maxRAMOpt() const 54 { 55 return m_pSlider ? m_pSlider->maxRAMOpt() : 0; 56 } 57 58 uint UIBaseMemoryEditor::maxRAMAlw() const 59 { 60 return m_pSlider ? m_pSlider->maxRAMAlw() : 0; 61 } 62 63 void UIBaseMemoryEditor::retranslateUi() 76 void UIVideoMemoryEditor::setGuestOSType(const CGuestOSType &comGuestOSType) 77 { 78 /* Check if guest OS type really changed: */ 79 if (m_comGuestOSType == comGuestOSType) 80 return; 81 82 /* Remember new guest OS type: */ 83 m_comGuestOSType = comGuestOSType; 84 85 /* Update requirements: */ 86 updateRequirements(); 87 } 88 89 void UIVideoMemoryEditor::setGuestScreenCount(int cGuestScreenCount) 90 { 91 /* Check if guest screen count really changed: */ 92 if (m_cGuestScreenCount == cGuestScreenCount) 93 return; 94 95 /* Remember new guest screen count: */ 96 m_cGuestScreenCount = cGuestScreenCount; 97 98 /* Update requirements: */ 99 updateRequirements(); 100 } 101 102 void UIVideoMemoryEditor::setGraphicsControllerType(const KGraphicsControllerType &enmGraphicsControllerType) 103 { 104 /* Check if graphics controller type really changed: */ 105 if (m_enmGraphicsControllerType == enmGraphicsControllerType) 106 return; 107 108 /* Remember new graphics controller type: */ 109 m_enmGraphicsControllerType = enmGraphicsControllerType; 110 111 /* Update requirements: */ 112 updateRequirements(); 113 } 114 115 #ifdef VBOX_WITH_CRHGSMI 116 void UIVideoMemoryEditor::set3DAccelerationSupported(bool fSupported) 117 { 118 /* Check if 3D acceleration really changed: */ 119 if (m_f3DAccelerationSupported == fSupported) 120 return; 121 122 /* Remember new 3D acceleration: */ 123 m_f3DAccelerationSupported = fSupported; 124 125 /* Update requirements: */ 126 updateRequirements(); 127 } 128 129 void UIVideoMemoryEditor::set3DAccelerationEnabled(bool fEnabled) 130 { 131 /* Check if 3D acceleration really changed: */ 132 if (m_f3DAccelerationEnabled == fEnabled) 133 return; 134 135 /* Remember new 3D acceleration: */ 136 m_f3DAccelerationEnabled = fEnabled; 137 138 /* Update requirements: */ 139 updateRequirements(); 140 } 141 #endif /* VBOX_WITH_CRHGSMI */ 142 143 #ifdef VBOX_WITH_VIDEOHWACCEL 144 void UIVideoMemoryEditor::set2DVideoAccelerationSupported(bool fSupported) 145 { 146 /* Check if 2D video acceleration really changed: */ 147 if (m_f2DVideoAccelerationSupported == fSupported) 148 return; 149 150 /* Remember new 2D video acceleration: */ 151 m_f2DVideoAccelerationSupported = fSupported; 152 153 /* Update requirements: */ 154 updateRequirements(); 155 } 156 157 void UIVideoMemoryEditor::set2DVideoAccelerationEnabled(bool fEnabled) 158 { 159 /* Check if 2D video acceleration really changed: */ 160 if (m_f2DVideoAccelerationEnabled == fEnabled) 161 return; 162 163 /* Remember new 2D video acceleration: */ 164 m_f2DVideoAccelerationEnabled = fEnabled; 165 166 /* Update requirements: */ 167 updateRequirements(); 168 } 169 #endif /* VBOX_WITH_VIDEOHWACCEL */ 170 171 void UIVideoMemoryEditor::retranslateUi() 64 172 { 65 173 if (m_pLabelMemory) 66 m_pLabelMemory->setText(tr(" Base&Memory:"));174 m_pLabelMemory->setText(tr("Video &Memory:")); 67 175 if (m_pLabelMemoryMin) 68 m_pLabelMemoryMin->setText(tr("%1 MB").arg(m_ pSlider->minRAM()));176 m_pLabelMemoryMin->setText(tr("%1 MB").arg(m_iMinVRAM)); 69 177 if (m_pLabelMemoryMax) 70 m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_ pSlider->maxRAM()));178 m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible)); 71 179 if (m_pSpinBox) 72 180 m_pSpinBox->setSuffix(QString(" %1").arg(tr("MB"))); 73 181 } 74 182 75 void UI BaseMemoryEditor::sltHandleSliderChange()183 void UIVideoMemoryEditor::sltHandleSliderChange() 76 184 { 77 185 /* Apply spin-box value keeping it's signals disabled: */ … … 87 195 } 88 196 89 void UI BaseMemoryEditor::sltHandleSpinBoxChange()197 void UIVideoMemoryEditor::sltHandleSpinBoxChange() 90 198 { 91 199 /* Apply slider value keeping it's signals disabled: */ … … 101 209 } 102 210 103 void UIBaseMemoryEditor::prepare() 104 { 211 void UIVideoMemoryEditor::prepare() 212 { 213 /* Prepare common variables: */ 214 const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 215 m_iMinVRAM = comProperties.GetMinGuestVRAM(); 216 m_iMaxVRAM = comProperties.GetMaxGuestVRAM(); 217 m_iMaxVRAMVisible = m_iMaxVRAM; 218 105 219 /* Create main layout: */ 106 220 QGridLayout *pMainLayout = new QGridLayout(this); … … 123 237 124 238 /* Create memory slider: */ 125 m_pSlider = new UIBaseMemorySlider(this);239 m_pSlider = new QIAdvancedSlider(this); 126 240 if (m_pSlider) 127 241 { 242 m_pSlider->setMinimum(m_iMinVRAM); 243 m_pSlider->setMaximum(m_iMaxVRAMVisible); 244 m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible)); 245 m_pSlider->setSingleStep(m_pSlider->pageStep() / 4); 246 m_pSlider->setTickInterval(m_pSlider->pageStep()); 247 m_pSlider->setSnappingEnabled(true); 248 m_pSlider->setErrorHint(0, 1); 128 249 m_pSlider->setMinimumWidth(150); 129 connect(m_pSlider, & UIBaseMemorySlider::valueChanged,130 this, &UI BaseMemoryEditor::sltHandleSliderChange);250 connect(m_pSlider, &QIAdvancedSlider::valueChanged, 251 this, &UIVideoMemoryEditor::sltHandleSliderChange); 131 252 pSliderLayout->addWidget(m_pSlider); 132 253 } … … 166 287 if (m_pLabelMemory) 167 288 m_pLabelMemory->setBuddy(m_pSpinBox); 168 m_pSpinBox->setMinimum(m_ pSlider->minRAM());169 m_pSpinBox->setMaximum(m_ pSlider->maxRAM());289 m_pSpinBox->setMinimum(m_iMinVRAM); 290 m_pSpinBox->setMaximum(m_iMaxVRAMVisible); 170 291 connect(m_pSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 171 this, &UI BaseMemoryEditor::sltHandleSpinBoxChange);292 this, &UIVideoMemoryEditor::sltHandleSpinBoxChange); 172 293 pMainLayout->addWidget(m_pSpinBox, 0, iRow++, 1, 1); 173 294 } … … 178 299 } 179 300 180 void UIBaseMemoryEditor::revalidate() 181 { 301 void UIVideoMemoryEditor::updateRequirements() 302 { 303 /* Make sure guest OS type is set: */ 304 if (m_comGuestOSType.isNull()) 305 return; 306 307 /* Get monitors count and base video memory requirements: */ 308 quint64 uNeedMBytes = UICommon::requiredVideoMemory(m_comGuestOSType.GetId(), m_cGuestScreenCount) / _1M; 309 310 /* Initial value: */ 311 m_iMaxVRAMVisible = m_cGuestScreenCount * 32; 312 313 /* No more than m_iMaxVRAM: */ 314 if (m_iMaxVRAMVisible > m_iMaxVRAM) 315 m_iMaxVRAMVisible = m_iMaxVRAM; 316 317 /* No less than 128MB (if possible): */ 318 if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128) 319 m_iMaxVRAMVisible = 128; 320 321 /* No less than initial VRAM size (wtf?): */ 322 if (m_iMaxVRAMVisible < m_iInitialVRAM) 323 m_iMaxVRAMVisible = m_iInitialVRAM; 324 325 #ifdef VBOX_WITH_CRHGSMI 326 if (m_f3DAccelerationEnabled && m_f3DAccelerationSupported) 327 { 328 uNeedMBytes = qMax(uNeedMBytes, (quint64)128); 329 /* No less than 256MB (if possible): */ 330 if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256) 331 m_iMaxVRAMVisible = 256; 332 } 333 #endif 334 335 #ifdef VBOX_WITH_VIDEOHWACCEL 336 if (m_f2DVideoAccelerationEnabled && m_f2DVideoAccelerationSupported) 337 { 338 uNeedMBytes += VBox2DHelpers::required2DOffscreenVideoMemory() / _1M; 339 } 340 #endif 341 342 if (m_pSpinBox) 343 m_pSpinBox->setMaximum(m_iMaxVRAMVisible); 182 344 if (m_pSlider) 183 emit sigValidChanged(m_pSlider->value() < (int)m_pSlider->maxRAMAlw()); 184 } 345 { 346 m_pSlider->setMaximum(m_iMaxVRAMVisible); 347 m_pSlider->setPageStep(calculatePageStep(m_iMaxVRAMVisible)); 348 m_pSlider->setWarningHint(1, qMin((int)uNeedMBytes, m_iMaxVRAMVisible)); 349 m_pSlider->setOptimalHint(qMin((int)uNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible); 350 } 351 if (m_pLabelMemoryMax) 352 m_pLabelMemoryMax->setText(tr("%1 MB").arg(m_iMaxVRAMVisible)); 353 } 354 355 void UIVideoMemoryEditor::revalidate() 356 { 357 if (m_pSlider) 358 emit sigValidChanged( m_enmGraphicsControllerType == KGraphicsControllerType_Null 359 || m_pSlider->value() > 0); 360 } 361 362 /* static */ 363 int UIVideoMemoryEditor::calculatePageStep(int iMax) 364 { 365 /* Reasonable max. number of page steps is 32. */ 366 const uint uPage = ((uint)iMax + 31) / 32; 367 /* Make it a power of 2: */ 368 uint uP = uPage, p2 = 0x1; 369 while ((uP >>= 1)) 370 p2 <<= 1; 371 if (uPage != p2) 372 p2 <<= 1; 373 if (p2 < 4) 374 p2 = 4; 375 return (int)p2; 376 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVideoMemoryEditor.h
r79996 r80043 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI BaseMemoryEditor class declaration.3 * VBox Qt GUI - UIVideoMemoryEditor 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_UIVideoMemoryEditor_h 19 #define FEQT_INCLUDED_SRC_widgets_UIVideoMemoryEditor_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 31 35 /* Forward declarations: */ 32 36 class QLabel; 33 37 class QSpinBox; 34 class UIBaseMemorySlider;38 class QIAdvancedSlider; 35 39 36 /** QWidget subclass used as a basememory editor. */37 class SHARED_LIBRARY_STUFF UI BaseMemoryEditor : public QIWithRetranslateUI<QWidget>40 /** QWidget subclass used as a video memory editor. */ 41 class SHARED_LIBRARY_STUFF UIVideoMemoryEditor : public QIWithRetranslateUI<QWidget> 38 42 { 39 43 Q_OBJECT; … … 46 50 public: 47 51 48 /** Constructs base-memory editor passing @a pParent to the base-class.52 /** Constructs video-memory editor passing @a pParent to the base-class. 49 53 * @param fWithLabel Brings whether we should add label ourselves. */ 50 UI BaseMemoryEditor(QWidget *pParent = 0, bool fWithLabel = false);54 UIVideoMemoryEditor(QWidget *pParent = 0, bool fWithLabel = false); 51 55 52 56 /** Defines editor @a iValue. */ … … 55 59 int value() const; 56 60 57 /** Returns the maximum optimal RAM. */ 58 uint maxRAMOpt() const; 59 /** Returns the maximum allowed RAM. */ 60 uint maxRAMAlw() const; 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_CRHGSMI 71 /** 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 #endif 76 77 #ifdef VBOX_WITH_VIDEOHWACCEL 78 /** Defines whether 2D video acceleration is @a fSupported. */ 79 void set2DVideoAccelerationSupported(bool fSupported); 80 /** Defines whether 2D video acceleration is @a fEnabled. */ 81 void set2DVideoAccelerationEnabled(bool fEnabled); 82 #endif 61 83 62 84 protected: … … 77 99 void prepare(); 78 100 101 /** Update requirements. */ 102 void updateRequirements(); 103 79 104 /** Revalidates and emits validity change signal. */ 80 105 void revalidate(); 106 107 /** Calculates the reasonably sane slider page step. */ 108 static int calculatePageStep(int iMax); 81 109 82 110 /** Holds whether descriptive label should be created. */ 83 111 bool m_fWithLabel; 84 112 113 /** Holds the guest OS type ID. */ 114 CGuestOSType m_comGuestOSType; 115 /** Holds the guest screen count. */ 116 int m_cGuestScreenCount; 117 /** Holds the graphics controller type. */ 118 KGraphicsControllerType m_enmGraphicsControllerType; 119 #ifdef VBOX_WITH_CRHGSMI 120 /** Holds whether 3D acceleration is supported. */ 121 bool m_f3DAccelerationSupported; 122 /** Holds whether 3D acceleration is enabled. */ 123 bool m_f3DAccelerationEnabled; 124 #endif 125 #ifdef VBOX_WITH_VIDEOHWACCEL 126 /** Holds whether 2D video acceleration is supported. */ 127 bool m_f2DVideoAccelerationSupported; 128 /** Holds whether 2D video acceleration is enabled. */ 129 bool m_f2DVideoAccelerationEnabled; 130 #endif 131 132 /** Holds the minimum lower limit of VRAM (MiB). */ 133 int m_iMinVRAM; 134 /** Holds the maximum upper limit of VRAM (MiB). */ 135 int m_iMaxVRAM; 136 /** Holds the upper limit of VRAM (MiB) for this dialog. 137 * @note This value is lower than m_iMaxVRAM to save 138 * careless users from setting useless big values. */ 139 int m_iMaxVRAMVisible; 140 /** Holds the initial VRAM value when the dialog is opened. */ 141 int m_iInitialVRAM; 142 85 143 /** Holds the memory label instance. */ 86 QLabel 144 QLabel *m_pLabelMemory; 87 145 /** Holds the memory slider instance. */ 88 UIBaseMemorySlider *m_pSlider;146 QIAdvancedSlider *m_pSlider; 89 147 /** Holds minimum memory label instance. */ 90 QLabel 148 QLabel *m_pLabelMemoryMin; 91 149 /** Holds maximum memory label instance. */ 92 QLabel 150 QLabel *m_pLabelMemoryMax; 93 151 /** Holds the memory spin-box instance. */ 94 QSpinBox 152 QSpinBox *m_pSpinBox; 95 153 }; 96 154 97 #endif /* !FEQT_INCLUDED_SRC_widgets_UI BaseMemoryEditor_h */155 #endif /* !FEQT_INCLUDED_SRC_widgets_UIVideoMemoryEditor_h */
Note:
See TracChangeset
for help on using the changeset viewer.