Changeset 76199 in vbox
- Timestamp:
- Dec 13, 2018 9:08:47 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
-
UIMediumSizeEditor.cpp (modified) (6 diffs)
-
UIMediumSizeEditor.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.cpp
r71922 r76199 36 36 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 37 37 38 const qulonglong UIMediumSizeEditor::m_uSectorSize = 512; 38 39 39 40 UIMediumSizeEditor::UIMediumSizeEditor(QWidget *pParent /* = 0 */) … … 108 109 /* Notify the listeners: */ 109 110 emit sigSizeChanged(m_uSize); 111 } 112 113 void UIMediumSizeEditor::sltSizeEditorEditingFinished() 114 { 115 qulonglong uSize = checkSectorSizeAlignment(m_uSize); 116 117 /* The size is already aligned to sector size: */ 118 if (uSize == m_uSize) 119 return; 120 setMediumSize(uSize); 110 121 } 111 122 … … 176 187 connect(m_pEditor, &QILineEdit::textChanged, 177 188 this, &UIMediumSizeEditor::sltSizeEditorChanged); 189 connect(m_pEditor, &QILineEdit::editingFinished, 190 this, &UIMediumSizeEditor::sltSizeEditorEditingFinished); 178 191 179 192 /* Add into layout: */ … … 229 242 int UIMediumSizeEditor::sizeMBToSlider(qulonglong uValue, int iSliderScale) 230 243 { 231 /* Make sure *any* slider value is multiple of 512: */232 uValue /= 512;244 /* Make sure *any* slider value is multiple of m_uSectorSize: */ 245 uValue /= m_uSectorSize; 233 246 234 247 /* Calculate result: */ … … 253 266 qulonglong uResult = uTickMB + (uTickMBNext - uTickMB) * iStep / iSliderScale; 254 267 255 /* Make sure *any* slider value is multiple of 512: */256 uResult *= 512;268 /* Make sure *any* slider value is multiple of m_uSectorSize: */ 269 uResult *= m_uSectorSize; 257 270 258 271 /* Return result: */ … … 266 279 m_pEditor->setToolTip(strToolTip); 267 280 } 281 282 qulonglong UIMediumSizeEditor::checkSectorSizeAlignment(qulonglong uSize) 283 { 284 if (m_uSectorSize == 0 || uSize % m_uSectorSize == 0) 285 return uSize; 286 qulonglong uNewSize = (uSize / m_uSectorSize) * m_uSectorSize; 287 return uNewSize; 288 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.h
r71922 r76199 64 64 /** Handles size editor change. */ 65 65 void sltSizeEditorChanged(const QString &strValue); 66 void sltSizeEditorEditingFinished(); 66 67 67 68 private: … … 80 81 /** Updates slider/editor tool-tips. */ 81 82 void updateSizeToolTips(qulonglong uSize); 83 /** Checks if the uSize is divisible by m_uSectorSize */ 84 qulonglong checkSectorSizeAlignment(qulonglong uSize); 82 85 86 /* Holds the block size. We force m_uSize to be multiple of this number. */ 87 static const qulonglong m_uSectorSize; 83 88 /** Holds the minimum medium size. */ 84 89 const qulonglong m_uSizeMin;
Note:
See TracChangeset
for help on using the changeset viewer.

