Changeset 104926 in vbox
- Timestamp:
- Jun 14, 2024 3:44:31 PM (11 months ago)
- svn:sync-xref-src-repo-rev:
- 163528
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.cpp
r104697 r104926 5 5 6 6 /* 7 * Copyright (C) 2006-202 3Oracle and/or its affiliates.7 * Copyright (C) 2006-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 44 44 45 45 46 const qulonglong UIMediumSizeEditor::m_uSectorSize = 512; 46 /* static */ 47 const qulonglong UIMediumSizeEditor::s_uSectorSize = 512; 47 48 48 49 UIMediumSizeEditor::UIMediumSizeEditor(QWidget *pParent, qulonglong uMinimumSize /* = _4M */) … … 57 58 , m_pEditor(0) 58 59 { 59 /* Prepare: */60 60 prepare(); 61 QString strRegEx = QString("[^\\d%1]").arg(UITranslator::decimalSep());62 m_regExNonDigitOrSeparator = QRegularExpression(strRegEx);63 61 } 64 62 … … 110 108 QString strSizeString = ensureSizeSuffix(m_pEditor->text()); 111 109 112 113 110 m_pEditor->blockSignals(true); 114 111 int iCursorPosition = m_pEditor->cursorPosition(); … … 129 126 } 130 127 131 QString UIMediumSizeEditor::ensureSizeSuffix(const QString &strSizeString)132 {133 /* Try to update the m_strSizeSuffix: */134 if (UITranslator::hasSizeSuffix(strSizeString))135 m_strSizeSuffix = gpConverter->toString(UITranslator::parseSizeSuffix(strSizeString));136 137 QString strOnlyDigits(strSizeString);138 /* Remove any chars from the string except digits and decimal separator and then add a space and size suffix: */139 return QString("%1 %2").arg(strOnlyDigits.remove(m_regExNonDigitOrSeparator)).arg(m_strSizeSuffix);140 }141 142 128 void UIMediumSizeEditor::prepare() 143 129 { 130 /* Configure reg-exp: */ 131 m_regExNonDigitOrSeparator = QRegularExpression(QString("[^\\d%1]").arg(UITranslator::decimalSep())); 132 144 133 /* Create layout: */ 145 134 QGridLayout *pLayout = new QGridLayout(this); … … 153 142 154 143 /* Create size slider: */ 155 m_pSlider = new QSlider ;144 m_pSlider = new QSlider(this); 156 145 if (m_pSlider) 157 146 { … … 262 251 int UIMediumSizeEditor::sizeMBToSlider(qulonglong uValue, int iSliderScale) 263 252 { 264 /* Make sure *any* slider value is multiple of m_uSectorSize: */265 uValue /= m_uSectorSize;253 /* Make sure *any* slider value is multiple of s_uSectorSize: */ 254 uValue /= s_uSectorSize; 266 255 267 256 /* Calculate result: */ … … 286 275 qulonglong uResult = uTickMB + (uTickMBNext - uTickMB) * iStep / iSliderScale; 287 276 288 /* Make sure *any* slider value is multiple of m_uSectorSize: */289 uResult *= m_uSectorSize;277 /* Make sure *any* slider value is multiple of s_uSectorSize: */ 278 uResult *= s_uSectorSize; 290 279 291 280 /* Return result: */ … … 302 291 qulonglong UIMediumSizeEditor::checkSectorSizeAlignment(qulonglong uSize) 303 292 { 304 if ( m_uSectorSize == 0 || uSize % m_uSectorSize == 0)293 if (s_uSectorSize == 0 || uSize % s_uSectorSize == 0) 305 294 return uSize; 306 qulonglong uNewSize = (uSize / m_uSectorSize) * m_uSectorSize; 307 return uNewSize; 308 } 295 return (uSize / s_uSectorSize) * s_uSectorSize; 296 } 297 298 QString UIMediumSizeEditor::ensureSizeSuffix(const QString &strSizeString) 299 { 300 /* Try to update the m_strSizeSuffix: */ 301 if (UITranslator::hasSizeSuffix(strSizeString)) 302 m_strSizeSuffix = gpConverter->toString(UITranslator::parseSizeSuffix(strSizeString)); 303 304 /* Remove any chars from the string except digits and decimal separator and then add a space and size suffix: */ 305 QString strOnlyDigits(strSizeString); 306 return QString("%1 %2").arg(strOnlyDigits.remove(m_regExNonDigitOrSeparator)).arg(m_strSizeSuffix); 307 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.h
r104358 r104926 5 5 6 6 /* 7 * Copyright (C) 2006-202 3Oracle and/or its affiliates.7 * Copyright (C) 2006-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 70 70 /** Handles translation event. */ 71 71 void sltRetranslateUI(); 72 72 73 /** Handles size slider change. */ 73 74 void sltSizeSliderChanged(int iValue); … … 90 91 /** Updates slider/editor tool-tips. */ 91 92 void updateSizeToolTips(qulonglong uSize); 92 /** Checks if the uSize is divisible by m_uSectorSize */93 /** Checks if the uSize is divisible by s_uSectorSize */ 93 94 qulonglong checkSectorSizeAlignment(qulonglong uSize); 95 /** Ensures there is only proper size-suffix available. */ 94 96 QString ensureSizeSuffix(const QString &strSizeString); 95 97 96 98 /* Holds the block size. We force m_uSize to be multiple of this number. */ 97 static const qulonglong m_uSectorSize;99 static const qulonglong s_uSectorSize; 98 100 /** Holds the minimum medium size. */ 99 101 const qulonglong m_uSizeMin;
Note:
See TracChangeset
for help on using the changeset viewer.