Changeset 71943 in vbox for trunk/src/VBox
- Timestamp:
- Apr 20, 2018 1:55:21 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71942 r71943 679 679 src/widgets/UIFilePathSelector.h \ 680 680 src/widgets/UIFilmContainer.h \ 681 src/widgets/UIGuestRAMSlider.h \ 681 682 src/widgets/UIHostComboEditor.h \ 682 683 src/widgets/UIHotKeyEditor.h \ … … 776 777 src/widgets/UIFilePathSelector.h \ 777 778 src/widgets/UIFilmContainer.h \ 779 src/widgets/UIGuestRAMSlider.h \ 778 780 src/widgets/UIHostComboEditor.h \ 779 781 src/widgets/UIHotKeyEditor.h \ … … 1056 1058 src/widgets/UISlidingWidget.cpp \ 1057 1059 src/widgets/UITabBar.cpp \ 1058 src/widgets/VBoxGuestRAMSlider.cpp \1059 1060 src/widgets/VBoxMediaComboBox.cpp \ 1060 1061 src/widgets/UIMenuToolBar.cpp \ … … 1215 1216 src/widgets/UIFilePathSelector.cpp \ 1216 1217 src/widgets/UIFilmContainer.cpp \ 1218 src/widgets/UIGuestRAMSlider.cpp \ 1217 1219 src/widgets/UIHostComboEditor.cpp \ 1218 1220 src/widgets/UIHotKeyEditor.cpp \ … … 1338 1340 src/widgets/UIFilePathSelector.cpp \ 1339 1341 src/widgets/UIFilmContainer.cpp \ 1342 src/widgets/UIGuestRAMSlider.cpp \ 1340 1343 src/widgets/UIHostComboEditor.cpp \ 1341 1344 src/widgets/UIHotKeyEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/precomp.h
r70824 r71943 639 639 #include "UIFilePathSelector.h" 640 640 #include "VBoxGlobal.h" 641 #include " VBoxGuestRAMSlider.h"641 #include "UIGuestRAMSlider.h" 642 642 //#include "VBoxIChatTheaterWrapper.h" 643 643 #include "VBoxLicenseViewer.h" -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.ui
r71027 r71943 49 49 </property> 50 50 <item> 51 <widget class=" VBoxGuestRAMSlider" name="m_pSliderMemorySize">51 <widget class="UIGuestRAMSlider" name="m_pSliderMemorySize"> 52 52 <property name="whatsThis"> 53 53 <string>Controls the amount of memory provided to the virtual machine. If you assign too much, the machine might not start.</string> … … 658 658 </customwidget> 659 659 <customwidget> 660 <class> VBoxGuestRAMSlider</class>660 <class>UIGuestRAMSlider</class> 661 661 <extends>QIAdvancedSlider</extends> 662 <header> VBoxGuestRAMSlider.h</header>662 <header>UIGuestRAMSlider.h</header> 663 663 </customwidget> 664 664 <customwidget> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestRAMSlider.cpp
r71942 r71943 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VirtualBox Qt extensions: VBoxGuestRAMSlider class implementation.3 * VBox Qt GUI - UIGuestRAMSlider class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* GUI includes: */ 23 # include "VBoxGuestRAMSlider.h"24 23 # include "VBoxGlobal.h" 24 # include "UIGuestRAMSlider.h" 25 25 26 26 /* COM includes: */ … … 30 30 31 31 32 VBoxGuestRAMSlider::VBoxGuestRAMSlider (QWidget *aParent /* = 0 */)33 : QIAdvancedSlider (aParent)34 , m MinRAM(0)35 , m MaxRAMOpt(0)36 , m MaxRAMAlw(0)37 , m MaxRAM(0)32 UIGuestRAMSlider::UIGuestRAMSlider(QWidget *pParent /* = 0 */) 33 : QIAdvancedSlider(pParent) 34 , m_uMinRAM(0) 35 , m_uMaxRAMOpt(0) 36 , m_uMaxRAMAlw(0) 37 , m_uMaxRAM(0) 38 38 { 39 init(); 39 /* Prepare: */ 40 prepare(); 40 41 } 41 42 42 VBoxGuestRAMSlider::VBoxGuestRAMSlider (Qt::Orientation aOrientation, QWidget *aParent /* = 0 */)43 : QIAdvancedSlider (aOrientation, aParent)44 , m MinRAM(0)45 , m MaxRAMOpt(0)46 , m MaxRAMAlw(0)47 , m MaxRAM(0)43 UIGuestRAMSlider::UIGuestRAMSlider(Qt::Orientation enmOrientation, QWidget *pParent /* = 0 */) 44 : QIAdvancedSlider(enmOrientation, pParent) 45 , m_uMinRAM(0) 46 , m_uMaxRAMOpt(0) 47 , m_uMaxRAMAlw(0) 48 , m_uMaxRAM(0) 48 49 { 49 init(); 50 /* Prepare: */ 51 prepare(); 50 52 } 51 53 52 uint VBoxGuestRAMSlider::minRAM() const54 uint UIGuestRAMSlider::minRAM() const 53 55 { 54 return m MinRAM;56 return m_uMinRAM; 55 57 } 56 58 57 uint VBoxGuestRAMSlider::maxRAMOpt() const59 uint UIGuestRAMSlider::maxRAMOpt() const 58 60 { 59 return m MaxRAMOpt;61 return m_uMaxRAMOpt; 60 62 } 61 63 62 uint VBoxGuestRAMSlider::maxRAMAlw() const64 uint UIGuestRAMSlider::maxRAMAlw() const 63 65 { 64 return m MaxRAMAlw;66 return m_uMaxRAMAlw; 65 67 } 66 68 67 uint VBoxGuestRAMSlider::maxRAM() const69 uint UIGuestRAMSlider::maxRAM() const 68 70 { 69 return m MaxRAM;71 return m_uMaxRAM; 70 72 } 71 73 72 void VBoxGuestRAMSlider::init()74 void UIGuestRAMSlider::prepare() 73 75 { 74 ulong fullSize = vboxGlobal().host().GetMemorySize();76 ulong uFullSize = vboxGlobal().host().GetMemorySize(); 75 77 CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); 76 m MinRAM = sys.GetMinGuestRAM();77 m MaxRAM = RT_MIN (RT_ALIGN (fullSize, _1G / _1M), sys.GetMaxGuestRAM());78 m_uMinRAM = sys.GetMinGuestRAM(); 79 m_uMaxRAM = RT_MIN(RT_ALIGN(uFullSize, _1G / _1M), sys.GetMaxGuestRAM()); 78 80 79 81 /* Come up with some nice round percent boundaries relative to … … 105 107 * Note. We might wanna put these calculations somewhere global later. */ 106 108 107 /* System RAM amount test */108 m MaxRAMAlw = (uint)(0.75 * fullSize);109 m MaxRAMOpt = (uint)(0.50 * fullSize);110 if ( fullSize < 3072)109 /* System RAM amount test: */ 110 m_uMaxRAMAlw = (uint)(0.75 * uFullSize); 111 m_uMaxRAMOpt = (uint)(0.50 * uFullSize); 112 if (uFullSize < 3072) 111 113 /* done */; 112 else if ( fullSize < 4096) /* 3GB */113 m MaxRAMAlw = (uint)(0.80 * fullSize);114 else if ( fullSize < 6144) /* 4-5GB */114 else if (uFullSize < 4096) /* 3GB */ 115 m_uMaxRAMAlw = (uint)(0.80 * uFullSize); 116 else if (uFullSize < 6144) /* 4-5GB */ 115 117 { 116 m MaxRAMAlw = (uint)(0.84 * fullSize);117 m MaxRAMOpt = (uint)(0.60 * fullSize);118 m_uMaxRAMAlw = (uint)(0.84 * uFullSize); 119 m_uMaxRAMOpt = (uint)(0.60 * uFullSize); 118 120 } 119 else if ( fullSize < 8192) /* 6-7GB */121 else if (uFullSize < 8192) /* 6-7GB */ 120 122 { 121 m MaxRAMAlw = (uint)(0.88 * fullSize);122 m MaxRAMOpt = (uint)(0.65 * fullSize);123 m_uMaxRAMAlw = (uint)(0.88 * uFullSize); 124 m_uMaxRAMOpt = (uint)(0.65 * uFullSize); 123 125 } 124 else if ( fullSize < 16384) /* 8-15GB */126 else if (uFullSize < 16384) /* 8-15GB */ 125 127 { 126 m MaxRAMAlw = (uint)(0.90 * fullSize);127 m MaxRAMOpt = (uint)(0.70 * fullSize);128 m_uMaxRAMAlw = (uint)(0.90 * uFullSize); 129 m_uMaxRAMOpt = (uint)(0.70 * uFullSize); 128 130 } 129 else if ( fullSize < 32768) /* 16-31GB */131 else if (uFullSize < 32768) /* 16-31GB */ 130 132 { 131 m MaxRAMAlw = (uint)(0.93 * fullSize);132 m MaxRAMOpt = (uint)(0.75 * fullSize);133 m_uMaxRAMAlw = (uint)(0.93 * uFullSize); 134 m_uMaxRAMOpt = (uint)(0.75 * uFullSize); 133 135 } 134 else if ( fullSize < 65536) /* 32-63GB */136 else if (uFullSize < 65536) /* 32-63GB */ 135 137 { 136 m MaxRAMAlw = (uint)(0.94 * fullSize);137 m MaxRAMOpt = (uint)(0.80 * fullSize);138 m_uMaxRAMAlw = (uint)(0.94 * uFullSize); 139 m_uMaxRAMOpt = (uint)(0.80 * uFullSize); 138 140 } 139 else if ( fullSize < 131072) /* 64-127GB */141 else if (uFullSize < 131072) /* 64-127GB */ 140 142 { 141 m MaxRAMAlw = (uint)(0.95 * fullSize);142 m MaxRAMOpt = (uint)(0.85 * fullSize);143 m_uMaxRAMAlw = (uint)(0.95 * uFullSize); 144 m_uMaxRAMOpt = (uint)(0.85 * uFullSize); 143 145 } 144 146 else /* 128GB- */ 145 147 { 146 m MaxRAMAlw = (uint)(0.96 * fullSize);147 m MaxRAMOpt = (uint)(0.90 * fullSize);148 m_uMaxRAMAlw = (uint)(0.96 * uFullSize); 149 m_uMaxRAMOpt = (uint)(0.90 * uFullSize); 148 150 } 149 151 /* Now check the calculated maximums are out of the range for the guest 150 152 * RAM. If so change it accordingly. */ 151 m MaxRAMAlw = RT_MIN (mMaxRAMAlw, mMaxRAM);152 m MaxRAMOpt = RT_MIN (mMaxRAMOpt, mMaxRAM);153 m_uMaxRAMAlw = RT_MIN(m_uMaxRAMAlw, m_uMaxRAM); 154 m_uMaxRAMOpt = RT_MIN(m_uMaxRAMOpt, m_uMaxRAM); 153 155 154 setPageStep (calcPageStep (mMaxRAM));155 setSingleStep 156 setTickInterval 156 setPageStep(calcPageStep(m_uMaxRAM)); 157 setSingleStep(pageStep() / 4); 158 setTickInterval(pageStep()); 157 159 /* Setup the scale so that ticks are at page step boundaries */ 158 setMinimum ((mMinRAM / pageStep()) * pageStep());159 setMaximum (mMaxRAM);160 setSnappingEnabled 161 setOptimalHint (mMinRAM, mMaxRAMOpt);162 setWarningHint (mMaxRAMOpt, mMaxRAMAlw);163 setErrorHint (mMaxRAMAlw, mMaxRAM);160 setMinimum((m_uMinRAM / pageStep()) * pageStep()); 161 setMaximum(m_uMaxRAM); 162 setSnappingEnabled(true); 163 setOptimalHint(m_uMinRAM, m_uMaxRAMOpt); 164 setWarningHint(m_uMaxRAMOpt, m_uMaxRAMAlw); 165 setErrorHint(m_uMaxRAMAlw, m_uMaxRAM); 164 166 } 165 167 166 /** 167 * Calculates a suitable page step size for the given max value. The returned 168 * size is so that there will be no more than 32 pages. The minimum returned 169 * page size is 4. 170 */ 171 int VBoxGuestRAMSlider::calcPageStep (int aMax) const 168 int UIGuestRAMSlider::calcPageStep(int iMaximum) const 172 169 { 173 /* reasonable max. number of page steps is 32 */ 174 uint page = ((uint) aMax + 31) / 32; 175 /* make it a power of 2 */ 176 uint p = page, p2 = 0x1; 170 /* Calculate a suitable page step size for the given max value. 171 * The returned size is so that there will be no more than 32 172 * pages. The minimum returned page size is 4. */ 173 174 /* Reasonable max. number of page steps is 32: */ 175 uint uPage = ((uint)iMaximum + 31) / 32; 176 /* Make it a power of 2: */ 177 uint p = uPage, p2 = 0x1; 177 178 while ((p >>= 1)) 178 179 p2 <<= 1; 179 if ( page != p2)180 if (uPage != p2) 180 181 p2 <<= 1; 181 182 if (p2 < 4) … … 183 184 return (int) p2; 184 185 } 185 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIGuestRAMSlider.h
r71942 r71943 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBoxGuestRAMSlider class declaration.3 * VBox Qt GUI - UIGuestRAMSlider class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 19 #ifndef __ VBoxGuestRAMSlider_h__20 #define __ VBoxGuestRAMSlider_h__19 #ifndef ___UIGuestRAMSlider_h___ 20 #define ___UIGuestRAMSlider_h___ 21 21 22 /* VBox includes*/22 /* GUI includes: */ 23 23 #include "QIAdvancedSlider.h" 24 #include "UILibraryDefs.h" 24 25 25 class VBoxGuestRAMSlider: public QIAdvancedSlider 26 /** QIAdvancedSlider subclass used as a guest RAM slider. */ 27 class SHARED_LIBRARY_STUFF UIGuestRAMSlider : public QIAdvancedSlider 26 28 { 29 Q_OBJECT; 30 27 31 public: 28 VBoxGuestRAMSlider (QWidget *aParent = 0);29 VBoxGuestRAMSlider (Qt::Orientation aOrientation, QWidget *aParent = 0);30 32 33 /** Constructs guest RAM slider passing @a pParent to the base-class. */ 34 UIGuestRAMSlider(QWidget *pParent = 0); 35 /** Constructs guest RAM slider passing @a pParent and @a enmOrientation to the base-class. */ 36 UIGuestRAMSlider(Qt::Orientation enmOrientation, QWidget *pParent = 0); 37 38 /** Returns the minimum RAM. */ 31 39 uint minRAM() const; 40 /** Returns the maximum optimal RAM. */ 32 41 uint maxRAMOpt() const; 42 /** Returns the maximum allowed RAM. */ 33 43 uint maxRAMAlw() const; 44 /** Returns the maximum possible RAM. */ 34 45 uint maxRAM() const; 35 46 36 47 private: 37 /* Private methods */38 void init();39 int calcPageStep (int aMax) const;40 48 41 /* Private member vars */ 42 uint mMinRAM; 43 uint mMaxRAMOpt; 44 uint mMaxRAMAlw; 45 uint mMaxRAM; 49 /** Prepares all. */ 50 void prepare(); 51 52 /** Calculates page step for passed @a iMaximum value. */ 53 int calcPageStep(int iMaximum) const; 54 55 /** Holds the minimum RAM. */ 56 uint m_uMinRAM; 57 /** Holds the maximum optimal RAM. */ 58 uint m_uMaxRAMOpt; 59 /** Holds the maximum allowed RAM. */ 60 uint m_uMaxRAMAlw; 61 /** Holds the maximum possible RAM. */ 62 uint m_uMaxRAM; 46 63 }; 47 64 48 #endif /* __VBoxGuestRAMSlider_h__ */ 49 65 #endif /* !___UIGuestRAMSlider_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp
r71027 r71943 32 32 # include "UIWizardNewVM.h" 33 33 # include "VBoxGlobal.h" 34 # include " VBoxGuestRAMSlider.h"34 # include "UIGuestRAMSlider.h" 35 35 # include "QIRichTextLabel.h" 36 36 … … 66 66 QGridLayout *pMemoryLayout = new QGridLayout; 67 67 { 68 m_pRamSlider = new VBoxGuestRAMSlider(this);68 m_pRamSlider = new UIGuestRAMSlider(this); 69 69 { 70 70 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); … … 102 102 103 103 /* Setup connections: */ 104 connect(m_pRamSlider, & VBoxGuestRAMSlider::valueChanged,104 connect(m_pRamSlider, &UIGuestRAMSlider::valueChanged, 105 105 this, &UIWizardNewVMPageBasic2::sltRamSliderValueChanged); 106 106 connect(m_pRamEditor, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h
r71027 r71943 23 23 24 24 /* Forward declarations: */ 25 class VBoxGuestRAMSlider;25 class UIGuestRAMSlider; 26 26 class QSpinBox; 27 27 class QLabel; … … 41 41 42 42 /* Widgets: */ 43 VBoxGuestRAMSlider *m_pRamSlider;43 UIGuestRAMSlider *m_pRamSlider; 44 44 QSpinBox *m_pRamEditor; 45 45 QLabel *m_pRamMin; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r71027 r71943 36 36 # include "UIIconPool.h" 37 37 # include "UINameAndSystemEditor.h" 38 # include " VBoxGuestRAMSlider.h"38 # include "UIGuestRAMSlider.h" 39 39 # include "VBoxMediaComboBox.h" 40 40 # include "QIToolButton.h" … … 64 64 QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt); 65 65 { 66 m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt);66 m_pRamSlider = new UIGuestRAMSlider(m_pMemoryCnt); 67 67 { 68 68 m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); … … 140 140 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, 141 141 this, &UIWizardNewVMPageExpert::sltOsTypeChanged); 142 connect(m_pRamSlider, & VBoxGuestRAMSlider::valueChanged,142 connect(m_pRamSlider, &UIGuestRAMSlider::valueChanged, 143 143 this, &UIWizardNewVMPageExpert::sltRamSliderValueChanged); 144 144 connect(m_pRamEditor, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
Note:
See TracChangeset
for help on using the changeset viewer.