VirtualBox

Changeset 2022 in vbox


Ignore:
Timestamp:
Apr 11, 2007 7:25:07 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20314
Message:

1908: UI for language selection:
Feature implemented with minor changes in design.

Base Feature description:

  1. Default system language is loading during VBox starting.
  2. After that, predefined user language (pointed in VBox configuration file, GUI/LanguageID key) is loading during VBox initializing.
  3. User can switch one language to another from the Global Settings interface language list. Language change applying just after the Global Settings dialog will be closed.
  4. If the configuration file has the local language predefined (en_US) and this language is not presented in necessary *.qm file then the global language similar to local will be applied (en), but the settings for local language will be left in the configuration file. Configuration file will be rewritten with this new global language selected only if the user changes language in the selection list himself.
  5. If naiver local language pointed in configuration file nor global language similar to local could be found then the user will be proposed with this fact and asked for changing language to built-in.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
8 edited

Legend:

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

    r1922 r2022  
    375375    bool openURL (const QString &aURL);
    376376
     377    static const QString& languageID();
     378    static void loadLanguage (const QString &aLangId = QString::null);
     379    static bool loadLanguageFile (const QString &);
     380
    377381    QString languageName() const;
    378382    QString languageCountry() const;
     
    506510
    507511    QString verString;
     512
     513    static QString mLoadedLangId;
    508514
    509515    QValueVector <CGuestOSType> vm_os_types;
  • trunk/src/VBox/Frontends/VirtualBox/include/VMGlobalSettings.h

    r1557 r2022  
    4444    bool autoCapture;
    4545    QString guiFeatures;
     46    QString languageId;
    4647
    4748    friend class VMGlobalSettings;
     
    5657    Q_PROPERTY (bool autoCapture READ autoCapture WRITE setAutoCapture)
    5758    Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures)
     59    Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId)
    5860
    5961public:
     
    8587    }
    8688    bool isFeatureActive (const char*) const;
     89
     90    QString languageId() const { return data()->languageId; }
     91    void setLanguageId (const QString &aLanguageId)
     92    {
     93        mData()->languageId = aLanguageId;
     94    }
    8795
    8896    //
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r1925 r2022  
    424424#endif /* Q_WS_WIN */
    425425
     426// Helpers for VBoxGlobal::loadLanguage()
     427/////////////////////////////////////////////////////////////////////////////
     428
     429extern const QString transFileName = "VirtualBox_";
     430extern const QString langIdRegExp  = "(([a-z]{2})(_([A-Z]{2}))?)";
     431extern const QString builtInName   = "built_in";
     432static const QString transFileExt  = ".qm";
     433class VBoxTranslator : public QTranslator
     434{
     435public:
     436
     437    VBoxTranslator (QObject *aParent = 0)
     438        : QTranslator (aParent, "VBoxTranslatorObject") {}
     439
     440    bool loadFile (const QString &aFileName)
     441    {
     442        QFile file (aFileName);
     443        if (!file.open (IO_ReadOnly))
     444            return false;
     445        mData = file.readAll();
     446        return load ((uchar*)mData.data(), mData.size());
     447    }
     448
     449private:
     450
     451    QByteArray mData;
     452};
     453static VBoxTranslator *mTranslator = 0;
    426454
    427455// VBoxGlobal
     
    16031631
    16041632/**
     1633 *  This variable used for storing loaded language id.
     1634 */
     1635/* static */
     1636QString VBoxGlobal::mLoadedLangId = builtInName;
     1637
     1638/**
     1639 *  This method returns loaded language id.
     1640 */
     1641/* static */
     1642const QString& VBoxGlobal::languageID()
     1643{
     1644    return mLoadedLangId;
     1645}
     1646
     1647/**
     1648 *  This method is used to load language by language id.
     1649 */
     1650/* static */
     1651void VBoxGlobal::loadLanguage (const QString &aLang)
     1652{
     1653    const QString &langId = aLang.isNull() ?
     1654        VBoxGlobal::systemLanguageID() : aLang;
     1655    QString languageFileName = QString::null;
     1656    QString selectedLangId = builtInName;
     1657
     1658    if (aLang != builtInName)
     1659    {
     1660        QRegExp regExp (langIdRegExp);
     1661        int rule = regExp.search (langId);
     1662        /* this rule should match the language id completely */
     1663        Assert (!rule);
     1664        if (rule == -1) return;
     1665
     1666        QString mId1part = regExp.cap (2);
     1667        QString mId2part = regExp.cap (4);
     1668        /* language localization (second part) should not be empty? */
     1669        // Assert (!mId2part.isEmpty());
     1670
     1671        QString nlsPath = qApp->applicationDirPath() + "/nls";
     1672        QDir nlsDir (nlsPath);
     1673        if (nlsDir.exists (transFileName + langId + transFileExt))
     1674        {
     1675            languageFileName = nlsDir.absFilePath (transFileName + langId + transFileExt);
     1676            selectedLangId = langId;
     1677        }
     1678        else if (nlsDir.exists (transFileName + mId1part + transFileExt))
     1679        {
     1680            languageFileName = nlsDir.absFilePath (transFileName + mId1part + transFileExt);
     1681            selectedLangId = mId1part;
     1682        }
     1683
     1684        if (mTranslator && languageFileName.isNull())
     1685        {
     1686            /* process downgrade situation */
     1687            int loadLanguageQuest = vboxProblem().message (
     1688                0, VBoxProblemReporter::Question,
     1689                tr ("<p>Correct *.qm language file for language with "
     1690                    "<b>%1</b> id could not be found in the "
     1691                    "%2 location.</p> Do you want to use built-in language "
     1692                    "instead of it?</p>").arg (langId).arg (nlsPath),
     1693                0, /* autoConfirmId */
     1694                QIMessageBox::Ok | QIMessageBox::Default,
     1695                QIMessageBox::Cancel | QIMessageBox::Escape);
     1696            if (loadLanguageQuest == QIMessageBox::Cancel)
     1697                return;
     1698        }
     1699    }
     1700
     1701    if (loadLanguageFile (languageFileName))
     1702    {
     1703        mLoadedLangId = selectedLangId;
     1704    }
     1705    else
     1706    {
     1707        /* passed file is not loaded */
     1708        vboxProblem().message (
     1709            0, VBoxProblemReporter::Warning,
     1710            tr ("<p>Language file <b>%1</b> could not be loaded. This "
     1711                "issue could be caused by incorrect file content.</p>")
     1712                .arg (languageFileName),
     1713            0, /* autoConfirmId */
     1714            QIMessageBox::Ok | QIMessageBox::Default);
     1715    }
     1716}
     1717
     1718/**
     1719 *  This method is used to load language file into translator
     1720 *  and install loaded translator.
     1721 */
     1722/* static */
     1723bool VBoxGlobal::loadLanguageFile (const QString &aFileName)
     1724{
     1725    if (mTranslator)
     1726        qApp->removeTranslator (mTranslator);
     1727    delete mTranslator;
     1728    mTranslator = new VBoxTranslator();
     1729    bool status = true;
     1730    if (!aFileName.isNull())
     1731        status = mTranslator->loadFile (aFileName);
     1732    qApp->installTranslator (mTranslator);
     1733    return status;
     1734}
     1735
     1736/**
    16051737 *  Native language name of the currently installed translation.
    16061738 *  Returns "English [built-in]" if no translation is installed
     
    27192851    }
    27202852
     2853    /* Load predefined language */
     2854    const QString &languageId = gset.languageId();
     2855    if (!languageId.isNull())
     2856        loadLanguage (languageId);
     2857
    27212858    // process command line
    27222859
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r1757 r2022  
    319319{
    320320    mBtnEdit->setTextLabel (tr ("Edit"));
    321     mBtnEdit->setAccel (QString ("Ctrl+E"));
     321    mBtnEdit->setAccel (tr ("Ctrl+E"));
    322322    QToolTip::add (mBtnEdit, tr ("Edit (Ctrl+E)"));
     323    mBtnEdit->adjustSize();
     324    mBtnEdit->updateGeometry();
    323325}
    324326
     
    973975            break;
    974976        }
     977        case QEvent::LanguageChange:
     978        {
     979            languageChange();
     980            break;
     981        }
    975982
    976983        default:
     
    9961003#endif
    9971004
     1005    vboxGlobal().languageChange();
     1006
    9981007    vmTabWidget->changeTab (vmDetailsView, tr ("&Details"));
    9991008    /* note: Snapshots and Details tabs are changed dynamically by
     
    10271036    vmDeleteAction->setMenuText (tr ("&Delete"));
    10281037    vmDeleteAction->setText (tr ("Delete"));
    1029     vmDeleteAction->setAccel( QString::null );
     1038    vmDeleteAction->setAccel (QString::null);
    10301039    vmDeleteAction->setStatusTip (tr ("Delete the selected virtual machine"));
    10311040
     
    11021111            vmDetailsView->setDetailsText (
    11031112                vboxGlobal().detailsReport (m, false /* isNewVM */,
    1104                                                modifyEnabled /* withLinks */));
     1113                                            modifyEnabled /* withLinks */));
    11051114        }
    11061115        if (aRefreshSnapshots)
  • trunk/src/VBox/Frontends/VirtualBox/src/VMGlobalSettings.cpp

    r1557 r2022  
    5656    autoCapture = true;
    5757    guiFeatures = QString::null;
     58    languageId  = QString::null;
    5859}
    5960
     
    6263    autoCapture = that.autoCapture;
    6364    guiFeatures = that.guiFeatures;
     65    languageId  = that.languageId;
    6466}
    6567
     
    7375        hostkey == that.hostkey &&
    7476        autoCapture == that.autoCapture &&
    75         guiFeatures == that.guiFeatures
     77        guiFeatures == that.guiFeatures &&
     78        languageId  == that.languageId
    7679    );
    7780}
     
    9497    { "GUI/Input/AutoCapture",  "autoCapture",  "true|false" },
    9598    { "GUI/Customizations",     "guiFeatures",  "\\S+" },
     99    { "GUI/LanguageID",         "languageId",   "([a-z]{2,5}(_[a-zA-Z]{2})?)?" },
    96100};
    97101
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r1922 r2022  
    161161
    162162    /* load a translation based on the current locale */
    163     QTranslator translator;
    164     QString lang = VBoxGlobal::systemLanguageID();
    165     QString nlsPath = a.applicationDirPath() + "/nls";
    166     LogFlowFunc (("lang=%S, nlsPath=\"%S\"\n",
    167                   lang.local8Bit().data(), nlsPath.local8Bit().data()));
    168     translator.load (QString ("VirtualBox_%1").arg (lang), nlsPath);
    169     a.installTranslator (&translator);
     163    VBoxGlobal::loadLanguage();
    170164
    171165    int rc = 1;
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui

    r1889 r2022  
    3232    </property>
    3333    <property name="caption">
    34         <string>VBoxGlobalSettingsDlg</string>
     34        <string>VirtualBox Global Settings</string>
    3535    </property>
    3636    <property name="sizeGripEnabled">
     
    139139            <property name="pixmap">
    140140                <pixmap>usb_16px.png</pixmap>
     141            </property>
     142            <property name="pixmap">
     143                <pixmap></pixmap>
     144            </property>
     145            <property name="pixmap">
     146                <pixmap></pixmap>
     147            </property>
     148        </item>
     149        <item>
     150            <property name="text">
     151                <string> Language </string>
     152            </property>
     153            <property name="text">
     154                <string>3</string>
     155            </property>
     156            <property name="text">
     157                <string>#language</string>
     158            </property>
     159            <property name="pixmap">
     160                <pixmap>site_16px.png</pixmap>
    141161            </property>
    142162            <property name="pixmap">
     
    734754                </vbox>
    735755            </widget>
     756            <widget class="QWidget">
     757                <property name="name">
     758                    <cstring>pageLanguage</cstring>
     759                </property>
     760                <attribute name="id">
     761                    <number>3</number>
     762                </attribute>
     763                <vbox>
     764                    <property name="name">
     765                        <cstring>unnamed</cstring>
     766                    </property>
     767                    <property name="margin">
     768                        <number>0</number>
     769                    </property>
     770                    <property name="spacing">
     771                        <number>0</number>
     772                    </property>
     773                    <widget class="QGroupBox">
     774                        <property name="name">
     775                            <cstring>gbInterface</cstring>
     776                        </property>
     777                        <property name="title">
     778                            <string>&amp;Interface Language</string>
     779                        </property>
     780                        <hbox>
     781                            <property name="name">
     782                                <cstring>unnamed</cstring>
     783                            </property>
     784                            <widget class="QListView">
     785                                <column>
     786                                    <property name="text">
     787                                        <string>Language</string>
     788                                    </property>
     789                                    <property name="clickable">
     790                                        <bool>false</bool>
     791                                    </property>
     792                                    <property name="resizable">
     793                                        <bool>false</bool>
     794                                    </property>
     795                                </column>
     796                                <property name="name">
     797                                    <cstring>lvLanguages</cstring>
     798                                </property>
     799                                <property name="sizePolicy">
     800                                    <sizepolicy>
     801                                        <hsizetype>0</hsizetype>
     802                                        <vsizetype>7</vsizetype>
     803                                        <horstretch>0</horstretch>
     804                                        <verstretch>0</verstretch>
     805                                    </sizepolicy>
     806                                </property>
     807                                <property name="resizeMode">
     808                                    <enum>AllColumns</enum>
     809                                </property>
     810                                <property name="whatsThis" stdset="0">
     811                                    <string>The list of languages available for interface translation.</string>
     812                                </property>
     813                            </widget>
     814                            <widget class="QLayoutWidget">
     815                                <property name="name">
     816                                    <cstring>layout7</cstring>
     817                                </property>
     818                                <vbox>
     819                                    <property name="name">
     820                                        <cstring>unnamed</cstring>
     821                                    </property>
     822                                    <widget class="QLayoutWidget">
     823                                        <property name="name">
     824                                            <cstring>layout6</cstring>
     825                                        </property>
     826                                        <grid>
     827                                            <property name="name">
     828                                                <cstring>unnamed</cstring>
     829                                            </property>
     830                                            <widget class="QLabel" row="1" column="1">
     831                                                <property name="name">
     832                                                    <cstring>tlAuthorData</cstring>
     833                                                </property>
     834                                                <property name="sizePolicy">
     835                                                    <sizepolicy>
     836                                                        <hsizetype>7</hsizetype>
     837                                                        <vsizetype>5</vsizetype>
     838                                                        <horstretch>0</horstretch>
     839                                                        <verstretch>0</verstretch>
     840                                                    </sizepolicy>
     841                                                </property>
     842                                                <property name="text">
     843                                                    <string></string>
     844                                                </property>
     845                                                <property name="alignment">
     846                                                    <set>WordBreak|AlignTop</set>
     847                                                </property>
     848                                            </widget>
     849                                            <widget class="QLabel" row="1" column="0">
     850                                                <property name="name">
     851                                                    <cstring>tlAuthorName</cstring>
     852                                                </property>
     853                                                <property name="sizePolicy">
     854                                                    <sizepolicy>
     855                                                        <hsizetype>1</hsizetype>
     856                                                        <vsizetype>5</vsizetype>
     857                                                        <horstretch>0</horstretch>
     858                                                        <verstretch>0</verstretch>
     859                                                    </sizepolicy>
     860                                                </property>
     861                                                <property name="text">
     862                                                    <string>Author(s):</string>
     863                                                </property>
     864                                                <property name="alignment">
     865                                                    <set>AlignTop</set>
     866                                                </property>
     867                                            </widget>
     868                                            <widget class="QLabel" row="0" column="0">
     869                                                <property name="name">
     870                                                    <cstring>tlLangName</cstring>
     871                                                </property>
     872                                                <property name="sizePolicy">
     873                                                    <sizepolicy>
     874                                                        <hsizetype>1</hsizetype>
     875                                                        <vsizetype>5</vsizetype>
     876                                                        <horstretch>0</horstretch>
     877                                                        <verstretch>0</verstretch>
     878                                                    </sizepolicy>
     879                                                </property>
     880                                                <property name="text">
     881                                                    <string>Language:</string>
     882                                                </property>
     883                                                <property name="alignment">
     884                                                    <set>AlignTop</set>
     885                                                </property>
     886                                            </widget>
     887                                            <widget class="QLabel" row="0" column="1">
     888                                                <property name="name">
     889                                                    <cstring>tlLangData</cstring>
     890                                                </property>
     891                                                <property name="sizePolicy">
     892                                                    <sizepolicy>
     893                                                        <hsizetype>7</hsizetype>
     894                                                        <vsizetype>5</vsizetype>
     895                                                        <horstretch>0</horstretch>
     896                                                        <verstretch>0</verstretch>
     897                                                    </sizepolicy>
     898                                                </property>
     899                                                <property name="text">
     900                                                    <string></string>
     901                                                </property>
     902                                                <property name="alignment">
     903                                                    <set>WordBreak|AlignTop</set>
     904                                                </property>
     905                                            </widget>
     906                                        </grid>
     907                                    </widget>
     908                                    <spacer>
     909                                        <property name="name">
     910                                            <cstring>spacer7</cstring>
     911                                        </property>
     912                                        <property name="orientation">
     913                                            <enum>Vertical</enum>
     914                                        </property>
     915                                        <property name="sizeType">
     916                                            <enum>Expanding</enum>
     917                                        </property>
     918                                        <property name="sizeHint">
     919                                            <size>
     920                                                <width>20</width>
     921                                                <height>121</height>
     922                                            </size>
     923                                        </property>
     924                                    </spacer>
     925                                </vbox>
     926                            </widget>
     927                        </hbox>
     928                    </widget>
     929                </vbox>
     930            </widget>
    736931        </widget>
    737932        <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2">
     
    9871182        <receiver>VBoxGlobalSettingsDlg</receiver>
    9881183        <slot>tbUSBFilterDown_clicked()</slot>
     1184    </connection>
     1185    <connection>
     1186        <sender>lvLanguages</sender>
     1187        <signal>currentChanged(QListViewItem*)</signal>
     1188        <receiver>VBoxGlobalSettingsDlg</receiver>
     1189        <slot>lvLanguages_currentChanged(QListViewItem*)</slot>
    9891190    </connection>
    9901191</connections>
     
    10041205    <tabstop>tbUSBFilterUp</tabstop>
    10051206    <tabstop>tbUSBFilterDown</tabstop>
     1207    <tabstop>lvLanguages</tabstop>
    10061208    <tabstop>buttonHelp</tabstop>
    10071209    <tabstop>buttonOk</tabstop>
     
    10411243    <variable access="private">bool mUSBFilterListModified;</variable>
    10421244    <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable>
     1245    <variable access="private">bool mLanguageChanged;</variable>
    10431246</variables>
    10441247<slots>
     
    10581261    <slot>tbUSBFilterUp_clicked()</slot>
    10591262    <slot>tbUSBFilterDown_clicked()</slot>
     1263    <slot>lvLanguages_currentChanged( QListViewItem* )</slot>
    10601264</slots>
    10611265<functions>
    10621266    <function access="private">init()</function>
     1267    <function access="private" returnType="bool">event( QEvent * )</function>
    10631268    <function access="protected">showEvent( QShowEvent * )</function>
    10641269    <function>getFrom( const CSystemProperties &amp; props, const VMGlobalSettings &amp; gs )</function>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h

    r1902 r2022  
    3131
    3232
     33extern const QString transFileName;
     34extern const QString langIdRegExp;
     35extern const QString builtInName;
     36
    3337/**
    3438 *  Returns the path to the item in the form of 'grandparent > parent > item'
     
    7377
    7478
     79class LanguageItem : public QListViewItem
     80{
     81public:
     82
     83    enum { TypeId = 1001 };
     84
     85    LanguageItem (QListView *aParent, const QString &aName)
     86        : QListViewItem (aParent, aName)
     87    {
     88        /* making separator field */
     89        if (aName == "-")
     90        {
     91            QString sepLine;
     92            while (listView()->fontMetrics().width (sepLine) < listView()->width())
     93                sepLine += "-";
     94            setText (0, sepLine);
     95            setSelectable (false);
     96        }
     97    }
     98
     99    LanguageItem (QListView *aParent, const QTranslator &aTranslator,
     100                  const QString &aId, bool aBuiltIn = false)
     101        : QListViewItem (aParent)
     102    {
     103        QTranslatorMessage transMes;
     104
     105        QString nativeLanguage = translate (aTranslator,
     106            "@@@", "English", "Native language name", aBuiltIn);
     107        QString nativeCountry = translate (aTranslator,
     108            "@@@", "built-in", "Native language country name "
     109            "(empty if this language is for all countries)", aBuiltIn);
     110
     111        QString englishLanguage = translate (aTranslator,
     112            "@@@", "English", "Language name, in English", aBuiltIn);
     113        QString englishCountry = translate (aTranslator,
     114            "@@@", "built-in", "Language country name, in English "
     115            "(empty if native country name is empty)", aBuiltIn);
     116
     117        QString translatorsName = translate (aTranslator,
     118            "@@@", "InnoTek", "Comma-separated list of translators", aBuiltIn);
     119        if (translatorsName.isNull())
     120            translatorsName = QListView::tr ("--", "no info");
     121
     122        QString itemName = nativeLanguage;
     123        if (!nativeCountry.isNull())
     124            itemName += " (" + nativeCountry + ")";
     125
     126        QString langName = englishLanguage;
     127        if (!englishCountry.isNull())
     128            langName += " (" + englishCountry + ")";
     129        if (!aBuiltIn)
     130            langName = itemName + " / " + langName;
     131
     132        setText (0, itemName);
     133        setText (1, aId);
     134        setText (2, langName);
     135        setText (3, translatorsName);
     136    }
     137
     138    int rtti() const { return TypeId; }
     139
     140    int compare (QListViewItem *aItem, int aColumn, bool aAscending) const
     141    {
     142        QString thisValue = text (1);
     143        QString thatValue = aItem->text (1);
     144        if (thisValue == builtInName)
     145            return -1;
     146        else if (thatValue == builtInName)
     147            return 1;
     148        else
     149            return QListViewItem::compare (aItem, aColumn, aAscending);
     150    }
     151
     152    void paintCell (QPainter *aPainter, const QColorGroup &aGroup,
     153                    int aColumn, int aWidth, int aSlign)
     154    {
     155        /* adjusting list-view width */
     156        int fullwidth = width (listView()->fontMetrics(), listView(), 0) + 4;
     157        if (listView()->width() < fullwidth)
     158            listView()->setFixedWidth (fullwidth);
     159        /* standard paint procedure */
     160        QListViewItem::paintCell (aPainter, aGroup, aColumn, aWidth, aSlign);
     161    }
     162
     163private:
     164
     165    QString translate (const QTranslator &aTranslator, const char *aCtxt,
     166                       const char *aSrc, const char *aCmnt, bool aBuiltIn)
     167    {
     168        QTranslatorMessage msg = aTranslator.findMessage (aCtxt, aSrc, aCmnt);
     169        return msg.translation().isNull() && aBuiltIn ? QString (aSrc) : msg.translation();
     170    }
     171};
     172
     173
    75174void VBoxGlobalSettingsDlg::init()
    76175{
    77176    polished = false;
    78177
    79     setCaption (tr ("VirtualBox Global Settings"));
    80178    setIcon (QPixmap::fromMimeSource ("global_settings_16px.png"));
    81179
     
    98196    listView->setSorting (listView_Id);
    99197    listView->sort();
    100     /*  disable further sorting (important for network adapters) */
    101     listView->setSorting (-1);
    102     /*  set the first item selected */
    103     listView->setSelected (listView->firstChild(), true);
    104     listView_currentChanged (listView->firstChild());
    105198
    106199    warningPixmap->setMaximumSize( 16, 16 );
     
    203296    /* keyboard page */
    204297
     298    /* Language page */
     299
     300    lvLanguages->header()->hide();
     301    lvLanguages->setSorting (0);
     302    QString nlsPath = qApp->applicationDirPath() + "/nls";
     303    QDir nlsDir (nlsPath);
     304    QStringList files = nlsDir.entryList (transFileName + "*", QDir::Files);
     305    QTranslator translator;
     306    new LanguageItem (lvLanguages, translator, builtInName, true /* built-in */);
     307    new LanguageItem (lvLanguages, tr ("-"));
     308    for (QStringList::Iterator it = files.begin(); it != files.end(); ++it)
     309    {
     310        const QString &fileName = *it;
     311        bool status = translator.load (fileName, nlsPath);
     312        if (!status) continue;
     313
     314        QRegExp regExp (transFileName + langIdRegExp);
     315        int pos = regExp.search (fileName);
     316        if (pos == -1) continue;
     317
     318        new LanguageItem (lvLanguages, translator, regExp.cap (1));
     319    }
     320
    205321    /*
    206322     *  update the Ok button state for pages with validation
     
    209325    wvalGeneral->revalidate();
    210326    wvalKeyboard->revalidate();
     327}
     328
     329bool VBoxGlobalSettingsDlg::event (QEvent *aEvent)
     330{
     331    bool result = QWidget::event (aEvent);
     332    if (aEvent->type() == QEvent::LanguageChange)
     333    {
     334        /* set the first item selected */
     335        listView->setSelected (listView->firstChild(), true);
     336        listView_currentChanged (listView->firstChild());
     337        lvLanguages_currentChanged (lvLanguages->currentItem());
     338        mLanguageChanged = false;
     339    }
     340    return result;
    211341}
    212342
     
    369499    }
    370500#endif
     501
     502    /* language properties */
     503
     504    QListViewItem *item = lvLanguages->findItem (VBoxGlobal::languageID(), 1);
     505    if (item)
     506    {
     507        lvLanguages->setCurrentItem (item);
     508        lvLanguages->setSelected (item, true);
     509    }
    371510}
    372511
     
    428567    }
    429568    mUSBFilterListModified = false;
     569
     570    /* language properties */
     571
     572    QListViewItem *selItem = lvLanguages->selectedItem();
     573    if (mLanguageChanged && selItem)
     574    {
     575        gs.setLanguageId (selItem->text (1) == VBoxGlobal::systemLanguageID() ?
     576                          QString::null : selItem->text (1));
     577        VBoxGlobal::loadLanguage (selItem->text (1));
     578    }
    430579}
    431580
     
    690839    mUSBFilterListModified = true;
    691840}
     841
     842void VBoxGlobalSettingsDlg::lvLanguages_currentChanged (QListViewItem *aItem)
     843{
     844    if (!aItem) return;
     845
     846    tlLangData->setText (aItem->text (2));
     847    tlAuthorData->setText (aItem->text (3));
     848    if (!mLanguageChanged)
     849        mLanguageChanged = true;
     850}
Note: See TracChangeset for help on using the changeset viewer.

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