VirtualBox

Changeset 72414 in vbox


Ignore:
Timestamp:
Jun 1, 2018 6:41:33 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Huge overhaul for VBoxGlobal class: Doxygen/comments.

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  
    159159#endif /* VBOX_WS_MAC */
    160160#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
    164166# include <X11/X.h>
    165167# include <X11/Xmd.h>
     
    177179
    178180
     181/** QTranslator subclass for VBox needs. */
    179182class VBoxTranslator : public QTranslator
    180183{
    181184public:
    182185
     186    /** Constructs translator passing @a pParent to the base-class. */
    183187    VBoxTranslator (QObject *aParent = 0)
    184188        : QTranslator (aParent) {}
    185189
     190    /** Loads language file with gained @a strFileName. */
    186191    bool loadFile (const QString &aFileName)
    187192    {
     
    195200private:
    196201
     202    /** Holds the loaded data. */
    197203    QByteArray mData;
    198204};
    199205
     206/** Holds the static #VBoxTranslator instance. */
    200207static VBoxTranslator *sTranslator = 0;
    201208
    202209
     210/** Port config cache. */
    203211struct PortConfig
    204212{
     
    208216};
    209217
     218/** Known port config COM ports. */
    210219static const PortConfig kComKnownPorts[] =
    211220{
     
    214223    { "COM3", 4, 0x3E8 },
    215224    { "COM4", 3, 0x2E8 },
    216     /* must not contain an element with IRQ=0 and IOBase=0 used to cause
     225    /* Must not contain an element with IRQ=0 and IOBase=0 used to cause
    217226     * toCOMPortName() to return the "User-defined" string for these values. */
    218227};
    219228
     229/** Known port config LPT ports. */
    220230static const PortConfig kLptKnownPorts[] =
    221231{
     
    223233    { "LPT2", 5, 0x278 },
    224234    { "LPT1", 2, 0x3BC },
    225     /* must not contain an element with IRQ=0 and IOBase=0 used to cause
     235    /* Must not contain an element with IRQ=0 and IOBase=0 used to cause
    226236     * toLPTPortName() to return the "User-defined" string for these values. */
    227237};
     
    400410#endif /* VBOX_WS_MAC */
    401411
    402 bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
     412bool VBoxGlobal::brandingIsActive (bool aForce /* = false */)
    403413{
    404414    if (aForce)
     
    413423}
    414424
    415 /**
    416   * Gets a value from the custom .ini file
    417   */
    418425QString VBoxGlobal::brandingGetKey (QString aKey)
    419426{
     
    424431bool VBoxGlobal::processArgs()
    425432{
     433    /* Among those arguments: */
    426434    bool fResult = false;
    427435    QStringList args = qApp->arguments();
     436    /* We are looking for a list of file URLs passed to the executable: */
    428437    QList<QUrl> list;
    429438    for (int i = 1; i < args.size(); ++i)
    430439    {
    431         /* We break out after the first parameter, cause there could be
    432            parameters with arguments (e.g. --comment comment). */
     440        /* But we break out after the first parameter, cause there
     441         * could be parameters with arguments (e.g. --comment comment). */
    433442        if (args.at(i).startsWith("-"))
    434443            break;
     
    438447        QString strArg = args.at(i);
    439448#endif /* !VBOX_WS_MAC */
     449        /* So if the argument file exists, we add it to URL list: */
    440450        if (   !strArg.isEmpty()
    441451            && QFile::exists(strArg))
    442452            list << QUrl::fromLocalFile(strArg);
    443453    }
     454    /* If there are file URLs: */
    444455    if (!list.isEmpty())
    445456    {
     457        /* We enumerate them and: */
    446458        for (int i = 0; i < list.size(); ++i)
    447459        {
     460            /* Check which of them has allowed VM extensions: */
    448461            const QString& strFile = list.at(i).toLocalFile();
    449462            if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts))
    450463            {
     464                /* So that we could run existing VMs: */
    451465                CVirtualBox vbox = virtualBox();
    452466                CMachine machine = vbox.FindMachine(strFile);
     
    455469                    fResult = true;
    456470                    launchMachine(machine);
    457                     /* Remove from the arg list. */
     471                    /* And remove their URLs from the ULR list: */
    458472                    list.removeAll(strFile);
    459473                }
     
    461475        }
    462476    }
     477    /* And if there are *still* URLs: */
    463478    if (!list.isEmpty())
    464479    {
    465         /* Store the URLs: */
     480        /* We store them: */
    466481        m_ArgUrlList = list;
    467         /* Ask UIStarter to open them: */
     482        /* And ask UIStarter to open them: */
    468483        emit sigAskToOpenURLs();
    469484    }
     
    522537#endif /* VBOX_GUI_WITH_PIDFILE */
    523538
    524 /**
    525  *  Native language name of the currently installed translation.
    526  *  Returns "English" if no translation is installed
    527  *  or if the translation file is invalid.
    528  */
    529539QString VBoxGlobal::languageName() const
    530540{
    531 
     541    /* Returns "English" if no translation is installed
     542     * or if the translation file is invalid. */
    532543    return qApp->translate ("@@@", "English",
    533544                            "Native language name");
    534545}
    535546
    536 /**
    537  *  Native language country name of the currently installed translation.
    538  *  Returns "--" if no translation is installed or if the translation file is
    539  *  invalid, or if the language is independent on the country.
    540  */
    541547QString VBoxGlobal::languageCountry() const
    542548{
     549    /* Returns "--" if no translation is installed or if the translation file
     550     * is invalid, or if the language is independent on the country. */
    543551    return qApp->translate ("@@@", "--",
    544552                            "Native language country name "
     
    546554}
    547555
    548 /**
    549  *  Language name of the currently installed translation, in English.
    550  *  Returns "English" if no translation is installed
    551  *  or if the translation file is invalid.
    552  */
    553556QString VBoxGlobal::languageNameEnglish() const
    554557{
    555 
     558    /* Returns "English" if no translation is installed
     559     * or if the translation file is invalid. */
    556560    return qApp->translate ("@@@", "English",
    557561                            "Language name, in English");
    558562}
    559563
    560 /**
    561  *  Language country name of the currently installed translation, in English.
    562  *  Returns "--" if no translation is installed or if the translation file is
    563  *  invalid, or if the language is independent on the country.
    564  */
    565564QString VBoxGlobal::languageCountryEnglish() const
    566565{
     566    /* Returns "--" if no translation is installed or if the translation file
     567     * is invalid, or if the language is independent on the country. */
    567568    return qApp->translate ("@@@", "--",
    568569                            "Language country name, in English "
     
    570571}
    571572
    572 /**
    573  *  Comma-separated list of authors of the currently installed translation.
    574  *  Returns "Oracle Corporation" if no translation is installed or if the
    575  *  translation file is invalid, or if the translation is supplied by Oracle
    576  *  Corporation
    577  */
    578573QString VBoxGlobal::languageTranslators() const
    579574{
     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. */
    580577    return qApp->translate ("@@@", "Oracle Corporation",
    581578                            "Comma-separated list of translators");
     
    612609}
    613610
    614 /**
    615  *  Returns the loaded (active) language ID.
    616  *  Note that it may not match with UIExtraDataManager::languageId() if the
    617  *  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 C
    621  *  locale is used in unix environments as a fallback when the requested
    622  *  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  */
    626611/* static */
    627612QString VBoxGlobal::languageId()
    628613{
     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
    629621    return s_strLoadedLanguageId;
    630622}
    631623
    632 /**
    633  *  This does exactly the same as QLocale::system().name() but corrects its
    634  *  wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes
    635  *  precedence over any other locale setting in the QLocale::system()
    636  *  implementation). This implementation first looks at LC_ALL (as defined by
    637  *  SUS), then looks at LC_MESSAGES which is designed to define a language for
    638  *  program messages in case if it differs from the language for other locale
    639  *  categories. Then it looks for LANG and finally falls back to
    640  *  QLocale::system().name().
    641  *
    642  *  The order of precedence is well defined here:
    643  *  http://opengroup.org/onlinepubs/007908799/xbd/envvar.html
    644  *
    645  *  @note This method will return "C" when the requested locale is invalid or
    646  *  when the "C" locale is set explicitly.
    647  */
    648624/* static */
    649625QString VBoxGlobal::systemLanguageId()
    650626{
     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
    651638#if defined (VBOX_WS_MAC)
    652     /* QLocale return the right id only if the user select the format of the
    653      * 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 */
    654641    return ::darwinSystemLanguage();
    655642#elif defined (Q_OS_UNIX)
     
    665652}
    666653
    667 /**
    668  *  Loads the language by language ID.
    669  *
    670  *  @param aLangId Language ID in in form of xx_YY. QString::null means the
    671  *                 system default language.
    672  */
    673654/* static */
    674655void VBoxGlobal::loadLanguage (const QString &aLangId)
     
    732713    }
    733714
    734     /* delete the old translator if there is one */
     715    /* Delete the old translator if there is one: */
    735716    if (sTranslator)
    736717    {
     
    741722    }
    742723
    743     /* load new language files */
     724    /* Load new language files: */
    744725    sTranslator = new VBoxTranslator (qApp);
    745726    Assert (sTranslator);
     
    752733            loadOk = sTranslator->loadFile (languageFileName);
    753734        }
    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): */
    757737        qApp->installTranslator (sTranslator);
    758738    }
     
    768748    }
    769749
    770     /* Try to load the corresponding Qt translation */
     750    /* Try to load the corresponding Qt translation: */
    771751    if (languageId() != vboxBuiltInLanguageName() && languageId() != "en")
    772752    {
     
    812792}
    813793
    814 /**
    815  *  Returns the decimal separator for the current locale.
    816  */
    817794/* static */
    818795QChar VBoxGlobal::decimalSep()
     
    821798}
    822799
    823 /**
    824  *  Returns the regexp string that defines the format of the human-readable
    825  *  size representation: @verbatim ####[.##] B|KB|MB|GB|TB|PB @endverbatim
    826  *
    827  *  This regexp will capture 5 groups of text:
    828  *  - cap(1): integer number in case when no decimal point is present
    829  *            (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 present
    833  *  - cap(5): size suffix in case when decimal point is present (note that
    834  *            B cannot appear there)
    835  */
    836800/* static */
    837801QString VBoxGlobal::sizeRegexp()
    838802{
     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
    839812    QString regexp =
    840813        QString ("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$")
     
    849822}
    850823
    851 /**
    852  *  Parses the given size string that should be in form of
    853  *  @verbatim ####[.##] B|KB|MB|GB|TB|PB @endverbatim and returns
    854  *  the size value in bytes. Zero is returned on error.
    855  */
    856824/* static */
    857825quint64 VBoxGlobal::parseSize (const QString &aText)
    858826{
     827    /* Text should be in form of B|KB|MB|GB|TB|PB. */
    859828    QRegExp regexp (sizeRegexp());
    860829    int pos = regexp.indexIn (aText);
     
    898867}
    899868
    900 /**
    901  * Formats the given @a aSize value in bytes to a human readable string
    902  * 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 resulting
    905  * 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 the
    908  *     closest number containing \a aDecimal decimal digits.
    909  * </li>
    910  * <li>When \a aMode is FormatSize_RoundDown, the result is rounded to the
    911  *     largest number with \a aDecimal decimal digits that is not greater than
    912  *     the result. This guarantees that converting the resulting string back to
    913  *     the integer value in bytes will not produce a value greater that the
    914  *     initial size parameter.
    915  * </li>
    916  * <li>When \a aMode is FormatSize_RoundUp, the result is rounded to the
    917  *     smallest number with \a aDecimal decimal digits that is not less than the
    918  *     result. This guarantees that converting the resulting string back to the
    919  *     integer value in bytes will not produce a value less that the initial
    920  *     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  */
    929869/* static */
    930870QString VBoxGlobal::formatSize (quint64 aSize, uint aDecimal /* = 2 */,
    931871                                FormatSize aMode /* = FormatSize_Round */)
    932872{
     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
    933888    quint64 denom = 0;
    934889    int suffix = 0;
     
    985940            else decm = (decm + denom / 2) / denom;
    986941        }
    987         /* check for the fractional part overflow due to rounding */
     942        /* Check for the fractional part overflow due to rounding: */
    988943        if (decm == mult)
    989944        {
    990945            decm = 0;
    991946            ++ 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: */
    993948            if (intg == 1024 && suffix + 1 < (int)SizeSuffix_Max)
    994949            {
     
    1027982}
    1028983
    1029 /**
    1030  *  Returns the list of the standard COM port names (i.e. "COMx").
    1031  */
    1032984QStringList VBoxGlobal::COMPortNames() const
    1033985{
     
    1039991}
    1040992
    1041 /**
    1042  *  Returns the name of the standard COM port corresponding to the given
    1043  *  parameters, or "User-defined" (which is also returned when both
    1044  *  @a aIRQ and @a aIOBase are 0).
    1045  */
    1046993QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const
    1047994{
     
    10541001}
    10551002
    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 one
    1059  *  of the standard names (i.e. "COMx").
    1060  */
    10611003bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ,
    10621004                                   ulong &aIOBase) const
     
    10731015}
    10741016
    1075 /**
    1076  *  Returns the list of the standard LPT port names (i.e. "LPTx").
    1077  */
    10781017QStringList VBoxGlobal::LPTPortNames() const
    10791018{
     
    10851024}
    10861025
    1087 /**
    1088  *  Returns the name of the standard LPT port corresponding to the given
    1089  *  parameters, or "User-defined" (which is also returned when both
    1090  *  @a aIRQ and @a aIOBase are 0).
    1091  */
    10921026QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const
    10931027{
     
    11001034}
    11011035
    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 one
    1105  *  of the standard names (i.e. "LPTx").
    1106  */
    11071036bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ,
    11081037                                   ulong &aIOBase) const
     
    11191048}
    11201049
    1121 /**
    1122  *  Reformats the input string @a aStr so that:
    1123  *  - strings in single quotes will be put inside \<nobr\> and marked
    1124  *    with blue color;
    1125  *  - UUIDs be put inside \<nobr\> and marked
    1126  *    with green color;
    1127  *  - replaces new line chars with \</p\>\<p\> constructs to form paragraphs
    1128  *    (note that \<p\> and \</p\> are not appended to the beginning and to the
    1129  *     end of the string respectively, to allow the result be appended
    1130  *     or prepended to the existing paragraph).
    1131  *
    1132  *  If @a aToolTip is true, colouring is not applied, only the \<nobr\> tag
    1133  *  is added. Also, new line chars are replaced with \<br\> instead of \<p\>.
    1134  */
    11351050/* static */
    11361051QString VBoxGlobal::highlight (const QString &aStr, bool aToolTip /* = false */)
    11371052{
     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
    11381066    QString strFont;
    11391067    QString uuidFont;
     
    11481076    QString text = aStr;
    11491077
    1150     /* replace special entities, '&' -- first! */
     1078    /* Replace special entities, '&' -- first! */
    11511079    text.replace ('&', "&amp;");
    11521080    text.replace ('<', "&lt;");
     
    11541082    text.replace ('\"', "&quot;");
    11551083
    1156     /* mark strings in single quotes with color */
     1084    /* Mark strings in single quotes with color: */
    11571085    QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");
    11581086    rx.setMinimal (true);
     
    11601088        QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strFont).arg (endFont));
    11611089
    1162     /* mark UUIDs with color */
     1090    /* Mark UUIDs with color: */
    11631091    text.replace (QRegExp (
    11641092        "((?:^|\\s)[(]?)"
     
    11671095        QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidFont).arg (endFont));
    11681096
    1169     /* split to paragraphs at \n chars */
     1097    /* Split to paragraphs at \n chars: */
    11701098    if (!aToolTip)
    11711099        text.replace ('\n', "</p><p>");
     
    11761104}
    11771105
    1178 /**
    1179  *  Reformats the input string @a aStr so that:
    1180  *  - strings in single quotes will be put inside \<nobr\> and marked
    1181  *    with bold style;
    1182  *  - UUIDs be put inside \<nobr\> and marked
    1183  *    with italic style;
    1184  *  - replaces new line chars with \</p\>\<p\> constructs to form paragraphs
    1185  *    (note that \<p\> and \</p\> are not appended to the beginning and to the
    1186  *     end of the string respectively, to allow the result be appended
    1187  *     or prepended to the existing paragraph).
    1188  */
    11891106/* static */
    11901107QString VBoxGlobal::emphasize (const QString &aStr)
    11911108{
     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
    11921119    QString strEmphStart ("<b>");
    11931120    QString strEmphEnd ("</b>");
     
    11971124    QString text = aStr;
    11981125
    1199     /* replace special entities, '&' -- first! */
     1126    /* Replace special entities, '&' -- first! */
    12001127    text.replace ('&', "&amp;");
    12011128    text.replace ('<', "&lt;");
     
    12031130    text.replace ('\"', "&quot;");
    12041131
    1205     /* mark strings in single quotes with bold style */
     1132    /* Mark strings in single quotes with bold style: */
    12061133    QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");
    12071134    rx.setMinimal (true);
     
    12091136        QString ("\\1%1<nobr>'\\2'</nobr>%2").arg (strEmphStart).arg (strEmphEnd));
    12101137
    1211     /* mark UUIDs with italic style */
     1138    /* Mark UUIDs with italic style: */
    12121139    text.replace (QRegExp (
    12131140        "((?:^|\\s)[(]?)"
     
    12161143        QString ("\\1%1<nobr>\\2</nobr>%2").arg (uuidEmphStart).arg (uuidEmphEnd));
    12171144
    1218     /* split to paragraphs at \n chars */
     1145    /* Split to paragraphs at \n chars: */
    12191146    text.replace ('\n', "</p><p>");
    12201147
     
    12221149}
    12231150
    1224 /**
    1225  *  Removes the accelerator mark (the ampersand symbol) from the given string
    1226  *  and returns the result. The string is supposed to be a menu item's text
    1227  *  that may (or may not) contain the accelerator mark.
    1228  *
    1229  *  In order to support accelerators used in non-alphabet languages
    1230  *  (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 a
    1232  *  whole. If such a pattern is not found, then the '&' character is simply
    1233  *  removed from the string.
    1234  *
    1235  *  @note This function removes only the first occurrence of the accelerator
    1236  *  mark.
    1237  *
    1238  *  @param aText Menu item's text to remove the accelerator mark from.
    1239  *
    1240  *  @return The resulting string.
    1241  */
    12421151/* static */
    12431152QString VBoxGlobal::removeAccelMark (const QString &aText)
    12441153{
     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
    12451160    QString result = aText;
    12461161
     
    13101225    QLocale lang (VBoxGlobal::languageId());
    13111226
    1312     /* Construct the path and the filename */
     1227    /* Construct the path and the filename: */
    13131228    QString manual = QString ("%1/%2_%3.%4").arg (szDocsPath)
    13141229                                            .arg (name)
    13151230                                            .arg (lang.name())
    13161231                                            .arg (suffix);
    1317     /* Check if a help file with that name exists */
     1232    /* Check if a help file with that name exists: */
    13181233    QFileInfo fi (manual);
    13191234    if (fi.exists())
    13201235        return manual;
    13211236
    1322     /* Fall back to the standard */
     1237    /* Fall back to the standard: */
    13231238    manual = QString ("%1/%2.%4").arg (szDocsPath)
    13241239                                 .arg (name)
     
    13441259}
    13451260
    1346 /**
    1347  *  Performs direct and flipped search of position for \a aRectangle to make sure
    1348  *  it is fully contained inside \a aBoundRegion region by moving & resizing
    1349  *  \a aRectangle if necessary. Selects the minimum shifted result between direct
    1350  *  and flipped variants.
    1351  */
    13521261/* static */
    13531262QRect VBoxGlobal::normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
    13541263                                     bool aCanResize /* = true */)
    13551264{
     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
    13561269    /* Direct search for normalized rectangle */
    13571270    QRect var1 (getNormalized (aRectangle, aBoundRegion, aCanResize));
    13581271
    1359     /* Flipped search for normalized rectangle */
     1272    /* Flipped search for normalized rectangle: */
    13601273    QRect var2 (flip (getNormalized (flip (aRectangle).boundingRect(),
    13611274                                     flip (aBoundRegion), aCanResize)).boundingRect());
    13621275
    1363     /* Calculate shift from starting position for both variants */
     1276    /* Calculate shift from starting position for both variants: */
    13641277    double length1 = sqrt (pow ((double) (var1.x() - aRectangle.x()), (double) 2) +
    13651278                           pow ((double) (var1.y() - aRectangle.y()), (double) 2));
     
    13671280                           pow ((double) (var2.y() - aRectangle.y()), (double) 2));
    13681281
    1369     /* Return minimum shifted variant */
     1282    /* Return minimum shifted variant: */
    13701283    return length1 > length2 ? var2 : var1;
    13711284}
    13721285
    1373 /**
    1374  *  Ensures that the given rectangle \a aRectangle is fully contained within the
    1375  *  region \a aBoundRegion by moving \a aRectangle if necessary. If \a aRectangle is
    1376  *  larger than \a aBoundRegion, top left corner of \a aRectangle is aligned with the
    1377  *  top left corner of maximum available rectangle and, if \a aCanResize is true,
    1378  *  \a aRectangle is shrinked to become fully visible.
    1379  */
    13801286/* static */
    13811287QRect VBoxGlobal::getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
    13821288                                 bool /* aCanResize = true */)
    13831289{
    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: */
    13851296    int windowVertical = aRectangle.center().y();
    13861297    QVector <QRect> rectanglesVector (aBoundRegion.rects());
     
    14121323    }
    14131324
    1414     /* Trying to find the appropriate place for window */
     1325    /* Trying to find the appropriate place for window: */
    14151326    QRect result;
    14161327    for (int i = -1; i < shiftsList.size(); ++ i)
    14171328    {
    1418         /* Move to appropriate vertical */
     1329        /* Move to appropriate vertical: */
    14191330        QRect rectangle (aRectangle);
    14201331        if (i >= 0) rectangle.translate (0, shiftsList [i]);
    14211332
    1422         /* Search horizontal shift */
     1333        /* Search horizontal shift: */
    14231334        int maxShift = 0;
    14241335        foreach (QRect item, rectanglesList)
     
    14401351        }
    14411352
    1442         /* Shift across the horizontal direction */
     1353        /* Shift across the horizontal direction: */
    14431354        rectangle.translate (maxShift, 0);
    14441355
    1445         /* Check the translated rectangle to feat the rules */
     1356        /* Check the translated rectangle to feat the rules: */
    14461357        if (aBoundRegion.united (rectangle) == aBoundRegion)
    14471358            result = rectangle;
     
    14531364    {
    14541365        /* Resize window to feat desirable size
    1455          * using max of available rectangles */
     1366         * using max of available rectangles: */
    14561367        QRect maxRectangle;
    14571368        quint64 maxSquare = 0;
     
    14771388}
    14781389
    1479 /**
    1480  *  Returns the flipped (transposed) region.
    1481  */
    14821390/* static */
    14831391QRegion VBoxGlobal::flip (const QRegion &aRegion)
     
    14911399}
    14921400
    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 visible
    1497  *  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 an
    1499  *  inappropriate minimum size limit (in which case the top left corner will be
    1500  *  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, but
    1503  *  if it's not top-level itself, its top-level widget will be used for
    1504  *  calculations. \a aRelative can also be NULL, in which case \a aWidget will
    1505  *  be centered relative to the available desktop area.
    1506  */
    15071401/* static */
    15081402void VBoxGlobal::centerWidget (QWidget *aWidget, QWidget *aRelative,
    15091403                               bool aCanResize /* = true */)
    15101404{
     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
    15111414    AssertReturnVoid (aWidget);
    15121415    AssertReturnVoid (aWidget->isTopLevel());
     
    15191422        deskGeo = gpDesktop->availableGeometry (w);
    15201423        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.
    15231427        QPoint d = w->mapToGlobal (QPoint (0, 0));
    15241428        d.rx() -= w->geometry().x() - w->x();
     
    15321436    }
    15331437
    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().
    15381443
    15391444    int extraw = 0, extrah = 0;
     
    15751480                            parentGeo.y() + (parentGeo.height() - 1) / 2));
    15761481
    1577     /* ensure the widget is within the available desktop area */
     1482    /* Ensure the widget is within the available desktop area: */
    15781483    QRect newGeo = normalizeGeometry (geo, deskGeo, aCanResize);
    15791484#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.
    15831489    if (w)
    15841490        newGeo.translate (0, ::darwinWindowToolBarHeight (aWidget));
     
    16251531    if (pWidget->isWindow() && pWidget->isVisible())
    16261532    {
    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.
    16331540        const double dDPR = gpDesktop->devicePixelRatio(pWidget);
    16341541        uint16_t fMask =   XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
     
    16681575    }
    16691576    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.
    16721580        pWidget->setGeometry(x, y, w, h);
    16731581# else /* !VBOX_WS_X11 */
     
    16821590}
    16831591
    1684 /**
    1685  * Activates the specified window. If necessary, the window will be
    1686  * de-iconified activation.
    1687  *
    1688  * @note On X11, it is implied that @a aWid represents a window of the same
    1689  * 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 before
    1693  *                          activation.
    1694  *
    1695  * @return @c true on success and @c false otherwise.
    1696  */
    16971592/* static */
    16981593bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */)
     
    17221617                                                    "_NET_WM_DESKTOP");
    17231618        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.
    17261622            desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,
    17271623                                                "_WIN_WORKSPACE");
     
    18091705    ev.xclient.message_type = msgAtom;
    18101706
    1811     /* always send as 32 bit for now */
     1707    /* Always send as 32 bit for now: */
    18121708    ev.xclient.format = 32;
    18131709    ev.xclient.data.l [0] = aData0;
     
    18211717}
    18221718
    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 find
    1825  * all of these atoms on the _NET_SUPPORTED root window property, so we have to test with all
    1826  * interesting window managers. If this fails for a user when you think it should succeed
    1827  * 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)". */
    18311719/* static */
    18321720bool VBoxGlobal::supportsFullScreenMonitorsProtocolX11()
    18331721{
    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. */
    18361732    Display *pDisplay = QX11Info::display();
    18371733    Atom atomSupported            = XInternAtom(pDisplay, "_NET_SUPPORTED",
     
    20171913}
    20181914
     1915/* static */
    20191916void VBoxGlobal::setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString)
    20201917{
     
    21602057void VBoxGlobal::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount)
    21612058{
     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
    21622064    /* Load options: */
    21632065    QStyleOptionSpinBox option;
     
    21822084}
    21832085
    2184 /**
    2185  *  Returns the list of few guest OS types, queried from
    2186  *  IVirtualBox corresponding to every family id.
    2187  */
    21882086QList<CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const
    21892087{
     
    21942092}
    21952093
    2196 /**
    2197  *  Returns the list of all guest OS types, queried from
    2198  *  IVirtualBox corresponding to passed family id.
    2199  */
    22002094QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const
    22012095{
     
    22052099}
    22062100
    2207 /**
    2208  *  Returns the guest OS type object corresponding to the given type id of list
    2209  *  containing OS types related to OS family determined by family id attribute.
    2210  *  If the index is invalid a null object is returned.
    2211  */
    22122101CGuestOSType VBoxGlobal::vmGuestOSType(const QString &aTypeId,
    22132102             const QString &aFamilyId /* = QString::null */) const
     
    22302119}
    22312120
    2232 /**
    2233  *  Returns the description corresponding to the given guest OS type id.
    2234  */
    22352121QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const
    22362122{
     
    22672153        return false;
    22682154
    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.
    22712158    if (id == 0)
    22722159        return true;
     
    22772164
    22782165#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.
    22832169    ProcessSerialNumber psn;
    22842170    psn.highLongOfPSN = id >> 32;
     
    25402426}
    25412427
    2542 /**
    2543  * Figures out which medium formats are currently supported by VirtualBox for
    2544  * the given device type.
    2545  * Returned is a list of pairs with the form
    2546  *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
    2547  */
    25482428/* static */
    25492429QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType)
    25502430{
     2431    /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */
    25512432    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
    25522433    QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats();
     
    25712452}
    25722453
    2573 /**
    2574  * Figures out which hard disk formats are currently supported by VirtualBox.
    2575  * Returned is a list of pairs with the form
    2576  *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
    2577  */
    25782454/* static */
    25792455QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()
     
    25822458}
    25832459
    2584 /**
    2585  * Figures out which optical disk formats are currently supported by VirtualBox.
    2586  * Returned is a list of pairs with the form
    2587  *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
    2588  */
    25892460/* static */
    25902461QList <QPair <QString, QString> > VBoxGlobal::DVDBackends()
     
    25932464}
    25942465
    2595 /**
    2596  * Figures out which floppy disk formats are currently supported by VirtualBox.
    2597  * Returned is a list of pairs with the form
    2598  *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
    2599  */
    26002466/* static */
    26012467QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends()
     
    26922558}
    26932559
    2694 QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0*/)
     2560QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0 */)
    26952561{
    26962562    /* Convert to native separators: */
     
    27552621}
    27562622
    2757 /* Open some external medium using file open dialog
    2758  * and temporary cache (enumerate) it in GUI inner mediums cache: */
    27592623QString VBoxGlobal::openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent,
    27602624                                                 const QString &strDefaultFolder /* = QString() */,
     
    28382702}
    28392703
    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  */
    28472704QString VBoxGlobal::createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder)
    28482705{
     
    28612718                                                       /// @todo tr("Please select files and directories to be on the VISO"),
    28622719                                                       tr("Please select files to be on the VISO"),
    2863                                                        0, true /*aResolveSymlinks*/, false /*aSingleFile*/);
     2720                                                       0, true /* resolve symlinks? */, false /* single file? */);
    28642721
    28652722    /* Return if no result. */
     
    32403097}
    32413098
    3242 QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true*/)
     3099QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true */)
    32433100{
    32443101    /* Search for corresponding UI medium: */
     
    32943151#endif /* RT_OS_LINUX */
    32953152
    3296 /**
    3297  *  Returns the details of the given USB device as a single-line string.
    3298  */
    32993153QString VBoxGlobal::details (const CUSBDevice &aDevice) const
    33003154{
     
    33353189}
    33363190
    3337 /**
    3338  *  Returns the multi-line description of the given USB device.
    3339  */
    33403191QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const
    33413192{
     
    33643215}
    33653216
    3366 /**
    3367  *  Returns the multi-line description of the given USB filter
    3368  */
    33693217QString VBoxGlobal::toolTip (const CUSBDeviceFilter &aFilter) const
    33703218{
     
    34173265}
    34183266
    3419 /** Returns the multi-line description of the given CHostVideoInputDevice filter. */
    34203267QString VBoxGlobal::toolTip(const CHostVideoInputDevice &webcam) const
    34213268{
     
    35213368}
    35223369
    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 not
    3527  * have 3D enabled, don't wast the developer's or user's time on launching the
    3528  * 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 a
    3532  *       RTONCE construct to serialize the efforts.
    3533  */
    35343370bool VBoxGlobal::is3DAvailableWorker() const
    35353371{
     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
    35363379#ifdef VBOX_WITH_CROGL
    35373380    bool fSupported = VBoxOglIs3DAccelerationSupported();
     
    35573400#endif /* VBOX_WITH_CRHGSMI */
    35583401
    3559 /**
    3560  *  Returns the required video memory in bytes for the current desktop
    3561  *  resolution at maximum possible screen depth in bpp.
    3562  */
    35633402/* static */
    35643403quint64 VBoxGlobal::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
     
    35773416        screenSize[i] = r.width() * r.height();
    35783417    }
    3579     /* Now sort the vector */
     3418    /* Now sort the vector: */
    35803419    qSort(screenSize.begin(), screenSize.end(), qGreater<int>());
    35813420    /* For the case that there are more guest screens configured then host
     
    35893428    for (int i = 0; i < cMonitors; ++i)
    35903429    {
    3591         /* Calculate summary required memory amount in bits */
     3430        /* Calculate summary required memory amount in bits: */
    35923431        needBits += (screenSize.at(i) * /* with x height */
    35933432                     32 + /* we will take the maximum possible bpp for now */
     
    35953434                    8 * 4096; /* adapter info */
    35963435    }
    3597     /* Translate value into megabytes with rounding to highest side */
     3436    /* Translate value into megabytes with rounding to highest side: */
    35983437    quint64 needMBytes = needBits % (8 * _1M) ? needBits / (8 * _1M) + 1 :
    35993438                         needBits / (8 * _1M) /* convert to megabytes */;
     
    36053444       if (isWddmCompatibleOsType(strGuestOSTypeId))
    36063445       {
    3607            /* wddm mode, there are two surfaces for each screen: shadow & primary */
     3446           /* WDDM mode, there are two surfaces for each screen: shadow & primary: */
    36083447           needMBytes *= 3;
    36093448       }
     
    36903529}
    36913530
    3692 /**
    3693  * Joins two pixmaps horizontally with 2px space between them and returns the
    3694  * result.
    3695  *
    3696  * @param aPM1 Left pixmap.
    3697  * @param aPM2 Right pixmap.
    3698  */
    36993531/* static */
    37003532QPixmap VBoxGlobal::joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2)
     
    37173549}
    37183550
    3719 /**
    3720  *  Replacement for QToolButton::setTextLabel() that handles the shortcut
    3721  *  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. Only
    3726  *  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  */
    37313551/* static */
    37323552void VBoxGlobal::setTextLabel (QToolButton *aToolButton,
     
    37463566}
    37473567
    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  */
    37533568/* static */
    37543569QString VBoxGlobal::locationForHTML (const QString &aFileName)
     
    37663581}
    37673582
    3768 /**
    3769  *  Searches for a widget that with @a aName (if it is not NULL) which inherits
    3770  *  @a aClassName (if it is not NULL) and among children of @a aParent. If @a
    3771  *  aParent is NULL, all top-level widgets are searched. If @a aRecursive is
    3772  *  true, child widgets are recursively searched as well.
    3773  */
    37743583/* static */
    37753584QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName,
     
    38063615}
    38073616
    3808 /**
    3809  * Opens the specified URL using OS/Desktop capabilities.
    3810  *
    3811  * @param aURL URL to open
    3812  *
    3813  * @return true on success and false otherwise
    3814  */
    38153617bool VBoxGlobal::openURL (const QString &aURL)
    38163618{
    3817     /* Service event */
     3619    /** Service event. */
    38183620    class ServiceEvent : public QEvent
    38193621    {
    38203622        public:
    38213623
     3624            /** Constructs service event on th basis of passed @a fResult. */
    38223625            ServiceEvent (bool aResult) : QEvent (QEvent::User), mResult (aResult) {}
    38233626
     3627            /** Returns the result which event brings. */
    38243628            bool result() const { return mResult; }
    38253629
    38263630        private:
    38273631
     3632            /** Holds the result which event brings. */
    38283633            bool mResult;
    38293634    };
    38303635
    3831     /* Service-Client object */
     3636    /** Service client object. */
    38323637    class ServiceClient : public QEventLoop
    38333638    {
    38343639        public:
    38353640
     3641            /** Constructs service client on the basis of passed @a fResult. */
    38363642            ServiceClient() : mResult (false) {}
    38373643
     3644            /** Returns the result which event brings. */
    38383645            bool result() const { return mResult; }
    38393646
    38403647        private:
    38413648
     3649            /** Handles any Qt @a pEvent. */
    38423650            bool event (QEvent *aEvent)
    38433651            {
     3652                /* Handle service event: */
    38443653                if (aEvent->type() == QEvent::User)
    38453654                {
     
    38563665    };
    38573666
    3858     /* Service-Server object */
     3667    /** Service server object. */
    38593668    class ServiceServer : public QThread
    38603669    {
    38613670        public:
    38623671
     3672            /** Constructs service server on the basis of passed @a client and @a strUrl. */
    38633673            ServiceServer (ServiceClient &aClient, const QString &sURL)
    38643674                : mClient (aClient), mURL (sURL) {}
     
    38663676        private:
    38673677
     3678            /** Executes thread task. */
    38683679            void run()
    38693680            {
     
    38713682            }
    38723683
     3684            /** Holds the client reference. */
    38733685            ServiceClient &mClient;
     3686            /** Holds the URL to be processed. */
    38743687            const QString &mURL;
    38753688    };
    38763689
     3690    /* Create/start client & server: */
    38773691    ServiceClient client;
    38783692    ServiceServer server (client, aURL);
     
    38813695    server.wait();
    38823696
     3697    /* Acquire client result: */
    38833698    bool result = client.result();
    38843699
     
    38993714bool VBoxGlobal::eventFilter (QObject *aObject, QEvent *aEvent)
    39003715{
     3716    /** @todo Just use the QIWithRetranslateUI3 template wrapper. */
     3717
    39013718    if (aEvent->type() == QEvent::LanguageChange &&
    39023719        aObject->isWidgetType() &&
     
    39093726        if (list.first() == aObject)
    39103727        {
    3911             /* call this only once per every language change (see
    3912              * QApplication::installTranslator() for details) */
     3728            /* Call this only once per every language change (see
     3729             * QApplication::installTranslator() for details): */
    39133730            retranslateUi();
    39143731        }
    39153732    }
    39163733
     3734    /* Call to base-class: */
    39173735    return QObject::eventFilter (aObject, aEvent);
    39183736}
    39193737
    3920 /**
    3921  *  Changes the language of all global string constants according to the
    3922  *  currently installed translations tables.
    3923  */
    39243738void VBoxGlobal::retranslateUi()
    39253739{
     
    39373751
    39383752#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.
    39413756    UINativeHotKey::retranslateKeyNames();
    39423757#endif /* VBOX_WS_X11 */
     
    42614076    }
    42624077
    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: */
    42644079    if (!isVMConsoleProcess())
    42654080    {
     
    45324347# define VBOXGLOBAL_DBG_CFG_VAR_DONE        RT_BIT(4)
    45334348
    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 this
    4539  *                              variable.
    4540  * @param   pszExtraDataName    The extra data name relating to this variable.
    4541  * @param   fDefault            The default value.
    4542  */
    45434349void VBoxGlobal::initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault)
    45444350{
     
    45874393}
    45884394
    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  */
    45954395void VBoxGlobal::setDebuggerVar(int *piDbgCfgVar, bool fState)
    45964396{
     
    46004400}
    46014401
    4602 /**
    4603  * Checks the state of a debugger config variable, updating it with the machine
    4604  * 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  */
    46104402bool VBoxGlobal::isDebuggerWorker(int *piDbgCfgVar, const char *pszExtraDataName) const
    46114403{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r72413 r72414  
    6565signals:
    6666
    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    /** @} */
    87102
    88103public:
     
    106121    };
    107122
    108     /** Whether to start the VM running. */
     123    /** VM launch running options. */
    109124    enum StartRunning
    110125    {
    111         StartRunning_Default,   /**< Default (depends on debug settings). */
    112         StartRunning_No,        /**< Start the VM paused. */
    113         StartRunning_Yes        /**< Start the VM running. */
     126        StartRunning_Default, /**< Default (depends on debug settings). */
     127        StartRunning_No,      /**< Start the VM paused. */
     128        StartRunning_Yes      /**< Start the VM running. */
    114129    };
    115130
    116     /* Static API: Create/destroy stuff: */
     131    /** Returns VBoxGlobal instance. */
    117132    static VBoxGlobal *instance() { return s_pInstance; }
    118133#ifndef VBOX_GUI_WITH_SHARED_LIBRARY
     134    /** Creates VBoxGlobal instance. */
    119135    static void create();
    120136#else
     137    /** Creates VBoxGlobal instance of passed @a enmType. */
    121138    static void create(UIType enmType);
    122139#endif
     140    /** Destroys VBoxGlobal instance. */
    123141    static void destroy();
    124142
    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; }
    139169
    140170#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; }
    145175#endif /* VBOX_WS_MAC */
    146176
    147177#ifdef VBOX_WS_X11
    148     /** X11: Returns whether the Window Manager we are running at is 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; }
    152182#endif /* VBOX_WS_X11 */
    153183
    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; }
    195247
    196248#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; }
    203260#endif /* VBOX_WITH_DEBUGGER_GUI */
    204261
    205     bool shouldStartPaused() const
    206     {
     262        /** Returns whether VM should start paused. */
     263        bool shouldStartPaused() const
     264        {
    207265#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;
    209267#else
    210         return false;
    211 #endif
    212     }
     268            return false;
     269#endif
     270        }
    213271
    214272#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,
    299406                                    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);
    315423
    316424#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);
    335443#endif /* VBOX_WS_X11 */
    336444
    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     * @{ */
    412568#ifdef RT_OS_LINUX
    413     static void checkForWrongUSBMounted();
     569        /** Verifies that USB drivers are properly configured on Linux. */
     570        static void checkForWrongUSBMounted();
    414571#endif /* RT_OS_LINUX */
    415572
    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; }
    438607
    439608#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);
    441611#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    /** @} */
    479665
    480666public slots:
    481667
    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    /** @} */
    485679
    486680protected:
    487681
     682    /** Preprocesses any Qt @a pEvent for passed @a pObject. */
    488683    bool eventFilter (QObject *, QEvent *);
    489684
     685    /** Handles translation event. */
    490686    void retranslateUi();
    491687
    492688protected slots:
    493689
    494     /* Handlers: Prepare/cleanup stuff: */
     690    /** Prepares all. */
    495691    void prepare();
     692    /** Cleanups all. */
    496693    void cleanup();
    497694
    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    /** @} */
    503706
    504707private:
     
    515718    virtual ~VBoxGlobal() /* override */;
    516719
     720    /** @name Common stuff.
     721     * @{ */
    517722#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     * @{ */
    522730#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    /** @} */
    530753
    531754    /** Holds the singleton VBoxGlobal instance. */
    532755    static VBoxGlobal *s_pInstance;
    533756
    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;
    539764
    540765#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;
    546772
    547773#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;
    550776#endif /* VBOX_WS_MAC */
    551777
    552778#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;
    557783#endif /* VBOX_WS_X11 */
    558784
    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). */
    579810        QString m_strFloppyImage;
    580         /** DVD image. */
     811        /** Holds the --dvd | --cdrom option value (DVD image). */
    581812        QString m_strDvdImage;
    582     /** @} */
    583 
    584     /** @name VMM options
    585      * @{ */
    586         /** The --disable-patm option. */
     813
     814        /** Holds the --disable-patm option value. */
    587815        bool mDisablePatm;
    588         /** The --disable-csam option. */
     816        /** Holds the --disable-csam option value. */
    589817        bool mDisableCsam;
    590         /** The --recompile-supervisor option. */
     818        /** Holds the --recompile-supervisor option value. */
    591819        bool mRecompileSupervisor;
    592         /** The --recompile-user option. */
     820        /** Holds the --recompile-user option value. */
    593821        bool mRecompileUser;
    594         /** The --execute-all-in-iem option. */
     822        /** Holds the --execute-all-in-iem option value. */
    595823        bool mExecuteAllInIem;
    596         /** The --warp-factor option value. */
     824        /** Holds the --warp-factor option value. */
    597825        uint32_t mWarpPct;
    598     /** @} */
    599826
    600827#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;
    618847
    619848#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 */
    664918    bool m_fEPInstallationRequested;
    665919
    666920#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    /** @} */
    670927#endif
    671928
    672929#if defined (VBOX_WS_WIN)
     930    /** @todo remove */
    673931    DWORD dwHTMLHelpCookie;
    674932#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette