]> git.lyx.org Git - lyx.git/commitdiff
Add a preference combo box for the preferred user interface language. The rc variable...
authorAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 13:32:27 +0000 (13:32 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 25 Jun 2008 13:32:27 +0000 (13:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25387 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyX.cpp
src/LyXFunc.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h
src/frontends/qt4/ui/PrefLanguageUi.ui

index 6a6c140e1f8488715ca444197c3f65a11f570ca5..5ff73f64eaf9a7b92987944b6c9627c3377d7f03 100644 (file)
@@ -347,8 +347,9 @@ void LyX::setRcGuiLanguage()
 {
        if (lyxrc.gui_language == "auto")
                return;
-       LYXERR(Debug::LOCALE, "Setting LANGUAGE to " << lyxrc.gui_language);
-       if (!setEnv("LANGUAGE", lyxrc.gui_language))
+       Language const * language = languages.getLanguage(lyxrc.gui_language);
+       LYXERR(Debug::LOCALE, "Setting LANGUAGE to " << language->code());
+       if (!setEnv("LANGUAGE", language->code()))
                LYXERR(Debug::LOCALE, "\t... failed!");
        LYXERR(Debug::LOCALE, "Setting LC_ALL to en_US");
        if (!setEnv("LC_ALL", "en_US"))
index 79d67237de35832b142407c4fa1afc16641a7129..6a3db5bb8559c086dcc1db2b4096cd755988c9f9 100644 (file)
@@ -1529,6 +1529,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        actOnUpdatedPrefs(lyxrc_orig, lyxrc);
 
+                       // Set the language defined by the user.
+                       LyX::ref().setRcGuiLanguage();
+
                        theApp()->resetGui();
 
                        /// We force the redraw in any case because there might be
index fc87c8de543790375a2b5b72972f23ca2c51c034..a0b815ed0405904a2c5a78c8d6144a4aff2b6e0c 100644 (file)
@@ -1689,13 +1689,35 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultLanguageCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(uiLanguageCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
 
        defaultLanguageCO->clear();
+       uiLanguageCO->clear();
 
        QAbstractItemModel * language_model = guiApp->languageModel();
        // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
        language_model->sort(0);
        defaultLanguageCO->setModel(language_model);
+
+       // FIXME: This is wrong, we need filter this list based on the available
+       // translation.
+       uiLanguageCO->blockSignals(true);
+       uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
+       for (int i = 0; i != language_model->rowCount(); ++i) {
+               QModelIndex index = language_model->index(i, 0);
+               uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
+                       index.data(Qt::UserRole).toString());
+       }
+       uiLanguageCO->blockSignals(false);
+}
+
+
+void PrefLanguage::on_uiLanguageCO_currentIndexChanged(int)
+{
+        QMessageBox::information(this, qt_("LyX needs to be restarted!"),
+                qt_("The change of user interface language will be fully "
+                "effective only after a restart."));
 }
 
 
@@ -1714,6 +1736,8 @@ void PrefLanguage::apply(LyXRC & rc) const
        rc.language_command_end = fromqstr(endCommandED->text());
        rc.default_language = fromqstr(
                defaultLanguageCO->itemData(defaultLanguageCO->currentIndex()).toString());
+       rc.gui_language = fromqstr(
+               uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
 }
 
 
@@ -1734,8 +1758,12 @@ void PrefLanguage::update(LyXRC const & rc)
        startCommandED->setText(toqstr(rc.language_command_begin));
        endCommandED->setText(toqstr(rc.language_command_end));
 
-       int const pos = defaultLanguageCO->findData(toqstr(rc.default_language));
+       int pos = defaultLanguageCO->findData(toqstr(rc.default_language));
        defaultLanguageCO->setCurrentIndex(pos);
+       pos = uiLanguageCO->findData(toqstr(rc.gui_language));
+       uiLanguageCO->blockSignals(true);
+       uiLanguageCO->setCurrentIndex(pos);
+       uiLanguageCO->blockSignals(false);
 }
 
 
index b9064d68dc03d68b9bc1fe2395defe8a44f1aeb9..6aed28dfefe3ecee45ef259a53b5b4e94c843e69 100644 (file)
@@ -369,6 +369,9 @@ public:
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
+
+private Q_SLOTS:
+       void on_uiLanguageCO_currentIndexChanged(int);
 };
 
 
