Changeset 72628 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 20, 2018 1:57:27 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r72626 r72628 185 185 186 186 /** Constructs translator passing @a pParent to the base-class. */ 187 VBoxTranslator (QObject *pParent = 0) 188 : QTranslator (pParent) {} 187 VBoxTranslator(QObject *pParent = 0) 188 : QTranslator(pParent) 189 {} 189 190 190 191 /** Loads language file with gained @a strFileName. */ 191 bool loadFile 192 { 193 QFile file 194 if (!file.open 192 bool loadFile(const QString &strFileName) 193 { 194 QFile file(strFileName); 195 if (!file.open(QIODevice::ReadOnly)) 195 196 return false; 196 197 m_data = file.readAll(); 197 return load 198 return load((uchar*)m_data.data(), m_data.size()); 198 199 } 199 200 … … 242 243 bool VBoxGlobal::s_fCleaningUp = false; 243 244 QString VBoxGlobal::s_strLoadedLanguageId = vboxBuiltInLanguageName(); 245 QString VBoxGlobal::s_strUserDefinedPortName = QString(); 244 246 245 247 /* static */ … … 346 348 QString VBoxGlobal::qtRTVersionString() 347 349 { 348 return QString::fromLatin1 350 return QString::fromLatin1(qVersion()); 349 351 } 350 352 … … 352 354 uint VBoxGlobal::qtRTVersion() 353 355 { 354 QString strVersionRT = VBoxGlobal::qtRTVersionString();355 return (strVersionRT.section 356 (strVersionRT.section 357 strVersionRT.section 356 const QString strVersionRT = VBoxGlobal::qtRTVersionString(); 357 return (strVersionRT.section('.', 0, 0).toInt() << 16) + 358 (strVersionRT.section('.', 1, 1).toInt() << 8) + 359 strVersionRT.section('.', 2, 2).toInt(); 358 360 } 359 361 … … 361 363 QString VBoxGlobal::qtCTVersionString() 362 364 { 363 return QString::fromLatin1 365 return QString::fromLatin1(QT_VERSION_STR); 364 366 } 365 367 … … 367 369 uint VBoxGlobal::qtCTVersion() 368 370 { 369 QString strVersionCompiled = VBoxGlobal::qtCTVersionString();371 const QString strVersionCompiled = VBoxGlobal::qtCTVersionString(); 370 372 return (strVersionCompiled.section('.', 0, 0).toInt() << 16) + 371 373 (strVersionCompiled.section('.', 1, 1).toInt() << 8) + … … 416 418 #endif /* VBOX_WS_MAC */ 417 419 418 bool VBoxGlobal::brandingIsActive 420 bool VBoxGlobal::brandingIsActive(bool fForce /* = false */) 419 421 { 420 422 if (fForce) … … 426 428 m_strBrandingConfigFilePath += "/custom/custom.ini"; 427 429 } 428 return QFile::exists (m_strBrandingConfigFilePath); 429 } 430 431 QString VBoxGlobal::brandingGetKey (QString strKey) 430 431 return QFile::exists(m_strBrandingConfigFilePath); 432 } 433 434 QString VBoxGlobal::brandingGetKey(QString strKey) 432 435 { 433 436 QSettings settings(m_strBrandingConfigFilePath, QSettings::IniFormat); … … 448 451 /* Among those arguments: */ 449 452 bool fResult = false; 450 QStringList args = qApp->arguments(); 453 const QStringList args = qApp->arguments(); 454 451 455 /* We are looking for a list of file URLs passed to the executable: */ 452 456 QList<QUrl> listArgUrls; … … 457 461 if (args.at(i).startsWith("-")) 458 462 break; 463 459 464 #ifdef VBOX_WS_MAC 460 QString strArg = ::darwinResolveAlias(args.at(i)); 461 #else /* VBOX_WS_MAC */ 462 QString strArg = args.at(i); 463 #endif /* !VBOX_WS_MAC */ 465 const QString strArg = ::darwinResolveAlias(args.at(i)); 466 #else 467 const QString strArg = args.at(i); 468 #endif 469 464 470 /* So if the argument file exists, we add it to URL list: */ 465 471 if ( !strArg.isEmpty() … … 467 473 listArgUrls << QUrl::fromLocalFile(strArg); 468 474 } 475 469 476 /* If there are file URLs: */ 470 477 if (!listArgUrls.isEmpty()) … … 474 481 { 475 482 /* Check which of them has allowed VM extensions: */ 476 const QString &strFile = listArgUrls.at(i).toLocalFile();483 const QString &strFile = listArgUrls.at(i).toLocalFile(); 477 484 if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts)) 478 485 { … … 490 497 } 491 498 } 499 492 500 /* And if there are *still* URLs: */ 493 501 if (!listArgUrls.isEmpty()) … … 498 506 emit sigAskToOpenURLs(); 499 507 } 508 500 509 return fResult; 501 510 } … … 540 549 if (!m_strPidFile.isEmpty()) 541 550 { 542 qint64 iPid = qApp->applicationPid();551 const qint64 iPid = qApp->applicationPid(); 543 552 QFile file(m_strPidFile); 544 553 if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) … … 561 570 #endif /* VBOX_GUI_WITH_PIDFILE */ 562 571 563 QString VBoxGlobal::languageName() const 572 /* static */ 573 QString VBoxGlobal::languageName() 564 574 { 565 575 /* Returns "English" if no translation is installed 566 576 * or if the translation file is invalid. */ 567 return qApp->translate ("@@@", "English", 568 "Native language name"); 569 } 570 571 QString VBoxGlobal::languageCountry() const 577 return QApplication::translate("@@@", "English", 578 "Native language name"); 579 } 580 581 /* static */ 582 QString VBoxGlobal::languageCountry() 572 583 { 573 584 /* Returns "--" if no translation is installed or if the translation file 574 585 * is invalid, or if the language is independent on the country. */ 575 return qApp->translate ("@@@", "--", 576 "Native language country name " 577 "(empty if this language is for all countries)"); 578 } 579 580 QString VBoxGlobal::languageNameEnglish() const 586 return QApplication::translate("@@@", "--", 587 "Native language country name " 588 "(empty if this language is for all countries)"); 589 } 590 591 /* static */ 592 QString VBoxGlobal::languageNameEnglish() 581 593 { 582 594 /* Returns "English" if no translation is installed 583 595 * or if the translation file is invalid. */ 584 return qApp->translate ("@@@", "English", 585 "Language name, in English"); 586 } 587 588 QString VBoxGlobal::languageCountryEnglish() const 596 return QApplication::translate("@@@", "English", 597 "Language name, in English"); 598 } 599 600 /* static */ 601 QString VBoxGlobal::languageCountryEnglish() 589 602 { 590 603 /* Returns "--" if no translation is installed or if the translation file 591 604 * is invalid, or if the language is independent on the country. */ 592 return qApp->translate ("@@@", "--", 593 "Language country name, in English " 594 "(empty if native country name is empty)"); 595 } 596 597 QString VBoxGlobal::languageTranslators() const 605 return QApplication::translate("@@@", "--", 606 "Language country name, in English " 607 "(empty if native country name is empty)"); 608 } 609 610 /* static */ 611 QString VBoxGlobal::languageTranslators() 598 612 { 599 613 /* Returns "Oracle Corporation" if no translation is installed or if the translation file 600 614 * is invalid, or if the translation is supplied by Oracle Corporation. */ 601 return qApp->translate("@@@", "Oracle Corporation",602 "Comma-separated list of translators");615 return QApplication::translate("@@@", "Oracle Corporation", 616 "Comma-separated list of translators"); 603 617 } 604 618 … … 660 674 * This method will return "C" when the requested locale is invalid or when the "C" locale is set explicitly. */ 661 675 662 #if defined 676 #if defined(VBOX_WS_MAC) 663 677 /* QLocale return the right id only if the user select the format 664 678 * of the language also. So we use our own implementation */ 665 679 return ::darwinSystemLanguage(); 666 #elif defined 667 const char *pszValue = RTEnvGet 680 #elif defined(Q_OS_UNIX) 681 const char *pszValue = RTEnvGet("LC_ALL"); 668 682 if (pszValue == 0) 669 pszValue = RTEnvGet 683 pszValue = RTEnvGet("LC_MESSAGES"); 670 684 if (pszValue == 0) 671 pszValue = RTEnvGet 685 pszValue = RTEnvGet("LANG"); 672 686 if (pszValue != 0) 673 return QLocale 687 return QLocale(pszValue).name(); 674 688 #endif 675 return QLocale::system().name(); 676 } 677 678 /* static */ 679 void VBoxGlobal::loadLanguage (const QString &strLangId) 680 { 681 QString strEffectiveLangId = strLangId.isEmpty() ? 682 VBoxGlobal::systemLanguageId() : strLangId; 689 return QLocale::system().name(); 690 } 691 692 /* static */ 693 void VBoxGlobal::loadLanguage(const QString &strLangId) 694 { 695 QString strEffectiveLangId = strLangId.isEmpty() 696 ? VBoxGlobal::systemLanguageId() 697 : strLangId; 683 698 QString strLanguageFileName; 684 699 QString strSelectedLangId = vboxBuiltInLanguageName(); … … 698 713 699 714 rc = RTPathAppPrivateNoArch(szNlsPath, sizeof(szNlsPath)); 700 AssertRC 715 AssertRC(rc); 701 716 702 717 QString strNlsPath = QString(szNlsPath) + vboxLanguageSubDirectory(); 703 QDir nlsDir 704 705 Assert 718 QDir nlsDir(strNlsPath); 719 720 Assert(!strEffectiveLangId.isEmpty()); 706 721 if (!strEffectiveLangId.isEmpty() && strEffectiveLangId != vboxBuiltInLanguageName()) 707 722 { 708 QRegExp regExp (vboxLanguageIdRegExp()); 709 int iPos = regExp.indexIn (strEffectiveLangId); 710 /* the language ID should match the regexp completely */ 711 AssertReturnVoid (iPos == 0); 712 713 QString strStrippedLangId = regExp.cap (2); 714 715 if (nlsDir.exists (vboxLanguageFileBase() + strEffectiveLangId + vboxLanguageFileExtension())) 716 { 717 strLanguageFileName = nlsDir.absoluteFilePath (vboxLanguageFileBase() + strEffectiveLangId + 718 vboxLanguageFileExtension()); 723 QRegExp regExp(vboxLanguageIdRegExp()); 724 int iPos = regExp.indexIn(strEffectiveLangId); 725 /* The language ID should match the regexp completely: */ 726 AssertReturnVoid(iPos == 0); 727 728 QString strStrippedLangId = regExp.cap(2); 729 730 if (nlsDir.exists(vboxLanguageFileBase() + strEffectiveLangId + vboxLanguageFileExtension())) 731 { 732 strLanguageFileName = nlsDir.absoluteFilePath(vboxLanguageFileBase() + 733 strEffectiveLangId + 734 vboxLanguageFileExtension()); 719 735 strSelectedLangId = strEffectiveLangId; 720 736 } 721 else if (nlsDir.exists (vboxLanguageFileBase() + strStrippedLangId + vboxLanguageFileExtension())) 722 { 723 strLanguageFileName = nlsDir.absoluteFilePath (vboxLanguageFileBase() + strStrippedLangId + 724 vboxLanguageFileExtension()); 737 else if (nlsDir.exists(vboxLanguageFileBase() + strStrippedLangId + vboxLanguageFileExtension())) 738 { 739 strLanguageFileName = nlsDir.absoluteFilePath(vboxLanguageFileBase() + 740 strStrippedLangId + 741 vboxLanguageFileExtension()); 725 742 strSelectedLangId = strStrippedLangId; 726 743 } … … 731 748 * fall-back to English (built-in). */ 732 749 if (!strLangId.isNull() && strEffectiveLangId != "en") 733 msgCenter().cannotFindLanguage 750 msgCenter().cannotFindLanguage(strEffectiveLangId, strNlsPath); 734 751 /* strSelectedLangId remains built-in here: */ 735 AssertReturnVoid 752 AssertReturnVoid(strSelectedLangId == vboxBuiltInLanguageName()); 736 753 } 737 754 } … … 747 764 748 765 /* Load new language files: */ 749 sTranslator = new VBoxTranslator 750 Assert 766 sTranslator = new VBoxTranslator(qApp); 767 Assert(sTranslator); 751 768 bool fLoadOk = true; 752 769 if (sTranslator) … … 754 771 if (strSelectedLangId != vboxBuiltInLanguageName()) 755 772 { 756 Assert 757 fLoadOk = sTranslator->loadFile 773 Assert(!strLanguageFileName.isNull()); 774 fLoadOk = sTranslator->loadFile(strLanguageFileName); 758 775 } 759 776 /* We install the translator in any case: on failure, this will 760 777 * activate an empty translator that will give us English (built-in): */ 761 qApp->installTranslator 778 qApp->installTranslator(sTranslator); 762 779 } 763 780 else … … 768 785 else 769 786 { 770 msgCenter().cannotLoadLanguage 787 msgCenter().cannotLoadLanguage(strLanguageFileName); 771 788 s_strLoadedLanguageId = vboxBuiltInLanguageName(); 772 789 } … … 780 797 strLanguageFileName = QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + 781 798 languageId() + vboxLanguageFileExtension(); 782 QTranslator *pQtSysTr = new QTranslator 783 Assert 784 if (pQtSysTr && pQtSysTr->load 785 qApp->installTranslator 799 QTranslator *pQtSysTr = new QTranslator(sTranslator); 800 Assert(pQtSysTr); 801 if (pQtSysTr && pQtSysTr->load(strLanguageFileName)) 802 qApp->installTranslator(pQtSysTr); 786 803 /* Note that the Qt translation supplied by Oracle is always loaded 787 804 * afterwards to make sure it will take precedence over the system … … 793 810 * Oracle translation is always the best one. */ 794 811 #endif 795 strLanguageFileName = nlsDir.absoluteFilePath (QString("qt_") +796 797 798 QTranslator *pQtTr = new QTranslator 799 Assert 800 if (pQtTr && (fLoadOk = pQtTr->load 801 qApp->installTranslator 812 strLanguageFileName = nlsDir.absoluteFilePath(QString("qt_") + 813 languageId() + 814 vboxLanguageFileExtension()); 815 QTranslator *pQtTr = new QTranslator(sTranslator); 816 Assert(pQtTr); 817 if (pQtTr && (fLoadOk = pQtTr->load(strLanguageFileName))) 818 qApp->installTranslator(pQtTr); 802 819 /* The below message doesn't fit 100% (because it's an additional 803 820 * language and the main one won't be reset to built-in on failure) … … 805 822 * message (but still, having something is better than having none) */ 806 823 if (!fLoadOk && !strLangId.isNull()) 807 msgCenter().cannotLoadLanguage 824 msgCenter().cannotLoadLanguage(strLanguageFileName); 808 825 } 809 826 if (fResetToC) … … 813 830 * Manually trigger an update. */ 814 831 ::darwinRetranslateAppMenu(); 815 #endif /* VBOX_WS_MAC */832 #endif 816 833 } 817 834 … … 870 887 * B cannot appear there). */ 871 888 872 QString strRegexp =873 QString 874 .arg 875 .arg (tr("B", "size suffix Bytes"))876 .arg (tr("KB", "size suffix KBytes=1024 Bytes"))877 .arg (tr("MB", "size suffix MBytes=1024 KBytes"))878 .arg (tr("GB", "size suffix GBytes=1024 MBytes"))879 .arg (tr("TB", "size suffix TBytes=1024 GBytes"))880 .arg (tr("PB", "size suffix PBytes=1024 TBytes"));889 const QString strRegexp = 890 QString("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$") 891 .arg(decimalSep()) 892 .arg(tr("B", "size suffix Bytes")) 893 .arg(tr("KB", "size suffix KBytes=1024 Bytes")) 894 .arg(tr("MB", "size suffix MBytes=1024 KBytes")) 895 .arg(tr("GB", "size suffix GBytes=1024 MBytes")) 896 .arg(tr("TB", "size suffix TBytes=1024 GBytes")) 897 .arg(tr("PB", "size suffix PBytes=1024 TBytes")); 881 898 return strRegexp; 882 899 } 883 900 884 901 /* static */ 885 quint64 VBoxGlobal::parseSize 902 quint64 VBoxGlobal::parseSize(const QString &strText) 886 903 { 887 904 /* Text should be in form of B|KB|MB|GB|TB|PB. */ 888 QRegExp regexp 889 int iPos = regexp.indexIn 905 QRegExp regexp(sizeRegexp()); 906 int iPos = regexp.indexIn(strText); 890 907 if (iPos != -1) 891 908 { 892 QString strInteger = regexp.cap 909 QString strInteger = regexp.cap(1); 893 910 QString strHundred; 894 QString strSuff = regexp.cap 911 QString strSuff = regexp.cap(2); 895 912 if (strInteger.isEmpty()) 896 913 { 897 strInteger = regexp.cap 898 strHundred = regexp.cap 899 strSuff = regexp.cap 914 strInteger = regexp.cap(3); 915 strHundred = regexp.cap(4); 916 strSuff = regexp.cap(5); 900 917 } 901 918 902 919 quint64 uDenominator = 0; 903 if (strSuff.isEmpty() || strSuff == tr 920 if (strSuff.isEmpty() || strSuff == tr("B", "size suffix Bytes")) 904 921 uDenominator = 1; 905 else if (strSuff == tr 922 else if (strSuff == tr("KB", "size suffix KBytes=1024 Bytes")) 906 923 uDenominator = _1K; 907 else if (strSuff == tr 924 else if (strSuff == tr("MB", "size suffix MBytes=1024 KBytes")) 908 925 uDenominator = _1M; 909 else if (strSuff == tr 926 else if (strSuff == tr("GB", "size suffix GBytes=1024 MBytes")) 910 927 uDenominator = _1G; 911 else if (strSuff == tr 928 else if (strSuff == tr("TB", "size suffix TBytes=1024 GBytes")) 912 929 uDenominator = _1T; 913 else if (strSuff == tr 930 else if (strSuff == tr("PB", "size suffix PBytes=1024 TBytes")) 914 931 uDenominator = _1P; 915 932 … … 918 935 return iInteger; 919 936 920 quint64 iHundred = strHundred.leftJustified 937 quint64 iHundred = strHundred.leftJustified(2, '0').toULongLong(); 921 938 iHundred = iHundred * uDenominator / 100; 922 939 iInteger = iInteger * uDenominator + iHundred; … … 928 945 929 946 /* static */ 930 QString VBoxGlobal::formatSize 931 947 QString VBoxGlobal::formatSize(quint64 uSize, uint cDecimal /* = 2 */, 948 FormatSize enmMode /* = FormatSize_Round */) 932 949 { 933 950 /* Text will be in form of B|KB|MB|GB|TB|PB. … … 983 1000 quint64 uDecimal = uSize % uDenominator; 984 1001 quint64 uMult = 1; 985 for (uint i = 0; i < cDecimal; ++ i) uMult *= 10; 1002 for (uint i = 0; i < cDecimal; ++i) 1003 uMult *= 10; 986 1004 987 1005 QString strNumber; … … 991 1009 { 992 1010 uDecimal *= uMult; 993 /* not greater*/1011 /* Not greater: */ 994 1012 if (enmMode == FormatSize_RoundDown) 995 1013 uDecimal = uDecimal / uDenominator; 996 /* not less*/1014 /* Not less: */ 997 1015 else if (enmMode == FormatSize_RoundUp) 998 1016 uDecimal = (uDecimal + uDenominator - 1) / uDenominator; 999 /* nearest */ 1000 else uDecimal = (uDecimal + uDenominator / 2) / uDenominator; 1017 /* Nearest: */ 1018 else 1019 uDecimal = (uDecimal + uDenominator / 2) / uDenominator; 1001 1020 } 1002 1021 /* Check for the fractional part overflow due to rounding: */ … … 1004 1023 { 1005 1024 uDecimal = 0; 1006 ++ 1025 ++uInteger; 1007 1026 /* Check if we've got 1024 XB after rounding and scale down if so: */ 1008 1027 if (uInteger == 1024 && iSuffix + 1 < (int)SizeSuffix_Max) 1009 1028 { 1010 1029 uInteger /= 1024; 1011 ++ 1030 ++iSuffix; 1012 1031 } 1013 1032 } 1014 strNumber = QString::number (uInteger); 1015 if (cDecimal) strNumber += QString ("%1%2").arg (decimalSep()) 1016 .arg (QString::number (uDecimal).rightJustified (cDecimal, '0')); 1033 strNumber = QString::number(uInteger); 1034 if (cDecimal) 1035 strNumber += QString("%1%2").arg(decimalSep()) 1036 .arg(QString::number(uDecimal).rightJustified(cDecimal, '0')); 1017 1037 } 1018 1038 else 1019 1039 { 1020 strNumber = QString::number 1021 } 1022 1023 return QString ("%1 %2").arg (strNumber).arg(gpConverter->toString(static_cast<SizeSuffix>(iSuffix)));1040 strNumber = QString::number(uInteger); 1041 } 1042 1043 return QString("%1 %2").arg(strNumber).arg(gpConverter->toString(static_cast<SizeSuffix>(iSuffix))); 1024 1044 } 1025 1045 … … 1042 1062 } 1043 1063 1044 QStringList VBoxGlobal::COMPortNames() const 1064 /* static */ 1065 QStringList VBoxGlobal::COMPortNames() 1045 1066 { 1046 1067 QStringList list; 1047 for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++i)1048 list << kComKnownPorts 1068 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 1069 list << kComKnownPorts[i].name; 1049 1070 1050 1071 return list; 1051 1072 } 1052 1073 1053 QString VBoxGlobal::toCOMPortName (ulong uIRQ, ulong uIOBase) const 1054 { 1055 for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i) 1056 if (kComKnownPorts [i].IRQ == uIRQ && 1057 kComKnownPorts [i].IOBase == uIOBase) 1058 return kComKnownPorts [i].name; 1059 1060 return m_strUserDefinedPortName; 1061 } 1062 1063 bool VBoxGlobal::toCOMPortNumbers (const QString &strName, ulong &uIRQ, 1064 ulong &uIOBase) const 1065 { 1066 for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i) 1067 if (strcmp (kComKnownPorts [i].name, strName.toUtf8().data()) == 0) 1068 { 1069 uIRQ = kComKnownPorts [i].IRQ; 1070 uIOBase = kComKnownPorts [i].IOBase; 1074 /* static */ 1075 QString VBoxGlobal::toCOMPortName(ulong uIRQ, ulong uIOBase) 1076 { 1077 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 1078 if (kComKnownPorts[i].IRQ == uIRQ && 1079 kComKnownPorts[i].IOBase == uIOBase) 1080 return kComKnownPorts[i].name; 1081 1082 return s_strUserDefinedPortName; 1083 } 1084 1085 /* static */ 1086 bool VBoxGlobal::toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase) 1087 { 1088 for (size_t i = 0; i < RT_ELEMENTS(kComKnownPorts); ++i) 1089 if (strcmp(kComKnownPorts[i].name, strName.toUtf8().data()) == 0) 1090 { 1091 uIRQ = kComKnownPorts[i].IRQ; 1092 uIOBase = kComKnownPorts[i].IOBase; 1071 1093 return true; 1072 1094 } … … 1075 1097 } 1076 1098 1077 QStringList VBoxGlobal::LPTPortNames() const 1099 /* static */ 1100 QStringList VBoxGlobal::LPTPortNames() 1078 1101 { 1079 1102 QStringList list; 1080 for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++i)1081 list << kLptKnownPorts 1103 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i) 1104 list << kLptKnownPorts[i].name; 1082 1105 1083 1106 return list; 1084 1107 } 1085 1108 1086 QString VBoxGlobal::toLPTPortName (ulong uIRQ, ulong uIOBase) const 1087 { 1088 for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i) 1089 if (kLptKnownPorts [i].IRQ == uIRQ && 1090 kLptKnownPorts [i].IOBase == uIOBase) 1091 return kLptKnownPorts [i].name; 1092 1093 return m_strUserDefinedPortName; 1094 } 1095 1096 bool VBoxGlobal::toLPTPortNumbers (const QString &strName, ulong &uIRQ, 1097 ulong &uIOBase) const 1098 { 1099 for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i) 1100 if (strcmp (kLptKnownPorts [i].name, strName.toUtf8().data()) == 0) 1101 { 1102 uIRQ = kLptKnownPorts [i].IRQ; 1103 uIOBase = kLptKnownPorts [i].IOBase; 1109 /* static */ 1110 QString VBoxGlobal::toLPTPortName(ulong uIRQ, ulong uIOBase) 1111 { 1112 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i) 1113 if (kLptKnownPorts[i].IRQ == uIRQ && 1114 kLptKnownPorts[i].IOBase == uIOBase) 1115 return kLptKnownPorts[i].name; 1116 1117 return s_strUserDefinedPortName; 1118 } 1119 1120 /* static */ 1121 bool VBoxGlobal::toLPTPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase) 1122 { 1123 for (size_t i = 0; i < RT_ELEMENTS(kLptKnownPorts); ++i) 1124 if (strcmp(kLptKnownPorts[i].name, strName.toUtf8().data()) == 0) 1125 { 1126 uIRQ = kLptKnownPorts[i].IRQ; 1127 uIOBase = kLptKnownPorts[i].IOBase; 1104 1128 return true; 1105 1129 } … … 1109 1133 1110 1134 /* static */ 1111 QString VBoxGlobal::highlight (const QString &strTextArg, bool fToolTip /* = false */)1135 QString VBoxGlobal::highlight(QString strText, bool fToolTip /* = false */) 1112 1136 { 1113 1137 /* We should reformat the input strText so that: … … 1134 1158 } 1135 1159 1136 QString strText = strTextArg;1137 1138 1160 /* Replace special entities, '&' -- first! */ 1139 strText.replace 1140 strText.replace 1141 strText.replace 1142 strText.replace 1161 strText.replace('&', "&"); 1162 strText.replace('<', "<"); 1163 strText.replace('>', ">"); 1164 strText.replace('\"', """); 1143 1165 1144 1166 /* Mark strings in single quotes with color: */ 1145 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1146 rx.setMinimal (true); 1147 strText.replace (rx, 1148 QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strFont).arg (endFont)); 1167 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1168 rx.setMinimal(true); 1169 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strFont).arg(endFont)); 1149 1170 1150 1171 /* Mark UUIDs with color: */ 1151 strText.replace (QRegExp(1172 strText.replace(QRegExp( 1152 1173 "((?:^|\\s)[(]?)" 1153 1174 "(\\{[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}\\})" 1154 1175 "(?=[:.-!);]?(?:\\s|$))"), 1155 QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidFont).arg(endFont));1176 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidFont).arg(endFont)); 1156 1177 1157 1178 /* Split to paragraphs at \n chars: */ 1158 1179 if (!fToolTip) 1159 strText.replace 1180 strText.replace('\n', "</p><p>"); 1160 1181 else 1161 strText.replace 1182 strText.replace('\n', "<br>"); 1162 1183 1163 1184 return strText; … … 1165 1186 1166 1187 /* static */ 1167 QString VBoxGlobal::emphasize (const QString &strTextArg)1188 QString VBoxGlobal::emphasize(QString strText) 1168 1189 { 1169 1190 /* We should reformat the input string @a strText so that: … … 1177 1198 * or prepended to the existing paragraph). */ 1178 1199 1179 QString strEmphStart ("<b>"); 1180 QString strEmphEnd ("</b>"); 1181 QString uuidEmphStart ("<i>"); 1182 QString uuidEmphEnd ("</i>"); 1183 1184 QString strText = strTextArg; 1200 QString strEmphStart("<b>"); 1201 QString strEmphEnd("</b>"); 1202 QString uuidEmphStart("<i>"); 1203 QString uuidEmphEnd("</i>"); 1185 1204 1186 1205 /* Replace special entities, '&' -- first! */ 1187 strText.replace 1188 strText.replace 1189 strText.replace 1190 strText.replace 1206 strText.replace('&', "&"); 1207 strText.replace('<', "<"); 1208 strText.replace('>', ">"); 1209 strText.replace('\"', """); 1191 1210 1192 1211 /* Mark strings in single quotes with bold style: */ 1193 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1194 rx.setMinimal (true); 1195 strText.replace(rx, 1196 QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strEmphStart).arg (strEmphEnd)); 1212 QRegExp rx = QRegExp("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1213 rx.setMinimal(true); 1214 strText.replace(rx, QString("\\1%1<nobr>'\\2'</nobr>%2").arg(strEmphStart).arg(strEmphEnd)); 1197 1215 1198 1216 /* Mark UUIDs with italic style: */ 1199 strText.replace (QRegExp(1217 strText.replace(QRegExp( 1200 1218 "((?:^|\\s)[(]?)" 1201 1219 "(\\{[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}\\})" 1202 1220 "(?=[:.-!);]?(?:\\s|$))"), 1203 QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidEmphStart).arg(uuidEmphEnd));1221 QString("\\1%1<nobr>\\2</nobr>%2").arg(uuidEmphStart).arg(uuidEmphEnd)); 1204 1222 1205 1223 /* Split to paragraphs at \n chars: */ 1206 strText.replace 1224 strText.replace('\n', "</p><p>"); 1207 1225 1208 1226 return strText; … … 1210 1228 1211 1229 /* static */ 1212 QString VBoxGlobal::removeAccelMark (const QString &strTextArg)1230 QString VBoxGlobal::removeAccelMark(QString strText) 1213 1231 { 1214 1232 /* In order to support accelerators used in non-alphabet languages … … 1218 1236 * removed from the string. */ 1219 1237 1220 QString strText = strTextArg; 1221 1222 QRegExp accel ("\\(&[a-zA-Z]\\)"); 1223 int iPos = accel.indexIn (strText); 1238 QRegExp accel("\\(&[a-zA-Z]\\)"); 1239 int iPos = accel.indexIn(strText); 1224 1240 if (iPos >= 0) 1225 strText.remove 1241 strText.remove(iPos, accel.cap().length()); 1226 1242 else 1227 1243 { 1228 iPos = strText.indexOf 1244 iPos = strText.indexOf('&'); 1229 1245 if (iPos >= 0) 1230 strText.remove 1246 strText.remove(iPos, 1); 1231 1247 } 1232 1248 … … 1249 1265 } 1250 1266 1251 QString VBoxGlobal::helpFile() const 1252 { 1253 #if defined (VBOX_WS_WIN) 1267 /* static */ 1268 QString VBoxGlobal::helpFile() 1269 { 1270 #if defined(VBOX_WS_WIN) 1254 1271 const QString strName = "VirtualBox"; 1255 1272 const QString strSuffix = "chm"; 1256 #elif defined 1273 #elif defined(VBOX_WS_MAC) 1257 1274 const QString strName = "UserManual"; 1258 1275 const QString strSuffix = "pdf"; 1259 #elif defined 1276 #elif defined(VBOX_WS_X11) 1260 1277 # if defined VBOX_OSE 1261 1278 const QString strName = "UserManual"; … … 1266 1283 # endif 1267 1284 #endif 1285 1268 1286 /* Where are the docs located? */ 1269 1287 char szDocsPath[RTPATH_MAX]; 1270 int rc = RTPathAppDocs (szDocsPath, sizeof (szDocsPath)); 1271 AssertRC (rc); 1288 int rc = RTPathAppDocs(szDocsPath, sizeof(szDocsPath)); 1289 AssertRC(rc); 1290 1272 1291 /* Make sure that the language is in two letter code. 1273 1292 * Note: if languageId() returns an empty string lang.name() will 1274 1293 * return "C" which is an valid language code. */ 1275 QLocale lang 1294 QLocale lang(VBoxGlobal::languageId()); 1276 1295 1277 1296 /* Construct the path and the filename: */ 1278 QString strManual = QString ("%1/%2_%3.%4").arg (szDocsPath) 1279 .arg (strName) 1280 .arg (lang.name()) 1281 .arg (strSuffix); 1297 QString strManual = QString("%1/%2_%3.%4").arg(szDocsPath) 1298 .arg(strName) 1299 .arg(lang.name()) 1300 .arg(strSuffix); 1301 1282 1302 /* Check if a help file with that name exists: */ 1283 QFileInfo fi 1303 QFileInfo fi(strManual); 1284 1304 if (fi.exists()) 1285 1305 return strManual; 1286 1306 1287 1307 /* Fall back to the standard: */ 1288 strManual = QString ("%1/%2.%4").arg(szDocsPath)1289 .arg(strName)1290 .arg(strSuffix);1308 strManual = QString("%1/%2.%4").arg(szDocsPath) 1309 .arg(strName) 1310 .arg(strSuffix); 1291 1311 return strManual; 1292 1312 } … … 1310 1330 1311 1331 /* static */ 1312 QRect VBoxGlobal::normalizeGeometry (const QRect &rectangle, const QRegion &boundRegion, 1313 bool fCanResize /* = true */) 1332 QRect VBoxGlobal::normalizeGeometry(const QRect &rectangle, const QRegion &boundRegion, bool fCanResize /* = true */) 1314 1333 { 1315 1334 /* Perform direct and flipped search of position for @a rectangle to make sure it is fully contained … … 1317 1336 * necessary. Selects the minimum shifted result between direct and flipped variants. */ 1318 1337 1319 /* Direct search for normalized rectangle */1320 QRect var1 (getNormalized(rectangle, boundRegion, fCanResize));1338 /* Direct search for normalized rectangle: */ 1339 QRect var1(getNormalized(rectangle, boundRegion, fCanResize)); 1321 1340 1322 1341 /* Flipped search for normalized rectangle: */ 1323 QRect var2 (flip (getNormalized (flip(rectangle).boundingRect(),1324 flip(boundRegion), fCanResize)).boundingRect());1342 QRect var2(flip(getNormalized(flip(rectangle).boundingRect(), 1343 flip(boundRegion), fCanResize)).boundingRect()); 1325 1344 1326 1345 /* Calculate shift from starting position for both variants: */ 1327 double dLength1 = sqrt (pow ((double) (var1.x() - rectangle.x()), (double)2) +1328 pow ((double) (var1.y() - rectangle.y()), (double)2));1329 double dLength2 = sqrt (pow ((double) (var2.x() - rectangle.x()), (double)2) +1330 pow ((double) (var2.y() - rectangle.y()), (double)2));1346 double dLength1 = sqrt(pow((double)(var1.x() - rectangle.x()), (double)2) + 1347 pow((double)(var1.y() - rectangle.y()), (double)2)); 1348 double dLength2 = sqrt(pow((double)(var2.x() - rectangle.x()), (double)2) + 1349 pow((double)(var2.y() - rectangle.y()), (double)2)); 1331 1350 1332 1351 /* Return minimum shifted variant: */ … … 1335 1354 1336 1355 /* static */ 1337 QRect VBoxGlobal::getNormalized (const QRect &rectangle, const QRegion &boundRegion, 1338 bool /* fCanResize = true */) 1356 QRect VBoxGlobal::getNormalized(const QRect &rectangle, const QRegion &boundRegion, bool /* fCanResize = true */) 1339 1357 { 1340 1358 /* Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion … … 1344 1362 1345 1363 /* Storing available horizontal sub-rectangles & vertical shifts: */ 1346 int iWindowVertical = rectangle.center().y(); 1347 QVector <QRect> rectanglesVector (boundRegion.rects()); 1348 QList <QRect> rectanglesList; 1349 QList <int> shiftsList; 1350 foreach (QRect currentItem, rectanglesVector) 1351 { 1352 int iCurrentDelta = qAbs (iWindowVertical - currentItem.center().y()); 1353 int iShift2Top = currentItem.top() - rectangle.top(); 1354 int iShift2Bot = currentItem.bottom() - rectangle.bottom(); 1364 const int iWindowVertical = rectangle.center().y(); 1365 QList<QRect> rectanglesList; 1366 QList<int> shiftsList; 1367 foreach (QRect currentItem, boundRegion.rects()) 1368 { 1369 const int iCurrentDelta = qAbs(iWindowVertical - currentItem.center().y()); 1370 const int iShift2Top = currentItem.top() - rectangle.top(); 1371 const int iShift2Bot = currentItem.bottom() - rectangle.bottom(); 1355 1372 1356 1373 int iTtemPosition = 0; 1357 1374 foreach (QRect item, rectanglesList) 1358 1375 { 1359 int iDelta = qAbs (iWindowVertical - item.center().y()); 1360 if (iDelta > iCurrentDelta) break; else ++ iTtemPosition; 1361 } 1362 rectanglesList.insert (iTtemPosition, currentItem); 1376 const int iDelta = qAbs(iWindowVertical - item.center().y()); 1377 if (iDelta > iCurrentDelta) 1378 break; 1379 else 1380 ++iTtemPosition; 1381 } 1382 rectanglesList.insert(iTtemPosition, currentItem); 1363 1383 1364 1384 int iShift2TopPos = 0; 1365 1385 foreach (int iShift, shiftsList) 1366 if (qAbs (iShift) > qAbs (iShift2Top)) break; else ++ iShift2TopPos; 1367 shiftsList.insert (iShift2TopPos, iShift2Top); 1386 if (qAbs(iShift) > qAbs(iShift2Top)) 1387 break; 1388 else 1389 ++iShift2TopPos; 1390 shiftsList.insert(iShift2TopPos, iShift2Top); 1368 1391 1369 1392 int iShift2BotPos = 0; 1370 1393 foreach (int iShift, shiftsList) 1371 if (qAbs(iShift) > qAbs(iShift2Bot)) break; else ++ iShift2BotPos; 1372 shiftsList.insert (iShift2BotPos, iShift2Bot); 1394 if (qAbs(iShift) > qAbs(iShift2Bot)) 1395 break; 1396 else 1397 ++iShift2BotPos; 1398 shiftsList.insert(iShift2BotPos, iShift2Bot); 1373 1399 } 1374 1400 1375 1401 /* Trying to find the appropriate place for window: */ 1376 1402 QRect result; 1377 for (int i = -1; i < shiftsList.size(); ++ 1403 for (int i = -1; i < shiftsList.size(); ++i) 1378 1404 { 1379 1405 /* Move to appropriate vertical: */ 1380 QRect newRectangle (rectangle); 1381 if (i >= 0) newRectangle.translate (0, shiftsList [i]); 1406 QRect newRectangle(rectangle); 1407 if (i >= 0) 1408 newRectangle.translate(0, shiftsList[i]); 1382 1409 1383 1410 /* Search horizontal shift: */ … … 1385 1412 foreach (QRect item, rectanglesList) 1386 1413 { 1387 QRect trectangle (newRectangle.translated(item.left() - newRectangle.left(), 0));1388 if (!item.intersects 1414 QRect trectangle(newRectangle.translated(item.left() - newRectangle.left(), 0)); 1415 if (!item.intersects(trectangle)) 1389 1416 continue; 1390 1417 1391 1418 if (newRectangle.left() < item.left()) 1392 1419 { 1393 int iShift = item.left() - newRectangle.left();1394 iMaxShift = qAbs (iShift) > qAbs(iMaxShift) ? iShift : iMaxShift;1420 const int iShift = item.left() - newRectangle.left(); 1421 iMaxShift = qAbs(iShift) > qAbs(iMaxShift) ? iShift : iMaxShift; 1395 1422 } 1396 1423 else if (newRectangle.right() > item.right()) 1397 1424 { 1398 int iShift = item.right() - newRectangle.right();1399 iMaxShift = qAbs (iShift) > qAbs(iMaxShift) ? iShift : iMaxShift;1425 const int iShift = item.right() - newRectangle.right(); 1426 iMaxShift = qAbs(iShift) > qAbs(iMaxShift) ? iShift : iMaxShift; 1400 1427 } 1401 1428 } 1402 1429 1403 1430 /* Shift across the horizontal direction: */ 1404 newRectangle.translate 1431 newRectangle.translate(iMaxShift, 0); 1405 1432 1406 1433 /* Check the translated rectangle to feat the rules: */ 1407 if (boundRegion.united 1434 if (boundRegion.united(newRectangle) == boundRegion) 1408 1435 result = newRectangle; 1409 1436 1410 if (!result.isNull()) break; 1437 if (!result.isNull()) 1438 break; 1411 1439 } 1412 1440 … … 1419 1447 foreach (QRect item, rectanglesList) 1420 1448 { 1421 quint64 uSquare = item.width() * item.height();1449 const quint64 uSquare = item.width() * item.height(); 1422 1450 if (uSquare > uMaxSquare) 1423 1451 { … … 1428 1456 1429 1457 result = rectangle; 1430 result.moveTo 1458 result.moveTo(maxRectangle.x(), maxRectangle.y()); 1431 1459 if (maxRectangle.right() < result.right()) 1432 result.setRight 1460 result.setRight(maxRectangle.right()); 1433 1461 if (maxRectangle.bottom() < result.bottom()) 1434 result.setBottom 1462 result.setBottom(maxRectangle.bottom()); 1435 1463 } 1436 1464 … … 1439 1467 1440 1468 /* static */ 1441 QRegion VBoxGlobal::flip 1469 QRegion VBoxGlobal::flip(const QRegion ®ion) 1442 1470 { 1443 1471 QRegion result; 1444 QVector <QRect> rectangles(region.rects());1472 QVector<QRect> rectangles(region.rects()); 1445 1473 foreach (QRect rectangle, rectangles) 1446 result += QRect 1447 1474 result += QRect(rectangle.y(), rectangle.x(), 1475 rectangle.height(), rectangle.width()); 1448 1476 return result; 1449 1477 } 1450 1478 1451 1479 /* static */ 1452 void VBoxGlobal::centerWidget (QWidget *pWidget, QWidget *pRelative, 1453 bool fCanResize /* = true */) 1480 void VBoxGlobal::centerWidget(QWidget *pWidget, QWidget *pRelative, bool fCanResize /* = true */) 1454 1481 { 1455 1482 /* If necessary, pWidget's position is adjusted to make it fully visible within … … 1462 1489 * pWidget will be centered relative to the available desktop area. */ 1463 1490 1464 AssertReturnVoid 1465 AssertReturnVoid 1491 AssertReturnVoid(pWidget); 1492 AssertReturnVoid(pWidget->isTopLevel()); 1466 1493 1467 1494 QRect deskGeo, parentGeo; 1468 QWidget *w = pRelative; 1469 if (w) 1470 { 1471 w = w->window(); 1472 deskGeo = gpDesktop->availableGeometry (w); 1473 parentGeo = w->frameGeometry(); 1495 if (pRelative) 1496 { 1497 pRelative = pRelative->window(); 1498 deskGeo = gpDesktop->availableGeometry(pRelative); 1499 parentGeo = pRelative->frameGeometry(); 1474 1500 // WORKAROUND: 1475 1501 // On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level 1476 1502 // widgets with parents, what a shame. Use mapToGlobal() to workaround. 1477 QPoint d = w->mapToGlobal (QPoint(0, 0));1478 d.rx() -= w->geometry().x() - w->x();1479 d.ry() -= w->geometry().y() - w->y();1480 parentGeo.moveTopLeft 1503 QPoint d = pRelative->mapToGlobal(QPoint(0, 0)); 1504 d.rx() -= pRelative->geometry().x() - pRelative->x(); 1505 d.ry() -= pRelative->geometry().y() - pRelative->y(); 1506 parentGeo.moveTopLeft(d); 1481 1507 } 1482 1508 else … … 1492 1518 // is based on the idea taken from QDialog::adjustPositionInternal(). 1493 1519 1494 int iExtraW = 0, iExtraH = 0; 1520 int iExtraW = 0; 1521 int iExtraH = 0; 1495 1522 1496 1523 QWidgetList list = QApplication::topLevelWidgets(); 1497 QListIterator<QWidget*> it 1524 QListIterator<QWidget*> it(list); 1498 1525 while ((iExtraW == 0 || iExtraH == 0) && it.hasNext()) 1499 1526 { … … 1506 1533 iFrameH = pCurrent->frameGeometry().height() - pCurrent->height(); 1507 1534 1508 iExtraW = qMax (iExtraW, iFrameW); 1509 iExtraH = qMax (iExtraH, iFrameH); 1510 } 1511 1512 /* On non-X11 platforms, the following would be enough instead of the 1513 * above workaround: */ 1535 iExtraW = qMax(iExtraW, iFrameW); 1536 iExtraH = qMax(iExtraH, iFrameH); 1537 } 1538 1539 /* On non-X11 platforms, the following would be enough instead of the above workaround: */ 1514 1540 // QRect geo = frameGeometry(); 1515 QRect geo = QRect 1516 1517 1518 geo.moveCenter (QPoint(parentGeo.x() + (parentGeo.width() - 1) / 2,1519 1541 QRect geo = QRect(0, 0, pWidget->width() + iExtraW, 1542 pWidget->height() + iExtraH); 1543 1544 geo.moveCenter(QPoint(parentGeo.x() + (parentGeo.width() - 1) / 2, 1545 parentGeo.y() + (parentGeo.height() - 1) / 2)); 1520 1546 1521 1547 /* Ensure the widget is within the available desktop area: */ 1522 QRect newGeo = normalizeGeometry 1548 QRect newGeo = normalizeGeometry(geo, deskGeo, fCanResize); 1523 1549 #ifdef VBOX_WS_MAC 1524 1550 // WORKAROUND: … … 1526 1552 // ::move call. So manually add the height of the toolbar before setting 1527 1553 // the position. 1528 if ( w)1529 newGeo.translate (0, ::darwinWindowToolBarHeight(pWidget));1554 if (pRelative) 1555 newGeo.translate(0, ::darwinWindowToolBarHeight(pWidget)); 1530 1556 #endif /* VBOX_WS_MAC */ 1531 1557 1532 pWidget->move 1533 1534 if ( fCanResize &&1535 (geo.width() != newGeo.width() || geo.height() != newGeo.height()))1558 pWidget->move(newGeo.topLeft()); 1559 1560 if ( fCanResize 1561 && (geo.width() != newGeo.width() || geo.height() != newGeo.height())) 1536 1562 pWidget->resize(newGeo.width() - iExtraW, newGeo.height() - iExtraH); 1537 1563 } … … 1580 1606 uint16_t fMask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y 1581 1607 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; 1582 uint32_t values[] = { (uint32_t)(x * dDPR), (uint32_t)(y * dDPR), 1583 (uint32_t)(w * dDPR), (uint32_t)(h * dDPR) }; 1608 uint32_t values[] = { (uint32_t)(x * dDPR), (uint32_t)(y * dDPR), (uint32_t)(w * dDPR), (uint32_t)(h * dDPR) }; 1584 1609 xcb_configure_window(QX11Info::connection(), (xcb_window_t)pWidget->winId(), 1585 1610 fMask, values); … … 1629 1654 } 1630 1655 1631 #if defined (VBOX_WS_X11) 1632 1633 static char *XXGetProperty (Display *pDpy, Window windowHandle, 1634 Atom propType, const char *pszPropName) 1635 { 1636 Atom propNameAtom = XInternAtom (pDpy, pszPropName, 1637 True /* only_if_exists */); 1656 #if defined(VBOX_WS_X11) 1657 1658 static char *XXGetProperty(Display *pDpy, Window windowHandle, Atom propType, const char *pszPropName) 1659 { 1660 Atom propNameAtom = XInternAtom(pDpy, pszPropName, True /* only_if_exists */); 1638 1661 if (propNameAtom == None) 1639 1662 return NULL; … … 1644 1667 unsigned long nBytesAfter = 0; 1645 1668 unsigned char *propVal = NULL; 1646 int rc = XGetWindowProperty 1647 1648 1649 1669 int rc = XGetWindowProperty(pDpy, windowHandle, propNameAtom, 1670 0, LONG_MAX, False /* delete */, 1671 propType, &actTypeAtom, &actFmt, 1672 &nItems, &nBytesAfter, &propVal); 1650 1673 if (rc != Success) 1651 1674 return NULL; 1652 1675 1653 return reinterpret_cast <char *>(propVal);1654 } 1655 1656 static Bool XXSendClientMessage 1657 1658 1659 1660 { 1661 Atom msgAtom = XInternAtom 1676 return reinterpret_cast<char*>(propVal); 1677 } 1678 1679 static Bool XXSendClientMessage(Display *pDpy, Window windowHandle, const char *pszMsg, 1680 unsigned long aData0 = 0, unsigned long aData1 = 0, 1681 unsigned long aData2 = 0, unsigned long aData3 = 0, 1682 unsigned long aData4 = 0) 1683 { 1684 Atom msgAtom = XInternAtom(pDpy, pszMsg, True /* only_if_exists */); 1662 1685 if (msgAtom == None) 1663 1686 return False; … … 1674 1697 /* Always send as 32 bit for now: */ 1675 1698 ev.xclient.format = 32; 1676 ev.xclient.data.l 1677 ev.xclient.data.l 1678 ev.xclient.data.l 1679 ev.xclient.data.l 1680 ev.xclient.data.l 1681 1682 return XSendEvent (pDpy, DefaultRootWindow(pDpy), False,1683 1699 ev.xclient.data.l[0] = aData0; 1700 ev.xclient.data.l[1] = aData1; 1701 ev.xclient.data.l[2] = aData2; 1702 ev.xclient.data.l[3] = aData3; 1703 ev.xclient.data.l[4] = aData4; 1704 1705 return XSendEvent(pDpy, DefaultRootWindow(pDpy), False, 1706 SubstructureRedirectMask, &ev) != 0; 1684 1707 } 1685 1708 … … 1687 1710 1688 1711 /* static */ 1689 bool VBoxGlobal::activateWindow 1712 bool VBoxGlobal::activateWindow(WId wId, bool fSwitchDesktop /* = true */) 1690 1713 { 1691 1714 RT_NOREF(fSwitchDesktop); 1692 1715 bool fResult = true; 1693 1716 1694 #if defined 1717 #if defined(VBOX_WS_WIN) 1695 1718 1696 1719 HWND handle = (HWND)wId; 1697 1720 1698 if (IsIconic 1699 fResult &= !!ShowWindow 1700 else if (!IsWindowVisible 1701 fResult &= !!ShowWindow 1702 1703 fResult &= !!SetForegroundWindow 1704 1705 #elif defined 1721 if (IsIconic(handle)) 1722 fResult &= !!ShowWindow(handle, SW_RESTORE); 1723 else if (!IsWindowVisible(handle)) 1724 fResult &= !!ShowWindow(handle, SW_SHOW); 1725 1726 fResult &= !!SetForegroundWindow(handle); 1727 1728 #elif defined(VBOX_WS_X11) 1706 1729 1707 1730 Display *pDisplay = QX11Info::display(); … … 1710 1733 { 1711 1734 /* try to find the desktop ID using the NetWM property */ 1712 CARD32 *pDesktop = (CARD32 *) XXGetProperty 1713 1735 CARD32 *pDesktop = (CARD32 *) XXGetProperty(pDisplay, wId, XA_CARDINAL, 1736 "_NET_WM_DESKTOP"); 1714 1737 if (pDesktop == NULL) 1715 1738 // WORKAROUND: 1716 1739 // if the NetWM properly is not supported try to find 1717 1740 // the desktop ID using the GNOME WM property. 1718 pDesktop = (CARD32 *) XXGetProperty 1719 1741 pDesktop = (CARD32 *) XXGetProperty(pDisplay, wId, XA_CARDINAL, 1742 "_WIN_WORKSPACE"); 1720 1743 1721 1744 if (pDesktop != NULL) 1722 1745 { 1723 Bool ok = XXSendClientMessage (pDisplay, DefaultRootWindow(pDisplay),1724 1725 1746 Bool ok = XXSendClientMessage(pDisplay, DefaultRootWindow(pDisplay), 1747 "_NET_CURRENT_DESKTOP", 1748 *pDesktop); 1726 1749 if (!ok) 1727 1750 { … … 1729 1752 fResult = false; 1730 1753 } 1731 XFree 1754 XFree(pDesktop); 1732 1755 } 1733 1756 else … … 1738 1761 } 1739 1762 1740 Bool ok = XXSendClientMessage 1763 Bool ok = XXSendClientMessage(pDisplay, wId, "_NET_ACTIVE_WINDOW"); 1741 1764 fResult &= !!ok; 1742 1765 1743 XRaiseWindow 1766 XRaiseWindow(pDisplay, wId); 1744 1767 1745 1768 #else 1746 1769 1747 NOREF 1748 NOREF 1770 NOREF(wId); 1771 NOREF(fSwitchDesktop); 1749 1772 AssertFailed(); 1750 1773 fResult = false; … … 1758 1781 } 1759 1782 1760 #if defined 1783 #if defined(VBOX_WS_X11) 1761 1784 1762 1785 /* static */ … … 1981 2004 } 1982 2005 1983 #endif 2006 #endif /* VBOX_WS_X11 */ 1984 2007 1985 2008 /* static */ … … 2002 2025 2003 2026 /* Calculate minimum-width magic: */ 2004 int iSpinBoxWidth = pSpinBox->width();2005 int iSpinBoxEditFieldWidth = rect.width();2006 int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth);2027 const int iSpinBoxWidth = pSpinBox->width(); 2028 const int iSpinBoxEditFieldWidth = rect.width(); 2029 const int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth); 2007 2030 QFontMetrics metrics(pSpinBox->font(), pSpinBox); 2008 QString strDummy(cCount, '0');2009 int iTextWidth = metrics.width(strDummy);2031 const QString strDummy(cCount, '0'); 2032 const int iTextWidth = metrics.width(strDummy); 2010 2033 2011 2034 /* Tune spin-box minimum-width: */ … … 2029 2052 2030 2053 CGuestOSType VBoxGlobal::vmGuestOSType(const QString &strTypeId, 2031 const QString &strFamilyId /* = QString() */) const2032 { 2033 QList 2034 if (m_guestOSFamilyIDs.contains 2035 { 2036 list = m_guestOSTypes [m_guestOSFamilyIDs.indexOf (strFamilyId)];2054 const QString &strFamilyId /* = QString() */) const 2055 { 2056 QList<CGuestOSType> list; 2057 if (m_guestOSFamilyIDs.contains(strFamilyId)) 2058 { 2059 list = m_guestOSTypes.at(m_guestOSFamilyIDs.indexOf(strFamilyId)); 2037 2060 } 2038 2061 else 2039 2062 { 2040 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ 2041 list += m_guestOSTypes [i];2042 } 2043 for (int j = 0; j < list.size(); ++ 2044 if (!list [j].GetId().compare(strTypeId))2045 return list [j];2046 AssertMsgFailed 2063 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i) 2064 list += m_guestOSTypes.at(i); 2065 } 2066 for (int j = 0; j < list.size(); ++j) 2067 if (!list.at(j).GetId().compare(strTypeId)) 2068 return list.at(j); 2069 AssertMsgFailed(("Type ID incorrect: '%s'.", strTypeId.toLatin1().constData())); 2047 2070 return CGuestOSType(); 2048 2071 } 2049 2072 2050 QString VBoxGlobal::vmGuestOSTypeDescription 2051 { 2052 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ 2053 { 2054 QList <CGuestOSType> list (m_guestOSTypes[i]);2055 for ( int j = 0; j < list.size(); ++j)2056 if (!list [j].GetId().compare(strTypeId))2057 return list [j].GetDescription();2073 QString VBoxGlobal::vmGuestOSTypeDescription(const QString &strTypeId) const 2074 { 2075 for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i) 2076 { 2077 QList<CGuestOSType> list(m_guestOSTypes[i]); 2078 for (int j = 0; j < list.size(); ++j) 2079 if (!list.at(j).GetId().compare(strTypeId)) 2080 return list.at(j).GetDescription(); 2058 2081 } 2059 2082 return QString(); … … 2061 2084 2062 2085 /* static */ 2063 bool VBoxGlobal::isDOSType 2064 { 2065 if ( strOSTypeId.left (3) == "dos" ||2066 strOSTypeId.left (3) == "win" ||2067 strOSTypeId.left(3) == "os2")2086 bool VBoxGlobal::isDOSType(const QString &strOSTypeId) 2087 { 2088 if ( strOSTypeId.left(3) == "dos" 2089 || strOSTypeId.left(3) == "win" 2090 || strOSTypeId.left(3) == "os2") 2068 2091 return true; 2069 2092 … … 2071 2094 } 2072 2095 2096 /* static */ 2073 2097 bool VBoxGlobal::switchToMachine(CMachine &comMachine) 2074 2098 { … … 2076 2100 ULONG64 id = comMachine.ShowConsoleWindow(); 2077 2101 #else 2078 WId id = (WId) 2102 WId id = (WId)comMachine.ShowConsoleWindow(); 2079 2103 #endif 2104 2080 2105 AssertWrapperOk(comMachine); 2081 2106 if (!comMachine.isOk()) … … 2090 2115 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 2091 2116 2092 return vboxGlobal().activateWindow(id, true);2117 return activateWindow(id, true); 2093 2118 2094 2119 #elif defined(VBOX_WS_MAC) 2120 2095 2121 // WORKAROUND: 2096 2122 // This is just for the case were the other process cannot steal … … 2130 2156 { 2131 2157 /* Just switch to existing VM window: */ 2132 return VBoxGlobal::switchToMachine(comMachine);2158 return switchToMachine(comMachine); 2133 2159 } 2134 2160 /* For the Runtime UI: */ … … 2137 2163 /* Only separate UI process can reach that place, 2138 2164 * switch to existing VM window and exit. */ 2139 VBoxGlobal::switchToMachine(comMachine);2165 switchToMachine(comMachine); 2140 2166 return false; 2141 2167 } … … 2167 2193 /* Allow started VM process to be foreground window: */ 2168 2194 AllowSetForegroundWindow(ASFW_ANY); 2169 #endif /* Q_OS_WIN */2195 #endif 2170 2196 #ifdef VBOX_WS_X11 2171 2197 /* Make sure VM process will start on the same display as the VM selector: */ … … 2176 2202 if (pXauth) 2177 2203 strEnv.append(QString("XAUTHORITY=%1\n").arg(pXauth)); 2178 #endif /* VBOX_WS_X11 */2204 #endif 2179 2205 QString strType; 2180 2206 switch (enmLaunchMode) 2181 2207 { 2182 2208 case LaunchMode_Default: strType = ""; break; 2183 case LaunchMode_Separate: strType = vboxGlobal().isSeparateProcess() ? "headless" : "separate"; break;2209 case LaunchMode_Separate: strType = isSeparateProcess() ? "headless" : "separate"; break; 2184 2210 case LaunchMode_Headless: strType = "headless"; break; 2185 2211 default: AssertFailedReturn(false); … … 2282 2308 } 2283 2309 2284 /* static */ 2285 QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType) 2310 QList<QPair<QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType) const 2286 2311 { 2287 2312 /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */ 2288 CSystemProperties comSystemProperties = v boxGlobal().virtualBox().GetSystemProperties();2313 CSystemProperties comSystemProperties = virtualBox().GetSystemProperties(); 2289 2314 QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats(); 2290 2315 QList< QPair<QString, QString> > backendPropList; 2291 for (int i = 0; i < mediumFormats.size(); ++ 2316 for (int i = 0; i < mediumFormats.size(); ++i) 2292 2317 { 2293 2318 /* File extensions */ … … 2295 2320 QVector <KDeviceType> deviceTypes; 2296 2321 2297 mediumFormats 2322 mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes); 2298 2323 2299 2324 QStringList f; 2300 for (int a = 0; a < fileExtensions.size(); ++ 2301 if (deviceTypes 2302 f << QString ("*.%1").arg (fileExtensions[a]);2325 for (int a = 0; a < fileExtensions.size(); ++a) 2326 if (deviceTypes[a] == enmType) 2327 f << QString("*.%1").arg(fileExtensions[a]); 2303 2328 /* Create a pair out of the backend description and all suffix's. */ 2304 2329 if (!f.isEmpty()) 2305 backendPropList << QPair<QString, QString> (mediumFormats[i].GetName(), f.join(" "));2330 backendPropList << QPair<QString, QString>(mediumFormats[i].GetName(), f.join(" ")); 2306 2331 } 2307 2332 return backendPropList; … … 2309 2334 2310 2335 /* static */ 2311 QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()2336 QList<QPair<QString, QString> > VBoxGlobal::HDDBackends() const 2312 2337 { 2313 2338 return MediumBackends(KDeviceType_HardDisk); … … 2315 2340 2316 2341 /* static */ 2317 QList <QPair <QString, QString> > VBoxGlobal::DVDBackends()2342 QList<QPair<QString, QString> > VBoxGlobal::DVDBackends() const 2318 2343 { 2319 2344 return MediumBackends(KDeviceType_DVD); … … 2321 2346 2322 2347 /* static */ 2323 QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends()2348 QList<QPair<QString, QString> > VBoxGlobal::FloppyBackends() const 2324 2349 { 2325 2350 return MediumBackends(KDeviceType_Floppy); … … 2360 2385 { 2361 2386 /* Redirect request to medium-enumerator: */ 2362 return m_pMediumEnumerator2363 && m_pMediumEnumerator->isMediumEnumerationInProgress();2387 return m_pMediumEnumerator 2388 && m_pMediumEnumerator->isMediumEnumerationInProgress(); 2364 2389 } 2365 2390 … … 2443 2468 recentMediumList.removeAll(strMediumLocation); 2444 2469 recentMediumList.prepend(strMediumLocation); 2445 while(recentMediumList.size() > 5) recentMediumList.removeLast(); 2470 while(recentMediumList.size() > 5) 2471 recentMediumList.removeLast(); 2446 2472 switch (enmMediumType) 2447 2473 { … … 2482 2508 { 2483 2509 /* Initialize variables: */ 2484 QList <QPair <QString, QString> > filters;2510 QList<QPair <QString, QString> > filters; 2485 2511 QStringList backends; 2486 2512 QStringList prefixes; … … 2493 2519 case UIMediumType_HardDisk: 2494 2520 { 2495 filters = vboxGlobal().HDDBackends();2521 filters = HDDBackends(); 2496 2522 strTitle = tr("Please choose a virtual hard disk file"); 2497 2523 allType = tr("All virtual hard disk files (%1)"); … … 2505 2531 case UIMediumType_DVD: 2506 2532 { 2507 filters = vboxGlobal().DVDBackends();2533 filters = DVDBackends(); 2508 2534 strTitle = tr("Please choose a virtual optical disk file"); 2509 2535 allType = tr("All virtual optical disk files (%1)"); … … 2517 2543 case UIMediumType_Floppy: 2518 2544 { 2519 filters = vboxGlobal().FloppyBackends();2545 filters = FloppyBackends(); 2520 2546 strTitle = tr("Please choose a virtual floppy disk file"); 2521 2547 allType = tr("All virtual floppy disk files (%1)"); … … 2531 2557 } 2532 2558 QString strHomeFolder = fUseLastFolder && !strLastFolder.isEmpty() ? strLastFolder : 2533 strDefaultFolder.isEmpty() ? vboxGlobal().homeFolder() : strDefaultFolder;2559 strDefaultFolder.isEmpty() ? homeFolder() : strDefaultFolder; 2534 2560 2535 2561 /* Prepare filters and backends: */ … … 2537 2563 { 2538 2564 /* Get iterated filter: */ 2539 QPair 2565 QPair<QString, QString> item = filters.at(i); 2540 2566 /* Create one backend filter string: */ 2541 2567 backends << QString("%1 (%2)").arg(item.first).arg(item.second); … … 2635 2661 { 2636 2662 /* Current attachment attributes: */ 2637 const CMediumAttachment comCurrentAttachment = comMachine.GetMediumAttachment(strControllerName, storageSlot.port, storageSlot.device); 2663 const CMediumAttachment comCurrentAttachment = comMachine.GetMediumAttachment(strControllerName, 2664 storageSlot.port, 2665 storageSlot.device); 2638 2666 const CMedium comCurrentMedium = comCurrentAttachment.GetMedium(); 2639 2667 const QString strCurrentID = comCurrentMedium.isNull() ? QString() : comCurrentMedium.GetId(); … … 2647 2675 AssertMsgReturnVoid(enmMediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n")); 2648 2676 2649 2650 2677 /* Prepare open-existing-medium action: */ 2651 QAction *pActionOpenExistingMedium = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(), pListener, pszSlotName); 2652 pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), comCurrentAttachment.GetDevice(), 2653 enmMediumType))); 2654 pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose disk image...", "This is used for hard disks, optical media and floppies")); 2678 QAction *pActionOpenExistingMedium = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), 2679 QString(), pListener, pszSlotName); 2680 pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), 2681 comCurrentAttachment.GetDevice(), enmMediumType))); 2682 pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose disk image...", 2683 "This is used for hard disks, optical media and floppies")); 2655 2684 2656 2685 /* Prepare ad-hoc-viso action for DVD-ROMs: */ 2657 2686 if (enmMediumType == UIMediumType_DVD) 2658 2687 { 2659 QAction *pActionAdHocViso = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(),2660 pListener, pszSlotName);2688 QAction *pActionAdHocViso = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), 2689 QString(), pListener, pszSlotName); 2661 2690 pActionAdHocViso->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), 2662 2691 comCurrentAttachment.GetDevice(), enmMediumType, 2663 2692 UIMediumTarget::UIMediumTargetType_CreateAdHocVISO))); 2664 pActionAdHocViso->setText(QApplication::translate("UIMachineSettingsStorage", "Create ad hoc VISO...", "This is used for optical media")); 2693 pActionAdHocViso->setText(QApplication::translate("UIMachineSettingsStorage", "Create ad hoc VISO...", 2694 "This is used for optical media")); 2665 2695 } 2666 2696 2667 2697 /* Insert separator: */ 2668 2698 menu.addSeparator(); 2669 2670 2699 2671 2700 /* Get existing-host-drive vector: */ … … 2700 2729 pActionChooseHostDrive->setCheckable(true); 2701 2730 pActionChooseHostDrive->setChecked(!comCurrentMedium.isNull() && comMedium.GetId() == strCurrentID); 2702 pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), comCurrentAttachment.GetDevice(), 2703 enmMediumType, UIMediumTarget::UIMediumTargetType_WithID, comMedium.GetId()))); 2704 } 2705 } 2706 2731 pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, 2732 comCurrentAttachment.GetPort(), 2733 comCurrentAttachment.GetDevice(), 2734 enmMediumType, 2735 UIMediumTarget::UIMediumTargetType_WithID, 2736 comMedium.GetId()))); 2737 } 2738 } 2707 2739 2708 2740 /* Get recent-medium list: */ … … 2746 2778 if (!fIsRecentMediumUsed) 2747 2779 { 2748 QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), pListener, pszSlotName); 2780 QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), 2781 pListener, pszSlotName); 2749 2782 pActionChooseRecentMedium->setCheckable(true); 2750 2783 pActionChooseRecentMedium->setChecked(!comCurrentMedium.isNull() && strRecentMediumLocation == strCurrentLocation); 2751 pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), comCurrentAttachment.GetDevice(), 2752 enmMediumType, UIMediumTarget::UIMediumTargetType_WithLocation, strRecentMediumLocation))); 2784 pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, 2785 comCurrentAttachment.GetPort(), 2786 comCurrentAttachment.GetDevice(), 2787 enmMediumType, 2788 UIMediumTarget::UIMediumTargetType_WithLocation, 2789 strRecentMediumLocation))); 2753 2790 pActionChooseRecentMedium->setToolTip(strRecentMediumLocation); 2754 2791 } 2755 2792 } 2756 2757 2793 2758 2794 /* Last action for optical/floppy attachments only: */ … … 2765 2801 QAction *pActionUnmountMedium = menu.addAction(QString(), pListener, pszSlotName); 2766 2802 pActionUnmountMedium->setEnabled(!comCurrentMedium.isNull()); 2767 pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), comCurrentAttachment.GetDevice()))); 2803 pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(), 2804 comCurrentAttachment.GetDevice()))); 2768 2805 pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive")); 2769 2806 if (enmMediumType == UIMediumType_DVD) … … 2816 2853 const QString strMachineFolder(QFileInfo(comConstMachine.GetSettingsFilePath()).absolutePath()); 2817 2854 const QString strMediumID = target.type != UIMediumTarget::UIMediumTargetType_CreateAdHocVISO 2818 ? vboxGlobal().openMediumWithFileOpenDialog(target.mediumType,2819 2820 2821 : vboxGlobal().createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(),2822 2855 ? openMediumWithFileOpenDialog(target.mediumType, 2856 windowManager().mainWindowShown(), 2857 strMachineFolder) 2858 : createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(), 2859 strMachineFolder); 2823 2860 /* Return focus back: */ 2824 2861 if (pLastFocusedWidget) … … 2838 2875 2839 2876 /* Prepare target medium: */ 2840 const UIMedium guiMedium = vboxGlobal().medium(strNewID);2877 const UIMedium guiMedium = medium(strNewID); 2841 2878 comMedium = guiMedium.medium(); 2842 2879 strActualID = fMount ? strNewID : strCurrentID; … … 2847 2884 { 2848 2885 /* Open medium by location and get new medium ID if any: */ 2849 const QString strNewID = vboxGlobal().openMedium(target.mediumType, target.data);2886 const QString strNewID = openMedium(target.mediumType, target.data); 2850 2887 /* Else just exit: */ 2851 2888 if (strNewID.isEmpty()) … … 2856 2893 2857 2894 /* Prepare target medium: */ 2858 const UIMedium guiMedium = fMount ? vboxGlobal().medium(strNewID) : UIMedium();2895 const UIMedium guiMedium = fMount ? medium(strNewID) : UIMedium(); 2859 2896 comMedium = fMount ? guiMedium.medium() : CMedium(); 2860 2897 strActualID = fMount ? strNewID : strCurrentID; … … 2920 2957 { 2921 2958 /* Ask for force remounting: */ 2922 if (msgCenter().cannotRemountMedium(comMachine, vboxGlobal().medium(strActualID),2959 if (msgCenter().cannotRemountMedium(comMachine, medium(strActualID), 2923 2960 fMount, true /* retry? */)) 2924 2961 { … … 2927 2964 fWasMounted = comMachine.isOk(); 2928 2965 if (!fWasMounted) 2929 msgCenter().cannotRemountMedium(comMachine, vboxGlobal().medium(strActualID),2966 msgCenter().cannotRemountMedium(comMachine, medium(strActualID), 2930 2967 fMount, false /* retry? */); 2931 2968 } … … 2964 3001 2965 3002 /* Search for corresponding UI medium again: */ 2966 2967 3003 guiMedium = medium(strMediumID); 2968 3004 if (guiMedium.isNull()) … … 3007 3043 #endif /* RT_OS_LINUX */ 3008 3044 3009 QString VBoxGlobal::details (const CUSBDevice &comDevice) const 3045 /* static */ 3046 QString VBoxGlobal::details(const CUSBDevice &comDevice) 3010 3047 { 3011 3048 QString strDetails; … … 3026 3063 { 3027 3064 strDetails = 3028 tr 3029 .arg (QString().sprintf("%04hX", comDevice.GetVendorId()))3030 .arg (QString().sprintf("%04hX", comDevice.GetProductId()));3065 tr("Unknown device %1:%2", "USB device details") 3066 .arg(QString().sprintf("%04hX", comDevice.GetVendorId())) 3067 .arg(QString().sprintf("%04hX", comDevice.GetProductId())); 3031 3068 } 3032 3069 else 3033 3070 { 3034 if (strProduct.toUpper().startsWith 3071 if (strProduct.toUpper().startsWith(strManufacturer.toUpper())) 3035 3072 strDetails = strProduct; 3036 3073 else … … 3039 3076 ushort iRev = comDevice.GetRevision(); 3040 3077 if (iRev != 0) 3041 strDetails += QString().sprintf 3078 strDetails += QString().sprintf(" [%04hX]", iRev); 3042 3079 } 3043 3080 … … 3045 3082 } 3046 3083 3047 QString VBoxGlobal::toolTip (const CUSBDevice &comDevice) const 3084 /* static */ 3085 QString VBoxGlobal::toolTip(const CUSBDevice &comDevice) 3048 3086 { 3049 3087 QString strTip = 3050 tr 3051 3052 3053 .arg (QString().sprintf("%04hX", comDevice.GetVendorId()))3054 .arg (QString().sprintf("%04hX", comDevice.GetProductId()))3055 .arg (QString().sprintf("%04hX", comDevice.GetRevision()));3056 3057 QString strSerial = comDevice.GetSerialNumber();3088 tr("<nobr>Vendor ID: %1</nobr><br>" 3089 "<nobr>Product ID: %2</nobr><br>" 3090 "<nobr>Revision: %3</nobr>", "USB device tooltip") 3091 .arg(QString().sprintf("%04hX", comDevice.GetVendorId())) 3092 .arg(QString().sprintf("%04hX", comDevice.GetProductId())) 3093 .arg(QString().sprintf("%04hX", comDevice.GetRevision())); 3094 3095 const QString strSerial = comDevice.GetSerialNumber(); 3058 3096 if (!strSerial.isEmpty()) 3059 strTip += QString (tr("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))3060 .arg(strSerial);3061 3062 /* add the state field if it's a host USB device*/3063 CHostUSBDevice hostDev 3097 strTip += QString(tr("<br><nobr>Serial No. %1</nobr>", "USB device tooltip")) 3098 .arg(strSerial); 3099 3100 /* Add the state field if it's a host USB device: */ 3101 CHostUSBDevice hostDev(comDevice); 3064 3102 if (!hostDev.isNull()) 3065 3103 { 3066 strTip += QString (tr("<br><nobr>State: %1</nobr>", "USB device tooltip"))3067 .arg (gpConverter->toString(hostDev.GetState()));3104 strTip += QString(tr("<br><nobr>State: %1</nobr>", "USB device tooltip")) 3105 .arg(gpConverter->toString(hostDev.GetState())); 3068 3106 } 3069 3107 … … 3071 3109 } 3072 3110 3073 QString VBoxGlobal::toolTip (const CUSBDeviceFilter &comFilter) const 3111 /* static */ 3112 QString VBoxGlobal::toolTip(const CUSBDeviceFilter &comFilter) 3074 3113 { 3075 3114 QString strTip; 3076 3115 3077 QString strVendorId = comFilter.GetVendorId();3116 const QString strVendorId = comFilter.GetVendorId(); 3078 3117 if (!strVendorId.isEmpty()) 3079 strTip += tr 3080 .arg(strVendorId);3081 3082 QString strProductId = comFilter.GetProductId();3118 strTip += tr("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip") 3119 .arg(strVendorId); 3120 3121 const QString strProductId = comFilter.GetProductId(); 3083 3122 if (!strProductId.isEmpty()) 3084 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3085 .arg(strProductId);3086 3087 QString strRevision = comFilter.GetRevision();3123 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product ID: %2</nobr>", "USB filter tooltip") 3124 .arg(strProductId); 3125 3126 const QString strRevision = comFilter.GetRevision(); 3088 3127 if (!strRevision.isEmpty()) 3089 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3090 .arg(strRevision);3091 3092 QString strProduct = comFilter.GetProduct();3128 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Revision: %3</nobr>", "USB filter tooltip") 3129 .arg(strRevision); 3130 3131 const QString strProduct = comFilter.GetProduct(); 3093 3132 if (!strProduct.isEmpty()) 3094 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3095 .arg(strProduct);3096 3097 QString strManufacturer = comFilter.GetManufacturer();3133 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product: %4</nobr>", "USB filter tooltip") 3134 .arg(strProduct); 3135 3136 const QString strManufacturer = comFilter.GetManufacturer(); 3098 3137 if (!strManufacturer.isEmpty()) 3099 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3100 .arg(strManufacturer);3101 3102 QString strSerial = comFilter.GetSerialNumber();3138 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip") 3139 .arg(strManufacturer); 3140 3141 const QString strSerial = comFilter.GetSerialNumber(); 3103 3142 if (!strSerial.isEmpty()) 3104 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3105 .arg(strSerial);3106 3107 QString strPort = comFilter.GetPort();3143 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Serial No.: %1</nobr>", "USB filter tooltip") 3144 .arg(strSerial); 3145 3146 const QString strPort = comFilter.GetPort(); 3108 3147 if (!strPort.isEmpty()) 3109 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3110 .arg(strPort);3111 3112 /* add the state field if it's a host USB device*/3113 CHostUSBDevice hostDev 3148 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>Port: %1</nobr>", "USB filter tooltip") 3149 .arg(strPort); 3150 3151 /* Add the state field if it's a host USB device: */ 3152 CHostUSBDevice hostDev(comFilter); 3114 3153 if (!hostDev.isNull()) 3115 3154 { 3116 strTip += strTip.isEmpty() ? "":"<br/>" + tr 3117 .arg (gpConverter->toString(hostDev.GetState()));3155 strTip += strTip.isEmpty() ? "":"<br/>" + tr("<nobr>State: %1</nobr>", "USB filter tooltip") 3156 .arg(gpConverter->toString(hostDev.GetState())); 3118 3157 } 3119 3158 … … 3121 3160 } 3122 3161 3123 QString VBoxGlobal::toolTip(const CHostVideoInputDevice &comWebcam) const 3162 /* static */ 3163 QString VBoxGlobal::toolTip(const CHostVideoInputDevice &comWebcam) 3124 3164 { 3125 3165 QStringList records; … … 3138 3178 /* static */ 3139 3179 void VBoxGlobal::doExtPackInstallation(QString const &strFilePath, QString const &strDigest, 3140 QWidget *pParent, QString *pstrExtPackName) 3180 QWidget *pParent, QString *pstrExtPackName) const 3141 3181 { 3142 3182 /* Open the extpack tarball via IExtPackManager: */ 3143 CExtPackManager comManager = v boxGlobal().virtualBox().GetExtensionPackManager();3183 CExtPackManager comManager = virtualBox().GetExtensionPackManager(); 3144 3184 CExtPackFile comExtPackFile; 3145 3185 if (strDigest.isEmpty()) … … 3238 3278 bool fSupported = false; 3239 3279 #endif 3240 unconst(this)->m_i3DAvailable = fSupported;3280 m_i3DAvailable = fSupported; 3241 3281 return fSupported; 3242 3282 } … … 3298 3338 } 3299 3339 /* Translate value into megabytes with rounding to highest side: */ 3300 quint64 uNeedMBytes = uNeedBits % (8 * _1M) ? uNeedBits / (8 * _1M) + 1 : 3301 uNeedBits / (8 * _1M) /* convert to megabytes */; 3340 quint64 uNeedMBytes = uNeedBits % (8 * _1M) 3341 ? uNeedBits / (8 * _1M) + 1 3342 : uNeedBits / (8 * _1M) /* convert to megabytes */; 3302 3343 3303 3344 if (strGuestOSTypeId.startsWith("Windows")) 3304 3345 { 3305 /* Windows guests need offscreen VRAM too for graphics acceleration features: */3346 /* Windows guests need offscreen VRAM too for graphics acceleration features: */ 3306 3347 #ifdef VBOX_WITH_CRHGSMI 3307 if (isWddmCompatibleOsType(strGuestOSTypeId))3308 {3309 /* WDDM mode, there are two surfaces for each screen: shadow & primary: */3310 uNeedMBytes *= 3;3311 }3312 else3348 if (isWddmCompatibleOsType(strGuestOSTypeId)) 3349 { 3350 /* WDDM mode, there are two surfaces for each screen: shadow & primary: */ 3351 uNeedMBytes *= 3; 3352 } 3353 else 3313 3354 #endif /* VBOX_WITH_CRHGSMI */ 3314 {3315 uNeedMBytes *= 2;3316 }3355 { 3356 uNeedMBytes *= 2; 3357 } 3317 3358 } 3318 3359 … … 3393 3434 3394 3435 /* static */ 3395 QPixmap VBoxGlobal::joinPixmaps 3436 QPixmap VBoxGlobal::joinPixmaps(const QPixmap &pixmap1, const QPixmap &pixmap2) 3396 3437 { 3397 3438 if (pixmap1.isNull()) … … 3400 3441 return pixmap1; 3401 3442 3402 QPixmap result 3403 qMax(pixmap1.height(), pixmap2.height()));3404 result.fill 3405 3406 QPainter painter 3407 painter.drawPixmap 3408 painter.drawPixmap 3443 QPixmap result(pixmap1.width() + pixmap2.width() + 2, 3444 qMax(pixmap1.height(), pixmap2.height())); 3445 result.fill(Qt::transparent); 3446 3447 QPainter painter(&result); 3448 painter.drawPixmap(0, 0, pixmap1); 3449 painter.drawPixmap(pixmap1.width() + 2, result.height() - pixmap2.height(), pixmap2); 3409 3450 painter.end(); 3410 3451 … … 3412 3453 } 3413 3454 3414 bool VBoxGlobal::openURL (const QString &strUrl)3455 bool VBoxGlobal::openURL(const QString &strUrl) const 3415 3456 { 3416 3457 /** Service event. */ 3417 3458 class ServiceEvent : public QEvent 3418 3459 { 3419 public: 3420 3421 /** Constructs service event on th basis of passed @a fResult. */ 3422 ServiceEvent (bool fResult) : QEvent (QEvent::User), m_fResult (fResult) {} 3423 3424 /** Returns the result which event brings. */ 3425 bool result() const { return m_fResult; } 3426 3427 private: 3428 3429 /** Holds the result which event brings. */ 3430 bool m_fResult; 3460 public: 3461 3462 /** Constructs service event on th basis of passed @a fResult. */ 3463 ServiceEvent(bool fResult) 3464 : QEvent(QEvent::User) 3465 , m_fResult(fResult) 3466 {} 3467 3468 /** Returns the result which event brings. */ 3469 bool result() const { return m_fResult; } 3470 3471 private: 3472 3473 /** Holds the result which event brings. */ 3474 bool m_fResult; 3431 3475 }; 3432 3476 … … 3434 3478 class ServiceClient : public QEventLoop 3435 3479 { 3436 public: 3437 3438 /** Constructs service client on the basis of passed @a fResult. */ 3439 ServiceClient() : m_fResult (false) {} 3440 3441 /** Returns the result which event brings. */ 3442 bool result() const { return m_fResult; } 3443 3444 private: 3445 3446 /** Handles any Qt @a pEvent. */ 3447 bool event (QEvent *pEvent) 3480 public: 3481 3482 /** Constructs service client on the basis of passed @a fResult. */ 3483 ServiceClient() 3484 : m_fResult(false) 3485 {} 3486 3487 /** Returns the result which event brings. */ 3488 bool result() const { return m_fResult; } 3489 3490 private: 3491 3492 /** Handles any Qt @a pEvent. */ 3493 bool event(QEvent *pEvent) 3494 { 3495 /* Handle service event: */ 3496 if (pEvent->type() == QEvent::User) 3448 3497 { 3449 /* Handle service event: */ 3450 if (pEvent->type() == QEvent::User) 3451 { 3452 ServiceEvent *pServiceEvent = static_cast <ServiceEvent*> (pEvent); 3453 m_fResult = pServiceEvent->result(); 3454 pServiceEvent->accept(); 3455 quit(); 3456 return true; 3457 } 3458 return false; 3498 ServiceEvent *pServiceEvent = static_cast<ServiceEvent*>(pEvent); 3499 m_fResult = pServiceEvent->result(); 3500 pServiceEvent->accept(); 3501 quit(); 3502 return true; 3459 3503 } 3460 3461 bool m_fResult; 3504 return false; 3505 } 3506 3507 bool m_fResult; 3462 3508 }; 3463 3509 … … 3465 3511 class ServiceServer : public QThread 3466 3512 { 3467 3468 3469 3470 ServiceServer(ServiceClient &client, const QString &strUrl)3471 : m_client (client), m_strUrl(strUrl) {}3472 3473 3474 3475 3476 3477 3478 QApplication::postEvent (&m_client, new ServiceEvent (QDesktopServices::openUrl(m_strUrl)));3479 3480 3481 3482 3483 3484 3513 public: 3514 3515 /** Constructs service server on the basis of passed @a client and @a strUrl. */ 3516 ServiceServer(ServiceClient &client, const QString &strUrl) 3517 : m_client(client), m_strUrl(strUrl) {} 3518 3519 private: 3520 3521 /** Executes thread task. */ 3522 void run() 3523 { 3524 QApplication::postEvent(&m_client, new ServiceEvent(QDesktopServices::openUrl(m_strUrl))); 3525 } 3526 3527 /** Holds the client reference. */ 3528 ServiceClient &m_client; 3529 /** Holds the URL to be processed. */ 3530 const QString &m_strUrl; 3485 3531 }; 3486 3532 3487 /* Create /startclient & server: */3533 /* Create client & server: */ 3488 3534 ServiceClient client; 3489 ServiceServer server 3535 ServiceServer server(client, strUrl); 3490 3536 server.start(); 3491 3537 client.exec(); … … 3496 3542 3497 3543 if (!fResult) 3498 msgCenter().cannotOpenURL 3544 msgCenter().cannotOpenURL(strUrl); 3499 3545 3500 3546 return fResult; … … 3509 3555 } 3510 3556 3511 bool VBoxGlobal::eventFilter 3557 bool VBoxGlobal::eventFilter(QObject *pObject, QEvent *pEvent) 3512 3558 { 3513 3559 /** @todo Just use the QIWithRetranslateUI3 template wrapper. */ 3514 3560 3515 if ( pEvent->type() == QEvent::LanguageChange &&3516 pObject->isWidgetType() &&3517 static_cast <QWidget *>(pObject)->isTopLevel())3561 if ( pEvent->type() == QEvent::LanguageChange 3562 && pObject->isWidgetType() 3563 && static_cast<QWidget*>(pObject)->isTopLevel()) 3518 3564 { 3519 3565 /* Catch the language change event before any other widget gets it in … … 3530 3576 3531 3577 /* Call to base-class: */ 3532 return QObject::eventFilter 3578 return QObject::eventFilter(pObject, pEvent); 3533 3579 } 3534 3580 3535 3581 void VBoxGlobal::retranslateUi() 3536 3582 { 3537 m_strUserDefinedPortName = tr("User-defined", "serial port");3538 3539 m_pixWarning = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning).pixmap 3540 Assert 3541 3542 m_pixError = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxCritical).pixmap 3543 Assert 3583 s_strUserDefinedPortName = tr("User-defined", "serial port"); 3584 3585 m_pixWarning = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning).pixmap(16, 16); 3586 Assert(!m_pixWarning.isNull()); 3587 3588 m_pixError = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxCritical).pixmap(16, 16); 3589 Assert(!m_pixError.isNull()); 3544 3590 3545 3591 /* Re-enumerate uimedium since they contain some translations too: */ … … 3552 3598 // we keep a table of them, which must be updated when the language is changed. 3553 3599 UINativeHotKey::retranslateKeyNames(); 3554 #endif /* VBOX_WS_X11 */3600 #endif 3555 3601 } 3556 3602 … … 3586 3632 3587 3633 HRESULT rc = COMBase::InitializeCOM(true); 3588 if (FAILED 3634 if (FAILED(rc)) 3589 3635 { 3590 3636 #ifdef VBOX_WITH_XPCOM … … 3644 3690 QString sLanguageId = gEDataManager->languageId(); 3645 3691 if (!sLanguageId.isNull()) 3646 loadLanguage 3692 loadLanguage(sLanguageId); 3647 3693 3648 3694 retranslateUi(); … … 3651 3697 this, &VBoxGlobal::sltGUILanguageChange); 3652 3698 3653 qApp->installEventFilter 3699 qApp->installEventFilter(this); 3654 3700 3655 3701 /* process command line */ … … 3673 3719 initDebuggerVar(&m_fDbgAutoShow, "VBOX_GUI_DBG_AUTO_SHOW", GUI_Dbg_AutoShow, false); 3674 3720 m_fDbgAutoShowCommandLine = m_fDbgAutoShowStatistics = m_fDbgAutoShow; 3675 m_enmLaunchRunning = LaunchRunning_Default;3676 3721 #endif 3677 3722 … … 3691 3736 * options to start a VM in main.cpp and hardenedmain.cpp exactly, 3692 3737 * otherwise there will be weird error messages. */ 3693 if ( !::strcmp 3694 || !::strcmp 3738 if ( !::strcmp(arg, "--startvm") 3739 || !::strcmp(arg, "-startvm")) 3695 3740 { 3696 3741 if (++i < argc) … … 3700 3745 } 3701 3746 } 3702 else if (!::strcmp (arg, "-separate") || !::strcmp(arg, "--separate"))3747 else if (!::strcmp(arg, "-separate") || !::strcmp(arg, "--separate")) 3703 3748 { 3704 3749 fSeparateProcess = true; … … 3721 3766 visualStateType = UIVisualStateType_Scale; 3722 3767 /* Passwords: */ 3723 else if (!::strcmp 3768 else if (!::strcmp(arg, "--settingspw")) 3724 3769 { 3725 3770 if (++i < argc) … … 3729 3774 } 3730 3775 } 3731 else if (!::strcmp 3776 else if (!::strcmp(arg, "--settingspwfile")) 3732 3777 { 3733 3778 if (++i < argc) … … 3765 3810 } 3766 3811 /* Misc options: */ 3767 else if (!::strcmp (arg, "-comment") || !::strcmp(arg, "--comment"))3812 else if (!::strcmp(arg, "-comment") || !::strcmp(arg, "--comment")) 3768 3813 ++i; 3769 3814 else if (!::strcmp(arg, "--no-startvm-errormsgbox")) … … 3806 3851 #ifdef VBOX_WITH_DEBUGGER_GUI 3807 3852 /* Debugger/Debugging options: */ 3808 else if (!::strcmp(arg, "-dbg") || !::strcmp 3853 else if (!::strcmp(arg, "-dbg") || !::strcmp(arg, "--dbg")) 3809 3854 setDebuggerVar(&m_fDbgEnabled, true); 3810 else if (!::strcmp( arg, "-debug") || !::strcmp 3855 else if (!::strcmp( arg, "-debug") || !::strcmp(arg, "--debug")) 3811 3856 { 3812 3857 setDebuggerVar(&m_fDbgEnabled, true); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r72626 r72628 61 61 class SHARED_LIBRARY_STUFF VBoxGlobal : public QObject 62 62 { 63 Q_OBJECT 63 Q_OBJECT; 64 64 65 65 signals: … … 144 144 * @{ */ 145 145 /** Returns whether VBoxGlobal cleanup is in progress. */ 146 bool isCleaningUp() { return s_fCleaningUp; }146 static bool isCleaningUp() { return s_fCleaningUp; } 147 147 148 148 /** Returns Qt runtime version string. */ … … 156 156 157 157 /** Returns whether VBoxGlobal instance is properly initialized. */ 158 bool isValid() { return m_fValid; }158 bool isValid() const { return m_fValid; } 159 159 160 160 /** Returns VBox version string. */ … … 170 170 /** Mac OS X: Returns #MacOSXRelease determined during VBoxGlobal prepare routine. */ 171 171 MacOSXRelease osRelease() const { return m_enmMacOSVersion; } 172 #endif /* VBOX_WS_MAC */172 #endif 173 173 174 174 #ifdef VBOX_WS_X11 … … 177 177 /** X11: Returns the type of the Window Manager we are running under. */ 178 178 X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; } 179 #endif /* VBOX_WS_X11 */179 #endif 180 180 181 181 /** Returns whether branding is active. */ 182 bool brandingIsActive 182 bool brandingIsActive(bool fForce = false); 183 183 /** Returns value for certain branding @a strKey from custom.ini file. */ 184 QString brandingGetKey 184 QString brandingGetKey(QString strKey); 185 185 /** @} */ 186 186 … … 229 229 bool isSupervisorCodeExecedRecompiled() const { return m_fRecompileSupervisor; } 230 230 /** Returns the --recompile-user option value. */ 231 bool isUserCodeExecedRecompiled() 231 bool isUserCodeExecedRecompiled() const { return m_fRecompileUser; } 232 232 /** Returns the --execute-all-in-iem option value. */ 233 bool areWeToExecuteAllInIem() 233 bool areWeToExecuteAllInIem() const { return m_fExecuteAllInIem; } 234 234 /** Returns whether --warp-factor option value is equal to 100. */ 235 235 bool isDefaultWarpPct() const { return m_uWarpPct == 100; } 236 236 /** Returns the --warp-factor option value. */ 237 uint32_t getWarpPct() 237 uint32_t getWarpPct() const { return m_uWarpPct; } 238 238 239 239 #ifdef VBOX_WITH_DEBUGGER_GUI … … 249 249 /** VBoxDbg module handle. */ 250 250 RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; } 251 #endif /* VBOX_WITH_DEBUGGER_GUI */251 #endif 252 252 253 253 /** Returns whether VM should start paused. */ … … 265 265 * @{ */ 266 266 /** Native language name of the currently installed translation. */ 267 QString languageName() const;267 static QString languageName(); 268 268 /** Native language country name of the currently installed translation. */ 269 QString languageCountry() const;269 static QString languageCountry(); 270 270 /** Language name of the currently installed translation, in English. */ 271 QString languageNameEnglish() const;271 static QString languageNameEnglish(); 272 272 /** Language country name of the currently installed translation, in English. */ 273 QString languageCountryEnglish() const;273 static QString languageCountryEnglish(); 274 274 /** Comma-separated list of authors of the currently installed translation. */ 275 QString languageTranslators() const;275 static QString languageTranslators(); 276 276 277 277 /** Returns VBox language sub-directory. */ … … 294 294 * @param strLangId Brings the language ID in in form of xx_YY. 295 295 * QString() means the system default language. */ 296 static void loadLanguage 296 static void loadLanguage(const QString &strLangId = QString()); 297 297 298 298 /** Returns tr("%n year(s)"). */ … … 314 314 static QString sizeRegexp(); 315 315 /** Parses the given size strText and returns the size value in bytes. */ 316 static quint64 parseSize 316 static quint64 parseSize(const QString &strText); 317 317 /** Formats the given @a uSize value in bytes to a human readable string. 318 318 * @param uSize Brings the size value in bytes. 319 319 * @param enmMode Brings the conversion mode. 320 320 * @param cDecimal Brings the number of decimal digits in result. */ 321 static QString formatSize 321 static QString formatSize(quint64 uSize, uint cDecimal = 2, FormatSize enmMode = FormatSize_Round); 322 322 323 323 /** Returns full medium-format name for the given @a strBaseMediumFormatName. */ … … 325 325 326 326 /** Returns the list of the standard COM port names (i.e. "COMx"). */ 327 QStringList COMPortNames() const;327 static QStringList COMPortNames(); 328 328 /** Returns the name of the standard COM port corresponding to the given parameters, 329 329 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */ 330 QString toCOMPortName (ulong uIRQ, ulong uIOBase) const;330 static QString toCOMPortName(ulong uIRQ, ulong uIOBase); 331 331 /** Returns port parameters corresponding to the given standard COM name. 332 332 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "COMx"). */ 333 bool toCOMPortNumbers (const QString &strName, ulong &uIRQ, ulong &uIOBase) const;333 static bool toCOMPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase); 334 334 /** Returns the list of the standard LPT port names (i.e. "LPTx"). */ 335 QStringList LPTPortNames() const;335 static QStringList LPTPortNames(); 336 336 /** Returns the name of the standard LPT port corresponding to the given parameters, 337 337 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */ 338 QString toLPTPortName (ulong uIRQ, ulong uIOBase) const;338 static QString toLPTPortName(ulong uIRQ, ulong uIOBase); 339 339 /** Returns port parameters corresponding to the given standard LPT name. 340 340 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "LPTx"). */ 341 bool toLPTPortNumbers (const QString &strName, ulong &uIRQ, ulong &uIOBase) const;341 static bool toLPTPortNumbers(const QString &strName, ulong &uIRQ, ulong &uIOBase); 342 342 343 343 /** Reformats the input @a strText to highlight it. */ 344 static QString highlight (const QString &strText, bool fToolTip = false);344 static QString highlight(QString strText, bool fToolTip = false); 345 345 /** Reformats the input @a strText to emphasize it. */ 346 static QString emphasize (const QString &strText);346 static QString emphasize(QString strText); 347 347 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */ 348 static QString removeAccelMark (const QString &strText);348 static QString removeAccelMark(QString strText); 349 349 /** Inserts a passed @a strKey into action @a strText. */ 350 350 static QString insertKeyToActionText (const QString &strText, const QString &strKey); … … 354 354 * @{ */ 355 355 /** Returns full help file name. */ 356 QString helpFile() const;356 static QString helpFile(); 357 357 358 358 /** Returns documents path. */ … … 363 363 * @{ */ 364 364 /** Search position for @a rectangle to make sure it is fully contained @a boundRegion. */ 365 static QRect normalizeGeometry 366 365 static QRect normalizeGeometry(const QRect &rectangle, const QRegion &boundRegion, 366 bool fCanResize = true); 367 367 /** Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion. */ 368 static QRect getNormalized 369 368 static QRect getNormalized(const QRect &rectangle, const QRegion &boundRegion, 369 bool fCanResize = true); 370 370 /** Returns the flipped (transposed) @a region. */ 371 static QRegion flip 371 static QRegion flip(const QRegion ®ion); 372 372 373 373 /** Aligns the center of @a pWidget with the center of @a pRelative. */ 374 static void centerWidget (QWidget *pWidget, QWidget *pRelative, 375 bool fCanResize = true); 374 static void centerWidget(QWidget *pWidget, QWidget *pRelative, bool fCanResize = true); 376 375 377 376 /** Assigns top-level @a pWidget geometry passed as QRect coordinates. … … 383 382 384 383 /** Activates the specified window with given @a wId. Can @a fSwitchDesktop if requested. */ 385 static bool activateWindow 384 static bool activateWindow(WId wId, bool fSwitchDesktop = true); 386 385 387 386 #ifdef VBOX_WS_X11 … … 434 433 /** Returns the list of few guest OS types, queried from 435 434 * IVirtualBox corresponding to every family id. */ 436 QList 435 QList<CGuestOSType> vmGuestOSFamilyList() const; 437 436 /** Returns the list of all guest OS types, queried from 438 437 * IVirtualBox corresponding to passed family id. */ 439 QList <CGuestOSType> vmGuestOSTypeList(const QString &strFamilyId) const;438 QList<CGuestOSType> vmGuestOSTypeList(const QString &strFamilyId) const; 440 439 441 440 /** Returns the guest OS type object corresponding to the given type id of list 442 441 * containing OS types related to OS family determined by family id attribute. 443 442 * If the index is invalid a null object is returned. */ 444 CGuestOSType vmGuestOSType (const QString &strTypeId, 445 const QString &strFamilyId = QString()) const; 443 CGuestOSType vmGuestOSType(const QString &strTypeId, const QString &strFamilyId = QString()) const; 446 444 /** Returns the description corresponding to the given guest OS type id. */ 447 QString vmGuestOSTypeDescription 445 QString vmGuestOSTypeDescription(const QString &strTypeId) const; 448 446 449 447 /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */ 450 static bool isDOSType 448 static bool isDOSType(const QString &strOSTypeId); 451 449 /** @} */ 452 450 … … 454 452 * @{ */ 455 453 /** Switches to certain @a comMachine. */ 456 bool switchToMachine(CMachine &comMachine);454 static bool switchToMachine(CMachine &comMachine); 457 455 /** Launches certain @a comMachine in specified @a enmLaunchMode. */ 458 456 bool launchMachine(CMachine &comMachine, LaunchMode enmLaunchMode = LaunchMode_Default); … … 467 465 * @{ */ 468 466 /** Returns medium formats which are currently supported by VirtualBox for the given @a enmDeviceType. */ 469 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);467 QList<QPair<QString, QString> > MediumBackends(KDeviceType enmDeviceType) const; 470 468 /** Returns which hard disk formats are currently supported by VirtualBox. */ 471 static QList <QPair <QString, QString> > HDDBackends();469 QList<QPair<QString, QString> > HDDBackends() const; 472 470 /** Returns which optical disk formats are currently supported by VirtualBox. */ 473 static QList <QPair <QString, QString> > DVDBackends();471 QList<QPair<QString, QString> > DVDBackends() const; 474 472 /** Returns which floppy disk formats are currently supported by VirtualBox. */ 475 static QList <QPair <QString, QString> > FloppyBackends();473 QList<QPair<QString, QString> > FloppyBackends() const; 476 474 477 475 /** Starts medium enumeration. */ … … 532 530 /** Verifies that USB drivers are properly configured on Linux. */ 533 531 static void checkForWrongUSBMounted(); 534 #endif /* RT_OS_LINUX */532 #endif 535 533 536 534 /** Generates details for passed USB @a comDevice. */ 537 QString details(const CUSBDevice &comDevice) const;535 static QString details(const CUSBDevice &comDevice); 538 536 /** Generates tool-tip for passed USB @a comDevice. */ 539 QString toolTip(const CUSBDevice &comDevice) const;537 static QString toolTip(const CUSBDevice &comDevice); 540 538 /** Generates tool-tip for passed USB @a comFilter. */ 541 QString toolTip(const CUSBDeviceFilter &comFilter) const;539 static QString toolTip(const CUSBDeviceFilter &comFilter); 542 540 /** Generates tool-tip for passed USB @a comWebcam. */ 543 QString toolTip(const CHostVideoInputDevice &comWebcam) const;541 static QString toolTip(const CHostVideoInputDevice &comWebcam); 544 542 /** @} */ 545 543 … … 551 549 * @param pParent Brings the parent dialog reference. 552 550 * @param pstrExtPackName Brings the extension pack name. */ 553 staticvoid doExtPackInstallation(QString const &strFilePath,554 555 556 QString *pstrExtPackName);551 void doExtPackInstallation(QString const &strFilePath, 552 QString const &strDigest, 553 QWidget *pParent, 554 QString *pstrExtPackName) const; 557 555 /** @} */ 558 556 … … 567 565 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */ 568 566 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId); 569 #endif /* VBOX_WITH_CRHGSMI */567 #endif 570 568 /** Returns the required video memory in bytes for the current desktop 571 569 * resolution at maximum possible screen depth in bpp. */ … … 576 574 * @{ */ 577 575 /** Returns the thread-pool instance. */ 578 UIThreadPool *threadPool() const { return m_pThreadPool; }576 UIThreadPool *threadPool() const { return m_pThreadPool; } 579 577 /** @} */ 580 578 … … 608 606 609 607 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */ 610 static QPixmap joinPixmaps 608 static QPixmap joinPixmaps(const QPixmap &pixmap1, const QPixmap &pixmap2); 611 609 /** @} */ 612 610 … … 616 614 * @{ */ 617 615 /** Opens the specified URL using OS/Desktop capabilities. */ 618 bool openURL (const QString &strURL);616 bool openURL(const QString &strURL) const; 619 617 /** @} */ 620 618 … … 628 626 629 627 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 630 bool eventFilter (QObject *pObject, QEvent *pEvent);628 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 631 629 632 630 /** Handles translation event. */ 633 v oid retranslateUi();631 virtual void retranslateUi() /* override */; 634 632 635 633 protected slots: … … 705 703 * @{ */ 706 704 /** Holds whether VBoxGlobal cleanup is in progress. */ 707 static bool 705 static bool s_fCleaningUp; 708 706 709 707 /** Holds the currently loaded language ID. */ 710 static QString s_strLoadedLanguageId; 708 static QString s_strLoadedLanguageId; 709 710 /** Holds the tr("User Defined") port name. */ 711 static QString s_strUserDefinedPortName; 711 712 712 713 #ifdef VBOX_GUI_WITH_SHARED_LIBRARY 713 714 /** Holds the UI type. */ 714 UIType m_enmType;715 UIType m_enmType; 715 716 #endif 716 717 717 718 /** Holds whether VBoxGlobal instance is properly initialized. */ 718 bool m_fValid;719 bool m_fValid; 719 720 720 721 #ifdef VBOX_WS_MAC 721 722 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */ 722 MacOSXRelease m_enmMacOSVersion;723 #endif /* VBOX_WS_MAC */723 MacOSXRelease m_enmMacOSVersion; 724 #endif 724 725 725 726 #ifdef VBOX_WS_X11 726 727 /** X11: Holds the #X11WMType of the Window Manager we are running under. */ 727 X11WMType m_enmWindowManagerType;728 X11WMType m_enmWindowManagerType; 728 729 /** X11: Holds whether the Window Manager we are running at is composition one. */ 729 bool m_fCompositingManagerRunning;730 #endif /* VBOX_WS_X11 */730 bool m_fCompositingManagerRunning; 731 #endif 731 732 732 733 /** Holds the VBox branding config file path. */ 733 QString m_strBrandingConfigFilePath;734 QString m_strBrandingConfigFilePath; 734 735 /** @} */ 735 736 … … 737 738 * @{ */ 738 739 /** Holds the URL arguments list. */ 739 QList<QUrl> m_listArgUrls;740 QList<QUrl> m_listArgUrls; 740 741 741 742 /** Holds the --startvm option value (managed VM id). */ 742 QString m_strManagedVMId;743 QString m_strManagedVMId; 743 744 /** Holds the --separate option value (whether GUI process is separate from VM process). */ 744 bool m_fSeparateProcess;745 bool m_fSeparateProcess; 745 746 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */ 746 bool m_fShowStartVMErrors;747 bool m_fShowStartVMErrors; 747 748 748 749 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */ 749 bool m_fAgressiveCaching;750 bool m_fAgressiveCaching; 750 751 751 752 /** Holds the --restore-current option value. */ 752 bool m_fRestoreCurrentSnapshot;753 bool m_fRestoreCurrentSnapshot; 753 754 754 755 /** Holds the --fda option value (floppy image). */ 755 QString m_strFloppyImage;756 QString m_strFloppyImage; 756 757 /** Holds the --dvd | --cdrom option value (DVD image). */ 757 QString m_strDvdImage;758 QString m_strDvdImage; 758 759 759 760 /** Holds the --disable-patm option value. */ 760 bool m_fDisablePatm;761 bool m_fDisablePatm; 761 762 /** Holds the --disable-csam option value. */ 762 bool m_fDisableCsam;763 bool m_fDisableCsam; 763 764 /** Holds the --recompile-supervisor option value. */ 764 bool m_fRecompileSupervisor;765 bool m_fRecompileSupervisor; 765 766 /** Holds the --recompile-user option value. */ 766 bool m_fRecompileUser;767 bool m_fRecompileUser; 767 768 /** Holds the --execute-all-in-iem option value. */ 768 bool m_fExecuteAllInIem;769 bool m_fExecuteAllInIem; 769 770 /** Holds the --warp-factor option value. */ 770 uint32_t m_uWarpPct;771 uint32_t m_uWarpPct; 771 772 772 773 #ifdef VBOX_WITH_DEBUGGER_GUI 773 774 /** Holds whether the debugger should be accessible. */ 774 mutable int m_fDbgEnabled;775 mutable int m_fDbgEnabled; 775 776 /** Holds whether to show the debugger automatically with the console. */ 776 mutable int m_fDbgAutoShow;777 mutable int m_fDbgAutoShow; 777 778 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */ 778 mutable int m_fDbgAutoShowCommandLine;779 mutable int m_fDbgAutoShowCommandLine; 779 780 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */ 780 mutable int m_fDbgAutoShowStatistics;781 mutable int m_fDbgAutoShowStatistics; 781 782 /** VBoxDbg module handle. */ 782 RTLDRMOD m_hVBoxDbg;783 RTLDRMOD m_hVBoxDbg; 783 784 784 785 /** Holds whether --start-running, --start-paused or nothing was given. */ 785 enum LaunchRunning m_enmLaunchRunning;786 enum LaunchRunning m_enmLaunchRunning; 786 787 #endif 787 788 788 789 /** Holds the --settingspw option value. */ 789 char m_astrSettingsPw[256];790 char m_astrSettingsPw[256]; 790 791 /** Holds the --settingspwfile option value. */ 791 bool m_fSettingsPwSet;792 bool m_fSettingsPwSet; 792 793 793 794 #ifdef VBOX_GUI_WITH_PIDFILE … … 795 796 QString m_strPidFile; 796 797 #endif 797 798 /** @todo remove */799 QString m_strUserDefinedPortName;800 798 /** @} */ 801 799 … … 803 801 * @{ */ 804 802 /** Holds the COM cleanup protection token. */ 805 QReadWriteLock m_comCleanupProtectionToken;803 QReadWriteLock m_comCleanupProtectionToken; 806 804 807 805 /** Holds the instance of VirtualBox client wrapper. */ 808 CVirtualBoxClient m_comVBoxClient;806 CVirtualBoxClient m_comVBoxClient; 809 807 /** Holds the copy of VirtualBox object wrapper. */ 810 CVirtualBox m_comVBox;808 CVirtualBox m_comVBox; 811 809 /** Holds the copy of VirtualBox host-object wrapper. */ 812 CHost m_comHost;810 CHost m_comHost; 813 811 /** Holds the symbolic VirtualBox home-folder representation. */ 814 QString m_strHomeFolder;812 QString m_strHomeFolder; 815 813 816 814 /** Holds whether acquired COM wrappers are currently valid. */ 817 bool m_fWrappersValid;815 bool m_fWrappersValid; 818 816 /** Holds whether VBoxSVC is currently available. */ 819 bool m_fVBoxSVCAvailable;817 bool m_fVBoxSVCAvailable; 820 818 821 819 /** Holds the guest OS family IDs. */ 822 QList<QString> m_guestOSFamilyIDs;820 QList<QString> m_guestOSFamilyIDs; 823 821 /** Holds the guest OS types for each family ID. */ 824 QList<QList<CGuestOSType> > m_guestOSTypes;822 QList<QList<CGuestOSType> > m_guestOSTypes; 825 823 /** @} */ 826 824 … … 828 826 * @{ */ 829 827 /** Holds whether 3D is available. */ 830 intm_i3DAvailable;828 mutable int m_i3DAvailable; 831 829 /** @} */ 832 830 … … 843 841 844 842 /** Holds the global file icon provider instance. */ 845 QFileIconProvider m_fileIconProvider;843 QFileIconProvider m_fileIconProvider; 846 844 847 845 /** Holds the warning pixmap. */ 848 QPixmap m_pixWarning;846 QPixmap m_pixWarning; 849 847 /** Holds the error pixmap. */ 850 QPixmap m_pixError;848 QPixmap m_pixError; 851 849 /** @} */ 852 850 … … 854 852 * @{ */ 855 853 /** Holds the medium enumerator cleanup protection token. */ 856 mutable QReadWriteLock m_meCleanupProtectionToken;854 mutable QReadWriteLock m_meCleanupProtectionToken; 857 855 858 856 /** Holds the medium enumerator. */
Note:
See TracChangeset
for help on using the changeset viewer.