儲存庫 vbox 的更動 91121
- 時間撮記:
- 2021-9-6 下午12:32:06 (3 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src
- 檔案:
-
- 修改 5 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r91114 r91121 1161 1161 #endif /* VBOX_GUI_WITH_PIDFILE */ 1162 1162 1163 /* static */1164 QString UICommon::helpFile()1165 {1166 #if defined (VBOX_WITH_QHELP_VIEWER)1167 const QString strName = "UserManual";1168 const QString strSuffix = "qhc";1169 #else1170 #if defined(VBOX_WS_WIN)1171 const QString strName = "VirtualBox";1172 const QString strSuffix = "chm";1173 #elif defined(VBOX_WS_MAC)1174 const QString strName = "UserManual";1175 const QString strSuffix = "pdf";1176 #elif defined(VBOX_WS_X11)1177 //# if defined(VBOX_OSE) || !defined(VBOX_WITH_KCHMVIEWER)1178 const QString strName = "UserManual";1179 const QString strSuffix = "pdf";1180 #endif1181 #endif1182 /* Where are the docs located? */1183 char szDocsPath[RTPATH_MAX];1184 int rc = RTPathAppDocs(szDocsPath, sizeof(szDocsPath));1185 AssertRC(rc);1186 1187 /* Make sure that the language is in two letter code.1188 * Note: if languageId() returns an empty string lang.name() will1189 * return "C" which is an valid language code. */1190 QLocale lang(UITranslator::languageId());1191 1192 /* Construct the path and the filename: */1193 QString strManual = QString("%1/%2_%3.%4").arg(szDocsPath)1194 .arg(strName)1195 .arg(lang.name())1196 .arg(strSuffix);1197 1198 /* Check if a help file with that name exists: */1199 QFileInfo fi(strManual);1200 if (fi.exists())1201 return strManual;1202 1203 /* Fall back to the standard: */1204 strManual = QString("%1/%2.%4").arg(szDocsPath)1205 .arg(strName)1206 .arg(strSuffix);1207 return strManual;1208 }1209 1210 /* static */1211 QString UICommon::documentsPath()1212 {1213 QString strPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);1214 QDir dir(strPath);1215 if (dir.exists())1216 return QDir::cleanPath(dir.canonicalPath());1217 else1218 {1219 dir.setPath(QDir::homePath() + "/Documents");1220 if (dir.exists())1221 return QDir::cleanPath(dir.canonicalPath());1222 else1223 return QDir::homePath();1224 }1225 }1226 1227 /* static */1228 bool UICommon::hasAllowedExtension(const QString &strFileName, const QStringList &extensions)1229 {1230 foreach (const QString &strExtension, extensions)1231 if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))1232 return true;1233 return false;1234 }1235 1236 /* static */1237 QString UICommon::findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName)1238 {1239 QDir folder(strFullFolderPath);1240 if (!folder.exists())1241 return strBaseFileName;1242 QFileInfoList folderContent = folder.entryInfoList();1243 QSet<QString> fileNameSet;1244 foreach (const QFileInfo &fileInfo, folderContent)1245 {1246 /* Remove the extension : */1247 fileNameSet.insert(fileInfo.completeBaseName());1248 }1249 int iSuffix = 0;1250 QString strNewName(strBaseFileName);1251 while (fileNameSet.contains(strNewName))1252 {1253 strNewName = strBaseFileName + QString("_") + QString::number(++iSuffix);1254 }1255 return strNewName;1256 }1257 1258 /* static */1259 void UICommon::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount)1260 {1261 /* Shame on Qt it hasn't stuff for tuning1262 * widget size suitable for reflecting content of desired size.1263 * For example QLineEdit, QSpinBox and similar widgets should have a methods1264 * to strict the minimum width to reflect at least [n] symbols. */1265 1266 /* Load options: */1267 QStyleOptionSpinBox option;1268 option.initFrom(pSpinBox);1269 1270 /* Acquire edit-field rectangle: */1271 QRect rect = pSpinBox->style()->subControlRect(QStyle::CC_SpinBox,1272 &option,1273 QStyle::SC_SpinBoxEditField,1274 pSpinBox);1275 1276 /* Calculate minimum-width magic: */1277 const int iSpinBoxWidth = pSpinBox->width();1278 const int iSpinBoxEditFieldWidth = rect.width();1279 const int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth);1280 QFontMetrics metrics(pSpinBox->font(), pSpinBox);1281 const QString strDummy(cCount, '0');1282 const int iTextWidth = metrics.width(strDummy);1283 1284 /* Tune spin-box minimum-width: */1285 pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta);1286 }1287 1288 1163 QString UICommon::vmGuestOSFamilyDescription(const QString &strFamilyId) const 1289 1164 { … … 1302 1177 1303 1178 CGuestOSType UICommon::vmGuestOSType(const QString &strTypeId, 1304 1179 const QString &strFamilyId /* = QString() */) const 1305 1180 { 1306 1181 QList<CGuestOSType> list; … … 1394 1269 } 1395 1270 1271 /* static */ 1396 1272 bool UICommon::launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode /* = LaunchMode_Default */) 1397 1273 { … … 1400 1276 && comMachine.CanShowConsoleWindow()) 1401 1277 { 1402 switch (ui Type())1278 switch (uiCommon().uiType()) 1403 1279 { 1404 1280 /* For Selector UI: */ … … 1460 1336 { 1461 1337 case LaunchMode_Default: strType = ""; break; 1462 case LaunchMode_Separate: strType = isSeparateProcess() ? "headless" : "separate"; break;1338 case LaunchMode_Separate: strType = uiCommon().isSeparateProcess() ? "headless" : "separate"; break; 1463 1339 case LaunchMode_Headless: strType = "headless"; break; 1464 1340 default: AssertFailedReturn(false); … … 2379 2255 } 2380 2256 2381 QString UICommon:: details(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml /* = true */)2257 QString UICommon::storageDetails(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml /* = true */) 2382 2258 { 2383 2259 /* Search for corresponding UI medium: */ … … 2664 2540 } 2665 2541 2542 /* static */ 2543 QString UICommon::helpFile() 2544 { 2545 #if defined (VBOX_WITH_QHELP_VIEWER) 2546 const QString strName = "UserManual"; 2547 const QString strSuffix = "qhc"; 2548 #else 2549 #if defined(VBOX_WS_WIN) 2550 const QString strName = "VirtualBox"; 2551 const QString strSuffix = "chm"; 2552 #elif defined(VBOX_WS_MAC) 2553 const QString strName = "UserManual"; 2554 const QString strSuffix = "pdf"; 2555 #elif defined(VBOX_WS_X11) 2556 //# if defined(VBOX_OSE) || !defined(VBOX_WITH_KCHMVIEWER) 2557 const QString strName = "UserManual"; 2558 const QString strSuffix = "pdf"; 2559 #endif 2560 #endif 2561 /* Where are the docs located? */ 2562 char szDocsPath[RTPATH_MAX]; 2563 int rc = RTPathAppDocs(szDocsPath, sizeof(szDocsPath)); 2564 AssertRC(rc); 2565 2566 /* Make sure that the language is in two letter code. 2567 * Note: if languageId() returns an empty string lang.name() will 2568 * return "C" which is an valid language code. */ 2569 QLocale lang(UITranslator::languageId()); 2570 2571 /* Construct the path and the filename: */ 2572 QString strManual = QString("%1/%2_%3.%4").arg(szDocsPath) 2573 .arg(strName) 2574 .arg(lang.name()) 2575 .arg(strSuffix); 2576 2577 /* Check if a help file with that name exists: */ 2578 QFileInfo fi(strManual); 2579 if (fi.exists()) 2580 return strManual; 2581 2582 /* Fall back to the standard: */ 2583 strManual = QString("%1/%2.%4").arg(szDocsPath) 2584 .arg(strName) 2585 .arg(strSuffix); 2586 return strManual; 2587 } 2588 2589 /* static */ 2590 QString UICommon::documentsPath() 2591 { 2592 QString strPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); 2593 QDir dir(strPath); 2594 if (dir.exists()) 2595 return QDir::cleanPath(dir.canonicalPath()); 2596 else 2597 { 2598 dir.setPath(QDir::homePath() + "/Documents"); 2599 if (dir.exists()) 2600 return QDir::cleanPath(dir.canonicalPath()); 2601 else 2602 return QDir::homePath(); 2603 } 2604 } 2605 2606 /* static */ 2607 bool UICommon::hasAllowedExtension(const QString &strFileName, const QStringList &extensions) 2608 { 2609 foreach (const QString &strExtension, extensions) 2610 if (strFileName.endsWith(strExtension, Qt::CaseInsensitive)) 2611 return true; 2612 return false; 2613 } 2614 2615 /* static */ 2616 QString UICommon::findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName) 2617 { 2618 QDir folder(strFullFolderPath); 2619 if (!folder.exists()) 2620 return strBaseFileName; 2621 QFileInfoList folderContent = folder.entryInfoList(); 2622 QSet<QString> fileNameSet; 2623 foreach (const QFileInfo &fileInfo, folderContent) 2624 { 2625 /* Remove the extension : */ 2626 fileNameSet.insert(fileInfo.completeBaseName()); 2627 } 2628 int iSuffix = 0; 2629 QString strNewName(strBaseFileName); 2630 while (fileNameSet.contains(strNewName)) 2631 { 2632 strNewName = strBaseFileName + QString("_") + QString::number(++iSuffix); 2633 } 2634 return strNewName; 2635 } 2636 2637 /* static */ 2638 void UICommon::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount) 2639 { 2640 /* Shame on Qt it hasn't stuff for tuning 2641 * widget size suitable for reflecting content of desired size. 2642 * For example QLineEdit, QSpinBox and similar widgets should have a methods 2643 * to strict the minimum width to reflect at least [n] symbols. */ 2644 2645 /* Load options: */ 2646 QStyleOptionSpinBox option; 2647 option.initFrom(pSpinBox); 2648 2649 /* Acquire edit-field rectangle: */ 2650 QRect rect = pSpinBox->style()->subControlRect(QStyle::CC_SpinBox, 2651 &option, 2652 QStyle::SC_SpinBoxEditField, 2653 pSpinBox); 2654 2655 /* Calculate minimum-width magic: */ 2656 const int iSpinBoxWidth = pSpinBox->width(); 2657 const int iSpinBoxEditFieldWidth = rect.width(); 2658 const int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth); 2659 QFontMetrics metrics(pSpinBox->font(), pSpinBox); 2660 const QString strDummy(cCount, '0'); 2661 const int iTextWidth = metrics.width(strDummy); 2662 2663 /* Tune spin-box minimum-width: */ 2664 pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta); 2665 } 2666 2666 2667 #ifdef VBOX_WITH_3D_ACCELERATION 2667 2668 /* static */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r91109 r91121 298 298 /** @} */ 299 299 300 /** @name File-system stuff.301 * @{ */302 /** Returns full help file name. */303 static QString helpFile();304 305 /** Returns documents path. */306 static QString documentsPath();307 308 /** Returns whether passed @a strFileName ends with one of allowed extension in the @a extensions list. */309 static bool hasAllowedExtension(const QString &strFileName, const QStringList &extensions);310 311 /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts312 * searching strBaseFileName and adds suffixes until a unique file name is found. */313 static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName);314 /** @} */315 316 /** @name Widget stuff.317 * @{ */318 /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */319 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);320 /** @} */321 322 300 /** @name COM stuff. 323 301 * @{ */ … … 340 318 /** @} */ 341 319 342 /** @name COM: Guest OS Type .320 /** @name COM: Guest OS Type stuff. 343 321 * @{ */ 344 322 /** Returns the list of family IDs. */ … … 365 343 static bool switchToMachine(CMachine &comMachine); 366 344 /** Launches certain @a comMachine in specified @a enmLaunchMode. */ 367 bool launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode = LaunchMode_Default);345 static bool launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode = LaunchMode_Default); 368 346 369 347 /** Opens session of certain @a enmLockType for VM with certain @a uId. */ … … 377 355 /** @} */ 378 356 379 /** @name C loud Virtual Machine stuff.357 /** @name COM: Cloud Virtual Machine stuff. 380 358 * @{ */ 381 359 /** Notifies listeners about cloud VM was unregistered. … … 425 403 * @param fUseLastFolder Brings whether we should propose to use last used folder. */ 426 404 QUuid openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent = 0, 427 405 const QString &strDefaultFolder = QString(), bool fUseLastFolder = false); 428 406 429 407 /** Creates and shows a UIMediumSelector dialog. … … 469 447 * @param fPredictDiff Brings whether medium will be marked differencing on attaching. 470 448 * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */ 471 QString details(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml = true);449 QString storageDetails(const CMedium &comMedium, bool fPredictDiff, bool fUseHtml = true); 472 450 473 451 /** Update extra data related to recently used/referred media. … … 497 475 /** Generates tool-tip for passed USB @a comWebcam. */ 498 476 static QString toolTip(const CHostVideoInputDevice &comWebcam); 477 /** @} */ 478 479 /** @name File-system stuff. 480 * @{ */ 481 /** Returns full help file name. */ 482 static QString helpFile(); 483 484 /** Returns documents path. */ 485 static QString documentsPath(); 486 487 /** Returns whether passed @a strFileName ends with one of allowed extension in the @a extensions list. */ 488 static bool hasAllowedExtension(const QString &strFileName, const QStringList &extensions); 489 490 /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts 491 * searching strBaseFileName and adds suffixes until a unique file name is found. */ 492 static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName); 493 /** @} */ 494 495 /** @name Widget stuff. 496 * @{ */ 497 /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */ 498 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount); 499 499 /** @} */ 500 500 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp
r90967 r91121 516 516 517 517 /* Prepare attachment information: */ 518 QString strAttachmentInfo = uiCommon(). details(attachment.GetMedium(), false, false);518 QString strAttachmentInfo = uiCommon().storageDetails(attachment.GetMedium(), false, false); 519 519 /* That hack makes sure 'Inaccessible' word is always bold: */ 520 520 { // hack -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r88633 r91121 81 81 82 82 /* Try to launch corresponding machine: */ 83 if (! uiCommon().launchMachine(machine, UICommon::LaunchMode_Separate))83 if (!UICommon::launchMachine(machine, UICommon::LaunchMode_Separate)) 84 84 return false; 85 85 } -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotDetailsWidget.cpp
r91109 r91121 1795 1795 /* Prepare current medium information: */ 1796 1796 const QString strMediumInfo = comAttachment.isOk() 1797 ? wipeHtmlStuff(uiCommon(). details(comAttachment.GetMedium(), false))1797 ? wipeHtmlStuff(uiCommon().storageDetails(comAttachment.GetMedium(), false)) 1798 1798 : QString(); 1799 1799
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器