Changeset 72414 in vbox
- Timestamp:
- Jun 1, 2018 6:41:33 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
r72413 r72414 159 159 #endif /* VBOX_WS_MAC */ 160 160 #ifdef VBOX_WS_X11 161 # undef BOOL /* typedef CARD8 BOOL in Xmd.h conflicts with #define BOOL PRBool 162 * in COMDefs.h. A better fix would be to isolate X11-specific 163 * stuff by placing XX* helpers below to a separate source file. */ 161 // WORKAROUND: 162 // typedef CARD8 BOOL in Xmd.h conflicts with #define BOOL PRBool 163 // in COMDefs.h. A better fix would be to isolate X11-specific 164 // stuff by placing XX* helpers below to a separate source file. 165 # undef BOOL 164 166 # include <X11/X.h> 165 167 # include <X11/Xmd.h> … … 177 179 178 180 181 /** QTranslator subclass for VBox needs. */ 179 182 class VBoxTranslator : public QTranslator 180 183 { 181 184 public: 182 185 186 /** Constructs translator passing @a pParent to the base-class. */ 183 187 VBoxTranslator (QObject *aParent = 0) 184 188 : QTranslator (aParent) {} 185 189 190 /** Loads language file with gained @a strFileName. */ 186 191 bool loadFile (const QString &aFileName) 187 192 { … … 195 200 private: 196 201 202 /** Holds the loaded data. */ 197 203 QByteArray mData; 198 204 }; 199 205 206 /** Holds the static #VBoxTranslator instance. */ 200 207 static VBoxTranslator *sTranslator = 0; 201 208 202 209 210 /** Port config cache. */ 203 211 struct PortConfig 204 212 { … … 208 216 }; 209 217 218 /** Known port config COM ports. */ 210 219 static const PortConfig kComKnownPorts[] = 211 220 { … … 214 223 { "COM3", 4, 0x3E8 }, 215 224 { "COM4", 3, 0x2E8 }, 216 /* must not contain an element with IRQ=0 and IOBase=0 used to cause225 /* Must not contain an element with IRQ=0 and IOBase=0 used to cause 217 226 * toCOMPortName() to return the "User-defined" string for these values. */ 218 227 }; 219 228 229 /** Known port config LPT ports. */ 220 230 static const PortConfig kLptKnownPorts[] = 221 231 { … … 223 233 { "LPT2", 5, 0x278 }, 224 234 { "LPT1", 2, 0x3BC }, 225 /* must not contain an element with IRQ=0 and IOBase=0 used to cause235 /* Must not contain an element with IRQ=0 and IOBase=0 used to cause 226 236 * toLPTPortName() to return the "User-defined" string for these values. */ 227 237 }; … … 400 410 #endif /* VBOX_WS_MAC */ 401 411 402 bool VBoxGlobal::brandingIsActive (bool aForce /* = false */)412 bool VBoxGlobal::brandingIsActive (bool aForce /* = false */) 403 413 { 404 414 if (aForce) … … 413 423 } 414 424 415 /**416 * Gets a value from the custom .ini file417 */418 425 QString VBoxGlobal::brandingGetKey (QString aKey) 419 426 { … … 424 431 bool VBoxGlobal::processArgs() 425 432 { 433 /* Among those arguments: */ 426 434 bool fResult = false; 427 435 QStringList args = qApp->arguments(); 436 /* We are looking for a list of file URLs passed to the executable: */ 428 437 QList<QUrl> list; 429 438 for (int i = 1; i < args.size(); ++i) 430 439 { 431 /* We break out after the first parameter, cause there could be432 440 /* But we break out after the first parameter, cause there 441 * could be parameters with arguments (e.g. --comment comment). */ 433 442 if (args.at(i).startsWith("-")) 434 443 break; … … 438 447 QString strArg = args.at(i); 439 448 #endif /* !VBOX_WS_MAC */ 449 /* So if the argument file exists, we add it to URL list: */ 440 450 if ( !strArg.isEmpty() 441 451 && QFile::exists(strArg)) 442 452 list << QUrl::fromLocalFile(strArg); 443 453 } 454 /* If there are file URLs: */ 444 455 if (!list.isEmpty()) 445 456 { 457 /* We enumerate them and: */ 446 458 for (int i = 0; i < list.size(); ++i) 447 459 { 460 /* Check which of them has allowed VM extensions: */ 448 461 const QString& strFile = list.at(i).toLocalFile(); 449 462 if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts)) 450 463 { 464 /* So that we could run existing VMs: */ 451 465 CVirtualBox vbox = virtualBox(); 452 466 CMachine machine = vbox.FindMachine(strFile); … … 455 469 fResult = true; 456 470 launchMachine(machine); 457 /* Remove from the arg list.*/471 /* And remove their URLs from the ULR list: */ 458 472 list.removeAll(strFile); 459 473 } … … 461 475 } 462 476 } 477 /* And if there are *still* URLs: */ 463 478 if (!list.isEmpty()) 464 479 { 465 /* Store the URLs: */480 /* We store them: */ 466 481 m_ArgUrlList = list; 467 /* A sk UIStarter to open them: */482 /* And ask UIStarter to open them: */ 468 483 emit sigAskToOpenURLs(); 469 484 } … … 522 537 #endif /* VBOX_GUI_WITH_PIDFILE */ 523 538 524 /**525 * Native language name of the currently installed translation.526 * Returns "English" if no translation is installed527 * or if the translation file is invalid.528 */529 539 QString VBoxGlobal::languageName() const 530 540 { 531 541 /* Returns "English" if no translation is installed 542 * or if the translation file is invalid. */ 532 543 return qApp->translate ("@@@", "English", 533 544 "Native language name"); 534 545 } 535 546 536 /**537 * Native language country name of the currently installed translation.538 * Returns "--" if no translation is installed or if the translation file is539 * invalid, or if the language is independent on the country.540 */541 547 QString VBoxGlobal::languageCountry() const 542 548 { 549 /* Returns "--" if no translation is installed or if the translation file 550 * is invalid, or if the language is independent on the country. */ 543 551 return qApp->translate ("@@@", "--", 544 552 "Native language country name " … … 546 554 } 547 555 548 /**549 * Language name of the currently installed translation, in English.550 * Returns "English" if no translation is installed551 * or if the translation file is invalid.552 */553 556 QString VBoxGlobal::languageNameEnglish() const 554 557 { 555 558 /* Returns "English" if no translation is installed 559 * or if the translation file is invalid. */ 556 560 return qApp->translate ("@@@", "English", 557 561 "Language name, in English"); 558 562 } 559 563 560 /**561 * Language country name of the currently installed translation, in English.562 * Returns "--" if no translation is installed or if the translation file is563 * invalid, or if the language is independent on the country.564 */565 564 QString VBoxGlobal::languageCountryEnglish() const 566 565 { 566 /* Returns "--" if no translation is installed or if the translation file 567 * is invalid, or if the language is independent on the country. */ 567 568 return qApp->translate ("@@@", "--", 568 569 "Language country name, in English " … … 570 571 } 571 572 572 /**573 * Comma-separated list of authors of the currently installed translation.574 * Returns "Oracle Corporation" if no translation is installed or if the575 * translation file is invalid, or if the translation is supplied by Oracle576 * Corporation577 */578 573 QString VBoxGlobal::languageTranslators() const 579 574 { 575 /* Returns "Oracle Corporation" if no translation is installed or if the translation file 576 * is invalid, or if the translation is supplied by Oracle Corporation. */ 580 577 return qApp->translate ("@@@", "Oracle Corporation", 581 578 "Comma-separated list of translators"); … … 612 609 } 613 610 614 /**615 * Returns the loaded (active) language ID.616 * Note that it may not match with UIExtraDataManager::languageId() if the617 * specified language cannot be loaded.618 * If the built-in language is active, this method returns "C".619 *620 * @note "C" is treated as the built-in language for simplicity -- the C621 * locale is used in unix environments as a fallback when the requested622 * locale is invalid. This way we don't need to process both the "built_in"623 * language and the "C" language (which is a valid environment setting)624 * separately.625 */626 611 /* static */ 627 612 QString VBoxGlobal::languageId() 628 613 { 614 /* Note that it may not match with UIExtraDataManager::languageId() if the specified language cannot be loaded. 615 * 616 * If the built-in language is active, this method returns "C". "C" is treated as the built-in language for 617 * simplicity -- the C locale is used in unix environments as a fallback when the requested locale is invalid. 618 * This way we don't need to process both the "built_in" language and the "C" language (which is a valid 619 * environment setting) separately. */ 620 629 621 return s_strLoadedLanguageId; 630 622 } 631 623 632 /**633 * This does exactly the same as QLocale::system().name() but corrects its634 * wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes635 * precedence over any other locale setting in the QLocale::system()636 * implementation). This implementation first looks at LC_ALL (as defined by637 * SUS), then looks at LC_MESSAGES which is designed to define a language for638 * program messages in case if it differs from the language for other locale639 * categories. Then it looks for LANG and finally falls back to640 * QLocale::system().name().641 *642 * The order of precedence is well defined here:643 * http://opengroup.org/onlinepubs/007908799/xbd/envvar.html644 *645 * @note This method will return "C" when the requested locale is invalid or646 * when the "C" locale is set explicitly.647 */648 624 /* static */ 649 625 QString VBoxGlobal::systemLanguageId() 650 626 { 627 /* This does exactly the same as QLocale::system().name() but corrects its wrong behavior on Linux systems 628 * (LC_NUMERIC for some strange reason takes precedence over any other locale setting in the QLocale::system() 629 * implementation). This implementation first looks at LC_ALL (as defined by SUS), then looks at LC_MESSAGES 630 * which is designed to define a language for program messages in case if it differs from the language for 631 * other locale categories. Then it looks for LANG and finally falls back to QLocale::system().name(). 632 * 633 * The order of precedence is well defined here: 634 * http://opengroup.org/onlinepubs/007908799/xbd/envvar.html 635 * 636 * This method will return "C" when the requested locale is invalid or when the "C" locale is set explicitly. */ 637 651 638 #if defined (VBOX_WS_MAC) 652 /* QLocale return the right id only if the user select the format of the653 * language also. So we use our own implementation */639 /* QLocale return the right id only if the user select the format 640 * of the language also. So we use our own implementation */ 654 641 return ::darwinSystemLanguage(); 655 642 #elif defined (Q_OS_UNIX) … … 665 652 } 666 653 667 /**668 * Loads the language by language ID.669 *670 * @param aLangId Language ID in in form of xx_YY. QString::null means the671 * system default language.672 */673 654 /* static */ 674 655 void VBoxGlobal::loadLanguage (const QString &aLangId) … … 732 713 } 733 714 734 /* delete the old translator if there is one*/715 /* Delete the old translator if there is one: */ 735 716 if (sTranslator) 736 717 { … … 741 722 } 742 723 743 /* load new language files*/724 /* Load new language files: */ 744 725 sTranslator = new VBoxTranslator (qApp); 745 726 Assert (sTranslator); … … 752 733 loadOk = sTranslator->loadFile (languageFileName); 753 734 } 754 /* we install the translator in any case: on failure, this will 755 * activate an empty translator that will give us English 756 * (built-in) */ 735 /* We install the translator in any case: on failure, this will 736 * activate an empty translator that will give us English (built-in): */ 757 737 qApp->installTranslator (sTranslator); 758 738 } … … 768 748 } 769 749 770 /* Try to load the corresponding Qt translation */750 /* Try to load the corresponding Qt translation: */ 771 751 if (languageId() != vboxBuiltInLanguageName() && languageId() != "en") 772 752 { … … 812 792 } 813 793 814 /**815 * Returns the decimal separator for the current locale.816 */817 794 /* static */ 818 795 QChar VBoxGlobal::decimalSep() … … 821 798 } 822 799 823 /**824 * Returns the regexp string that defines the format of the human-readable825 * size representation: @verbatim ####[.##] B|KB|MB|GB|TB|PB @endverbatim826 *827 * This regexp will capture 5 groups of text:828 * - cap(1): integer number in case when no decimal point is present829 * (if empty, it means that decimal point is present)830 * - cap(2): size suffix in case when no decimal point is present (may be empty)831 * - cap(3): integer number in case when decimal point is present (may be empty)832 * - cap(4): fraction number (hundredth) in case when decimal point is present833 * - cap(5): size suffix in case when decimal point is present (note that834 * B cannot appear there)835 */836 800 /* static */ 837 801 QString VBoxGlobal::sizeRegexp() 838 802 { 803 /* This regexp will capture 5 groups of text: 804 * - cap(1): integer number in case when no decimal point is present 805 * (if empty, it means that decimal point is present) 806 * - cap(2): size suffix in case when no decimal point is present (may be empty) 807 * - cap(3): integer number in case when decimal point is present (may be empty) 808 * - cap(4): fraction number (hundredth) in case when decimal point is present 809 * - cap(5): size suffix in case when decimal point is present (note that 810 * B cannot appear there). */ 811 839 812 QString regexp = 840 813 QString ("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$") … … 849 822 } 850 823 851 /**852 * Parses the given size string that should be in form of853 * @verbatim ####[.##] B|KB|MB|GB|TB|PB @endverbatim and returns854 * the size value in bytes. Zero is returned on error.855 */856 824 /* static */ 857 825 quint64 VBoxGlobal::parseSize (const QString &aText) 858 826 { 827 /* Text should be in form of B|KB|MB|GB|TB|PB. */ 859 828 QRegExp regexp (sizeRegexp()); 860 829 int pos = regexp.indexIn (aText); … … 898 867 } 899 868 900 /**901 * Formats the given @a aSize value in bytes to a human readable string902 * in form of @verbatim ####[.##] B|KB|MB|GB|TB|PB @endverbatim.903 *904 * The @a aMode and @a aDecimal parameters are used for rounding the resulting905 * number when converting the size value to KB, MB, etc gives a fractional part:906 * <ul>907 * <li>When \a aMode is FormatSize_Round, the result is rounded to the908 * closest number containing \a aDecimal decimal digits.909 * </li>910 * <li>When \a aMode is FormatSize_RoundDown, the result is rounded to the911 * largest number with \a aDecimal decimal digits that is not greater than912 * the result. This guarantees that converting the resulting string back to913 * the integer value in bytes will not produce a value greater that the914 * initial size parameter.915 * </li>916 * <li>When \a aMode is FormatSize_RoundUp, the result is rounded to the917 * smallest number with \a aDecimal decimal digits that is not less than the918 * result. This guarantees that converting the resulting string back to the919 * integer value in bytes will not produce a value less that the initial920 * size parameter.921 * </li>922 * </ul>923 *924 * @param aSize Size value in bytes.925 * @param aMode Conversion mode.926 * @param aDecimal Number of decimal digits in result.927 * @return Human-readable size string.928 */929 869 /* static */ 930 870 QString VBoxGlobal::formatSize (quint64 aSize, uint aDecimal /* = 2 */, 931 871 FormatSize aMode /* = FormatSize_Round */) 932 872 { 873 /* Text will be in form of B|KB|MB|GB|TB|PB. 874 * 875 * When enmMode is FormatSize_Round, the result is rounded to the 876 * closest number containing @a aDecimal decimal digits. 877 * When enmMode is FormatSize_RoundDown, the result is rounded to the 878 * largest number with @a aDecimal decimal digits that is not greater than 879 * the result. This guarantees that converting the resulting string back to 880 * the integer value in bytes will not produce a value greater that the 881 * initial size parameter. 882 * When enmMode is FormatSize_RoundUp, the result is rounded to the 883 * smallest number with @a aDecimal decimal digits that is not less than the 884 * result. This guarantees that converting the resulting string back to the 885 * integer value in bytes will not produce a value less that the initial 886 * size parameter. */ 887 933 888 quint64 denom = 0; 934 889 int suffix = 0; … … 985 940 else decm = (decm + denom / 2) / denom; 986 941 } 987 /* check for the fractional part overflow due to rounding*/942 /* Check for the fractional part overflow due to rounding: */ 988 943 if (decm == mult) 989 944 { 990 945 decm = 0; 991 946 ++ intg; 992 /* check if we've got 1024 XB after rounding and scale down if so*/947 /* Check if we've got 1024 XB after rounding and scale down if so: */ 993 948 if (intg == 1024 && suffix + 1 < (int)SizeSuffix_Max) 994 949 { … … 1027 982 } 1028 983 1029 /**1030 * Returns the list of the standard COM port names (i.e. "COMx").1031 */1032 984 QStringList VBoxGlobal::COMPortNames() const 1033 985 { … … 1039 991 } 1040 992 1041 /**1042 * Returns the name of the standard COM port corresponding to the given1043 * parameters, or "User-defined" (which is also returned when both1044 * @a aIRQ and @a aIOBase are 0).1045 */1046 993 QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const 1047 994 { … … 1054 1001 } 1055 1002 1056 /**1057 * Returns port parameters corresponding to the given standard COM name.1058 * Returns @c true on success, or @c false if the given port name is not one1059 * of the standard names (i.e. "COMx").1060 */1061 1003 bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ, 1062 1004 ulong &aIOBase) const … … 1073 1015 } 1074 1016 1075 /**1076 * Returns the list of the standard LPT port names (i.e. "LPTx").1077 */1078 1017 QStringList VBoxGlobal::LPTPortNames() const 1079 1018 { … … 1085 1024 } 1086 1025 1087 /**1088 * Returns the name of the standard LPT port corresponding to the given1089 * parameters, or "User-defined" (which is also returned when both1090 * @a aIRQ and @a aIOBase are 0).1091 */1092 1026 QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const 1093 1027 { … … 1100 1034 } 1101 1035 1102 /**1103 * Returns port parameters corresponding to the given standard LPT name.1104 * Returns @c true on success, or @c false if the given port name is not one1105 * of the standard names (i.e. "LPTx").1106 */1107 1036 bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ, 1108 1037 ulong &aIOBase) const … … 1119 1048 } 1120 1049 1121 /**1122 * Reformats the input string @a aStr so that:1123 * - strings in single quotes will be put inside \<nobr\> and marked1124 * with blue color;1125 * - UUIDs be put inside \<nobr\> and marked1126 * with green color;1127 * - replaces new line chars with \</p\>\<p\> constructs to form paragraphs1128 * (note that \<p\> and \</p\> are not appended to the beginning and to the1129 * end of the string respectively, to allow the result be appended1130 * or prepended to the existing paragraph).1131 *1132 * If @a aToolTip is true, colouring is not applied, only the \<nobr\> tag1133 * is added. Also, new line chars are replaced with \<br\> instead of \<p\>.1134 */1135 1050 /* static */ 1136 1051 QString VBoxGlobal::highlight (const QString &aStr, bool aToolTip /* = false */) 1137 1052 { 1053 /* We should reformat the input strText so that: 1054 * - strings in single quotes will be put inside <nobr> and marked 1055 * with blue color; 1056 * - UUIDs be put inside <nobr> and marked 1057 * with green color; 1058 * - replaces new line chars with </p><p> constructs to form paragraphs 1059 * (note that <p\> and </p> are not appended to the beginning and to the 1060 * end of the string respectively, to allow the result be appended 1061 * or prepended to the existing paragraph). 1062 * 1063 * If @a fToolTip is true, colouring is not applied, only the <nobr> tag 1064 * is added. Also, new line chars are replaced with <br> instead of <p>. */ 1065 1138 1066 QString strFont; 1139 1067 QString uuidFont; … … 1148 1076 QString text = aStr; 1149 1077 1150 /* replace special entities, '&' -- first! */1078 /* Replace special entities, '&' -- first! */ 1151 1079 text.replace ('&', "&"); 1152 1080 text.replace ('<', "<"); … … 1154 1082 text.replace ('\"', """); 1155 1083 1156 /* mark strings in single quotes with color*/1084 /* Mark strings in single quotes with color: */ 1157 1085 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1158 1086 rx.setMinimal (true); … … 1160 1088 QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strFont).arg (endFont)); 1161 1089 1162 /* mark UUIDs with color*/1090 /* Mark UUIDs with color: */ 1163 1091 text.replace (QRegExp ( 1164 1092 "((?:^|\\s)[(]?)" … … 1167 1095 QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidFont).arg (endFont)); 1168 1096 1169 /* split to paragraphs at \n chars*/1097 /* Split to paragraphs at \n chars: */ 1170 1098 if (!aToolTip) 1171 1099 text.replace ('\n', "</p><p>"); … … 1176 1104 } 1177 1105 1178 /**1179 * Reformats the input string @a aStr so that:1180 * - strings in single quotes will be put inside \<nobr\> and marked1181 * with bold style;1182 * - UUIDs be put inside \<nobr\> and marked1183 * with italic style;1184 * - replaces new line chars with \</p\>\<p\> constructs to form paragraphs1185 * (note that \<p\> and \</p\> are not appended to the beginning and to the1186 * end of the string respectively, to allow the result be appended1187 * or prepended to the existing paragraph).1188 */1189 1106 /* static */ 1190 1107 QString VBoxGlobal::emphasize (const QString &aStr) 1191 1108 { 1109 /* We should reformat the input string @a strText so that: 1110 * - strings in single quotes will be put inside \<nobr\> and marked 1111 * with bold style; 1112 * - UUIDs be put inside \<nobr\> and marked 1113 * with italic style; 1114 * - replaces new line chars with \</p\>\<p\> constructs to form paragraphs 1115 * (note that \<p\> and \</p\> are not appended to the beginning and to the 1116 * end of the string respectively, to allow the result be appended 1117 * or prepended to the existing paragraph). */ 1118 1192 1119 QString strEmphStart ("<b>"); 1193 1120 QString strEmphEnd ("</b>"); … … 1197 1124 QString text = aStr; 1198 1125 1199 /* replace special entities, '&' -- first! */1126 /* Replace special entities, '&' -- first! */ 1200 1127 text.replace ('&', "&"); 1201 1128 text.replace ('<', "<"); … … 1203 1130 text.replace ('\"', """); 1204 1131 1205 /* mark strings in single quotes with bold style*/1132 /* Mark strings in single quotes with bold style: */ 1206 1133 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1207 1134 rx.setMinimal (true); … … 1209 1136 QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strEmphStart).arg (strEmphEnd)); 1210 1137 1211 /* mark UUIDs with italic style*/1138 /* Mark UUIDs with italic style: */ 1212 1139 text.replace (QRegExp ( 1213 1140 "((?:^|\\s)[(]?)" … … 1216 1143 QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidEmphStart).arg (uuidEmphEnd)); 1217 1144 1218 /* split to paragraphs at \n chars*/1145 /* Split to paragraphs at \n chars: */ 1219 1146 text.replace ('\n', "</p><p>"); 1220 1147 … … 1222 1149 } 1223 1150 1224 /**1225 * Removes the accelerator mark (the ampersand symbol) from the given string1226 * and returns the result. The string is supposed to be a menu item's text1227 * that may (or may not) contain the accelerator mark.1228 *1229 * In order to support accelerators used in non-alphabet languages1230 * (e.g. Japanese) that has a form of "(&\<L\>)" (where \<L\> is a latin letter),1231 * this method first searches for this pattern and, if found, removes it as a1232 * whole. If such a pattern is not found, then the '&' character is simply1233 * removed from the string.1234 *1235 * @note This function removes only the first occurrence of the accelerator1236 * mark.1237 *1238 * @param aText Menu item's text to remove the accelerator mark from.1239 *1240 * @return The resulting string.1241 */1242 1151 /* static */ 1243 1152 QString VBoxGlobal::removeAccelMark (const QString &aText) 1244 1153 { 1154 /* In order to support accelerators used in non-alphabet languages 1155 * (e.g. Japanese) that has a form of "(&<L>)" (where <L> is a latin letter), 1156 * this method first searches for this pattern and, if found, removes it as a 1157 * whole. If such a pattern is not found, then the '&' character is simply 1158 * removed from the string. */ 1159 1245 1160 QString result = aText; 1246 1161 … … 1310 1225 QLocale lang (VBoxGlobal::languageId()); 1311 1226 1312 /* Construct the path and the filename */1227 /* Construct the path and the filename: */ 1313 1228 QString manual = QString ("%1/%2_%3.%4").arg (szDocsPath) 1314 1229 .arg (name) 1315 1230 .arg (lang.name()) 1316 1231 .arg (suffix); 1317 /* Check if a help file with that name exists */1232 /* Check if a help file with that name exists: */ 1318 1233 QFileInfo fi (manual); 1319 1234 if (fi.exists()) 1320 1235 return manual; 1321 1236 1322 /* Fall back to the standard */1237 /* Fall back to the standard: */ 1323 1238 manual = QString ("%1/%2.%4").arg (szDocsPath) 1324 1239 .arg (name) … … 1344 1259 } 1345 1260 1346 /**1347 * Performs direct and flipped search of position for \a aRectangle to make sure1348 * it is fully contained inside \a aBoundRegion region by moving & resizing1349 * \a aRectangle if necessary. Selects the minimum shifted result between direct1350 * and flipped variants.1351 */1352 1261 /* static */ 1353 1262 QRect VBoxGlobal::normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion, 1354 1263 bool aCanResize /* = true */) 1355 1264 { 1265 /* Perform direct and flipped search of position for @a rectangle to make sure it is fully contained 1266 * inside @a boundRegion region by moving & resizing (if @a fCanResize is specified) @a rectangle if 1267 * necessary. Selects the minimum shifted result between direct and flipped variants. */ 1268 1356 1269 /* Direct search for normalized rectangle */ 1357 1270 QRect var1 (getNormalized (aRectangle, aBoundRegion, aCanResize)); 1358 1271 1359 /* Flipped search for normalized rectangle */1272 /* Flipped search for normalized rectangle: */ 1360 1273 QRect var2 (flip (getNormalized (flip (aRectangle).boundingRect(), 1361 1274 flip (aBoundRegion), aCanResize)).boundingRect()); 1362 1275 1363 /* Calculate shift from starting position for both variants */1276 /* Calculate shift from starting position for both variants: */ 1364 1277 double length1 = sqrt (pow ((double) (var1.x() - aRectangle.x()), (double) 2) + 1365 1278 pow ((double) (var1.y() - aRectangle.y()), (double) 2)); … … 1367 1280 pow ((double) (var2.y() - aRectangle.y()), (double) 2)); 1368 1281 1369 /* Return minimum shifted variant */1282 /* Return minimum shifted variant: */ 1370 1283 return length1 > length2 ? var2 : var1; 1371 1284 } 1372 1285 1373 /**1374 * Ensures that the given rectangle \a aRectangle is fully contained within the1375 * region \a aBoundRegion by moving \a aRectangle if necessary. If \a aRectangle is1376 * larger than \a aBoundRegion, top left corner of \a aRectangle is aligned with the1377 * top left corner of maximum available rectangle and, if \a aCanResize is true,1378 * \a aRectangle is shrinked to become fully visible.1379 */1380 1286 /* static */ 1381 1287 QRect VBoxGlobal::getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion, 1382 1288 bool /* aCanResize = true */) 1383 1289 { 1384 /* Storing available horizontal sub-rectangles & vertical shifts */ 1290 /* Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion 1291 * by moving @a rectangle if necessary. If @a rectangle is larger than @a boundRegion, top left 1292 * corner of @a rectangle is aligned with the top left corner of maximum available rectangle and, 1293 * if @a fCanResize is true, @a rectangle is shrinked to become fully visible. */ 1294 1295 /* Storing available horizontal sub-rectangles & vertical shifts: */ 1385 1296 int windowVertical = aRectangle.center().y(); 1386 1297 QVector <QRect> rectanglesVector (aBoundRegion.rects()); … … 1412 1323 } 1413 1324 1414 /* Trying to find the appropriate place for window */1325 /* Trying to find the appropriate place for window: */ 1415 1326 QRect result; 1416 1327 for (int i = -1; i < shiftsList.size(); ++ i) 1417 1328 { 1418 /* Move to appropriate vertical */1329 /* Move to appropriate vertical: */ 1419 1330 QRect rectangle (aRectangle); 1420 1331 if (i >= 0) rectangle.translate (0, shiftsList [i]); 1421 1332 1422 /* Search horizontal shift */1333 /* Search horizontal shift: */ 1423 1334 int maxShift = 0; 1424 1335 foreach (QRect item, rectanglesList) … … 1440 1351 } 1441 1352 1442 /* Shift across the horizontal direction */1353 /* Shift across the horizontal direction: */ 1443 1354 rectangle.translate (maxShift, 0); 1444 1355 1445 /* Check the translated rectangle to feat the rules */1356 /* Check the translated rectangle to feat the rules: */ 1446 1357 if (aBoundRegion.united (rectangle) == aBoundRegion) 1447 1358 result = rectangle; … … 1453 1364 { 1454 1365 /* Resize window to feat desirable size 1455 * using max of available rectangles */1366 * using max of available rectangles: */ 1456 1367 QRect maxRectangle; 1457 1368 quint64 maxSquare = 0; … … 1477 1388 } 1478 1389 1479 /**1480 * Returns the flipped (transposed) region.1481 */1482 1390 /* static */ 1483 1391 QRegion VBoxGlobal::flip (const QRegion &aRegion) … … 1491 1399 } 1492 1400 1493 /**1494 * Aligns the center of \a aWidget with the center of \a aRelative.1495 *1496 * If necessary, \a aWidget's position is adjusted to make it fully visible1497 * within the available desktop area. If \a aWidget is bigger then this area,1498 * it will also be resized unless \a aCanResize is false or there is an1499 * inappropriate minimum size limit (in which case the top left corner will be1500 * simply aligned with the top left corner of the available desktop area).1501 *1502 * \a aWidget must be a top-level widget. \a aRelative may be any widget, but1503 * if it's not top-level itself, its top-level widget will be used for1504 * calculations. \a aRelative can also be NULL, in which case \a aWidget will1505 * be centered relative to the available desktop area.1506 */1507 1401 /* static */ 1508 1402 void VBoxGlobal::centerWidget (QWidget *aWidget, QWidget *aRelative, 1509 1403 bool aCanResize /* = true */) 1510 1404 { 1405 /* If necessary, pWidget's position is adjusted to make it fully visible within 1406 * the available desktop area. If pWidget is bigger then this area, it will also 1407 * be resized unless fCanResize is false or there is an inappropriate minimum 1408 * size limit (in which case the top left corner will be simply aligned with the top 1409 * left corner of the available desktop area). pWidget must be a top-level widget. 1410 * pRelative may be any widget, but if it's not top-level itself, its top-level 1411 * widget will be used for calculations. pRelative can also be NULL, in which case 1412 * pWidget will be centered relative to the available desktop area. */ 1413 1511 1414 AssertReturnVoid (aWidget); 1512 1415 AssertReturnVoid (aWidget->isTopLevel()); … … 1519 1422 deskGeo = gpDesktop->availableGeometry (w); 1520 1423 parentGeo = w->frameGeometry(); 1521 /* On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level 1522 * widgets with parents, what a shame. Use mapToGlobal() to workaround. */ 1424 // WORKAROUND: 1425 // On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level 1426 // widgets with parents, what a shame. Use mapToGlobal() to workaround. 1523 1427 QPoint d = w->mapToGlobal (QPoint (0, 0)); 1524 1428 d.rx() -= w->geometry().x() - w->x(); … … 1532 1436 } 1533 1437 1534 /* On X11, there is no way to determine frame geometry (including WM 1535 * decorations) before the widget is shown for the first time. Stupidly 1536 * enumerate other top level widgets to find the thickest frame. The code 1537 * is based on the idea taken from QDialog::adjustPositionInternal(). */ 1438 // WORKAROUND: 1439 // On X11, there is no way to determine frame geometry (including WM 1440 // decorations) before the widget is shown for the first time. Stupidly 1441 // enumerate other top level widgets to find the thickest frame. The code 1442 // is based on the idea taken from QDialog::adjustPositionInternal(). 1538 1443 1539 1444 int extraw = 0, extrah = 0; … … 1575 1480 parentGeo.y() + (parentGeo.height() - 1) / 2)); 1576 1481 1577 /* ensure the widget is within the available desktop area*/1482 /* Ensure the widget is within the available desktop area: */ 1578 1483 QRect newGeo = normalizeGeometry (geo, deskGeo, aCanResize); 1579 1484 #ifdef VBOX_WS_MAC 1580 /* No idea why, but Qt doesn't respect if there is a unified toolbar on the 1581 * ::move call. So manually add the height of the toolbar before setting 1582 * the position. */ 1485 // WORKAROUND: 1486 // No idea why, but Qt doesn't respect if there is a unified toolbar on the 1487 // ::move call. So manually add the height of the toolbar before setting 1488 // the position. 1583 1489 if (w) 1584 1490 newGeo.translate (0, ::darwinWindowToolBarHeight (aWidget)); … … 1625 1531 if (pWidget->isWindow() && pWidget->isVisible()) 1626 1532 { 1627 /* X11 window managers are not required to accept geometry changes on 1628 * the top-level window. Unfortunately, current at Qt 5.6 and 5.7, Qt 1629 * assumes that the change will succeed, and resizes all sub-windows 1630 * unconditionally. By calling ConfigureWindow directly, Qt will see 1631 * our change request as an externally triggered one on success and not 1632 * at all if it is rejected. */ 1533 // WORKAROUND: 1534 // X11 window managers are not required to accept geometry changes on 1535 // the top-level window. Unfortunately, current at Qt 5.6 and 5.7, Qt 1536 // assumes that the change will succeed, and resizes all sub-windows 1537 // unconditionally. By calling ConfigureWindow directly, Qt will see 1538 // our change request as an externally triggered one on success and not 1539 // at all if it is rejected. 1633 1540 const double dDPR = gpDesktop->devicePixelRatio(pWidget); 1634 1541 uint16_t fMask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y … … 1668 1575 } 1669 1576 else 1670 /* Call the Qt method if the window is not visible as otherwise no 1671 * Configure event will arrive to tell Qt what geometry we want. */ 1577 // WORKAROUND: 1578 // Call the Qt method if the window is not visible as otherwise no 1579 // Configure event will arrive to tell Qt what geometry we want. 1672 1580 pWidget->setGeometry(x, y, w, h); 1673 1581 # else /* !VBOX_WS_X11 */ … … 1682 1590 } 1683 1591 1684 /**1685 * Activates the specified window. If necessary, the window will be1686 * de-iconified activation.1687 *1688 * @note On X11, it is implied that @a aWid represents a window of the same1689 * display the application was started on.1690 *1691 * @param aWId Window ID to activate.1692 * @param aSwitchDesktop @c true to switch to the window's desktop before1693 * activation.1694 *1695 * @return @c true on success and @c false otherwise.1696 */1697 1592 /* static */ 1698 1593 bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */) … … 1722 1617 "_NET_WM_DESKTOP"); 1723 1618 if (desktop == NULL) 1724 /* if the NetWM properly is not supported try to find the desktop 1725 * ID using the GNOME WM property */ 1619 // WORKAROUND: 1620 // if the NetWM properly is not supported try to find 1621 // the desktop ID using the GNOME WM property. 1726 1622 desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL, 1727 1623 "_WIN_WORKSPACE"); … … 1809 1705 ev.xclient.message_type = msgAtom; 1810 1706 1811 /* always send as 32 bit for now*/1707 /* Always send as 32 bit for now: */ 1812 1708 ev.xclient.format = 32; 1813 1709 ev.xclient.data.l [0] = aData0; … … 1821 1717 } 1822 1718 1823 /* This method tests whether the current X11 window manager supports full-screen mode as we need it.1824 * Unfortunately the EWMH specification was not fully clear about whether we can expect to find1825 * all of these atoms on the _NET_SUPPORTED root window property, so we have to test with all1826 * interesting window managers. If this fails for a user when you think it should succeed1827 * they should try executing:1828 * xprop -root | egrep -w '_NET_WM_FULLSCREEN_MONITORS|_NET_WM_STATE|_NET_WM_STATE_FULLSCREEN'1829 * in an X11 terminal window.1830 * All three strings should be found under a property called "_NET_SUPPORTED(ATOM)". */1831 1719 /* static */ 1832 1720 bool VBoxGlobal::supportsFullScreenMonitorsProtocolX11() 1833 1721 { 1834 /* Using a global to get at the display does not feel right, but that is 1835 * how it is done elsewhere in the code. */ 1722 /* This method tests whether the current X11 window manager supports full-screen mode as we need it. 1723 * Unfortunately the EWMH specification was not fully clear about whether we can expect to find 1724 * all of these atoms on the _NET_SUPPORTED root window property, so we have to test with all 1725 * interesting window managers. If this fails for a user when you think it should succeed 1726 * they should try executing: 1727 * xprop -root | egrep -w '_NET_WM_FULLSCREEN_MONITORS|_NET_WM_STATE|_NET_WM_STATE_FULLSCREEN' 1728 * in an X11 terminal window. 1729 * All three strings should be found under a property called "_NET_SUPPORTED(ATOM)". */ 1730 1731 /* Using a global to get at the display does not feel right, but that is how it is done elsewhere in the code. */ 1836 1732 Display *pDisplay = QX11Info::display(); 1837 1733 Atom atomSupported = XInternAtom(pDisplay, "_NET_SUPPORTED", … … 2017 1913 } 2018 1914 1915 /* static */ 2019 1916 void VBoxGlobal::setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString) 2020 1917 { … … 2160 2057 void VBoxGlobal::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount) 2161 2058 { 2059 /* Shame on Qt it hasn't stuff for tuning 2060 * widget size suitable for reflecting content of desired size. 2061 * For example QLineEdit, QSpinBox and similar widgets should have a methods 2062 * to strict the minimum width to reflect at least [n] symbols. */ 2063 2162 2064 /* Load options: */ 2163 2065 QStyleOptionSpinBox option; … … 2182 2084 } 2183 2085 2184 /**2185 * Returns the list of few guest OS types, queried from2186 * IVirtualBox corresponding to every family id.2187 */2188 2086 QList<CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const 2189 2087 { … … 2194 2092 } 2195 2093 2196 /**2197 * Returns the list of all guest OS types, queried from2198 * IVirtualBox corresponding to passed family id.2199 */2200 2094 QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const 2201 2095 { … … 2205 2099 } 2206 2100 2207 /**2208 * Returns the guest OS type object corresponding to the given type id of list2209 * containing OS types related to OS family determined by family id attribute.2210 * If the index is invalid a null object is returned.2211 */2212 2101 CGuestOSType VBoxGlobal::vmGuestOSType(const QString &aTypeId, 2213 2102 const QString &aFamilyId /* = QString::null */) const … … 2230 2119 } 2231 2120 2232 /**2233 * Returns the description corresponding to the given guest OS type id.2234 */2235 2121 QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const 2236 2122 { … … 2267 2153 return false; 2268 2154 2269 /* winId = 0 it means the console window has already done everything 2270 * necessary to implement the "show window" semantics. */ 2155 // WORKAROUND: 2156 // winId = 0 it means the console window has already done everything 2157 // necessary to implement the "show window" semantics. 2271 2158 if (id == 0) 2272 2159 return true; … … 2277 2164 2278 2165 #elif defined(VBOX_WS_MAC) 2279 /* 2280 * This is just for the case were the other process cannot steal 2281 * the focus from us. It will send us a PSN so we can try. 2282 */ 2166 // WORKAROUND: 2167 // This is just for the case were the other process cannot steal 2168 // the focus from us. It will send us a PSN so we can try. 2283 2169 ProcessSerialNumber psn; 2284 2170 psn.highLongOfPSN = id >> 32; … … 2540 2426 } 2541 2427 2542 /**2543 * Figures out which medium formats are currently supported by VirtualBox for2544 * the given device type.2545 * Returned is a list of pairs with the form2546 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.2547 */2548 2428 /* static */ 2549 2429 QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType) 2550 2430 { 2431 /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */ 2551 2432 CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties(); 2552 2433 QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats(); … … 2571 2452 } 2572 2453 2573 /**2574 * Figures out which hard disk formats are currently supported by VirtualBox.2575 * Returned is a list of pairs with the form2576 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.2577 */2578 2454 /* static */ 2579 2455 QList <QPair <QString, QString> > VBoxGlobal::HDDBackends() … … 2582 2458 } 2583 2459 2584 /**2585 * Figures out which optical disk formats are currently supported by VirtualBox.2586 * Returned is a list of pairs with the form2587 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.2588 */2589 2460 /* static */ 2590 2461 QList <QPair <QString, QString> > VBoxGlobal::DVDBackends() … … 2593 2464 } 2594 2465 2595 /**2596 * Figures out which floppy disk formats are currently supported by VirtualBox.2597 * Returned is a list of pairs with the form2598 * <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.2599 */2600 2466 /* static */ 2601 2467 QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends() … … 2692 2558 } 2693 2559 2694 QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0 */)2560 QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0 */) 2695 2561 { 2696 2562 /* Convert to native separators: */ … … 2755 2621 } 2756 2622 2757 /* Open some external medium using file open dialog2758 * and temporary cache (enumerate) it in GUI inner mediums cache: */2759 2623 QString VBoxGlobal::openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent, 2760 2624 const QString &strDefaultFolder /* = QString() */, … … 2838 2702 } 2839 2703 2840 /**2841 * Create a VISO using the file open dialog.2842 *2843 * Temporarily caches (enumerate) it in GUI inner mediums cache.2844 *2845 * @returns Medium ID string, empty on abort.2846 */2847 2704 QString VBoxGlobal::createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder) 2848 2705 { … … 2861 2718 /// @todo tr("Please select files and directories to be on the VISO"), 2862 2719 tr("Please select files to be on the VISO"), 2863 0, true /* aResolveSymlinks*/, false /*aSingleFile*/);2720 0, true /* resolve symlinks? */, false /* single file? */); 2864 2721 2865 2722 /* Return if no result. */ … … 3240 3097 } 3241 3098 3242 QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true */)3099 QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true */) 3243 3100 { 3244 3101 /* Search for corresponding UI medium: */ … … 3294 3151 #endif /* RT_OS_LINUX */ 3295 3152 3296 /**3297 * Returns the details of the given USB device as a single-line string.3298 */3299 3153 QString VBoxGlobal::details (const CUSBDevice &aDevice) const 3300 3154 { … … 3335 3189 } 3336 3190 3337 /**3338 * Returns the multi-line description of the given USB device.3339 */3340 3191 QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const 3341 3192 { … … 3364 3215 } 3365 3216 3366 /**3367 * Returns the multi-line description of the given USB filter3368 */3369 3217 QString VBoxGlobal::toolTip (const CUSBDeviceFilter &aFilter) const 3370 3218 { … … 3417 3265 } 3418 3266 3419 /** Returns the multi-line description of the given CHostVideoInputDevice filter. */3420 3267 QString VBoxGlobal::toolTip(const CHostVideoInputDevice &webcam) const 3421 3268 { … … 3521 3368 } 3522 3369 3523 /**3524 * Inner worker that for lazily querying for 3D support.3525 *3526 * Rational is that when starting a text mode guest (like DOS) that does not3527 * have 3D enabled, don't wast the developer's or user's time on launching the3528 * test application when starting the VM or editing it's settings.3529 *3530 * @returns true / false.3531 * @note If we ever end up checking this concurrently on multiple threads, use a3532 * RTONCE construct to serialize the efforts.3533 */3534 3370 bool VBoxGlobal::is3DAvailableWorker() const 3535 3371 { 3372 /* Rational is that when starting a text mode guest (like DOS) that does not 3373 * have 3D enabled, don't wast the developer's or user's time on launching the 3374 * test application when starting the VM or editing it's settings. 3375 * 3376 * Keep in mind that if we ever end up checking this concurrently on multiple threads, 3377 * use a RTONCE construct to serialize the efforts. */ 3378 3536 3379 #ifdef VBOX_WITH_CROGL 3537 3380 bool fSupported = VBoxOglIs3DAccelerationSupported(); … … 3557 3400 #endif /* VBOX_WITH_CRHGSMI */ 3558 3401 3559 /**3560 * Returns the required video memory in bytes for the current desktop3561 * resolution at maximum possible screen depth in bpp.3562 */3563 3402 /* static */ 3564 3403 quint64 VBoxGlobal::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */) … … 3577 3416 screenSize[i] = r.width() * r.height(); 3578 3417 } 3579 /* Now sort the vector */3418 /* Now sort the vector: */ 3580 3419 qSort(screenSize.begin(), screenSize.end(), qGreater<int>()); 3581 3420 /* For the case that there are more guest screens configured then host … … 3589 3428 for (int i = 0; i < cMonitors; ++i) 3590 3429 { 3591 /* Calculate summary required memory amount in bits */3430 /* Calculate summary required memory amount in bits: */ 3592 3431 needBits += (screenSize.at(i) * /* with x height */ 3593 3432 32 + /* we will take the maximum possible bpp for now */ … … 3595 3434 8 * 4096; /* adapter info */ 3596 3435 } 3597 /* Translate value into megabytes with rounding to highest side */3436 /* Translate value into megabytes with rounding to highest side: */ 3598 3437 quint64 needMBytes = needBits % (8 * _1M) ? needBits / (8 * _1M) + 1 : 3599 3438 needBits / (8 * _1M) /* convert to megabytes */; … … 3605 3444 if (isWddmCompatibleOsType(strGuestOSTypeId)) 3606 3445 { 3607 /* wddm mode, there are two surfaces for each screen: shadow & primary*/3446 /* WDDM mode, there are two surfaces for each screen: shadow & primary: */ 3608 3447 needMBytes *= 3; 3609 3448 } … … 3690 3529 } 3691 3530 3692 /**3693 * Joins two pixmaps horizontally with 2px space between them and returns the3694 * result.3695 *3696 * @param aPM1 Left pixmap.3697 * @param aPM2 Right pixmap.3698 */3699 3531 /* static */ 3700 3532 QPixmap VBoxGlobal::joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2) … … 3717 3549 } 3718 3550 3719 /**3720 * Replacement for QToolButton::setTextLabel() that handles the shortcut3721 * letter (if it is present in the argument string) as if it were a setText()3722 * call: the shortcut letter is used to automatically assign an "Alt+<letter>"3723 * accelerator key sequence to the given tool button.3724 *3725 * @note This method preserves the icon set if it was assigned before. Only3726 * the text label and the accelerator are changed.3727 *3728 * @param aToolButton Tool button to set the text label on.3729 * @param aTextLabel Text label to set.3730 */3731 3551 /* static */ 3732 3552 void VBoxGlobal::setTextLabel (QToolButton *aToolButton, … … 3746 3566 } 3747 3567 3748 /**3749 * Puts soft hyphens after every path component in the given file name.3750 *3751 * @param aFileName File name (must be a full path name).3752 */3753 3568 /* static */ 3754 3569 QString VBoxGlobal::locationForHTML (const QString &aFileName) … … 3766 3581 } 3767 3582 3768 /**3769 * Searches for a widget that with @a aName (if it is not NULL) which inherits3770 * @a aClassName (if it is not NULL) and among children of @a aParent. If @a3771 * aParent is NULL, all top-level widgets are searched. If @a aRecursive is3772 * true, child widgets are recursively searched as well.3773 */3774 3583 /* static */ 3775 3584 QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName, … … 3806 3615 } 3807 3616 3808 /**3809 * Opens the specified URL using OS/Desktop capabilities.3810 *3811 * @param aURL URL to open3812 *3813 * @return true on success and false otherwise3814 */3815 3617 bool VBoxGlobal::openURL (const QString &aURL) 3816 3618 { 3817 /* Service event*/3619 /** Service event. */ 3818 3620 class ServiceEvent : public QEvent 3819 3621 { 3820 3622 public: 3821 3623 3624 /** Constructs service event on th basis of passed @a fResult. */ 3822 3625 ServiceEvent (bool aResult) : QEvent (QEvent::User), mResult (aResult) {} 3823 3626 3627 /** Returns the result which event brings. */ 3824 3628 bool result() const { return mResult; } 3825 3629 3826 3630 private: 3827 3631 3632 /** Holds the result which event brings. */ 3828 3633 bool mResult; 3829 3634 }; 3830 3635 3831 /* Service-Client object*/3636 /** Service client object. */ 3832 3637 class ServiceClient : public QEventLoop 3833 3638 { 3834 3639 public: 3835 3640 3641 /** Constructs service client on the basis of passed @a fResult. */ 3836 3642 ServiceClient() : mResult (false) {} 3837 3643 3644 /** Returns the result which event brings. */ 3838 3645 bool result() const { return mResult; } 3839 3646 3840 3647 private: 3841 3648 3649 /** Handles any Qt @a pEvent. */ 3842 3650 bool event (QEvent *aEvent) 3843 3651 { 3652 /* Handle service event: */ 3844 3653 if (aEvent->type() == QEvent::User) 3845 3654 { … … 3856 3665 }; 3857 3666 3858 /* Service-Server object*/3667 /** Service server object. */ 3859 3668 class ServiceServer : public QThread 3860 3669 { 3861 3670 public: 3862 3671 3672 /** Constructs service server on the basis of passed @a client and @a strUrl. */ 3863 3673 ServiceServer (ServiceClient &aClient, const QString &sURL) 3864 3674 : mClient (aClient), mURL (sURL) {} … … 3866 3676 private: 3867 3677 3678 /** Executes thread task. */ 3868 3679 void run() 3869 3680 { … … 3871 3682 } 3872 3683 3684 /** Holds the client reference. */ 3873 3685 ServiceClient &mClient; 3686 /** Holds the URL to be processed. */ 3874 3687 const QString &mURL; 3875 3688 }; 3876 3689 3690 /* Create/start client & server: */ 3877 3691 ServiceClient client; 3878 3692 ServiceServer server (client, aURL); … … 3881 3695 server.wait(); 3882 3696 3697 /* Acquire client result: */ 3883 3698 bool result = client.result(); 3884 3699 … … 3899 3714 bool VBoxGlobal::eventFilter (QObject *aObject, QEvent *aEvent) 3900 3715 { 3716 /** @todo Just use the QIWithRetranslateUI3 template wrapper. */ 3717 3901 3718 if (aEvent->type() == QEvent::LanguageChange && 3902 3719 aObject->isWidgetType() && … … 3909 3726 if (list.first() == aObject) 3910 3727 { 3911 /* call this only once per every language change (see3912 * QApplication::installTranslator() for details) */3728 /* Call this only once per every language change (see 3729 * QApplication::installTranslator() for details): */ 3913 3730 retranslateUi(); 3914 3731 } 3915 3732 } 3916 3733 3734 /* Call to base-class: */ 3917 3735 return QObject::eventFilter (aObject, aEvent); 3918 3736 } 3919 3737 3920 /**3921 * Changes the language of all global string constants according to the3922 * currently installed translations tables.3923 */3924 3738 void VBoxGlobal::retranslateUi() 3925 3739 { … … 3937 3751 3938 3752 #ifdef VBOX_WS_X11 3939 /* As X11 do not have functionality for providing human readable key names, 3940 * we keep a table of them, which must be updated when the language is changed. */ 3753 // WORKAROUND: 3754 // As X11 do not have functionality for providing human readable key names, 3755 // we keep a table of them, which must be updated when the language is changed. 3941 3756 UINativeHotKey::retranslateKeyNames(); 3942 3757 #endif /* VBOX_WS_X11 */ … … 4261 4076 } 4262 4077 4263 /* After initializing * vmUuid* we already know if that is VM process or not: */4078 /* After initializing *m_strManagedVMId* we already know if that is VM process or not: */ 4264 4079 if (!isVMConsoleProcess()) 4265 4080 { … … 4532 4347 # define VBOXGLOBAL_DBG_CFG_VAR_DONE RT_BIT(4) 4533 4348 4534 /**4535 * Initialize a debugger config variable.4536 *4537 * @param piDbgCfgVar The debugger config variable to init.4538 * @param pszEnvVar The environment variable name relating to this4539 * variable.4540 * @param pszExtraDataName The extra data name relating to this variable.4541 * @param fDefault The default value.4542 */4543 4349 void VBoxGlobal::initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault) 4544 4350 { … … 4587 4393 } 4588 4394 4589 /**4590 * Set a debugger config variable according according to start up argument.4591 *4592 * @param piDbgCfgVar The debugger config variable to set.4593 * @param fState The value from the command line.4594 */4595 4395 void VBoxGlobal::setDebuggerVar(int *piDbgCfgVar, bool fState) 4596 4396 { … … 4600 4400 } 4601 4401 4602 /**4603 * Checks the state of a debugger config variable, updating it with the machine4604 * settings on the first invocation.4605 *4606 * @returns true / false.4607 * @param piDbgCfgVar The debugger config variable to consult.4608 * @param pszExtraDataName The extra data name relating to this variable.4609 */4610 4402 bool VBoxGlobal::isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const 4611 4403 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r72413 r72414 65 65 signals: 66 66 67 /** Asks listener to commit data. */ 68 void sigAskToCommitData(); 69 70 /** Asks listener to open URLs. */ 71 void sigAskToOpenURLs(); 72 73 /** Asks listener to recreate UI. */ 74 void sigAskToRestartUI(); 75 76 /** Notifies listeners about the VBoxSVC availability change. */ 77 void sigVBoxSVCAvailabilityChange(); 78 79 /* Notifiers: Medium-processing stuff: */ 80 void sigMediumCreated(const QString &strMediumID); 81 void sigMediumDeleted(const QString &strMediumID); 82 83 /* Notifiers: Medium-enumeration stuff: */ 84 void sigMediumEnumerationStarted(); 85 void sigMediumEnumerated(const QString &strMediumID); 86 void sigMediumEnumerationFinished(); 67 /** @name Common stuff. 68 * @{ */ 69 /** Asks #UIStarter listener to commit data. */ 70 void sigAskToCommitData(); 71 /** @} */ 72 73 /** @name Process arguments stuff. 74 * @{ */ 75 /** Asks #UIStarter listener to open URLs. */ 76 void sigAskToOpenURLs(); 77 /** @} */ 78 79 /** @name COM stuff. 80 * @{ */ 81 /** Asks #UIStarter listener to restart UI. */ 82 void sigAskToRestartUI(); 83 84 /** Notifies listeners about the VBoxSVC availability change. */ 85 void sigVBoxSVCAvailabilityChange(); 86 /** @} */ 87 88 /** @name COM: Virtual Media stuff. 89 * @{ */ 90 /** Notifies listeners about medium with certain @a strMediumID created. */ 91 void sigMediumCreated(const QString &strMediumID); 92 /** Notifies listeners about medium with certain @a strMediumID deleted. */ 93 void sigMediumDeleted(const QString &strMediumID); 94 95 /** Notifies listeners about medium enumeration started. */ 96 void sigMediumEnumerationStarted(); 97 /** Notifies listeners about medium with certain @a strMediumID enumerated. */ 98 void sigMediumEnumerated(const QString &strMediumID); 99 /** Notifies listeners about medium enumeration finished. */ 100 void sigMediumEnumerationFinished(); 101 /** @} */ 87 102 88 103 public: … … 106 121 }; 107 122 108 /** Whether to start the VM running. */123 /** VM launch running options. */ 109 124 enum StartRunning 110 125 { 111 StartRunning_Default, 112 StartRunning_No, 113 StartRunning_Yes 126 StartRunning_Default, /**< Default (depends on debug settings). */ 127 StartRunning_No, /**< Start the VM paused. */ 128 StartRunning_Yes /**< Start the VM running. */ 114 129 }; 115 130 116 /* Static API: Create/destroy stuff:*/131 /** Returns VBoxGlobal instance. */ 117 132 static VBoxGlobal *instance() { return s_pInstance; } 118 133 #ifndef VBOX_GUI_WITH_SHARED_LIBRARY 134 /** Creates VBoxGlobal instance. */ 119 135 static void create(); 120 136 #else 137 /** Creates VBoxGlobal instance of passed @a enmType. */ 121 138 static void create(UIType enmType); 122 139 #endif 140 /** Destroys VBoxGlobal instance. */ 123 141 static void destroy(); 124 142 125 bool isCleaningUp() { return s_fCleanupInProgress; } 126 127 static QString qtRTVersionString(); 128 static uint qtRTVersion(); 129 static QString qtCTVersionString(); 130 static uint qtCTVersion(); 131 132 bool isValid() { return mValid; } 133 134 QString vboxVersionString() const; 135 QString vboxVersionStringNormalized() const; 136 bool isBeta() const; 137 138 QString versionString() const { return mVerString; } 143 /** @name Common stuff. 144 * @{ */ 145 /** Returns whether VBoxGlobal cleanup is in progress. */ 146 bool isCleaningUp() { return s_fCleanupInProgress; } 147 148 /** Returns Qt runtime version string. */ 149 static QString qtRTVersionString(); 150 /** Returns Qt runtime version. */ 151 static uint qtRTVersion(); 152 /** Returns Qt compiled version string. */ 153 static QString qtCTVersionString(); 154 /** Returns Qt compiled version. */ 155 static uint qtCTVersion(); 156 157 /** Returns whether VBoxGlobal instance is properly initialized. */ 158 bool isValid() { return mValid; } 159 160 /** Returns VBox version string. */ 161 QString vboxVersionString() const; 162 /** Returns normalized VBox version string. */ 163 QString vboxVersionStringNormalized() const; 164 /** Returns whether VBox version string contains BETA word. */ 165 bool isBeta() const; 166 167 /** todo remove */ 168 QString versionString() const { return mVerString; } 139 169 140 170 #ifdef VBOX_WS_MAC 141 /** Mac OS X: Returns #MacOSXRelease determined using<i>uname</i> call. */142 static MacOSXRelease determineOsRelease();143 /** Mac OS X: Returns #MacOSXRelease determined during VBoxGlobal prepare routine. */144 MacOSXRelease osRelease() const { return m_osRelease; }171 /** Mac OS X: Returns #MacOSXRelease determined by <i>uname</i> call. */ 172 static MacOSXRelease determineOsRelease(); 173 /** Mac OS X: Returns #MacOSXRelease determined during VBoxGlobal prepare routine. */ 174 MacOSXRelease osRelease() const { return m_osRelease; } 145 175 #endif /* VBOX_WS_MAC */ 146 176 147 177 #ifdef VBOX_WS_X11 148 /** X11: Returns whether the Window Manager we are running atis composition one. */149 bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }150 /** X11: Returns the type of the Window Manager we are running under. */151 X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }178 /** X11: Returns whether the Window Manager we are running under is composition one. */ 179 bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; } 180 /** X11: Returns the type of the Window Manager we are running under. */ 181 X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; } 152 182 #endif /* VBOX_WS_X11 */ 153 183 154 /* branding */ 155 bool brandingIsActive (bool aForce = false); 156 QString brandingGetKey (QString aKey); 157 158 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList) 159 { 160 for (int i = 0; i < extList.size(); ++i) 161 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive)) 162 return true; 163 return false; 164 } 165 166 bool processArgs(); 167 168 QList<QUrl> &argUrlList() { return m_ArgUrlList; } 169 170 QString managedVMUuid() const { return vmUuid; } 171 bool isVMConsoleProcess() const { return !vmUuid.isNull(); } 172 /** Returns whether GUI is separate (from VM) process. */ 173 bool isSeparateProcess() const { return m_fSeparateProcess; } 174 bool showStartVMErrors() const { return mShowStartVMErrors; } 175 176 bool agressiveCaching() const { return mAgressiveCaching; } 177 178 /** Returns whether we should restore current snapshot before VM started. */ 179 bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; } 180 /** Defines whether we should fRestore current snapshot before VM started. */ 181 void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; } 182 183 bool hasFloppyImageToMount() const { return !m_strFloppyImage.isEmpty(); } 184 bool hasDvdImageToMount() const { return !m_strDvdImage.isEmpty(); } 185 QString const &getFloppyImage() const { return m_strFloppyImage; } 186 QString const &getDvdImage() const { return m_strDvdImage; } 187 188 bool isPatmDisabled() const { return mDisablePatm; } 189 bool isCsamDisabled() const { return mDisableCsam; } 190 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; } 191 bool isUserCodeExecedRecompiled() const { return mRecompileUser; } 192 bool areWeToExecuteAllInIem() const { return mExecuteAllInIem; } 193 bool isDefaultWarpPct() const { return mWarpPct == 100; } 194 uint32_t getWarpPct() const { return mWarpPct; } 184 /** Returns whether branding is active. */ 185 bool brandingIsActive (bool aForce = false); 186 /** Returns value for certain branding @a strKey from custom.ini file. */ 187 QString brandingGetKey (QString aKey); 188 /** @} */ 189 190 /** @name Process arguments stuff. 191 * @{ */ 192 /** Returns whether passed @a strExt ends with one of allowed extension in the @a extList. */ 193 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList) 194 { 195 for (int i = 0; i < extList.size(); ++i) 196 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive)) 197 return true; 198 return false; 199 } 200 201 /** Process application args. */ 202 bool processArgs(); 203 204 /** Returns the URL arguments list. */ 205 QList<QUrl> &argUrlList() { return m_ArgUrlList; } 206 207 /** Returns the --startvm option value (managed VM id). */ 208 QString managedVMUuid() const { return vmUuid; } 209 /** Returns whether this is VM console process. */ 210 bool isVMConsoleProcess() const { return !vmUuid.isNull(); } 211 /** Returns the --separate option value (whether GUI process is separate from VM process). */ 212 bool isSeparateProcess() const { return m_fSeparateProcess; } 213 /** Returns the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */ 214 bool showStartVMErrors() const { return mShowStartVMErrors; } 215 216 /** Returns the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */ 217 bool agressiveCaching() const { return mAgressiveCaching; } 218 219 /** Returns the --restore-current option value (whether we should restore current snapshot before VM started). */ 220 bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; } 221 /** Defines whether we should fRestore current snapshot before VM started. */ 222 void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; } 223 224 /** Returns the --fda option value (whether we have floppy image). */ 225 bool hasFloppyImageToMount() const { return !m_strFloppyImage.isEmpty(); } 226 /** Returns the --dvd | --cdrom option value (whether we have DVD image). */ 227 bool hasDvdImageToMount() const { return !m_strDvdImage.isEmpty(); } 228 /** Returns floppy image name. */ 229 QString const &getFloppyImage() const { return m_strFloppyImage; } 230 /** Returns DVD image name. */ 231 QString const &getDvdImage() const { return m_strDvdImage; } 232 233 /** Returns the --disable-patm option value. */ 234 bool isPatmDisabled() const { return mDisablePatm; } 235 /** Returns the --disable-csam option value. */ 236 bool isCsamDisabled() const { return mDisableCsam; } 237 /** Returns the --recompile-supervisor option value. */ 238 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; } 239 /** Returns the --recompile-user option value. */ 240 bool isUserCodeExecedRecompiled() const { return mRecompileUser; } 241 /** Returns the --execute-all-in-iem option value. */ 242 bool areWeToExecuteAllInIem() const { return mExecuteAllInIem; } 243 /** Returns whether --warp-factor option value is equal to 100. */ 244 bool isDefaultWarpPct() const { return mWarpPct == 100; } 245 /** Returns the --warp-factor option value. */ 246 uint32_t getWarpPct() const { return mWarpPct; } 195 247 196 248 #ifdef VBOX_WITH_DEBUGGER_GUI 197 bool isDebuggerEnabled() const; 198 bool isDebuggerAutoShowEnabled() const; 199 bool isDebuggerAutoShowCommandLineEnabled() const; 200 bool isDebuggerAutoShowStatisticsEnabled() const; 201 202 RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; } 249 /** Holds whether the debugger should be accessible. */ 250 bool isDebuggerEnabled() const; 251 /** Holds whether to show the debugger automatically with the console. */ 252 bool isDebuggerAutoShowEnabled() const; 253 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */ 254 bool isDebuggerAutoShowCommandLineEnabled() const; 255 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */ 256 bool isDebuggerAutoShowStatisticsEnabled() const; 257 258 /** VBoxDbg module handle. */ 259 RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; } 203 260 #endif /* VBOX_WITH_DEBUGGER_GUI */ 204 261 205 bool shouldStartPaused() const 206 { 262 /** Returns whether VM should start paused. */ 263 bool shouldStartPaused() const 264 { 207 265 #ifdef VBOX_WITH_DEBUGGER_GUI 208 return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No;266 return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No; 209 267 #else 210 return false;211 #endif 212 }268 return false; 269 #endif 270 } 213 271 214 272 #ifdef VBOX_GUI_WITH_PIDFILE 215 void createPidfile(); 216 void deletePidfile(); 217 #endif 218 219 QString languageName() const; 220 QString languageCountry() const; 221 QString languageNameEnglish() const; 222 QString languageCountryEnglish() const; 223 QString languageTranslators() const; 224 225 /** Returns VBox language sub-directory. */ 226 static QString vboxLanguageSubDirectory(); 227 /** Returns VBox language file-base. */ 228 static QString vboxLanguageFileBase(); 229 /** Returns VBox language file-extension. */ 230 static QString vboxLanguageFileExtension(); 231 /** Returns VBox language ID reg-exp. */ 232 static QString vboxLanguageIdRegExp(); 233 /** Returns built in language name. */ 234 static QString vboxBuiltInLanguageName(); 235 236 static QString languageId(); 237 static QString systemLanguageId(); 238 239 static void loadLanguage (const QString &aLangId = QString::null); 240 241 static inline QString yearsToString (uint32_t cVal) 242 { 243 return tr("%n year(s)", "", cVal); 244 } 245 246 static inline QString monthsToString (uint32_t cVal) 247 { 248 return tr("%n month(s)", "", cVal); 249 } 250 251 static inline QString daysToString (uint32_t cVal) 252 { 253 return tr("%n day(s)", "", cVal); 254 } 255 256 static inline QString hoursToString (uint32_t cVal) 257 { 258 return tr("%n hour(s)", "", cVal); 259 } 260 261 static inline QString minutesToString (uint32_t cVal) 262 { 263 return tr("%n minute(s)", "", cVal); 264 } 265 266 static inline QString secondsToString (uint32_t cVal) 267 { 268 return tr("%n second(s)", "", cVal); 269 } 270 271 static QChar decimalSep(); 272 static QString sizeRegexp(); 273 274 static quint64 parseSize (const QString &); 275 static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round); 276 277 /* Returns full medium-format name for the given base medium-format name: */ 278 static QString fullMediumFormatName(const QString &strBaseMediumFormatName); 279 280 QStringList COMPortNames() const; 281 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const; 282 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const; 283 284 QStringList LPTPortNames() const; 285 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const; 286 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const; 287 288 static QString highlight (const QString &aStr, bool aToolTip = false); 289 static QString emphasize (const QString &aStr); 290 static QString removeAccelMark (const QString &aText); 291 static QString insertKeyToActionText (const QString &aText, const QString &aKey); 292 293 static QString replaceHtmlEntities(QString strText); 294 295 QString helpFile() const; 296 static QString documentsPath(); 297 298 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion, 273 /** Creates PID file. */ 274 void createPidfile(); 275 /** Deletes PID file. */ 276 void deletePidfile(); 277 #endif 278 /** @} */ 279 280 /** @name Localization stuff. 281 * @{ */ 282 /** Native language name of the currently installed translation. */ 283 QString languageName() const; 284 /** Native language country name of the currently installed translation. */ 285 QString languageCountry() const; 286 /** Language name of the currently installed translation, in English. */ 287 QString languageNameEnglish() const; 288 /** Language country name of the currently installed translation, in English. */ 289 QString languageCountryEnglish() const; 290 /** Comma-separated list of authors of the currently installed translation. */ 291 QString languageTranslators() const; 292 293 /** Returns VBox language sub-directory. */ 294 static QString vboxLanguageSubDirectory(); 295 /** Returns VBox language file-base. */ 296 static QString vboxLanguageFileBase(); 297 /** Returns VBox language file-extension. */ 298 static QString vboxLanguageFileExtension(); 299 /** Returns VBox language ID reg-exp. */ 300 static QString vboxLanguageIdRegExp(); 301 /** Returns built in language name. */ 302 static QString vboxBuiltInLanguageName(); 303 304 /** Returns the loaded (active) language ID. */ 305 static QString languageId(); 306 /** Returns the system language ID. */ 307 static QString systemLanguageId(); 308 309 /** Loads the language by language ID. 310 * @param strLangId Brings the language ID in in form of xx_YY. 311 * QString() means the system default language. */ 312 static void loadLanguage (const QString &aLangId = QString::null); 313 314 /** Returns tr("%n year(s)"). */ 315 static inline QString yearsToString (uint32_t cVal) 316 { 317 return tr("%n year(s)", "", cVal); 318 } 319 /** Returns tr("%n month(s)"). */ 320 static inline QString monthsToString (uint32_t cVal) 321 { 322 return tr("%n month(s)", "", cVal); 323 } 324 /** Returns tr("%n day(s)"). */ 325 static inline QString daysToString (uint32_t cVal) 326 { 327 return tr("%n day(s)", "", cVal); 328 } 329 /** Returns tr("%n hour(s)"). */ 330 static inline QString hoursToString (uint32_t cVal) 331 { 332 return tr("%n hour(s)", "", cVal); 333 } 334 /** Returns tr("%n minute(s)"). */ 335 static inline QString minutesToString (uint32_t cVal) 336 { 337 return tr("%n minute(s)", "", cVal); 338 } 339 /** Returns tr("%n second(s)"). */ 340 static inline QString secondsToString (uint32_t cVal) 341 { 342 return tr("%n second(s)", "", cVal); 343 } 344 345 /** Returns the decimal separator for the current locale. */ 346 static QChar decimalSep(); 347 /** Returns the regexp string that defines the format of the human-readable size representation. */ 348 static QString sizeRegexp(); 349 /** Parses the given size strText and returns the size value in bytes. */ 350 static quint64 parseSize (const QString &); 351 /** Formats the given @a uSize value in bytes to a human readable string. 352 * @param uSize Brings the size value in bytes. 353 * @param enmMode Brings the conversion mode. 354 * @param cDecimal Brings the number of decimal digits in result. */ 355 static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round); 356 357 /** Returns full medium-format name for the given @a strBaseMediumFormatName. */ 358 static QString fullMediumFormatName(const QString &strBaseMediumFormatName); 359 360 /** Returns the list of the standard COM port names (i.e. "COMx"). */ 361 QStringList COMPortNames() const; 362 /** Returns the name of the standard COM port corresponding to the given parameters, 363 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */ 364 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const; 365 /** Returns port parameters corresponding to the given standard COM name. 366 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "COMx"). */ 367 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const; 368 /** Returns the list of the standard LPT port names (i.e. "LPTx"). */ 369 QStringList LPTPortNames() const; 370 /** Returns the name of the standard LPT port corresponding to the given parameters, 371 * or "User-defined" (which is also returned when both @a uIRQ and @a uIOBase are 0). */ 372 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const; 373 /** Returns port parameters corresponding to the given standard LPT name. 374 * Returns @c true on success, or @c false if the given port name is not one of the standard names (i.e. "LPTx"). */ 375 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const; 376 377 /** Reformats the input @a strText to highlight it. */ 378 static QString highlight (const QString &aStr, bool aToolTip = false); 379 /** Reformats the input @a strText to emphasize it. */ 380 static QString emphasize (const QString &aStr); 381 /** Removes the first occurrence of the accelerator mark (the ampersand symbol) from the given @a strText. */ 382 static QString removeAccelMark (const QString &aText); 383 /** Inserts a passed @a strKey into action @a strText. */ 384 static QString insertKeyToActionText (const QString &aText, const QString &aKey); 385 386 /** @todo remove */ 387 static QString replaceHtmlEntities(QString strText); 388 /** @} */ 389 390 /** @name File-system stuff. 391 * @{ */ 392 /** Returns full help file name. */ 393 QString helpFile() const; 394 395 /** Returns documents path. */ 396 static QString documentsPath(); 397 /** @} */ 398 399 /** @name Window/widget geometry stuff. 400 * @{ */ 401 /** Search position for @a rectangle to make sure it is fully contained @a boundRegion. */ 402 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion, 403 bool aCanResize = true); 404 /** Ensures that the given rectangle @a rectangle is fully contained within the region @a boundRegion. */ 405 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion, 299 406 bool aCanResize = true); 300 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion, 301 bool aCanResize = true); 302 static QRegion flip (const QRegion &aRegion); 303 304 static void centerWidget (QWidget *aWidget, QWidget *aRelative, 305 bool aCanResize = true); 306 307 /** Assigns top-level @a pWidget geometry passed as QRect coordinates. 308 * @note Take into account that this request may fail on X11. */ 309 static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h); 310 /** Assigns top-level @a pWidget geometry passed as @a rect. 311 * @note Take into account that this request may fail on X11. */ 312 static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect); 313 314 static bool activateWindow (WId aWId, bool aSwitchDesktop = true); 407 /** Returns the flipped (transposed) @a region. */ 408 static QRegion flip (const QRegion &aRegion); 409 410 /** Aligns the center of @a pWidget with the center of @a pRelative. */ 411 static void centerWidget (QWidget *aWidget, QWidget *aRelative, 412 bool aCanResize = true); 413 414 /** Assigns top-level @a pWidget geometry passed as QRect coordinates. 415 * @note Take into account that this request may fail on X11. */ 416 static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h); 417 /** Assigns top-level @a pWidget geometry passed as @a rect. 418 * @note Take into account that this request may fail on X11. */ 419 static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect); 420 421 /** Activates the specified window with given @a wId. Can @a fSwitchDesktop if requested. */ 422 static bool activateWindow (WId aWId, bool aSwitchDesktop = true); 315 423 316 424 #ifdef VBOX_WS_X11 317 /** X11: Test whether the current window manager supports full screen mode. */318 static bool supportsFullScreenMonitorsProtocolX11();319 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */320 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);321 322 /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */323 static QVector<Atom> flagsNetWmState(QWidget *pWidget);324 /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */325 static bool isFullScreenFlagSet(QWidget *pWidget);326 /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */327 static void setFullScreenFlag(QWidget *pWidget);328 /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */329 static void setSkipTaskBarFlag(QWidget *pWidget);330 /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */331 static void setSkipPagerFlag(QWidget *pWidget);332 333 /** Assigns WM_CLASS property for passed @a pWidget. */334 static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);425 /** X11: Test whether the current window manager supports full screen mode. */ 426 static bool supportsFullScreenMonitorsProtocolX11(); 427 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */ 428 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId); 429 430 /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */ 431 static QVector<Atom> flagsNetWmState(QWidget *pWidget); 432 /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */ 433 static bool isFullScreenFlagSet(QWidget *pWidget); 434 /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */ 435 static void setFullScreenFlag(QWidget *pWidget); 436 /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */ 437 static void setSkipTaskBarFlag(QWidget *pWidget); 438 /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */ 439 static void setSkipPagerFlag(QWidget *pWidget); 440 441 /** Assigns WM_CLASS property for passed @a pWidget. */ 442 static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString); 335 443 #endif /* VBOX_WS_X11 */ 336 444 337 /* Shame on Qt it hasn't stuff for tuning 338 * widget size suitable for reflecting content of desired size. 339 * For example QLineEdit, QSpinBox and similar widgets should have a methods 340 * to strict the minimum width to reflect at least [n] symbols. */ 341 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount); 342 343 /** Try to acquire COM cleanup protection token for reading. */ 344 bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); } 345 /** Unlock previously acquired COM cleanup protection token. */ 346 void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); } 347 348 /** Returns the copy of VirtualBox client wrapper. */ 349 CVirtualBoxClient virtualBoxClient() const { return m_client; } 350 /** Returns the copy of VirtualBox object wrapper. */ 351 CVirtualBox virtualBox() const { return m_vbox; } 352 /** Returns the copy of VirtualBox host-object wrapper. */ 353 CHost host() const { return m_host; } 354 /** Returns the symbolic VirtualBox home-folder representation. */ 355 QString homeFolder() const { return m_strHomeFolder; } 356 357 /** Returns the VBoxSVC availability value. */ 358 bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; } 359 360 QList <CGuestOSType> vmGuestOSFamilyList() const; 361 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const; 362 363 CGuestOSType vmGuestOSType (const QString &aTypeId, 364 const QString &aFamilyId = QString::null) const; 365 QString vmGuestOSTypeDescription (const QString &aTypeId) const; 366 367 static bool isDOSType (const QString &aOSTypeId); 368 369 bool switchToMachine(CMachine &machine); 370 bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default); 371 372 CSession openSession(const QString &aId, KLockType aLockType = KLockType_Write); 373 /** Shortcut to openSession (aId, true). */ 374 CSession openExistingSession(const QString &aId) { return openSession(aId, KLockType_Shared); } 375 376 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType); 377 static QList <QPair <QString, QString> > HDDBackends(); 378 static QList <QPair <QString, QString> > DVDBackends(); 379 static QList <QPair <QString, QString> > FloppyBackends(); 380 381 /* API: Medium-enumeration stuff: */ 382 void startMediumEnumeration(); 383 bool isMediumEnumerationInProgress() const; 384 UIMedium medium(const QString &strMediumID) const; 385 QList<QString> mediumIDs() const; 386 void createMedium(const UIMedium &medium); 387 void deleteMedium(const QString &strMediumID); 388 389 /* API: Medium-processing stuff: */ 390 QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0); 391 392 QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0, 393 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true); 394 395 QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder); 396 397 /** Prepares storage menu according passed parameters. 398 * @param menu QMenu being prepared. 399 * @param pListener Listener QObject, this menu being prepared for. 400 * @param pszSlotName SLOT in the @a pListener above, this menu will be handled with. 401 * @param machine CMachine object, this menu being prepared for. 402 * @param strControllerName The name of the CStorageController in the @a machine above. 403 * @param storageSlot The StorageSlot of the CStorageController called @a strControllerName above. */ 404 void prepareStorageMenu(QMenu &menu, 405 QObject *pListener, const char *pszSlotName, 406 const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot); 407 /** Updates @a constMachine storage with data described by @a target. */ 408 void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target); 409 410 QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true); 411 445 /** Assigns minimum @a pSpinBox to correspond to @a cCount digits. */ 446 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount); 447 /** @} */ 448 449 /** @name COM stuff. 450 * @{ */ 451 /** Try to acquire COM cleanup protection token for reading. */ 452 bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); } 453 /** Unlock previously acquired COM cleanup protection token. */ 454 void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); } 455 456 /** Returns the copy of VirtualBox client wrapper. */ 457 CVirtualBoxClient virtualBoxClient() const { return m_client; } 458 /** Returns the copy of VirtualBox object wrapper. */ 459 CVirtualBox virtualBox() const { return m_vbox; } 460 /** Returns the copy of VirtualBox host-object wrapper. */ 461 CHost host() const { return m_host; } 462 /** Returns the symbolic VirtualBox home-folder representation. */ 463 QString homeFolder() const { return m_strHomeFolder; } 464 465 /** Returns the VBoxSVC availability value. */ 466 bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; } 467 /** @} */ 468 469 /** @name COM: Guest OS Type. 470 * @{ */ 471 /** Returns the list of few guest OS types, queried from 472 * IVirtualBox corresponding to every family id. */ 473 QList <CGuestOSType> vmGuestOSFamilyList() const; 474 /** Returns the list of all guest OS types, queried from 475 * IVirtualBox corresponding to passed family id. */ 476 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const; 477 478 /** Returns the guest OS type object corresponding to the given type id of list 479 * containing OS types related to OS family determined by family id attribute. 480 * If the index is invalid a null object is returned. */ 481 CGuestOSType vmGuestOSType (const QString &aTypeId, 482 const QString &aFamilyId = QString::null) const; 483 /** Returns the description corresponding to the given guest OS type id. */ 484 QString vmGuestOSTypeDescription (const QString &aTypeId) const; 485 486 /** Returns whether guest type with passed @a strOSTypeId is one of DOS types. */ 487 static bool isDOSType (const QString &aOSTypeId); 488 /** @} */ 489 490 /** @name COM: Virtual Machine stuff. 491 * @{ */ 492 /** Switches to certain @a comMachine. */ 493 bool switchToMachine(CMachine &machine); 494 /** Launches certain @a comMachine in specified @a enmLaunchMode. */ 495 bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default); 496 497 /** Opens session of certain @a enmLockType for VM with certain @a strId. */ 498 CSession openSession(const QString &aId, KLockType aLockType = KLockType_Write); 499 /** Opens session of KLockType_Shared type for VM with certain @a strId. */ 500 CSession openExistingSession(const QString &aId) { return openSession(aId, KLockType_Shared); } 501 /** @} */ 502 503 /** @name COM: Virtual Media stuff. 504 * @{ */ 505 /** Returns medium formats which are currently supported by VirtualBox for the given @a enmDeviceType. */ 506 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType); 507 /** Returns which hard disk formats are currently supported by VirtualBox. */ 508 static QList <QPair <QString, QString> > HDDBackends(); 509 /** Returns which optical disk formats are currently supported by VirtualBox. */ 510 static QList <QPair <QString, QString> > DVDBackends(); 511 /** Returns which floppy disk formats are currently supported by VirtualBox. */ 512 static QList <QPair <QString, QString> > FloppyBackends(); 513 514 /** Starts medium enumeration. */ 515 void startMediumEnumeration(); 516 /** Returns whether medium enumeration is in progress. */ 517 bool isMediumEnumerationInProgress() const; 518 /** Returns enumerated medium with certain @a strMediumID. */ 519 UIMedium medium(const QString &strMediumID) const; 520 /** Returns enumerated medium IDs. */ 521 QList<QString> mediumIDs() const; 522 /** Creates medium on the basis of passed @a guiMedium description. */ 523 void createMedium(const UIMedium &medium); 524 /** Deletes medium with certain @a strMediumID. */ 525 void deleteMedium(const QString &strMediumID); 526 527 /** Opens external medium by passed @a strMediumLocation. 528 * @param enmMediumType Brings the medium type. 529 * @param pParent Brings the dialog parent. 530 * @param strMediumLocation Brings the file path to load medium from. 531 * @param pParent Brings the dialog parent. */ 532 QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0); 533 534 /** Opens external medium using file-open dialog. 535 * @param enmMediumType Brings the medium type. 536 * @param pParent Brings the dialog parent. 537 * @param strDefaultFolder Brings the folder to browse for medium. 538 * @param fUseLastFolder Brings whether we should propose to use last used folder. */ 539 QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0, 540 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true); 541 542 /** Creates a VISO using the file-open dialog. 543 * @param pParent Brings the dialog parent. 544 * @param strFolder Brings the folder to browse for VISO file contents. */ 545 QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder); 546 547 /** Prepares storage menu according passed parameters. 548 * @param menu Brings the #QMenu to be prepared. 549 * @param pListener Brings the listener #QObject, this @a menu being prepared for. 550 * @param pszSlotName Brings the name of the SLOT in the @a pListener above, this menu will be handled with. 551 * @param machine Brings the #CMachine object, this @a menu being prepared for. 552 * @param strControllerName Brings the name of the #CStorageController in the @a machine above. 553 * @param storageSlot Brings the #StorageSlot of the storage controller with @a strControllerName above. */ 554 void prepareStorageMenu(QMenu &menu, 555 QObject *pListener, const char *pszSlotName, 556 const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot); 557 /** Updates @a comConstMachine storage with data described by @a target. */ 558 void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target); 559 560 /** Generates details for passed @a comMedium. 561 * @param fPredictDiff Brings whether medium will be marked differencing on attaching. 562 * @param fUseHtml Brings whether HTML subsets should be used in the generated output. */ 563 QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true); 564 /** @} */ 565 566 /** @name COM: USB stuff. 567 * @{ */ 412 568 #ifdef RT_OS_LINUX 413 static void checkForWrongUSBMounted(); 569 /** Verifies that USB drivers are properly configured on Linux. */ 570 static void checkForWrongUSBMounted(); 414 571 #endif /* RT_OS_LINUX */ 415 572 416 QString details (const CUSBDevice &aDevice) const; 417 QString toolTip (const CUSBDevice &aDevice) const; 418 QString toolTip (const CUSBDeviceFilter &aFilter) const; 419 QString toolTip(const CHostVideoInputDevice &webcam) const; 420 421 /** Initiates the extension pack installation process. 422 * @param strFilePath Brings the extension pack file path. 423 * @param strDigest Brings the extension pack file digest. 424 * @param pParent Brings the parent dialog reference. 425 * @param pstrExtPackName Brings the extension pack name. */ 426 static void doExtPackInstallation(QString const &strFilePath, 427 QString const &strDigest, 428 QWidget *pParent, 429 QString *pstrExtPackName); 430 431 /** Returns whether the Extension Pack installation was requested at startup. */ 432 bool isEPInstallationRequested() const { return m_fEPInstallationRequested; } 433 /** Defines whether the Extension Pack installation was @a fRequested at startup. */ 434 void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; } 435 436 bool is3DAvailableWorker() const; 437 bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; } 573 /** Generates details for passed USB @a comDevice. */ 574 QString details (const CUSBDevice &aDevice) const; 575 /** Generates tool-tip for passed USB @a comDevice. */ 576 QString toolTip (const CUSBDevice &aDevice) const; 577 /** Generates tool-tip for passed USB @a comFilter. */ 578 QString toolTip (const CUSBDeviceFilter &aFilter) const; 579 /** Generates tool-tip for passed USB @a comWebcam. */ 580 QString toolTip(const CHostVideoInputDevice &webcam) const; 581 /** @} */ 582 583 /** @name COM: Extension Pack stuff. 584 * @{ */ 585 /** Initiates the extension pack installation process. 586 * @param strFilePath Brings the extension pack file path. 587 * @param strDigest Brings the extension pack file digest. 588 * @param pParent Brings the parent dialog reference. 589 * @param pstrExtPackName Brings the extension pack name. */ 590 static void doExtPackInstallation(QString const &strFilePath, 591 QString const &strDigest, 592 QWidget *pParent, 593 QString *pstrExtPackName); 594 595 /** @todo remove */ 596 bool isEPInstallationRequested() const { return m_fEPInstallationRequested; } 597 /** @todo remove */ 598 void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; } 599 /** @} */ 600 601 /** @name Display stuff. 602 * @{ */ 603 /** Inner worker for lazily querying for 3D support. */ 604 bool is3DAvailableWorker() const; 605 /** Returns whether 3D is available, runs worker above if necessary. */ 606 bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; } 438 607 439 608 #ifdef VBOX_WITH_CRHGSMI 440 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId); 609 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */ 610 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId); 441 611 #endif /* VBOX_WITH_CRHGSMI */ 442 443 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1); 444 445 /** Returns the thread-pool instance. */ 446 UIThreadPool* threadPool() const { return m_pThreadPool; } 447 448 /** Returns icon defined for a passed @a comMachine. */ 449 QIcon vmUserIcon(const CMachine &comMachine) const; 450 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */ 451 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const; 452 /** Returns pixmap defined for a passed @a comMachine. 453 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 454 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const; 455 456 /** Returns pixmap corresponding to passed @a strOSTypeID. */ 457 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const; 458 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */ 459 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const; 460 /** Returns pixmap corresponding to passed @a strOSTypeID. 461 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 462 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 463 464 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); } 465 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); } 466 467 QPixmap warningIcon() const { return mWarningIcon; } 468 QPixmap errorIcon() const { return mErrorIcon; } 469 470 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2); 471 472 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel); 473 474 static QString locationForHTML (const QString &aFileName); 475 476 static QWidget *findWidget (QWidget *aParent, const char *aName, 477 const char *aClassName = NULL, 478 bool aRecursive = false); 612 /** Returns the required video memory in bytes for the current desktop 613 * resolution at maximum possible screen depth in bpp. */ 614 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1); 615 /** @} */ 616 617 /** @name Thread stuff. 618 * @{ */ 619 /** Returns the thread-pool instance. */ 620 UIThreadPool* threadPool() const { return m_pThreadPool; } 621 /** @} */ 622 623 /** @name Icon/Pixmap stuff. 624 * @{ */ 625 /** Returns icon defined for a passed @a comMachine. */ 626 QIcon vmUserIcon(const CMachine &comMachine) const; 627 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */ 628 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const; 629 /** Returns pixmap defined for a passed @a comMachine. 630 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 631 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const; 632 633 /** Returns pixmap corresponding to passed @a strOSTypeID. */ 634 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const; 635 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */ 636 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const; 637 /** Returns pixmap corresponding to passed @a strOSTypeID. 638 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 639 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 640 641 /** Returns default icon of certain @a enmType. */ 642 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); } 643 /** Returns file icon fetched from passed file @a info. */ 644 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); } 645 646 /** Returns cached default warning pixmap. */ 647 QPixmap warningIcon() const { return mWarningIcon; } 648 /** Returns cached default error pixmap. */ 649 QPixmap errorIcon() const { return mErrorIcon; } 650 651 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */ 652 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2); 653 654 /** @todo remove */ 655 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel); 656 657 /** @todo remove */ 658 static QString locationForHTML (const QString &aFileName); 659 660 /** @todo remove */ 661 static QWidget *findWidget (QWidget *aParent, const char *aName, 662 const char *aClassName = NULL, 663 bool aRecursive = false); 664 /** @} */ 479 665 480 666 public slots: 481 667 482 bool openURL (const QString &aURL); 483 484 void sltGUILanguageChange(QString strLang); 668 /** @name Process arguments stuff. 669 * @{ */ 670 /** Opens the specified URL using OS/Desktop capabilities. */ 671 bool openURL (const QString &aURL); 672 /** @} */ 673 674 /** @name Localization stuff. 675 * @{ */ 676 /** Handles language change to new @a strLanguage. */ 677 void sltGUILanguageChange(QString strLang); 678 /** @} */ 485 679 486 680 protected: 487 681 682 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 488 683 bool eventFilter (QObject *, QEvent *); 489 684 685 /** Handles translation event. */ 490 686 void retranslateUi(); 491 687 492 688 protected slots: 493 689 494 /* Handlers: Prepare/cleanup stuff:*/690 /** Prepares all. */ 495 691 void prepare(); 692 /** Cleanups all. */ 496 693 void cleanup(); 497 694 498 /** Handles @a manager request for emergency session shutdown. */ 499 void sltHandleCommitDataRequest(QSessionManager &manager); 500 501 /** Handles the VBoxSVC availability change. */ 502 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable); 695 /** @name Common stuff. 696 * @{ */ 697 /** Handles @a manager request for emergency session shutdown. */ 698 void sltHandleCommitDataRequest(QSessionManager &manager); 699 /** @} */ 700 701 /** @name COM stuff. 702 * @{ */ 703 /** Handles the VBoxSVC availability change. */ 704 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable); 705 /** @} */ 503 706 504 707 private: … … 515 718 virtual ~VBoxGlobal() /* override */; 516 719 720 /** @name Common stuff. 721 * @{ */ 517 722 #ifdef VBOX_WS_WIN 518 /** Wraps WinAPI ShutdownBlockReasonCreate function. */ 519 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason); 520 #endif 521 723 /** Wraps WinAPI ShutdownBlockReasonCreate function. */ 724 static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason); 725 #endif 726 /** @} */ 727 728 /** @name Process arguments stuff. 729 * @{ */ 522 730 #ifdef VBOX_WITH_DEBUGGER_GUI 523 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false); 524 void setDebuggerVar(int *piDbgCfgVar, bool fState); 525 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const; 526 #endif 527 528 /** Re-initializes COM wrappers and containers. */ 529 void comWrappersReinit(); 731 /** Initializes a debugger config variable. 732 * @param piDbgCfgVar Brings the debugger config variable to init. 733 * @param pszEnvVar Brings the environment variable name relating to this variable. 734 * @param pszExtraDataName Brings the extra data name relating to this variable. 735 * @param fDefault Brings the default value. */ 736 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false); 737 /** Set a debugger config variable according according to start up argument. 738 * @param piDbgCfgVar Brings the debugger config variable to set. 739 * @param fState Brings the value from the command line. */ 740 void setDebuggerVar(int *piDbgCfgVar, bool fState); 741 /** Checks the state of a debugger config variable, updating it with the machine settings on the first invocation. 742 * @param piDbgCfgVar Brings the debugger config variable to consult. 743 * @param pszExtraDataName Brings the extra data name relating to this variable. */ 744 bool isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const; 745 #endif 746 /** @} */ 747 748 /** @name COM stuff. 749 * @{ */ 750 /** Re-initializes COM wrappers and containers. */ 751 void comWrappersReinit(); 752 /** @} */ 530 753 531 754 /** Holds the singleton VBoxGlobal instance. */ 532 755 static VBoxGlobal *s_pInstance; 533 756 534 /** Holds the currently loaded language ID. */ 535 static QString s_strLoadedLanguageId; 536 537 /** Holds whether VBoxGlobal cleanup is in progress. */ 538 static bool s_fCleanupInProgress; 757 /** @name Common stuff. 758 * @{ */ 759 /** Holds the currently loaded language ID. */ 760 static QString s_strLoadedLanguageId; 761 762 /** Holds whether VBoxGlobal cleanup is in progress. */ 763 static bool s_fCleanupInProgress; 539 764 540 765 #ifdef VBOX_GUI_WITH_SHARED_LIBRARY 541 /** Holds the UI type. */ 542 UIType m_enmType; 543 #endif 544 545 bool mValid; 766 /** Holds the UI type. */ 767 UIType m_enmType; 768 #endif 769 770 /** Holds whether VBoxGlobal instance is properly initialized. */ 771 bool mValid; 546 772 547 773 #ifdef VBOX_WS_MAC 548 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */549 MacOSXRelease m_osRelease;774 /** Mac OS X: Holds the #MacOSXRelease determined using <i>uname</i> call. */ 775 MacOSXRelease m_osRelease; 550 776 #endif /* VBOX_WS_MAC */ 551 777 552 778 #ifdef VBOX_WS_X11 553 /** X11: Holds whether the Window Manager we are running at is composition one. */554 bool m_fCompositingManagerRunning;555 /** X11: Holds the type of the Window Manager we are running under. */556 X11WMType m_enmWindowManagerType;779 /** X11: Holds whether the Window Manager we are running at is composition one. */ 780 bool m_fCompositingManagerRunning; 781 /** X11: Holds the #X11WMType of the Window Manager we are running under. */ 782 X11WMType m_enmWindowManagerType; 557 783 #endif /* VBOX_WS_X11 */ 558 784 559 QString mVerString; 560 QString mBrandingConfig; 561 562 QList<QUrl> m_ArgUrlList; 563 564 QString vmUuid; 565 /** Holds whether GUI is separate (from VM) process. */ 566 bool m_fSeparateProcess; 567 /** Whether to show error message boxes for VM start errors. */ 568 bool mShowStartVMErrors; 569 570 /** The --aggressive-caching / --no-aggressive-caching option. */ 571 bool mAgressiveCaching; 572 573 /** The --restore-current option. */ 574 bool mRestoreCurrentSnapshot; 575 576 /** @name Ad-hoc VM reconfiguration. 577 * @{ */ 578 /** Floppy image. */ 785 /** @todo remove */ 786 QString mVerString; 787 /** Holds the VBox branding config file path. */ 788 QString mBrandingConfig; 789 /** @} */ 790 791 /** @name Process arguments stuff. 792 * @{ */ 793 /** Holds the URL arguments list. */ 794 QList<QUrl> m_ArgUrlList; 795 796 /** Holds the --startvm option value (managed VM id). */ 797 QString vmUuid; 798 /** Holds the --separate option value (whether GUI process is separate from VM process). */ 799 bool m_fSeparateProcess; 800 /** Holds the --no-startvm-errormsgbox option value (whether startup VM errors are disabled). */ 801 bool mShowStartVMErrors; 802 803 /** Holds the --aggressive-caching / --no-aggressive-caching option value (whether medium-enumeration is required). */ 804 bool mAgressiveCaching; 805 806 /** Holds the --restore-current option value. */ 807 bool mRestoreCurrentSnapshot; 808 809 /** Holds the --fda option value (floppy image). */ 579 810 QString m_strFloppyImage; 580 /** DVD image. */811 /** Holds the --dvd | --cdrom option value (DVD image). */ 581 812 QString m_strDvdImage; 582 /** @} */ 583 584 /** @name VMM options 585 * @{ */ 586 /** The --disable-patm option. */ 813 814 /** Holds the --disable-patm option value. */ 587 815 bool mDisablePatm; 588 /** The --disable-csam option. */816 /** Holds the --disable-csam option value. */ 589 817 bool mDisableCsam; 590 /** The --recompile-supervisor option. */818 /** Holds the --recompile-supervisor option value. */ 591 819 bool mRecompileSupervisor; 592 /** The --recompile-user option. */820 /** Holds the --recompile-user option value. */ 593 821 bool mRecompileUser; 594 /** The --execute-all-in-iem option. */822 /** Holds the --execute-all-in-iem option value. */ 595 823 bool mExecuteAllInIem; 596 /** The --warp-factor option value. */824 /** Holds the --warp-factor option value. */ 597 825 uint32_t mWarpPct; 598 /** @} */599 826 600 827 #ifdef VBOX_WITH_DEBUGGER_GUI 601 /** Whether the debugger should be accessible or not. */ 602 mutable int m_fDbgEnabled; 603 /** Whether to show the debugger automatically with the console. */ 604 mutable int m_fDbgAutoShow; 605 /** Whether to show the command line window when m_fDbgAutoShow is set. */ 606 mutable int m_fDbgAutoShowCommandLine; 607 /** Whether to show the statistics window when m_fDbgAutoShow is set. */ 608 mutable int m_fDbgAutoShowStatistics; 609 /** VBoxDbg module handle. */ 610 RTLDRMOD m_hVBoxDbg; 611 612 /** Whether --start-running, --start-paused or nothing was given. */ 613 enum StartRunning m_enmStartRunning; 614 #endif 615 616 char mSettingsPw[256]; 617 bool mSettingsPwSet; 828 /** Holds whether the debugger should be accessible. */ 829 mutable int m_fDbgEnabled; 830 /** Holds whether to show the debugger automatically with the console. */ 831 mutable int m_fDbgAutoShow; 832 /** Holds whether to show the command line window when m_fDbgAutoShow is set. */ 833 mutable int m_fDbgAutoShowCommandLine; 834 /** Holds whether to show the statistics window when m_fDbgAutoShow is set. */ 835 mutable int m_fDbgAutoShowStatistics; 836 /** VBoxDbg module handle. */ 837 RTLDRMOD m_hVBoxDbg; 838 839 /** Holds whether --start-running, --start-paused or nothing was given. */ 840 enum StartRunning m_enmStartRunning; 841 #endif 842 843 /** Holds the --settingspw option value. */ 844 char mSettingsPw[256]; 845 /** Holds the --settingspwfile option value. */ 846 bool mSettingsPwSet; 618 847 619 848 #ifdef VBOX_GUI_WITH_PIDFILE 620 QString m_strPidfile; 621 #endif 622 623 QString mUserDefinedPortName; 624 625 /** COM cleanup protection token. */ 626 QReadWriteLock m_comCleanupProtectionToken; 627 628 /** Holds the instance of VirtualBox client wrapper. */ 629 CVirtualBoxClient m_client; 630 /** Holds the copy of VirtualBox object wrapper. */ 631 CVirtualBox m_vbox; 632 /** Holds the copy of VirtualBox host-object wrapper. */ 633 CHost m_host; 634 /** Holds the symbolic VirtualBox home-folder representation. */ 635 QString m_strHomeFolder; 636 637 /** Holds whether acquired COM wrappers are currently valid. */ 638 bool m_fWrappersValid; 639 /** Holds whether VBoxSVC is currently available. */ 640 bool m_fVBoxSVCAvailable; 641 642 /** Holds the guest OS family IDs. */ 643 QList<QString> m_guestOSFamilyIDs; 644 /** Holds the guest OS types for each family ID. */ 645 QList<QList<CGuestOSType> > m_guestOSTypes; 646 647 int m3DAvailable; 648 649 /** Holds the thread-pool instance. */ 650 UIThreadPool *m_pThreadPool; 651 652 /** General icon-pool. */ 653 UIIconPoolGeneral *m_pIconPool; 654 655 QFileIconProvider m_globalIconProvider; 656 657 QPixmap mWarningIcon, mErrorIcon; 658 659 /* Variable: Medium-enumeration stuff: */ 660 mutable QReadWriteLock m_mediumEnumeratorDtorRwLock; 661 UIMediumEnumerator *m_pMediumEnumerator; 662 663 /** Holds whether the Extension Pack installation was requested at startup. */ 849 /** Holds the --pidfile option value (application PID file path). */ 850 QString m_strPidfile; 851 #endif 852 853 /** @todo remove */ 854 QString mUserDefinedPortName; 855 /** @} */ 856 857 /** @name COM stuff. 858 * @{ */ 859 /** Holds the COM cleanup protection token. */ 860 QReadWriteLock m_comCleanupProtectionToken; 861 862 /** Holds the instance of VirtualBox client wrapper. */ 863 CVirtualBoxClient m_client; 864 /** Holds the copy of VirtualBox object wrapper. */ 865 CVirtualBox m_vbox; 866 /** Holds the copy of VirtualBox host-object wrapper. */ 867 CHost m_host; 868 /** Holds the symbolic VirtualBox home-folder representation. */ 869 QString m_strHomeFolder; 870 871 /** Holds whether acquired COM wrappers are currently valid. */ 872 bool m_fWrappersValid; 873 /** Holds whether VBoxSVC is currently available. */ 874 bool m_fVBoxSVCAvailable; 875 876 /** Holds the guest OS family IDs. */ 877 QList<QString> m_guestOSFamilyIDs; 878 /** Holds the guest OS types for each family ID. */ 879 QList<QList<CGuestOSType> > m_guestOSTypes; 880 /** @} */ 881 882 /** @name Display stuff. 883 * @{ */ 884 /** Holds whether 3D is available. */ 885 int m3DAvailable; 886 /** @} */ 887 888 /** @name Thread stuff. 889 * @{ */ 890 /** Holds the thread-pool instance. */ 891 UIThreadPool *m_pThreadPool; 892 /** @} */ 893 894 /** @name Icon/Pixmap stuff. 895 * @{ */ 896 /** Holds the general icon-pool instance. */ 897 UIIconPoolGeneral *m_pIconPool; 898 899 /** Holds the global file icon provider instance. */ 900 QFileIconProvider m_globalIconProvider; 901 902 /** Holds the warning pixmap. */ 903 QPixmap mWarningIcon; 904 /** Holds the error pixmap. */ 905 QPixmap mErrorIcon; 906 /** @} */ 907 908 /** @name Media related stuff. 909 * @{ */ 910 /** Holds the medium enumerator cleanup protection token. */ 911 mutable QReadWriteLock m_mediumEnumeratorDtorRwLock; 912 913 /** Holds the medium enumerator. */ 914 UIMediumEnumerator *m_pMediumEnumerator; 915 /** @} */ 916 917 /** @todo remove */ 664 918 bool m_fEPInstallationRequested; 665 919 666 920 #if defined(VBOX_WS_WIN) && defined(VBOX_GUI_WITH_SHARED_LIBRARY) 667 /** Holds the ATL module instance (for use with VBoxGlobal shared library only). 668 * @note Required internally by ATL (constructor records instance in global variable). */ 669 ATL::CComModule _Module; 921 /** @name ATL stuff. 922 * @{ */ 923 /** Holds the ATL module instance (for use with VBoxGlobal shared library only). 924 * @note Required internally by ATL (constructor records instance in global variable). */ 925 ATL::CComModule _Module; 926 /** @} */ 670 927 #endif 671 928 672 929 #if defined (VBOX_WS_WIN) 930 /** @todo remove */ 673 931 DWORD dwHTMLHelpCookie; 674 932 #endif
Note:
See TracChangeset
for help on using the changeset viewer.