index 813baaa49a1ee47b4a3a63d4cf200da5778bda93..3628bbe23e64ec8867f147b4b8872542796a4a7a 100644 (file)
   <property name="windowTitle" >
    <string/>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
-   <item row="10" column="0" colspan="3" >
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" colspan="2" >
+    <widget class="QLabel" name="uiLanguageLA" >
+     <property name="text" >
+      <string>&amp;User Interface language:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>defaultLanguageCO</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2" >
+    <widget class="QComboBox" name="uiLanguageCO" >
+     <property name="toolTip" >
+      <string>Select the default language of your documents</string>
+     </property>
+     <property name="maxVisibleItems" >
+      <number>20</number>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="2" >
+    <widget class="QLabel" name="defaultLanguageLA" >
+     <property name="text" >
+      <string>&amp;Default language:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>defaultLanguageCO</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2" >
+    <widget class="QComboBox" name="defaultLanguageCO" >
+     <property name="toolTip" >
+      <string>Select the default language of your documents</string>
+     </property>
+     <property name="maxVisibleItems" >
+      <number>20</number>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2" >
+    <widget class="QLabel" name="languagePackageLA" >
+     <property name="text" >
+      <string>Language pac&amp;kage:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>languagePackageED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2" >
+    <widget class="QLineEdit" name="languagePackageED" >
+     <property name="toolTip" >
+      <string>Enter the command to load the language package (default: babel)</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="2" >
+    <widget class="QLabel" name="startCommandLA" >
+     <property name="text" >
+      <string>Command s&amp;tart:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>startCommandED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="2" >
+    <widget class="QLineEdit" name="startCommandED" >
+     <property name="toolTip" >
+      <string>The LaTeX command that starts a switch to a foreign language</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0" colspan="2" >
+    <widget class="QLabel" name="endCommandLA" >
+     <property name="text" >
+      <string>Command e&amp;nd:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>endCommandED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2" >
+    <widget class="QLineEdit" name="endCommandED" >
+     <property name="toolTip" >
+      <string>The LaTeX command that ends a switch to a foreign language</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="0" colspan="3" >
+    <widget class="QCheckBox" name="useBabelCB" >
+     <property name="toolTip" >
+      <string>Use the babel package for multilingual support</string>
+     </property>
+     <property name="text" >
+      <string>Use b&amp;abel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0" colspan="3" >
+    <widget class="QCheckBox" name="globalCB" >
+     <property name="toolTip" >
+      <string>Check to pass the language globally (to the document class), not locally (to the language package)</string>
+     </property>
+     <property name="text" >
+      <string>&amp;Global</string>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="0" colspan="3" >
+    <widget class="QCheckBox" name="autoBeginCB" >
+     <property name="toolTip" >
+      <string>If checked, the document language is not explicitely set by a language switch command</string>
+     </property>
+     <property name="text" >
+      <string>Auto &amp;begin</string>
+     </property>
+    </widget>
+   </item>
+   <item row="8" column="0" colspan="3" >
+    <widget class="QCheckBox" name="autoEndCB" >
+     <property name="toolTip" >
+      <string>If checked, the document language is not explicitely closed by a language switch command</string>
+     </property>
+     <property name="text" >
+      <string>Auto &amp;end</string>
+     </property>
+    </widget>
+   </item>
+   <item row="9" column="0" colspan="4" >
+    <widget class="QCheckBox" name="markForeignCB" >
+     <property name="toolTip" >
+      <string>Check to highlight foreign languages visually in the work area</string>
+     </property>
+     <property name="text" >
+      <string>Mark &amp;foreign languages</string>
+     </property>
+    </widget>
+   </item>
+   <item row="10" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>20</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="11" column="0" colspan="3" >
     <widget class="QGroupBox" name="rtlGB2" >
      <property name="toolTip" >
       <string/>
         <property name="orientation" >
          <enum>Qt::Horizontal</enum>
         </property>
