VirtualBox

Changeset 1922 in vbox for trunk


Ignore:
Timestamp:
Apr 4, 2007 10:59:48 AM (18 years ago)
Author:
vboxsync
Message:

FE/Qt: Use our own logic to detect the system language setting (in Qt, LC_NUMERIC takes precedence over other lcoale settings on Linux).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r1915 r1922  
    375375    bool openURL (const QString &aURL);
    376376
    377     QString languageID() const;
    378377    QString languageName() const;
    379378    QString languageCountry() const;
     
    409408
    410409    static QString highlight (const QString &aStr, bool aToolTip = false);
     410
     411    static QString systemLanguageID();
    411412
    412413    static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r1915 r1922  
    16031603
    16041604/**
    1605  *  Shortcut to QLocale::system().name().
    1606  */
    1607 QString VBoxGlobal::languageID() const
    1608 {
    1609     return  QLocale::system().name();
    1610 }
    1611 
    1612 /**
    16131605 *  Native language name of the currently installed translation.
    16141606 *  Returns "English [built-in]" if no translation is installed
     
    22082200
    22092201/**
     2202 *  This does exactly the same as QLocale::system().name() but corrects its
     2203 *  wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes
     2204 *  precedence over any other locale setting in the QLocale::system()
     2205 *  implementation). This implementation first looks at LC_MESSAGES which is
     2206 *  designed to define a language for program messages in case if it differs
     2207 *  from the language for other locale categories. Then it looks for LC_ALL,
     2208 *  then for LANG and finally falls back to QLocale::system().name().
     2209 */
     2210/* static */
     2211QString VBoxGlobal::systemLanguageID()
     2212{
     2213#ifdef Q_OS_UNIX
     2214    const char *s = getenv ("LC_MESSAGES");
     2215    if (s == 0)
     2216        s = getenv ("LC_ALL");
     2217    if (s == 0)
     2218        s = getenv ("LANG");
     2219    if (s != 0)
     2220        return QLocale (s).name();
     2221#endif
     2222    return  QLocale::system().name();
     2223}
     2224
     2225/**
    22102226 *  Reimplementation of QFileDialog::getExistingDirectory() that removes some
    22112227 *  oddities and limitations.
     
    22792295            bi.lpfn = winGetExistDirCallbackProc;
    22802296            bi.lParam = Q_ULONG (&mDir);
    2281             if (mParent) mParent->setEnabled (false);
     2297
     2298            /* Qt is uncapable to properly handle modal state if the modal
     2299             * window is not a QWidget. For example, if we have the W1->W2->N
     2300             * ownership where Wx are QWidgets (W2 is modal), and N is a
     2301             * native modal window, cliking on the title bar of W1 will still
     2302             * activate W2 and redirect keyboard/mouse to it. The dirty hack
     2303             * to prevent it is to disable the entire widget... */
     2304            if (mParent)
     2305                mParent->setEnabled (false);
     2306
    22822307            LPITEMIDLIST itemIdList = SHBrowseForFolder (&bi);
    22832308            if (itemIdList)
     
    22972322                result = QString::null;
    22982323            QApplication::postEvent (mTarget, new VBoxGetExistDirectoryEvent (result));
    2299             if (mParent) mParent->setEnabled (true);
     2324
     2325            /* Enable the parent widget again. */
     2326            if (mParent)
     2327                mParent->setEnabled (true);
    23002328        }
    23012329
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r1688 r1922  
    162162    /* load a translation based on the current locale */
    163163    QTranslator translator;
    164     QString lang = QLocale::system().name();
     164    QString lang = VBoxGlobal::systemLanguageID();
    165165    QString nlsPath = a.applicationDirPath() + "/nls";
    166166    LogFlowFunc (("lang=%S, nlsPath=\"%S\"\n",
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