Changeset 90967 in vbox
- Timestamp:
- Aug 27, 2021 8:37:40 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 26 edited
-
activity/overview/UIVMActivityOverviewWidget.cpp (modified) (10 diffs)
-
activity/vmactivity/UIVMActivityMonitor.cpp (modified) (6 diffs)
-
globals/UIActionPool.cpp (modified) (3 diffs)
-
globals/UICommon.cpp (modified) (3 diffs)
-
globals/UICommon.h (modified) (2 diffs)
-
globals/UICustomFileSystemModel.cpp (modified) (2 diffs)
-
globals/UIDetailsGenerator.cpp (modified) (2 diffs)
-
globals/UIErrorString.cpp (modified) (2 diffs)
-
globals/UIMessageCenter.cpp (modified) (5 diffs)
-
globals/UITranslator.cpp (modified) (4 diffs)
-
globals/UITranslator.h (modified) (3 diffs)
-
guestctrl/UIFileManagerTable.cpp (modified) (2 diffs)
-
medium/UIMedium.cpp (modified) (4 diffs)
-
medium/UIMediumDetailsWidget.cpp (modified) (3 diffs)
-
medium/UIMediumItem.cpp (modified) (2 diffs)
-
notificationcenter/UINotificationObjects.cpp (modified) (3 diffs)
-
settings/global/UIGlobalSettingsInput.cpp (modified) (4 diffs)
-
settings/machine/UIMachineSettingsDisplay.cpp (modified) (5 diffs)
-
settings/machine/UIMachineSettingsGeneral.cpp (modified) (3 diffs)
-
settings/machine/UIMachineSettingsNetwork.cpp (modified) (2 diffs)
-
settings/machine/UIMachineSettingsSerial.cpp (modified) (8 diffs)
-
settings/machine/UIMachineSettingsSystem.cpp (modified) (6 diffs)
-
snapshots/UISnapshotDetailsWidget.cpp (modified) (3 diffs)
-
snapshots/UISnapshotPane.cpp (modified) (6 diffs)
-
widgets/UIMediumSizeEditor.cpp (modified) (9 diffs)
-
widgets/UIProgressDialog.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp
r89094 r90967 32 32 /* GUI includes: */ 33 33 #include "QIDialogButtonBox.h" 34 #include "QIToolBar.h" 34 35 #include "UIActionPoolManager.h" 35 36 #include "UICommon.h" … … 38 39 #include "UIExtraDataManager.h" 39 40 #include "UIIconPool.h" 41 #include "UIMessageCenter.h" 42 #include "UITranslator.h" 43 #include "UIVirtualBoxEventHandler.h" 40 44 #include "UIVMActivityMonitor.h" 41 45 #include "UIVMActivityOverviewWidget.h" 42 #include "UIMessageCenter.h"43 #include "QIToolBar.h"44 #include "UIVirtualBoxEventHandler.h"45 46 46 47 #ifdef VBOX_WS_MAC … … 634 635 if (m_pRAMFreeLabel) 635 636 { 636 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMFree);637 QString strRAM = UITranslator::formatSize(m_hostStats.m_iRAMFree); 637 638 QString strColor = QColor(m_RAMFreeColor).name(QColor::HexRgb); 638 639 m_pRAMFreeLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(UIVMActivityOverviewWidget::tr("Free")).arg(strRAM)); … … 640 641 if (m_pRAMUsedLabel) 641 642 { 642 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMTotal - m_hostStats.m_iRAMFree);643 QString strRAM = UITranslator::formatSize(m_hostStats.m_iRAMTotal - m_hostStats.m_iRAMFree); 643 644 QString strColor = QColor(m_RAMUsedColor).name(QColor::HexRgb); 644 645 m_pRAMUsedLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(UIVMActivityOverviewWidget::tr("Used")).arg(strRAM)); … … 646 647 if (m_pRAMTotalLabel) 647 648 { 648 QString strRAM = uiCommon().formatSize(m_hostStats.m_iRAMTotal);649 QString strRAM = UITranslator::formatSize(m_hostStats.m_iRAMTotal); 649 650 m_pRAMTotalLabel->setText(QString("%1: %2").arg(UIVMActivityOverviewWidget::tr("Total")).arg(strRAM)); 650 651 } … … 653 654 if (m_pFSFreeLabel) 654 655 { 655 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSFree);656 QString strFS = UITranslator::formatSize(m_hostStats.m_iFSFree); 656 657 QString strColor = QColor(m_RAMFreeColor).name(QColor::HexRgb); 657 658 m_pFSFreeLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(UIVMActivityOverviewWidget::tr("Free")).arg(strFS)); … … 659 660 if (m_pFSUsedLabel) 660 661 { 661 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSTotal - m_hostStats.m_iFSFree);662 QString strFS = UITranslator::formatSize(m_hostStats.m_iFSTotal - m_hostStats.m_iFSFree); 662 663 QString strColor = QColor(m_RAMUsedColor).name(QColor::HexRgb); 663 664 m_pFSUsedLabel->setText(QString("<font color=\"%1\">%2: %3</font>").arg(strColor).arg(UIVMActivityOverviewWidget::tr("Used")).arg(strFS)); … … 665 666 if (m_pFSTotalLabel) 666 667 { 667 QString strFS = uiCommon().formatSize(m_hostStats.m_iFSTotal);668 QString strFS = UITranslator::formatSize(m_hostStats.m_iFSTotal); 668 669 m_pFSTotalLabel->setText(QString("%1: %2").arg(UIVMActivityOverviewWidget::tr("Total")).arg(strFS)); 669 670 } … … 1178 1179 if (m_itemList[i].isWithGuestAdditions()) 1179 1180 m_itemList[i].m_columnData[VMActivityOverviewColumn_RAMUsedAndTotal] = 1180 QString("%1/%2").arg( uiCommon().formatSize(_1K * m_itemList[i].m_uUsedRAM, iDecimalCount)).1181 arg( uiCommon().formatSize(_1K * m_itemList[i].m_uTotalRAM, iDecimalCount));1181 QString("%1/%2").arg(UITranslator::formatSize(_1K * m_itemList[i].m_uUsedRAM, iDecimalCount)). 1182 arg(UITranslator::formatSize(_1K * m_itemList[i].m_uTotalRAM, iDecimalCount)); 1182 1183 else 1183 1184 m_itemList[i].m_columnData[VMActivityOverviewColumn_RAMUsedAndTotal] = UIVMActivityOverviewWidget::tr("N/A"); … … 1190 1191 1191 1192 m_itemList[i].m_columnData[VMActivityOverviewColumn_NetworkUpRate] = 1192 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uNetworkUpRate, iDecimalCount));1193 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uNetworkUpRate, iDecimalCount)); 1193 1194 1194 1195 m_itemList[i].m_columnData[VMActivityOverviewColumn_NetworkDownRate] = 1195 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uNetworkDownRate, iDecimalCount));1196 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uNetworkDownRate, iDecimalCount)); 1196 1197 1197 1198 m_itemList[i].m_columnData[VMActivityOverviewColumn_NetworkUpTotal] = 1198 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uNetworkUpTotal, iDecimalCount));1199 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uNetworkUpTotal, iDecimalCount)); 1199 1200 1200 1201 m_itemList[i].m_columnData[VMActivityOverviewColumn_NetworkDownTotal] = 1201 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uNetworkDownTotal, iDecimalCount));1202 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uNetworkDownTotal, iDecimalCount)); 1202 1203 1203 1204 m_itemList[i].m_columnData[VMActivityOverviewColumn_DiskIOReadRate] = 1204 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uDiskReadRate, iDecimalCount));1205 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uDiskReadRate, iDecimalCount)); 1205 1206 1206 1207 m_itemList[i].m_columnData[VMActivityOverviewColumn_DiskIOWriteRate] = 1207 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uDiskWriteRate, iDecimalCount));1208 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uDiskWriteRate, iDecimalCount)); 1208 1209 1209 1210 m_itemList[i].m_columnData[VMActivityOverviewColumn_DiskIOReadTotal] = 1210 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uDiskReadTotal, iDecimalCount));1211 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uDiskReadTotal, iDecimalCount)); 1211 1212 1212 1213 m_itemList[i].m_columnData[VMActivityOverviewColumn_DiskIOWriteTotal] = 1213 QString("%1").arg( uiCommon().formatSize(m_itemList[i].m_uDiskWriteTotal, iDecimalCount));1214 QString("%1").arg(UITranslator::formatSize(m_itemList[i].m_uDiskWriteTotal, iDecimalCount)); 1214 1215 1215 1216 m_itemList[i].m_columnData[VMActivityOverviewColumn_VMExits] = 1216 QString("%1/%2").arg(UI Common::addMetricSuffixToNumber(m_itemList[i].m_uVMExitRate)).1217 arg(UI Common::addMetricSuffixToNumber(m_itemList[i].m_uVMExitTotal));1217 QString("%1/%2").arg(UITranslator::addMetricSuffixToNumber(m_itemList[i].m_uVMExitRate)). 1218 arg(UITranslator::addMetricSuffixToNumber(m_itemList[i].m_uVMExitTotal)); 1218 1219 } 1219 1220 -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r89093 r90967 32 32 #include "UICommon.h" 33 33 #include "UIIconPool.h" 34 #include "UITranslator.h" 34 35 #include "UIVMActivityMonitor.h" 35 36 #include "UIVirtualBoxEventHandler.h" … … 521 522 return QString::number(iValue); 522 523 else if (m_pMetric->unit().compare("kb", Qt::CaseInsensitive) == 0) 523 return uiCommon().formatSize(_1K * (quint64)iValue, g_iDecimalCount);524 return UITranslator::formatSize(_1K * (quint64)iValue, g_iDecimalCount); 524 525 else if (m_pMetric->unit().compare("b", Qt::CaseInsensitive) == 0 || 525 526 m_pMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0) 526 return uiCommon().formatSize(iValue, g_iDecimalCount);527 return UITranslator::formatSize(iValue, g_iDecimalCount); 527 528 else if (m_pMetric->unit().compare("times", Qt::CaseInsensitive) == 0) 528 return UI Common::addMetricSuffixToNumber(iValue);529 return UITranslator::addMetricSuffixToNumber(iValue); 529 530 return QString(); 530 531 } … … 1334 1335 { 1335 1336 QString strInfo; 1336 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg( uiCommon().formatSize(_1K * iTotalRAM, g_iDecimalCount))1337 .arg(m_strRAMInfoLabelFree).arg( uiCommon().formatSize(_1K * (iFreeRAM), g_iDecimalCount))1338 .arg(m_strRAMInfoLabelUsed).arg( uiCommon().formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount));1337 strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strRAMInfoLabelTitle).arg(m_strRAMInfoLabelTotal).arg(UITranslator::formatSize(_1K * iTotalRAM, g_iDecimalCount)) 1338 .arg(m_strRAMInfoLabelFree).arg(UITranslator::formatSize(_1K * (iFreeRAM), g_iDecimalCount)) 1339 .arg(m_strRAMInfoLabelUsed).arg(UITranslator::formatSize(_1K * (iTotalRAM - iFreeRAM), g_iDecimalCount)); 1339 1340 m_infoLabels[m_strRAMMetricName]->setText(strInfo); 1340 1341 } … … 1367 1368 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1368 1369 .arg(m_strNetworkInfoLabelTitle) 1369 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg( uiCommon().formatSize((quint64)iReceiveRate, g_iDecimalCount))1370 .arg(m_strNetworkInfoLabelReceivedTotal).arg( uiCommon().formatSize((quint64)iReceiveTotal, g_iDecimalCount))1371 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg( uiCommon().formatSize((quint64)iTransmitRate, g_iDecimalCount))1372 .arg(m_strNetworkInfoLabelTransmittedTotal).arg( uiCommon().formatSize((quint64)iTransmitTotal, g_iDecimalCount));1370 .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(UITranslator::formatSize((quint64)iReceiveRate, g_iDecimalCount)) 1371 .arg(m_strNetworkInfoLabelReceivedTotal).arg(UITranslator::formatSize((quint64)iReceiveTotal, g_iDecimalCount)) 1372 .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(UITranslator::formatSize((quint64)iTransmitRate, g_iDecimalCount)) 1373 .arg(m_strNetworkInfoLabelTransmittedTotal).arg(UITranslator::formatSize((quint64)iTransmitTotal, g_iDecimalCount)); 1373 1374 m_infoLabels[m_strNetworkMetricName]->setText(strInfo); 1374 1375 } … … 1465 1466 QString strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>") 1466 1467 .arg(m_strDiskIOInfoLabelTitle) 1467 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg( uiCommon().formatSize((quint64)iWriteRate, g_iDecimalCount))1468 .arg(m_strDiskIOInfoLabelWrittenTotal).arg( uiCommon().formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount))1469 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg( uiCommon().formatSize((quint64)iReadRate, g_iDecimalCount))1470 .arg(m_strDiskIOInfoLabelReadTotal).arg( uiCommon().formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount));1468 .arg(dataColorString(m_strDiskIOMetricName, 0)).arg(m_strDiskIOInfoLabelWritten).arg(UITranslator::formatSize((quint64)iWriteRate, g_iDecimalCount)) 1469 .arg(m_strDiskIOInfoLabelWrittenTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalWritten, g_iDecimalCount)) 1470 .arg(dataColorString(m_strDiskIOMetricName, 1)).arg(m_strDiskIOInfoLabelRead).arg(UITranslator::formatSize((quint64)iReadRate, g_iDecimalCount)) 1471 .arg(m_strDiskIOInfoLabelReadTotal).arg(UITranslator::formatSize((quint64)uDiskIOTotalRead, g_iDecimalCount)); 1471 1472 m_infoLabels[m_strDiskIOMetricName]->setText(strInfo); 1472 1473 } … … 1495 1496 strInfo = QString("<b>%1</b></b><br/>%2: %3 %4<br/>%5: %6 %7") 1496 1497 .arg(m_strVMExitInfoLabelTitle) 1497 .arg(m_strVMExitLabelCurrent).arg(UI Common::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit())1498 .arg(m_strVMExitLabelTotal).arg(UI Common::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit());1498 .arg(m_strVMExitLabelCurrent).arg(UITranslator::addMetricSuffixToNumber(iRate)).arg(VMExitMetric.unit()) 1499 .arg(m_strVMExitLabelTotal).arg(UITranslator::addMetricSuffixToNumber(uTotalVMExits)).arg(VMExitMetric.unit()); 1499 1500 m_infoLabels[m_strVMExitMetricName]->setText(strInfo); 1500 1501 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r90490 r90967 29 29 #include "UIMessageCenter.h" 30 30 #include "UIShortcutPool.h" 31 #include "UITranslator.h" 31 32 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 32 33 # include "UIExtraDataManager.h" … … 191 192 case UIActionPoolType_Manager: return name(); 192 193 /* Filtered name for Runtime UI: */ 193 case UIActionPoolType_Runtime: return UI Common::removeAccelMark(name());194 case UIActionPoolType_Runtime: return UITranslator::removeAccelMark(name()); 194 195 } 195 196 /* Nothing by default: */ … … 228 229 { 229 230 if (m_fMachineMenuAction) 230 setText( uiCommon().insertKeyToActionText(nameInMenu(),231 gShortcutPool->shortcut(actionPool(), this).primaryToPortableText()));231 setText(UITranslator::insertKeyToActionText(nameInMenu(), 232 gShortcutPool->shortcut(actionPool(), this).primaryToPortableText())); 232 233 else 233 234 setText(nameInMenu()); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r90966 r90967 172 172 173 173 174 /** Port config cache. */175 struct PortConfig176 {177 const char *name;178 const ulong IRQ;179 const ulong IOBase;180 };181 182 /** Known port config COM ports. */183 static const PortConfig kComKnownPorts[] =184 {185 { "COM1", 4, 0x3F8 },186 { "COM2", 3, 0x2F8 },187 { "COM3", 4, 0x3E8 },188 { "COM4", 3, 0x2E8 },189 /* Must not contain an element with IRQ=0 and IOBase=0 used to cause190 * toCOMPortName() to return the "User-defined" string for these values. */191 };192 193 /** Known port config LPT ports. */194 static const PortConfig kLptKnownPorts[] =195 {196 { "LPT1", 7, 0x378 },197 { "LPT2", 5, 0x278 },198 { "LPT1", 2, 0x3BC },199 /* Must not contain an element with IRQ=0 and IOBase=0 used to cause200 * toLPTPortName() to return the "User-defined" string for these values. */201 };202 203 204 174 /* static */ 205 175 UICommon *UICommon::s_pInstance = 0; 206 QString UICommon::s_strUserDefinedPortName = QString();207 176 208 177 /* static */ … … 1222 1191 1223 1192 /* static */ 1224 QString UICommon::yearsToString(uint32_t cVal)1225 {1226 return QApplication::translate("UICommon", "%n year(s)", "", cVal);1227 }1228 1229 /* static */1230 QString UICommon::monthsToString(uint32_t cVal)1231 {1232 return QApplication::translate("UICommon", "%n month(s)", "", cVal);1233 }1234 1235 /* static */1236 QString UICommon::daysToString(uint32_t cVal)1237 {1238 return QApplication::translate("UICommon", "%n day(s)", "", cVal);1239 }1240 1241 /* static */1242 QString UICommon::hoursToString(uint32_t cVal)1243 {1244 return QApplication::translate("UICommon", "%n hour(s)", "", cVal);1245 }1246 1247 /* static */1248 QString UICommon::minutesToString(uint32_t cVal)1249 {1250 return QApplication::translate("UICommon", "%n minute(s)", "", cVal);1251 }1252 1253 /* static */1254 QString UICommon::secondsToString(uint32_t cVal)1255 {1256 return QApplication::translate("UICommon", "%n second(s)", "", cVal);1257 }1258 1259 /* static */1260 QChar UICommon::decimalSep()1261 {1262 return QLocale::system().decimalPoint();1263 }1264 1265 /* static */1266 QString UICommon::sizeRegexp()1267 {1268 /* This regexp will capture 5 groups of text:1269 * - cap(1): integer number in case when no decimal point is present1270 * (if empty, it means that decimal point is present)1271 * - cap(2): size suffix in case when no decimal point is present (may be empty)1272 * - cap(3): integer number in case when decimal point is present (may be empty)1273 * - cap(4): fraction number (hundredth) in case when decimal point is present1274 * - cap(5): size suffix in case when decimal point is present (note that1275 * B cannot appear there). */1276 1277 const QString strRegexp =1278 QString("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$")1279 .arg(decimalSep())1280 .arg(tr("B", "size suffix Bytes"))1281 .arg(tr("KB", "size suffix KBytes=1024 Bytes"))1282 .arg(tr("MB", "size suffix MBytes=1024 KBytes"))1283 .arg(tr("GB", "size suffix GBytes=1024 MBytes"))1284 .arg(tr("TB", "size suffix TBytes=1024 GBytes"))1285 .arg(tr("PB", "size suffix PBytes=1024 TBytes"));1286 return strRegexp;1287 }1288 1289 /* static */1290 quint64 UICommon::parseSize(const QString &strText)1291 {1292 /* Text should be in form of B|KB|MB|GB|TB|PB. */1293 QRegExp regexp(sizeRegexp());1294 int iPos = regexp.indexIn(strText);1295 if (iPos != -1)1296 {1297 QString strInteger = regexp.cap(1);1298 QString strHundred;1299 QString strSuff = regexp.cap(2);1300 if (strInteger.isEmpty())1301 {1302 strInteger = regexp.cap(3);1303 strHundred = regexp.cap(4);1304 strSuff = regexp.cap(5);1305 }1306 1307 quint64 uDenominator = 0;1308 if (strSuff.isEmpty() || strSuff == tr("B", "size suffix Bytes"))1309 uDenominator = 1;1310 else if (strSuff == tr("KB", "size suffix KBytes=1024 Bytes"))1311 uDenominator = _1K;1312 else if (strSuff == tr("MB", "size suffix MBytes=1024 KBytes"))1313 uDenominator = _1M;1314 else if (strSuff == tr("GB", "size suffix GBytes=1024 MBytes"))1315 uDenominator = _1G;1316 else if (strSuff == tr("TB", "size suffix TBytes=1024 GBytes"))1317 uDenominator = _1T;1318 else if (strSuff == tr("PB", "size suffix PBytes=1024 TBytes"))1319 uDenominator = _1P;1320 1321 quint64 iInteger = strInteger.toULongLong();1322 if (uDenominator == 1)1323 return iInteger;1324 1325 quint64 iHundred = strHundred.leftJustified(2, '0').toULongLong();1326 iHundred = iHundred * uDenominator / 100;1327 iInteger = iInteger * uDenominator + iHundred;1328 return iInteger;1329 }1330 else1331 return 0;1332 }1333 1334 /* static */1335 SizeSuffix UICommon::parseSizeSuffix(const QString &strText)1336 {1337 /* Text should be in form of B|KB|MB|GB|TB|PB. */1338 QRegExp regexp(sizeRegexp());1339 int iPos = regexp.indexIn(strText);1340 if (iPos != -1)1341 {1342 QString strInteger = regexp.cap(1);1343 QString strSuff = regexp.cap(2);1344 if (strInteger.isEmpty())1345 {1346 strInteger = regexp.cap(3);1347 strSuff = regexp.cap(5);1348 }1349 1350 SizeSuffix enmSizeSuffix = SizeSuffix_Byte;1351 1352 if (strSuff.isEmpty() || strSuff == tr("B", "size suffix Bytes"))1353 enmSizeSuffix = SizeSuffix_Byte;1354 else if (strSuff == tr("KB", "size suffix KBytes=1024 Bytes"))1355 enmSizeSuffix = SizeSuffix_KiloByte;1356 else if (strSuff == tr("MB", "size suffix MBytes=1024 KBytes"))1357 enmSizeSuffix = SizeSuffix_MegaByte;1358 else if (strSuff == tr("GB", "size suffix GBytes=1024 MBytes"))1359 enmSizeSuffix = SizeSuffix_GigaByte;1360 else if (strSuff == tr("TB", "size suffix TBytes=1024 GBytes"))1361 enmSizeSuffix = SizeSuffix_TeraByte;1362 else if (strSuff == tr("PB", "size suffix PBytes=1024 TBytes"))1363 enmSizeSuffix = SizeSuffix_PetaByte;1364 return enmSizeSuffix;1365 }1366 else1367 return SizeSuffix_Byte;1368 }1369 1370 /* static */1371 bool UICommon::hasSizeSuffix(const QString &strText)1372 {1373 /* Text should be in form of B|KB|MB|GB|TB|PB. */1374 QRegExp regexp(sizeRegexp());1375 int iPos = regexp.indexIn(strText);1376 if (iPos != -1)1377 {1378 QString strInteger = regexp.cap(1);1379 QString strSuff = regexp.cap(2);1380 if (strInteger.isEmpty())1381 {1382 strInteger = regexp.cap(3);1383 strSuff = regexp.cap(5);1384 }1385 1386 if (strSuff.isEmpty())1387 return false;1388 if (strSuff == tr("B", "size suffix Bytes") ||1389 strSuff == tr("KB", "size suffix KBytes=1024 Bytes") ||1390 strSuff == tr("MB", "size suffix MBytes=1024 KBytes") ||1391 strSuff == tr("GB", "size suffix GBytes=1024 MBytes") ||1392 strSuff == tr("TB", "size suffix TBytes=1024 GBytes") ||1393 strSuff == tr("PB", "size suffix PBytes=1024 TBytes"))1394 return true;1395 return false;1396 }1397 else1398 return false;1399 }1400 1401 /* static */1402 QString UICommon::formatSize(quint64 uSize, uint cDecimal /* = 2 */,1403 FormatSize enmMode /* = FormatSize_Round */)1404 {1405 /* Text will be in form of B|KB|MB|GB|TB|PB.1406 *1407 * When enmMode is FormatSize_Round, the result is rounded to the1408 * closest number containing @a aDecimal decimal digits.1409 * When enmMode is FormatSize_RoundDown, the result is rounded to the1410 * largest number with @a aDecimal decimal digits that is not greater than1411 * the result. This guarantees that converting the resulting string back to1412 * the integer value in bytes will not produce a value greater that the1413 * initial size parameter.1414 * When enmMode is FormatSize_RoundUp, the result is rounded to the1415 * smallest number with @a aDecimal decimal digits that is not less than the1416 * result. This guarantees that converting the resulting string back to the1417 * integer value in bytes will not produce a value less that the initial1418 * size parameter. */1419 1420 quint64 uDenominator = 0;1421 int iSuffix = 0;1422 1423 if (uSize < _1K)1424 {1425 uDenominator = 1;1426 iSuffix = 0;1427 }1428 else if (uSize < _1M)1429 {1430 uDenominator = _1K;1431 iSuffix = 1;1432 }1433 else if (uSize < _1G)1434 {1435 uDenominator = _1M;1436 iSuffix = 2;1437 }1438 else if (uSize < _1T)1439 {1440 uDenominator = _1G;1441 iSuffix = 3;1442 }1443 else if (uSize < _1P)1444 {1445 uDenominator = _1T;1446 iSuffix = 4;1447 }1448 else1449 {1450 uDenominator = _1P;1451 iSuffix = 5;1452 }1453 1454 quint64 uInteger = uSize / uDenominator;1455 quint64 uDecimal = uSize % uDenominator;1456 quint64 uMult = 1;1457 for (uint i = 0; i < cDecimal; ++i)1458 uMult *= 10;1459 1460 QString strNumber;1461 if (uDenominator > 1)1462 {1463 if (uDecimal)1464 {1465 uDecimal *= uMult;1466 /* Not greater: */1467 if (enmMode == FormatSize_RoundDown)1468 uDecimal = uDecimal / uDenominator;1469 /* Not less: */1470 else if (enmMode == FormatSize_RoundUp)1471 uDecimal = (uDecimal + uDenominator - 1) / uDenominator;1472 /* Nearest: */1473 else1474 uDecimal = (uDecimal + uDenominator / 2) / uDenominator;1475 }1476 /* Check for the fractional part overflow due to rounding: */1477 if (uDecimal == uMult)1478 {1479 uDecimal = 0;1480 ++uInteger;1481 /* Check if we've got 1024 XB after rounding and scale down if so: */1482 if (uInteger == 1024 && iSuffix + 1 < (int)SizeSuffix_Max)1483 {1484 uInteger /= 1024;1485 ++iSuffix;1486 }1487 }1488 strNumber = QString::number(uInteger);1489 if (cDecimal)1490 strNumber += QString("%1%2").arg(decimalSep())1491 .arg(QString::number(uDecimal).rightJustified(cDecimal, '0'));1492 }1493 else1494 {1495 strNumber = QString::number(uInteger);1496 }1497 1498 return QString("%1 %2").arg(strNumber).arg(gpConverter->toString(static_cast<SizeSuffix>(iSuffix)));1499 }1500 1501 /* static */1502 QString UICommon::addMetricSuffixToNumber(quint64 uNumber)1503 {1504 if (uNumber <= 0)1505 return QString();1506 /* See https://en.wikipedia.org/wiki/Metric_prefix for metric suffixes:*/1507 char suffixes[] = {'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'};1508 int zeroCount = (int)log10((long double)uNumber);1509 if (zeroCount < 3)1510 return QString::number(uNumber);1511 int h = 3 * (zeroCount / 3);1512 char result[128];1513 sprintf(result, "%.2f", uNumber / (float)pow((double)10, h));1514 return QString("%1%2").arg(result).arg(suffixes[h / 3 - 1]);1515 }1516 1517 /* static */1518 QStringList UICommon::COMPortNames()1519 {1520 QStringList list;1521 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i)1522 list << kComKnownPorts[i].name;1523 1524 return list;1525 }1526 1527 /* static */1528 QString UICommon::toCOMPortName(ulong uIRQ, ulong uIOBase)1529 {1530 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i)1531 if (kComKnownPorts[i].IRQ == uIRQ &&1532 kComKnownPorts[i].IOBase == uIOBase)1533 return kComKnownPorts[i].name;1534 1535 return s_strUserDefinedPortName;1536 }1537 1538 /* static */1539 bool UICommon::toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase)1540 {1541 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i)1542 if (strcmp(kComKnownPorts[i].name, strName.toUtf8().data()) == 0)1543 {1544 uIRQ = kComKnownPorts[i].IRQ;1545 uIOBase = kComKnownPorts[i].IOBase;1546 return true;1547 }1548 1549 return false;1550 }1551 1552 /* static */1553 QStringList UICommon::LPTPortNames()1554 {1555 QStringList list;1556 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i)1557 list << kLptKnownPorts[i].name;1558 1559 return list;1560 }1561 1562 /* static */1563 QString UICommon::toLPTPortName(ulong uIRQ, ulong uIOBase)1564 {1565 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i)1566 if (kLptKnownPorts[i].IRQ == uIRQ &&1567 kLptKnownPorts[i].IOBase == uIOBase)1568 return kLptKnownPorts[i].name;1569 1570 return s_strUserDefinedPortName;1571 }1572 1573 /* static */1574 bool UICommon::toLPTPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase)1575 {1576 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i)1577 if (strcmp(kLptKnownPorts[i].name, strName.toUtf8().data()) == 0)1578 {1579 uIRQ = kLptKnownPorts[i].IRQ;1580 uIOBase = kLptKnownPorts[i].IOBase;1581 return true;1582 }1583 1584 return false;1585 }1586 1587 /* static */1588 QString UICommon::highlight(QString strText, bool fToolTip /* = false */)1589 {1590 /* We should reformat the input strText so that:1591 * - strings in single quotes will be put inside <nobr> and marked1592 * with blue color;1593 * - UUIDs be put inside <nobr> and marked1594 * with green color;1595 * - replaces new line chars with </p><p> constructs to form paragraphs1596 * (note that <p\> and </p> are not appended to the beginning and to the1597 * end of the string respectively, to allow the result be appended1598 * or prepended to the existing paragraph).1599 *1600 * If @a fToolTip is true, colouring is not applied, only the <nobr> tag1601 * is added. Also, new line chars are replaced with <br> instead of <p>. */1602 1603 QString strFont;1604 QString uuidFont;1605 QString endFont;1606 if (!fToolTip)1607 {1608 strFont = "<font color=#0000CC>";1609 uuidFont = "<font color=#008000>";1610 endFont = "</font>";1611 }1612 1613 /* Replace special entities, '&' -- first! */1614 strText.replace('&', "&");1615 strText.replace('<', "<");1616 strText.replace('>', ">");1617 strText.replace('\"', """);1618 1619 /* Mark strings in single quotes with color: */1620 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");1621 rx.setMinimal(true);1622 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strFont).arg(endFont));1623 1624 /* Mark UUIDs with color: */1625 strText.replace(QRegExp(1626 "((?:^|\\s)[(]?)"1627 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})"1628 "(?=[:.-!);]?(?:\\s|$))"),1629 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidFont).arg(endFont));1630 1631 /* Split to paragraphs at \n chars: */1632 if (!fToolTip)1633 strText.replace('\n', "</p><p>");1634 else1635 strText.replace('\n', "<br>");1636 1637 return strText;1638 }1639 1640 /* static */1641 QString UICommon::emphasize(QString strText)1642 {1643 /* We should reformat the input string @a strText so that:1644 * - strings in single quotes will be put inside \<nobr\> and marked1645 * with bold style;1646 * - UUIDs be put inside \<nobr\> and marked1647 * with italic style;1648 * - replaces new line chars with \</p\>\<p\> constructs to form paragraphs1649 * (note that \<p\> and \</p\> are not appended to the beginning and to the1650 * end of the string respectively, to allow the result be appended1651 * or prepended to the existing paragraph). */1652 1653 QString strEmphStart("<b>");1654 QString strEmphEnd("</b>");1655 QString uuidEmphStart("<i>");1656 QString uuidEmphEnd("</i>");1657 1658 /* Replace special entities, '&' -- first! */1659 strText.replace('&', "&");1660 strText.replace('<', "<");1661 strText.replace('>', ">");1662 strText.replace('\"', """);1663 1664 /* Mark strings in single quotes with bold style: */1665 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");1666 rx.setMinimal(true);1667 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strEmphStart).arg(strEmphEnd));1668 1669 /* Mark UUIDs with italic style: */1670 strText.replace(QRegExp(1671 "((?:^|\\s)[(]?)"1672 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})"1673 "(?=[:.-!);]?(?:\\s|$))"),1674 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidEmphStart).arg(uuidEmphEnd));1675 1676 /* Split to paragraphs at \n chars: */1677 strText.replace('\n', "</p><p>");1678 1679 return strText;1680 }1681 1682 /* static */1683 QString UICommon::removeAccelMark(QString strText)1684 {1685 /* In order to support accelerators used in non-alphabet languages1686 * (e.g. Japanese) that has a form of "(&<L>)" (where <L> is a latin letter),1687 * this method first searches for this pattern and, if found, removes it as a1688 * whole. If such a pattern is not found, then the '&' character is simply1689 * removed from the string. */1690 1691 QRegExp accel("\\(&[a-zA-Z]\\)");1692 int iPos = accel.indexIn(strText);1693 if (iPos >= 0)1694 strText.remove(iPos, accel.cap().length());1695 else1696 {1697 iPos = strText.indexOf('&');1698 if (iPos >= 0)1699 strText.remove(iPos, 1);1700 }1701 1702 return strText;1703 }1704 1705 /* static */1706 QString UICommon::insertKeyToActionText(const QString &strText, const QString &strKey)1707 {1708 #ifdef VBOX_WS_MAC1709 QString strPattern("%1 (Host+%2)");1710 #else1711 QString strPattern("%1 \tHost+%2");1712 #endif1713 if ( strKey.isEmpty()1714 || strKey.compare("None", Qt::CaseInsensitive) == 0)1715 return strText;1716 else1717 return strPattern.arg(strText).arg(QKeySequence(strKey).toString(QKeySequence::NativeText));1718 }1719 1720 /* static */1721 1193 QString UICommon::helpFile() 1722 1194 { … … 4433 3905 void UICommon::retranslateUi() 4434 3906 { 4435 s_strUserDefinedPortName = tr("User-defined", "serial port");4436 4437 3907 m_pixWarning = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning).pixmap(16, 16); 4438 3908 Assert(!m_pixWarning.isNull()); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r90966 r90967 301 301 void deletePidfile(); 302 302 #endif 303 /** @} */304 305 /** @name Localization stuff.306 * @{ */307 /** Returns tr("%n year(s)"). */308 static QString yearsToString(uint32_t cVal);309 /** Returns tr("%n month(s)"). */310 static QString monthsToString(uint32_t cVal);311 /** Returns tr("%n day(s)"). */312 static QString daysToString(uint32_t cVal);313 /** Returns tr("%n hour(s)"). */314 static QString hoursToString(uint32_t cVal);315 /** Returns tr("%n minute(s)"). */316 static QString minutesToString(uint32_t cVal);317 /** Returns tr("%n second(s)"). */318 static QString secondsToString(uint32_t cVal);319 320 /** Returns the decimal separator for the current locale. */321 static QChar decimalSep();322 /** Returns the regexp string that defines the format of the human-readable size representation. */323 static QString sizeRegexp();324 /** Parses the given size strText and returns the size value in bytes. */325 static quint64 parseSize(const QString &strText);326 /** Parses the given size strText and returns the size suffix. */327 static SizeSuffix parseSizeSuffix(const QString &strText);328 /** Parses the given string @a strText and returns true if it includes a size suffix. */329 static bool hasSizeSuffix(const QString &strText);330 /** Formats the given @a uSize value in bytes to a human readable string.331 * @param uSize Brings the size value in bytes.332 * @param enmMode Brings the conversion mode.333 * @param cDecimal Brings the number of decimal digits in result. */334 static QString formatSize(quint64 uSize, uint cDecimal = 2, FormatSize enmMode = FormatSize_Round);335 /** Formats the given @a uNumber to that 'k' is added for thousand, 'M' for million and so on. */336 static QString addMetricSuffixToNumber(quint64 uNumber);337 338 /** Returns the list of the standard COM port names (i.e. "COMx"). */339 static QStringList COMPortNames();340 /** Returns the name of the standard COM port corresponding to the given parameters,341 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */342 static QString toCOMPortName(ulong uIRQ, ulong uIOBase);343 /** Returns port parameters corresponding to the given standard COM name.344 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "COMx"). */345 static bool toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase);346 /** Returns the list of the standard LPT port names (i.e. "LPTx"). */347 static QStringList LPTPortNames();348 /** Returns the name of the standard LPT port corresponding to the given parameters,349 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */350 static QString toLPTPortName(ulong uIRQ, ulong uIOBase);351 /** Returns port parameters corresponding to the given standard LPT name.352 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "LPTx"). */353 static bool toLPTPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase);354 355 /** Reformats the input @a strText to highlight it. */356 static QString highlight(QString strText, bool fToolTip = false);357 /** Reformats the input @a strText to emphasize it. */358 static QString emphasize(QString strText);359 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */360 static QString removeAccelMark(QString strText);361 /** Inserts a passed @a strKey into action @a strText. */362 static QString insertKeyToActionText (const QString &strText, const QString &strKey);363 303 /** @} */ 364 304 … … 834 774 /** @name General stuff. 835 775 * @{ */ 836 /** Holds the tr("User Defined") port name. */837 static QString s_strUserDefinedPortName;838 839 776 /** Holds the UI type. */ 840 777 UIType m_enmType; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp
r87719 r90967 22 22 23 23 /* GUI includes: */ 24 #include "UICommon.h" 25 #include "UICustomFileSystemModel.h" 24 26 #include "UIErrorString.h" 25 #include "UICustomFileSystemModel.h"26 27 #include "UIPathOperations.h" 27 #include "UI Common.h"28 #include "UITranslator.h" 28 29 29 30 const char *UICustomFileSystemModel::strUpDirectoryString = ".."; … … 440 441 { 441 442 qulonglong size = item->data(index.column()).toULongLong(); 442 return uiCommon().formatSize(size);443 return UITranslator::formatSize(size); 443 444 } 444 445 else -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp
r86275 r90967 22 22 /* GUI includes: */ 23 23 #include "UIBootOrderEditor.h" 24 #include "UICommon.h" 24 25 #include "UIConverter.h" 25 26 #include "UIDetailsGenerator.h" 26 27 #include "UIErrorString.h" 27 #include "UI Common.h"28 #include "UITranslator.h" 28 29 29 30 /* COM includes: */ … … 816 817 /* Gather port information: */ 817 818 const KPortMode enmMode = comPort.GetHostMode(); 818 const QString strModeTemplate = uiCommon().toCOMPortName(comPort.GetIRQ(), comPort.GetIOBase()) + ", ";819 const QString strModeTemplate = UITranslator::toCOMPortName(comPort.GetIRQ(), comPort.GetIOBase()) + ", "; 819 820 QString strModeType; 820 821 switch (enmMode) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIErrorString.cpp
r89582 r90967 24 24 #include "UICommon.h" 25 25 #include "UIErrorString.h" 26 #include "UITranslator.h" 26 27 27 28 /* COM includes: */ … … 149 150 if ( strDetailsInfo == QString::fromLatin1(strDetailsInfo.toLatin1()) 150 151 && strDetailsInfo != QObject::tr(strDetailsInfo.toLatin1().constData())) 151 strFormatted += QString("<p>%1.</p>").arg( uiCommon().emphasize(QObject::tr(strDetailsInfo.toLatin1().constData())));152 strFormatted += QString("<p>%1.</p>").arg(UITranslator::emphasize(QObject::tr(strDetailsInfo.toLatin1().constData()))); 152 153 else 153 strFormatted += QString("<p>%1.</p>").arg( uiCommon().emphasize(strDetailsInfo));154 strFormatted += QString("<p>%1.</p>").arg(UITranslator::emphasize(strDetailsInfo)); 154 155 } 155 156 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r90941 r90967 2559 2559 QString formatted("<!--EOM-->"); 2560 2560 if (!strErrorMsg.isEmpty()) 2561 formatted.prepend(QString("<p>%1.</p>").arg( uiCommon().emphasize(strErrorMsg)));2561 formatted.prepend(QString("<p>%1.</p>").arg(UITranslator::emphasize(strErrorMsg))); 2562 2562 if (!strErrorId.isEmpty()) 2563 2563 formatted += QString("<table bgcolor=%1 border=0 cellspacing=5 " … … 2788 2788 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>" 2789 2789 "<p>Press <b>Ignore</b> to switch to full-screen mode anyway or press <b>Cancel</b> to cancel the operation.</p>") 2790 .arg(UI Common::formatSize(uMinVRAM)),2790 .arg(UITranslator::formatSize(uMinVRAM)), 2791 2791 0 /* auto-confirm id */, 2792 2792 tr("Ignore")); … … 2800 2800 "<p>You should configure the virtual machine to have at " 2801 2801 "least <b>%1</b> of video memory.</p>") 2802 .arg(UI Common::formatSize(uMinVRAM)));2802 .arg(UITranslator::formatSize(uMinVRAM))); 2803 2803 } 2804 2804 … … 2809 2809 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>" 2810 2810 "<p>Press <b>Ignore</b> to switch the screen anyway or press <b>Cancel</b> to cancel the operation.</p>") 2811 .arg(UI Common::formatSize(uMinVRAM)),2811 .arg(UITranslator::formatSize(uMinVRAM)), 2812 2812 0 /* auto-confirm id */, 2813 2813 tr("Ignore")); … … 2821 2821 "<p>You should configure the virtual machine to have at " 2822 2822 "least <b>%1</b> of video memory.</p>") 2823 .arg(UI Common::formatSize(uMinVRAM)));2823 .arg(UITranslator::formatSize(uMinVRAM))); 2824 2824 } 2825 2825 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UITranslator.cpp
r90951 r90967 19 19 #include <QApplication> 20 20 #include <QDir> 21 #include <QKeySequence> 21 22 #ifdef Q_OS_UNIX 22 23 # include <QLibraryInfo> … … 24 25 25 26 /* GUI includes: */ 27 #include "UIConverter.h" 26 28 #include "UIMessageCenter.h" 27 29 #include "UITranslator.h" … … 36 38 # include <iprt/env.h> 37 39 #endif 40 41 42 /** Port config cache. */ 43 struct PortConfig 44 { 45 const char *name; 46 const ulong IRQ; 47 const ulong IOBase; 48 }; 49 50 /** Known port config COM ports. */ 51 static const PortConfig kComKnownPorts[] = 52 { 53 { "COM1", 4, 0x3F8 }, 54 { "COM2", 3, 0x2F8 }, 55 { "COM3", 4, 0x3E8 }, 56 { "COM4", 3, 0x2E8 }, 57 /* Must not contain an element with IRQ=0 and IOBase=0 used to cause 58 * toCOMPortName() to return the "User-defined" string for these values. */ 59 }; 60 38 61 39 62 /* static */ … … 227 250 } 228 251 252 /* static */ 253 QString UITranslator::yearsToString(uint32_t cVal) 254 { 255 return QApplication::translate("UITranslator", "%n year(s)", "", cVal); 256 } 257 258 /* static */ 259 QString UITranslator::monthsToString(uint32_t cVal) 260 { 261 return QApplication::translate("UITranslator", "%n month(s)", "", cVal); 262 } 263 264 /* static */ 265 QString UITranslator::daysToString(uint32_t cVal) 266 { 267 return QApplication::translate("UITranslator", "%n day(s)", "", cVal); 268 } 269 270 /* static */ 271 QString UITranslator::hoursToString(uint32_t cVal) 272 { 273 return QApplication::translate("UITranslator", "%n hour(s)", "", cVal); 274 } 275 276 /* static */ 277 QString UITranslator::minutesToString(uint32_t cVal) 278 { 279 return QApplication::translate("UITranslator", "%n minute(s)", "", cVal); 280 } 281 282 /* static */ 283 QString UITranslator::secondsToString(uint32_t cVal) 284 { 285 return QApplication::translate("UITranslator", "%n second(s)", "", cVal); 286 } 287 288 /* static */ 289 QChar UITranslator::decimalSep() 290 { 291 return QLocale::system().decimalPoint(); 292 } 293 294 /* static */ 295 QString UITranslator::sizeRegexp() 296 { 297 /* This regexp will capture 5 groups of text: 298 * - cap(1): integer number in case when no decimal point is present 299 * (if empty, it means that decimal point is present) 300 * - cap(2): size suffix in case when no decimal point is present (may be empty) 301 * - cap(3): integer number in case when decimal point is present (may be empty) 302 * - cap(4): fraction number (hundredth) in case when decimal point is present 303 * - cap(5): size suffix in case when decimal point is present (note that 304 * B cannot appear there). */ 305 306 const QString strRegexp = 307 QString("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$") 308 .arg(decimalSep()) 309 .arg(tr("B", "size suffix Bytes")) 310 .arg(tr("KB", "size suffix KBytes=1024 Bytes")) 311 .arg(tr("MB", "size suffix MBytes=1024 KBytes")) 312 .arg(tr("GB", "size suffix GBytes=1024 MBytes")) 313 .arg(tr("TB", "size suffix TBytes=1024 GBytes")) 314 .arg(tr("PB", "size suffix PBytes=1024 TBytes")); 315 return strRegexp; 316 } 317 318 /* static */ 319 quint64 UITranslator::parseSize(const QString &strText) 320 { 321 /* Text should be in form of B|KB|MB|GB|TB|PB. */ 322 QRegExp regexp(sizeRegexp()); 323 int iPos = regexp.indexIn(strText); 324 if (iPos != -1) 325 { 326 QString strInteger = regexp.cap(1); 327 QString strHundred; 328 QString strSuff = regexp.cap(2); 329 if (strInteger.isEmpty()) 330 { 331 strInteger = regexp.cap(3); 332 strHundred = regexp.cap(4); 333 strSuff = regexp.cap(5); 334 } 335 336 quint64 uDenominator = 0; 337 if (strSuff.isEmpty() || strSuff == tr("B", "size suffix Bytes")) 338 uDenominator = 1; 339 else if (strSuff == tr("KB", "size suffix KBytes=1024 Bytes")) 340 uDenominator = _1K; 341 else if (strSuff == tr("MB", "size suffix MBytes=1024 KBytes")) 342 uDenominator = _1M; 343 else if (strSuff == tr("GB", "size suffix GBytes=1024 MBytes")) 344 uDenominator = _1G; 345 else if (strSuff == tr("TB", "size suffix TBytes=1024 GBytes")) 346 uDenominator = _1T; 347 else if (strSuff == tr("PB", "size suffix PBytes=1024 TBytes")) 348 uDenominator = _1P; 349 350 quint64 iInteger = strInteger.toULongLong(); 351 if (uDenominator == 1) 352 return iInteger; 353 354 quint64 iHundred = strHundred.leftJustified(2, '0').toULongLong(); 355 iHundred = iHundred * uDenominator / 100; 356 iInteger = iInteger * uDenominator + iHundred; 357 return iInteger; 358 } 359 else 360 return 0; 361 } 362 363 /* static */ 364 SizeSuffix UITranslator::parseSizeSuffix(const QString &strText) 365 { 366 /* Text should be in form of B|KB|MB|GB|TB|PB. */ 367 QRegExp regexp(sizeRegexp()); 368 int iPos = regexp.indexIn(strText); 369 if (iPos != -1) 370 { 371 QString strInteger = regexp.cap(1); 372 QString strSuff = regexp.cap(2); 373 if (strInteger.isEmpty()) 374 { 375 strInteger = regexp.cap(3); 376 strSuff = regexp.cap(5); 377 } 378 379 SizeSuffix enmSizeSuffix = SizeSuffix_Byte; 380 381 if (strSuff.isEmpty() || strSuff == tr("B", "size suffix Bytes")) 382 enmSizeSuffix = SizeSuffix_Byte; 383 else if (strSuff == tr("KB", "size suffix KBytes=1024 Bytes")) 384 enmSizeSuffix = SizeSuffix_KiloByte; 385 else if (strSuff == tr("MB", "size suffix MBytes=1024 KBytes")) 386 enmSizeSuffix = SizeSuffix_MegaByte; 387 else if (strSuff == tr("GB", "size suffix GBytes=1024 MBytes")) 388 enmSizeSuffix = SizeSuffix_GigaByte; 389 else if (strSuff == tr("TB", "size suffix TBytes=1024 GBytes")) 390 enmSizeSuffix = SizeSuffix_TeraByte; 391 else if (strSuff == tr("PB", "size suffix PBytes=1024 TBytes")) 392 enmSizeSuffix = SizeSuffix_PetaByte; 393 return enmSizeSuffix; 394 } 395 else 396 return SizeSuffix_Byte; 397 } 398 399 /* static */ 400 bool UITranslator::hasSizeSuffix(const QString &strText) 401 { 402 /* Text should be in form of B|KB|MB|GB|TB|PB. */ 403 QRegExp regexp(sizeRegexp()); 404 int iPos = regexp.indexIn(strText); 405 if (iPos != -1) 406 { 407 QString strInteger = regexp.cap(1); 408 QString strSuff = regexp.cap(2); 409 if (strInteger.isEmpty()) 410 { 411 strInteger = regexp.cap(3); 412 strSuff = regexp.cap(5); 413 } 414 415 if (strSuff.isEmpty()) 416 return false; 417 if (strSuff == tr("B", "size suffix Bytes") || 418 strSuff == tr("KB", "size suffix KBytes=1024 Bytes") || 419 strSuff == tr("MB", "size suffix MBytes=1024 KBytes") || 420 strSuff == tr("GB", "size suffix GBytes=1024 MBytes") || 421 strSuff == tr("TB", "size suffix TBytes=1024 GBytes") || 422 strSuff == tr("PB", "size suffix PBytes=1024 TBytes")) 423 return true; 424 return false; 425 } 426 else 427 return false; 428 } 429 430 /* static */ 431 QString UITranslator::formatSize(quint64 uSize, uint cDecimal /* = 2 */, 432 FormatSize enmMode /* = FormatSize_Round */) 433 { 434 /* Text will be in form of B|KB|MB|GB|TB|PB. 435 * 436 * When enmMode is FormatSize_Round, the result is rounded to the 437 * closest number containing @a aDecimal decimal digits. 438 * When enmMode is FormatSize_RoundDown, the result is rounded to the 439 * largest number with @a aDecimal decimal digits that is not greater than 440 * the result. This guarantees that converting the resulting string back to 441 * the integer value in bytes will not produce a value greater that the 442 * initial size parameter. 443 * When enmMode is FormatSize_RoundUp, the result is rounded to the 444 * smallest number with @a aDecimal decimal digits that is not less than the 445 * result. This guarantees that converting the resulting string back to the 446 * integer value in bytes will not produce a value less that the initial 447 * size parameter. */ 448 449 quint64 uDenominator = 0; 450 int iSuffix = 0; 451 452 if (uSize < _1K) 453 { 454 uDenominator = 1; 455 iSuffix = 0; 456 } 457 else if (uSize < _1M) 458 { 459 uDenominator = _1K; 460 iSuffix = 1; 461 } 462 else if (uSize < _1G) 463 { 464 uDenominator = _1M; 465 iSuffix = 2; 466 } 467 else if (uSize < _1T) 468 { 469 uDenominator = _1G; 470 iSuffix = 3; 471 } 472 else if (uSize < _1P) 473 { 474 uDenominator = _1T; 475 iSuffix = 4; 476 } 477 else 478 { 479 uDenominator = _1P; 480 iSuffix = 5; 481 } 482 483 quint64 uInteger = uSize / uDenominator; 484 quint64 uDecimal = uSize % uDenominator; 485 quint64 uMult = 1; 486 for (uint i = 0; i < cDecimal; ++i) 487 uMult *= 10; 488 489 QString strNumber; 490 if (uDenominator > 1) 491 { 492 if (uDecimal) 493 { 494 uDecimal *= uMult; 495 /* Not greater: */ 496 if (enmMode == FormatSize_RoundDown) 497 uDecimal = uDecimal / uDenominator; 498 /* Not less: */ 499 else if (enmMode == FormatSize_RoundUp) 500 uDecimal = (uDecimal + uDenominator - 1) / uDenominator; 501 /* Nearest: */ 502 else 503 uDecimal = (uDecimal + uDenominator / 2) / uDenominator; 504 } 505 /* Check for the fractional part overflow due to rounding: */ 506 if (uDecimal == uMult) 507 { 508 uDecimal = 0; 509 ++uInteger; 510 /* Check if we've got 1024 XB after rounding and scale down if so: */ 511 if (uInteger == 1024 && iSuffix + 1 < (int)SizeSuffix_Max) 512 { 513 uInteger /= 1024; 514 ++iSuffix; 515 } 516 } 517 strNumber = QString::number(uInteger); 518 if (cDecimal) 519 strNumber += QString("%1%2").arg(decimalSep()) 520 .arg(QString::number(uDecimal).rightJustified(cDecimal, '0')); 521 } 522 else 523 { 524 strNumber = QString::number(uInteger); 525 } 526 527 return QString("%1 %2").arg(strNumber).arg(gpConverter->toString(static_cast<SizeSuffix>(iSuffix))); 528 } 529 530 /* static */ 531 QString UITranslator::addMetricSuffixToNumber(quint64 uNumber) 532 { 533 if (uNumber <= 0) 534 return QString(); 535 /* See https://en.wikipedia.org/wiki/Metric_prefix for metric suffixes:*/ 536 char suffixes[] = {'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}; 537 int zeroCount = (int)log10((long double)uNumber); 538 if (zeroCount < 3) 539 return QString::number(uNumber); 540 int h = 3 * (zeroCount / 3); 541 char result[128]; 542 sprintf(result, "%.2f", uNumber / (float)pow((double)10, h)); 543 return QString("%1%2").arg(result).arg(suffixes[h / 3 - 1]); 544 } 545 546 /* static */ 547 QStringList UITranslator::COMPortNames() 548 { 549 QStringList list; 550 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 551 list << kComKnownPorts[i].name; 552 553 return list; 554 } 555 556 /* static */ 557 QString UITranslator::toCOMPortName(ulong uIRQ, ulong uIOBase) 558 { 559 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 560 if (kComKnownPorts[i].IRQ == uIRQ && 561 kComKnownPorts[i].IOBase == uIOBase) 562 return kComKnownPorts[i].name; 563 564 return tr("User-defined", "serial port");; 565 } 566 567 /* static */ 568 bool UITranslator::toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase) 569 { 570 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 571 if (strcmp(kComKnownPorts[i].name, strName.toUtf8().data()) == 0) 572 { 573 uIRQ = kComKnownPorts[i].IRQ; 574 uIOBase = kComKnownPorts[i].IOBase; 575 return true; 576 } 577 578 return false; 579 } 580 581 /* static */ 582 QString UITranslator::highlight(QString strText, bool fToolTip /* = false */) 583 { 584 /* We should reformat the input strText so that: 585 * - strings in single quotes will be put inside <nobr> and marked 586 * with blue color; 587 * - UUIDs be put inside <nobr> and marked 588 * with green color; 589 * - replaces new line chars with </p><p> constructs to form paragraphs 590 * (note that <p\> and </p> are not appended to the beginning and to the 591 * end of the string respectively, to allow the result be appended 592 * or prepended to the existing paragraph). 593 * 594 * If @a fToolTip is true, colouring is not applied, only the <nobr> tag 595 * is added. Also, new line chars are replaced with <br> instead of <p>. */ 596 597 QString strFont; 598 QString uuidFont; 599 QString endFont; 600 if (!fToolTip) 601 { 602 strFont = "<font color=#0000CC>"; 603 uuidFont = "<font color=#008000>"; 604 endFont = "</font>"; 605 } 606 607 /* Replace special entities, '&' -- first! */ 608 strText.replace('&', "&"); 609 strText.replace('<', "<"); 610 strText.replace('>', ">"); 611 strText.replace('\"', """); 612 613 /* Mark strings in single quotes with color: */ 614 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 615 rx.setMinimal(true); 616 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strFont).arg(endFont)); 617 618 /* Mark UUIDs with color: */ 619 strText.replace(QRegExp( 620 "((?:^|\\s)[(]?)" 621 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})" 622 "(?=[:.-!);]?(?:\\s|$))"), 623 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidFont).arg(endFont)); 624 625 /* Split to paragraphs at \n chars: */ 626 if (!fToolTip) 627 strText.replace('\n', "</p><p>"); 628 else 629 strText.replace('\n', "<br>"); 630 631 return strText; 632 } 633 634 /* static */ 635 QString UITranslator::emphasize(QString strText) 636 { 637 /* We should reformat the input string @a strText so that: 638 * - strings in single quotes will be put inside \<nobr\> and marked 639 * with bold style; 640 * - UUIDs be put inside \<nobr\> and marked 641 * with italic style; 642 * - replaces new line chars with \</p\>\<p\> constructs to form paragraphs 643 * (note that \<p\> and \</p\> are not appended to the beginning and to the 644 * end of the string respectively, to allow the result be appended 645 * or prepended to the existing paragraph). */ 646 647 QString strEmphStart("<b>"); 648 QString strEmphEnd("</b>"); 649 QString uuidEmphStart("<i>"); 650 QString uuidEmphEnd("</i>"); 651 652 /* Replace special entities, '&' -- first! */ 653 strText.replace('&', "&"); 654 strText.replace('<', "<"); 655 strText.replace('>', ">"); 656 strText.replace('\"', """); 657 658 /* Mark strings in single quotes with bold style: */ 659 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 660 rx.setMinimal(true); 661 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strEmphStart).arg(strEmphEnd)); 662 663 /* Mark UUIDs with italic style: */ 664 strText.replace(QRegExp( 665 "((?:^|\\s)[(]?)" 666 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})" 667 "(?=[:.-!);]?(?:\\s|$))"), 668 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidEmphStart).arg(uuidEmphEnd)); 669 670 /* Split to paragraphs at \n chars: */ 671 strText.replace('\n', "</p><p>"); 672 673 return strText; 674 } 675 676 /* static */ 677 QString UITranslator::removeAccelMark(QString strText) 678 { 679 /* In order to support accelerators used in non-alphabet languages 680 * (e.g. Japanese) that has a form of "(&<L>)" (where <L> is a latin letter), 681 * this method first searches for this pattern and, if found, removes it as a 682 * whole. If such a pattern is not found, then the '&' character is simply 683 * removed from the string. */ 684 685 QRegExp accel("\\(&[a-zA-Z]\\)"); 686 int iPos = accel.indexIn(strText); 687 if (iPos >= 0) 688 strText.remove(iPos, accel.cap().length()); 689 else 690 { 691 iPos = strText.indexOf('&'); 692 if (iPos >= 0) 693 strText.remove(iPos, 1); 694 } 695 696 return strText; 697 } 698 699 /* static */ 700 QString UITranslator::insertKeyToActionText(const QString &strText, const QString &strKey) 701 { 702 #ifdef VBOX_WS_MAC 703 QString strPattern("%1 (Host+%2)"); 704 #else 705 QString strPattern("%1 \tHost+%2"); 706 #endif 707 if ( strKey.isEmpty() 708 || strKey.compare("None", Qt::CaseInsensitive) == 0) 709 return strText; 710 else 711 return strPattern.arg(strText).arg(QKeySequence(strKey).toString(QKeySequence::NativeText)); 712 } 713 229 714 UITranslator::UITranslator(QObject *pParent /* = 0 */) 230 715 : QTranslator(pParent) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UITranslator.h
r90950 r90967 25 25 #include <QTranslator> 26 26 27 /* GUI includes: */ 28 #include "UIDefs.h" 29 #include "UILibraryDefs.h" 30 27 31 /** QTranslator subclass for VBox needs. */ 28 class UITranslator : public QTranslator32 class SHARED_LIBRARY_STUFF UITranslator : public QTranslator 29 33 { 30 34 Q_OBJECT; … … 50 54 /** Returns the loaded (active) language ID. */ 51 55 static QString languageId(); 56 57 /** Returns tr("%n year(s)"). */ 58 static QString yearsToString(uint32_t cVal); 59 /** Returns tr("%n month(s)"). */ 60 static QString monthsToString(uint32_t cVal); 61 /** Returns tr("%n day(s)"). */ 62 static QString daysToString(uint32_t cVal); 63 /** Returns tr("%n hour(s)"). */ 64 static QString hoursToString(uint32_t cVal); 65 /** Returns tr("%n minute(s)"). */ 66 static QString minutesToString(uint32_t cVal); 67 /** Returns tr("%n second(s)"). */ 68 static QString secondsToString(uint32_t cVal); 69 70 /** Returns the decimal separator for the current locale. */ 71 static QChar decimalSep(); 72 /** Returns the regexp string that defines the format of the human-readable size representation. */ 73 static QString sizeRegexp(); 74 /** Parses the given size strText and returns the size value in bytes. */ 75 static quint64 parseSize(const QString &strText); 76 /** Parses the given size strText and returns the size suffix. */ 77 static SizeSuffix parseSizeSuffix(const QString &strText); 78 /** Parses the given string @a strText and returns true if it includes a size suffix. */ 79 static bool hasSizeSuffix(const QString &strText); 80 /** Formats the given @a uSize value in bytes to a human readable string. 81 * @param uSize Brings the size value in bytes. 82 * @param enmMode Brings the conversion mode. 83 * @param cDecimal Brings the number of decimal digits in result. */ 84 static QString formatSize(quint64 uSize, uint cDecimal = 2, FormatSize enmMode = FormatSize_Round); 85 /** Formats the given @a uNumber to that 'k' is added for thousand, 'M' for million and so on. */ 86 static QString addMetricSuffixToNumber(quint64 uNumber); 87 88 /** Returns the list of the standard COM port names (i.e. "COMx"). */ 89 static QStringList COMPortNames(); 90 /** Returns the name of the standard COM port corresponding to the given parameters, 91 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */ 92 static QString toCOMPortName(ulong uIRQ, ulong uIOBase); 93 /** Returns port parameters corresponding to the given standard COM name. 94 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "COMx"). */ 95 static bool toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase); 96 97 /** Reformats the input @a strText to highlight it. */ 98 static QString highlight(QString strText, bool fToolTip = false); 99 /** Reformats the input @a strText to emphasize it. */ 100 static QString emphasize(QString strText); 101 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */ 102 static QString removeAccelMark(QString strText); 103 /** Inserts a passed @a strKey into action @a strText. */ 104 static QString insertKeyToActionText(const QString &strText, const QString &strKey); 52 105 53 106 private: … … 75 128 /** Holds the singleton instance. */ 76 129 static UITranslator *s_pTranslator; 130 77 131 /** Holds the currently loaded language ID. */ 78 static QString s_strLoadedLanguageId;132 static QString s_strLoadedLanguageId; 79 133 80 134 /** Holds the loaded data. */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r88793 r90967 31 31 #include "QILabel.h" 32 32 #include "QILineEdit.h" 33 #include "QIToolBar.h" 33 34 #include "QIToolButton.h" 35 #include "UIActionPool.h" 34 36 #include "UICommon.h" 35 #include "UIActionPool.h"36 37 #include "UICustomFileSystemModel.h" 37 38 #include "UIErrorString.h" 39 #include "UIFileManager.h" 38 40 #include "UIFileManagerGuestTable.h" 39 41 #include "UIFileManagerTable.h" 40 #include "UIFileManager.h"41 42 #include "UIIconPool.h" 42 43 #include "UIPathOperations.h" 43 #include " QIToolBar.h"44 #include "UITranslator.h" 44 45 45 46 /* COM includes: */ … … 1484 1485 /* static */ QString UIFileManagerTable::humanReadableSize(ULONG64 size) 1485 1486 { 1486 return uiCommon().formatSize(size);1487 return UITranslator::formatSize(size); 1487 1488 } 1488 1489 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.cpp
r83371 r90967 21 21 22 22 /* GUI includes: */ 23 #include "UIMedium.h"24 23 #include "UICommon.h" 25 24 #include "UIConverter.h" … … 27 26 #include "UIExtraDataManager.h" 28 27 #include "UIIconPool.h" 28 #include "UIMedium.h" 29 #include "UITranslator.h" 29 30 30 31 /* COM includes: */ … … 226 227 { 227 228 m_uSize = m_medium.GetSize(); 228 m_strSize = uiCommon().formatSize(m_uSize);229 m_strSize = UITranslator::formatSize(m_uSize); 229 230 if (m_type == UIMediumDeviceType_HardDisk) 230 231 { 231 232 m_uLogicalSize = m_medium.GetLogicalSize(); 232 m_strLogicalSize = uiCommon().formatSize(m_uLogicalSize);233 m_strLogicalSize = UITranslator::formatSize(m_uLogicalSize); 233 234 } 234 235 else … … 409 410 { 410 411 /* Not Accessible: */ 411 m_strToolTip += m_sstrRow.arg("<hr>") + m_sstrRow.arg(UI Common::highlight(m_strLastAccessError, true /* aToolTip */));412 m_strToolTip += m_sstrRow.arg("<hr>") + m_sstrRow.arg(UITranslator::highlight(m_strLastAccessError, true /* aToolTip */)); 412 413 } 413 414 else -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp
r90761 r90967 33 33 #include "QITabWidget.h" 34 34 #include "QIToolButton.h" 35 #include "UICommon.h" 35 36 #include "UIConverter.h" 36 37 #include "UIIconPool.h" … … 38 39 #include "UIMediumManager.h" 39 40 #include "UIMediumSizeEditor.h" 40 #include "UI Common.h"41 #include "UITranslator.h" 41 42 42 43 /* COM includes: */ … … 777 778 if (!pWidget || pWidget == m_pErrorPaneSize) 778 779 m_pErrorPaneSize->setToolTip(tr("Cannot change medium size from <b>%1</b> to <b>%2</b> as storage shrinking is currently not implemented.") 779 .arg( uiCommon().formatSize(m_oldData.m_options.m_uLogicalSize))780 .arg( uiCommon().formatSize(m_newData.m_options.m_uLogicalSize)));780 .arg(UITranslator::formatSize(m_oldData.m_options.m_uLogicalSize)) 781 .arg(UITranslator::formatSize(m_newData.m_options.m_uLogicalSize))); 781 782 } 782 783 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp
r90564 r90967 29 29 #include "UIMessageCenter.h" 30 30 #include "UINotificationCenter.h" 31 #include "UITranslator.h" 31 32 32 33 /* COM includes: */ … … 143 144 { 144 145 int iColumn = treeWidget()->sortColumn(); 145 ULONG64 uThisValue = uiCommon().parseSize( text(iColumn));146 ULONG64 uThatValue = uiCommon().parseSize(other.text(iColumn));146 ULONG64 uThisValue = UITranslator::parseSize( text(iColumn)); 147 ULONG64 uThatValue = UITranslator::parseSize(other.text(iColumn)); 147 148 return uThisValue && uThatValue ? uThisValue < uThatValue : QTreeWidgetItem::operator<(other); 148 149 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90933 r90967 26 26 #include "UINotificationCenter.h" 27 27 #include "UINotificationObjects.h" 28 #include "UITranslator.h" 28 29 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 29 30 # include "UIDownloaderExtensionPack.h" … … 428 429 QString UINotificationProgressMediumCreate::details() const 429 430 { 430 return UINotificationProgress::tr("<b>Location:</b> %1<br><b>Size:</b> %2").arg(m_strLocation, uiCommon().formatSize(m_uSize));431 return UINotificationProgress::tr("<b>Location:</b> %1<br><b>Size:</b> %2").arg(m_strLocation, UITranslator::formatSize(m_uSize)); 431 432 } 432 433 … … 579 580 { 580 581 return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2") 581 .arg( uiCommon().formatSize(m_uFrom),582 uiCommon().formatSize(m_uTo));582 .arg(UITranslator::formatSize(m_uFrom), 583 UITranslator::formatSize(m_uTo)); 583 584 } 584 585 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r89323 r90967 24 24 #include "UIAutoCaptureKeyboardEditor.h" 25 25 #include "UICommon.h" 26 #include "UIExtraDataManager.h" 26 27 #include "UIGlobalSettingsInput.h" 27 28 #include "UIHostComboEditor.h" 28 29 #include "UIShortcutConfigurationEditor.h" 29 30 #include "UIShortcutPool.h" 30 #include "UI ExtraDataManager.h"31 #include "UITranslator.h" 31 32 32 33 … … 101 102 list << UIShortcutConfigurationItem(strShortcutKey, 102 103 shortcut.scope(), 103 UI Common::removeAccelMark(shortcut.description()),104 UITranslator::removeAccelMark(shortcut.description()), 104 105 shortcut.primaryToNativeText(), 105 106 shortcut.defaultSequence().toString(QKeySequence::NativeText)); … … 156 157 { 157 158 UIValidationMessage message; 158 message.first = UI Common::removeAccelMark(m_pEditorShortcutConfiguration->tabNameManager());159 message.first = UITranslator::removeAccelMark(m_pEditorShortcutConfiguration->tabNameManager()); 159 160 message.second << tr("Some items have the same shortcuts assigned."); 160 161 messages << message; … … 166 167 { 167 168 UIValidationMessage message; 168 message.first = UI Common::removeAccelMark(m_pEditorShortcutConfiguration->tabNameRuntime());169 message.first = UITranslator::removeAccelMark(m_pEditorShortcutConfiguration->tabNameRuntime()); 169 170 message.second << tr("Some items have the same shortcuts assigned."); 170 171 messages << message; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r87608 r90967 39 39 #include "UIMachineSettingsDisplay.h" 40 40 #include "UIScaleFactorEditor.h" 41 #include "UITranslator.h" 41 42 #include "UIVideoMemoryEditor.h" 42 43 … … 646 647 /* Prepare message: */ 647 648 UIValidationMessage message; 648 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(0));649 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(0)); 649 650 650 651 /* Video RAM amount test: */ … … 658 659 message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory " 659 660 "which is the minimum amount required to switch to full-screen or seamless mode.") 660 .arg( uiCommon().formatSize(uNeedBytes, 0, FormatSize_RoundUp));661 .arg(UITranslator::formatSize(uNeedBytes, 0, FormatSize_RoundUp)); 661 662 } 662 663 #ifdef VBOX_WITH_3D_ACCELERATION … … 670 671 "and the operating system hint is set to Windows Vista or later. " 671 672 "For best performance you should set the machine's video memory to at least <b>%1</b>.") 672 .arg( uiCommon().formatSize(uNeedBytes, 0, FormatSize_RoundUp));673 .arg(UITranslator::formatSize(uNeedBytes, 0, FormatSize_RoundUp)); 673 674 } 674 675 } … … 706 707 /* Prepare message: */ 707 708 UIValidationMessage message; 708 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(1));709 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(1)); 709 710 710 711 /* VRDE Extension Pack presence test: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r88446 r90967 36 36 #include "UINameAndSystemEditor.h" 37 37 #include "UIProgressObject.h" 38 #include "UITranslator.h" 38 39 39 40 /* COM includes: */ … … 383 384 384 385 /* 'Basic' tab validations: */ 385 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(0));386 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(0)); 386 387 message.second.clear(); 387 388 … … 407 408 408 409 /* 'Encryption' tab validations: */ 409 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(3));410 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(3)); 410 411 message.second.clear(); 411 412 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp
r87460 r90967 33 33 #include "UIConverter.h" 34 34 #include "UIErrorString.h" 35 #include "UIExtraDataManager.h" 35 36 #include "UIIconPool.h" 36 37 #include "UIMachineSettingsNetwork.h" 37 #include "UIExtraDataManager.h"38 38 #include "UINetworkAttachmentEditor.h" 39 #include "UITranslator.h" 39 40 40 41 /* COM includes: */ … … 421 422 /* Prepare message: */ 422 423 UIValidationMessage message; 423 message.first = uiCommon().removeAccelMark(tabTitle());424 message.first = UITranslator::removeAccelMark(tabTitle()); 424 425 425 426 /* Validate alternatives: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r86045 r90967 27 27 #include "QITabWidget.h" 28 28 #include "QIWidgetValidator.h" 29 #include "UICommon.h" 29 30 #include "UIConverter.h" 31 #include "UIErrorString.h" 30 32 #include "UIMachineSettingsSerial.h" 31 #include "UIErrorString.h" 32 #include "UICommon.h" 33 #include "UITranslator.h" 33 34 34 35 /* COM includes: */ … … 213 214 /* Polish port page: */ 214 215 ulong uIRQ, uIOBase; 215 const bool fStd = uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), uIRQ, uIOBase);216 const bool fStd = UITranslator::toCOMPortNumbers(m_pComboNumber->currentText(), uIRQ, uIOBase); 216 217 const KPortMode enmMode = m_pComboMode->currentData().value<KPortMode>(); 217 218 m_pCheckBoxPort->setEnabled(m_pParent->isMachineOffline()); … … 239 240 /* Load port data: */ 240 241 m_pCheckBoxPort->setChecked(portData.m_fPortEnabled); 241 m_pComboNumber->setCurrentIndex(m_pComboNumber->findText( uiCommon().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase)));242 m_pComboNumber->setCurrentIndex(m_pComboNumber->findText(UITranslator::toCOMPortName(portData.m_uIRQ, portData.m_uIOBase))); 242 243 m_pLineEditIRQ->setText(QString::number(portData.m_uIRQ)); 243 244 m_pLineEditIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper()); … … 283 284 { 284 285 ulong a, b; 285 return ! uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), a, b);286 return !UITranslator::toCOMPortNumbers(m_pComboNumber->currentText(), a, b); 286 287 } 287 288 … … 315 316 "the TCP \"port\" when in server mode, or \"hostname:port\" when in client mode.")); 316 317 317 m_pComboNumber->setItemText(m_pComboNumber->count() - 1, uiCommon().toCOMPortName(0, 0));318 m_pComboNumber->setItemText(m_pComboNumber->count() - 1, UITranslator::toCOMPortName(0, 0)); 318 319 319 320 /* Translate combo-boxes content: */ … … 339 340 { 340 341 ulong uIRQ, uIOBase; 341 bool fStd = uiCommon().toCOMPortNumbers(strText, uIRQ, uIOBase);342 bool fStd = UITranslator::toCOMPortNumbers(strText, uIRQ, uIOBase); 342 343 343 344 m_pLineEditIRQ->setEnabled(!fStd); … … 416 417 if (m_pLabelNumber) 417 418 m_pLabelNumber->setBuddy(m_pComboNumber); 418 m_pComboNumber->insertItem(0, uiCommon().toCOMPortName(0, 0));419 m_pComboNumber->insertItems(0, uiCommon().COMPortNames());419 m_pComboNumber->insertItem(0, UITranslator::toCOMPortName(0, 0)); 420 m_pComboNumber->insertItems(0, UITranslator::COMPortNames()); 420 421 pLayoutPortSettings->addWidget(m_pComboNumber, 0, 1); 421 422 } … … 688 689 /* Prepare message: */ 689 690 UIValidationMessage message; 690 message.first = uiCommon().removeAccelMark(m_pTabWidget->tabText(m_pTabWidget->indexOf(pTab)));691 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(m_pTabWidget->indexOf(pTab))); 691 692 692 693 /* Check the port attribute emptiness & uniqueness: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp
r86045 r90967 30 30 #include "UIBaseMemoryEditor.h" 31 31 #include "UIBootOrderEditor.h" 32 #include "UICommon.h" 32 33 #include "UIConverter.h" 34 #include "UIErrorString.h" 33 35 #include "UIIconPool.h" 34 36 #include "UIMachineSettingsSystem.h" 35 #include "UIErrorString.h" 36 #include "UICommon.h" 37 #include "UITranslator.h" 37 38 38 39 /* COM includes: */ … … 412 413 /* Prepare message: */ 413 414 UIValidationMessage message; 414 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(0));415 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(0)); 415 416 416 417 /* RAM amount test: */ … … 422 423 "Not enough memory is left for the host operating system. Please select a smaller amount.") 423 424 .arg((unsigned)qRound((double)m_pEditorBaseMemory->maxRAMAlw() / uFullSize * 100.0)) 424 .arg( uiCommon().formatSize((uint64_t)uFullSize * _1M));425 .arg(UITranslator::formatSize((uint64_t)uFullSize * _1M)); 425 426 fPass = false; 426 427 } … … 431 432 "There might not be enough memory left for the host operating system. Please consider selecting a smaller amount.") 432 433 .arg((unsigned)qRound((double)m_pEditorBaseMemory->maxRAMOpt() / uFullSize * 100.0)) 433 .arg( uiCommon().formatSize((uint64_t)uFullSize * _1M));434 .arg(UITranslator::formatSize((uint64_t)uFullSize * _1M)); 434 435 } 435 436 … … 461 462 /* Prepare message: */ 462 463 UIValidationMessage message; 463 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(1));464 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(1)); 464 465 465 466 /* VCPU amount test: */ … … 554 555 /* Prepare message: */ 555 556 UIValidationMessage message; 556 message.first = UI Common::removeAccelMark(m_pTabWidget->tabText(2));557 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(2)); 557 558 558 559 /* HW Virt Ex test: */ -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotDetailsWidget.cpp
r88862 r90967 34 34 #include "QIDialogButtonBox.h" 35 35 #include "QIFlowLayout.h" 36 #include "UICommon.h" 36 37 #include "UIConverter.h" 37 38 #include "UIDesktopWidgetWatchdog.h" … … 39 40 #include "UISnapshotDetailsWidget.h" 40 41 #include "UIMessageCenter.h" 41 #include "UI Common.h"42 #include "UITranslator.h" 42 43 #include "VBoxUtils.h" 43 44 … … 1913 1914 /* Compose the data: */ 1914 1915 QStringList aInfo; 1915 aInfo << uiCommon().toCOMPortName(comPort.GetIRQ(), comPort.GetIOBase());1916 aInfo << UITranslator::toCOMPortName(comPort.GetIRQ(), comPort.GetIOBase()); 1916 1917 if ( enmMode == KPortMode_HostPipe 1917 1918 || enmMode == KPortMode_HostDevice -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp
r90737 r90967 32 32 /* GUI includes: */ 33 33 #include "QIMessageBox.h" 34 #include "QIToolBar.h" 34 35 #include "QITreeWidget.h" 35 36 #include "UIActionPoolManager.h" … … 43 44 #include "UISnapshotPane.h" 44 45 #include "UITakeSnapshotDialog.h" 45 #include " QIToolBar.h"46 #include "UITranslator.h" 46 47 #include "UIVirtualBoxEventHandler.h" 47 48 #include "UIWizardCloneVM.h" … … 357 358 { 358 359 strAge = tr("%1 (%2 ago)", "date time (how long ago)") 359 .arg(then.toString(Qt::LocalDate), UI Common::daysToString(then.secsTo(now) / 60 / 60 / 24));360 .arg(then.toString(Qt::LocalDate), UITranslator::daysToString(then.secsTo(now) / 60 / 60 / 24)); 360 361 enmAgeFormat = SnapshotAgeFormat_InDays; 361 362 } … … 363 364 { 364 365 strAge = tr("%1 (%2 ago)", "date time (how long ago)") 365 .arg(then.toString(Qt::LocalDate), UI Common::hoursToString(then.secsTo(now) / 60 / 60));366 .arg(then.toString(Qt::LocalDate), UITranslator::hoursToString(then.secsTo(now) / 60 / 60)); 366 367 enmAgeFormat = SnapshotAgeFormat_InHours; 367 368 } … … 369 370 { 370 371 strAge = tr("%1 (%2 ago)", "date time (how long ago)") 371 .arg(then.toString(Qt::LocalDate), UI Common::minutesToString(then.secsTo(now) / 60));372 .arg(then.toString(Qt::LocalDate), UITranslator::minutesToString(then.secsTo(now) / 60)); 372 373 enmAgeFormat = SnapshotAgeFormat_InMinutes; 373 374 } … … 375 376 { 376 377 strAge = tr("%1 (%2 ago)", "date time (how long ago)") 377 .arg(then.toString(Qt::LocalDate), UI Common::secondsToString(then.secsTo(now)));378 .arg(then.toString(Qt::LocalDate), UITranslator::secondsToString(then.secsTo(now))); 378 379 enmAgeFormat = SnapshotAgeFormat_InSeconds; 379 380 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMediumSizeEditor.cpp
r90761 r90967 27 27 #include "UIConverter.h" 28 28 #include "UIMediumSizeEditor.h" 29 #include "UITranslator.h" 29 30 30 31 /* COM includes: */ … … 48 49 /* Prepare: */ 49 50 prepare(); 50 QString strRegEx = QString("[^\\d%1]").arg( uiCommon().decimalSep());51 QString strRegEx = QString("[^\\d%1]").arg(UITranslator::decimalSep()); 51 52 m_regExNonDigitOrSeparator = QRegularExpression(strRegEx); 52 53 } … … 62 63 m_pSlider->blockSignals(false); 63 64 m_pEditor->blockSignals(true); 64 m_pEditor->setText( uiCommon().formatSize(m_uSize));65 m_enmSizeSuffix = uiCommon().parseSizeSuffix(m_pEditor->text());65 m_pEditor->setText(UITranslator::formatSize(m_uSize)); 66 m_enmSizeSuffix = UITranslator::parseSizeSuffix(m_pEditor->text()); 66 67 m_pEditor->blockSignals(false); 67 68 … … 73 74 { 74 75 /* Translate labels: */ 75 m_pLabelMinSize->setText( uiCommon().formatSize(m_uSizeMin));76 m_pLabelMaxSize->setText( uiCommon().formatSize(m_uSizeMax));76 m_pLabelMinSize->setText(UITranslator::formatSize(m_uSizeMin)); 77 m_pLabelMaxSize->setText(UITranslator::formatSize(m_uSizeMax)); 77 78 78 79 /* Translate fields: */ … … 90 91 /* Update the other widget: */ 91 92 m_pEditor->blockSignals(true); 92 m_pEditor->setText( uiCommon().formatSize(m_uSize));93 m_enmSizeSuffix = uiCommon().parseSizeSuffix(m_pEditor->text());93 m_pEditor->setText(UITranslator::formatSize(m_uSize)); 94 m_enmSizeSuffix = UITranslator::parseSizeSuffix(m_pEditor->text()); 94 95 m_pEditor->blockSignals(false); 95 96 /* Update the tool-tips: */ … … 111 112 112 113 /* Update the current size: */ 113 m_uSize = checkSectorSizeAlignment( uiCommon().parseSize(strSizeString));114 m_uSize = checkSectorSizeAlignment(UITranslator::parseSize(strSizeString)); 114 115 115 116 /* Update the other widget: */ … … 126 127 { 127 128 /* Try to update the m_enmSizeSuffix: */ 128 if ( uiCommon().hasSizeSuffix(strSizeString))129 m_enmSizeSuffix = uiCommon().parseSizeSuffix(strSizeString);129 if (UITranslator::hasSizeSuffix(strSizeString)) 130 m_enmSizeSuffix = UITranslator::parseSizeSuffix(strSizeString); 130 131 131 132 QString strOnlyDigits(strSizeString); … … 198 199 m_pEditor->setFixedWidthByText("88888.88 MB"); 199 200 m_pEditor->setAlignment(Qt::AlignRight); 200 m_pEditor->setValidator(new QRegExpValidator(QRegExp( uiCommon().sizeRegexp()), this));201 m_pEditor->setValidator(new QRegExpValidator(QRegExp(UITranslator::sizeRegexp()), this)); 201 202 connect(m_pEditor, &QILineEdit::textChanged, 202 203 this, &UIMediumSizeEditor::sltSizeEditorTextChanged); … … 287 288 void UIMediumSizeEditor::updateSizeToolTips(qulonglong uSize) 288 289 { 289 const QString strToolTip = tr("<nobr>%1 (%2 B)</nobr>").arg( uiCommon().formatSize(uSize)).arg(uSize);290 const QString strToolTip = tr("<nobr>%1 (%2 B)</nobr>").arg(UITranslator::formatSize(uSize)).arg(uSize); 290 291 m_pSlider->setToolTip(strToolTip); 291 292 m_pEditor->setToolTip(strToolTip); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp
r86772 r90967 34 34 #include "UIProgressEventHandler.h" 35 35 #include "UISpecialControls.h" 36 #include "UI Common.h"36 #include "UITranslator.h" 37 37 #ifdef VBOX_WS_MAC 38 38 # include "VBoxUtils-darwin.h" … … 423 423 iHours -= iDays * 24; 424 424 425 const QString strDays = UI Common::daysToString(iDays);426 const QString strHours = UI Common::hoursToString(iHours);427 const QString strMinutes = UI Common::minutesToString(iMinutes);428 const QString strSeconds = UI Common::secondsToString(iSeconds);425 const QString strDays = UITranslator::daysToString(iDays); 426 const QString strHours = UITranslator::hoursToString(iHours); 427 const QString strMinutes = UITranslator::minutesToString(iMinutes); 428 const QString strSeconds = UITranslator::secondsToString(iSeconds); 429 429 430 430 const QString strTwoComp = tr("%1, %2 remaining", "You may wish to translate this more like \"Time remaining: %1, %2\"");
Note:
See TracChangeset
for help on using the changeset viewer.