-        <property name="sizeHint" >
+        <property name="sizeHint" stdset="0" >
          <size>
           <width>101</width>
           <height>20</height>
       </item>
       <item row="1" column="0" >
        <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>0</number>
-        </property>
         <property name="spacing" >
          <number>6</number>
         </property>
+        <property name="margin" >
+         <number>0</number>
+        </property>
         <item>
          <widget class="QLabel" name="cursorMovementLA" >
           <property name="text" >
      </layout>
     </widget>
    </item>
-   <item row="8" column="0" colspan="4" >
-    <widget class="QCheckBox" name="markForeignCB" >
-     <property name="toolTip" >
-      <string>Check to highlight foreign languages visually in the work area</string>
-     </property>
-     <property name="text" >
-      <string>Mark &amp;foreign languages</string>
-     </property>
-    </widget>
-   </item>
-   <item row="11" column="1" >
+   <item row="12" column="1" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      <property name="sizeType" >
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>20</width>
        <height>20</height>
      </property>
     </spacer>
    </item>
-   <item row="0" column="2" >
-    <widget class="QComboBox" name="defaultLanguageCO" >
-     <property name="toolTip" >
-      <string>Select the default language of your documents</string>
-     </property>
-     <property name="maxVisibleItems" >
-      <number>20</number>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="2" >
-    <widget class="QLineEdit" name="startCommandED" >
-     <property name="toolTip" >
-      <string>The LaTeX command that starts a switch to a foreign language</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="2" >
-    <widget class="QLineEdit" name="languagePackageED" >
-     <property name="toolTip" >
-      <string>Enter the command to load the language package (default: babel)</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="2" >
-    <widget class="QLineEdit" name="endCommandED" >
-     <property name="toolTip" >
-      <string>The LaTeX command that ends a switch to a foreign language</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="3" >
+   <item row="2" column="3" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>40</width>
        <height>20</height>
      </property>
     </spacer>
    </item>
-   <item row="0" column="0" colspan="2" >
-    <widget class="QLabel" name="defaultLanguageLA" >
-     <property name="text" >
-      <string>&amp;Default language:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>defaultLanguageCO</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0" colspan="2" >
-    <widget class="QLabel" name="languagePackageLA" >
-     <property name="text" >
-      <string>Language pac&amp;kage:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>languagePackageED</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="0" colspan="2" >
-    <widget class="QLabel" name="startCommandLA" >
-     <property name="text" >
-      <string>Command s&amp;tart:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>startCommandED</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0" colspan="2" >
-    <widget class="QLabel" name="endCommandLA" >
-     <property name="text" >
-      <string>Command e&amp;nd:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>endCommandED</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="0" colspan="3" >
-    <widget class="QCheckBox" name="globalCB" >
-     <property name="toolTip" >
-      <string>Check to pass the language globally (to the document class), not locally (to the language package)</string>
-     </property>
-     <property name="text" >
-      <string>&amp;Global</string>
-     </property>
-    </widget>
-   </item>
-   <item row="6" column="0" colspan="3" >
-    <widget class="QCheckBox" name="autoBeginCB" >
-     <property name="toolTip" >
-      <string>If checked, the document language is not explicitely set by a language switch command</string>
-     </property>
-     <property name="text" >
-      <string>Auto &amp;begin</string>
-     </property>
-    </widget>
-   </item>
-   <item row="7" column="0" colspan="3" >
-    <widget class="QCheckBox" name="autoEndCB" >
-     <property name="toolTip" >
-      <string>If checked, the document language is not explicitely closed by a language switch command</string>
-     </property>
-     <property name="text" >
-      <string>Auto &amp;end</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0" colspan="3" >
-    <widget class="QCheckBox" name="useBabelCB" >
-     <property name="toolTip" >
-      <string>Use the babel package for multilingual support</string>
-     </property>
-     <property name="text" >
-      <string>Use b&amp;abel</string>
-     </property>
-    </widget>
-   </item>
-   <item row="9" column="0" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>20</width>
-       <height>16</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
   </layout>
  </widget>
  <tabstops>