]> git.lyx.org Git - features.git/commitdiff
GuiDocument: Further encoding GUI improvement
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 12 May 2019 07:10:24 +0000 (09:10 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 12 May 2019 07:10:24 +0000 (09:10 +0200)
Move the odd "(no inputenc)" option out of the encoding list.

src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/ui/LanguageUi.ui

index 666c45178650ec45296be85a3cd4f28430c3ff12..23bb35cb8752e6a10bf98cdf329cb73302015095 100644 (file)
@@ -937,6 +937,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(encodingSwitched(int)));
        connect(langModule->customEncodingCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
+       connect(langModule->noInputencCB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
        connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
        connect(langModule->languagePackageCO, SIGNAL(activated(int)),
@@ -962,9 +964,7 @@ GuiDocument::GuiDocument(GuiView & lv)
                                        toqstr("auto-legacy"));
        langModule->encodingCO->addItem(qt_("ASCII"), toqstr("ascii"));
        langModule->encodingCO->addItem(qt_("Custom"), toqstr("custom"));
-       // Always put the default encoding in the first position.
-       langModule->customEncodingCO->addItem(qt_("Traditional (inputenc not loaded)"),
-                                             toqstr("auto-legacy-plain"));
+
        QMap<QString,QString> encodingmap;
        for (auto const & encvar : encodings) {
                if (!encvar.unsafe() && !encvar.guiName().empty())
@@ -2258,6 +2258,10 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
                langModule->encodingCO->itemData(
                        langModule->encodingCO->currentIndex()).toString() == "custom");
        langModule->encodingCO->setEnabled(tex_fonts);
+       langModule->noInputencCB->setEnabled(tex_fonts
+                                            && langModule->encodingCO->currentIndex() < 2);
+       if (!tex_fonts)
+               langModule->noInputencCB->setChecked(false);
 
        fontModule->fontsDefaultCO->setEnabled(tex_fonts);
        fontModule->fontsDefaultLA->setEnabled(tex_fonts);
@@ -2280,6 +2284,11 @@ void GuiDocument::encodingSwitched(int i)
        langModule->customEncodingCO->setEnabled(
                                !fontModule->osFontsCB->isChecked()
                                && langModule->encodingCO->itemData(i).toString() == "custom");
+       langModule->noInputencCB->setEnabled(!fontModule->osFontsCB->isChecked()
+                                            && langModule->encodingCO->currentIndex() < 2);
+       if (!langModule->noInputencCB->isEnabled())
+               langModule->noInputencCB->setChecked(false);
+
 }
 
 
@@ -3233,6 +3242,9 @@ void GuiDocument::applyView()
        else
                bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
                                        langModule->customEncodingCO->currentIndex()).toString());
+       if (langModule->noInputencCB->isChecked()
+           && (encoding == "auto-legacy" || encoding == "utf8"))
+               bp_.inputenc += "-plain";
 
        bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
                langModule->quoteStyleCO->currentIndex()).toInt();
@@ -3724,13 +3736,20 @@ void GuiDocument::paramsToDialog()
                langModule->quoteStyleCO->findData(bp_.quotes_style));
        langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
 
-       int p = langModule->encodingCO->findData(toqstr(bp_.inputenc));
+       QString inputenc = toqstr(bp_.inputenc);
+       bool plain = false;
+       if (inputenc.endsWith("-plain")) {
+               inputenc = inputenc.left(inputenc.lastIndexOf("-plain"));
+               plain = true;
+       }
+       langModule->noInputencCB->setChecked(plain);
+       int p = langModule->encodingCO->findData(inputenc);
        if (p != -1)
                langModule->encodingCO->setCurrentIndex(p);
        else {
                langModule->encodingCO->setCurrentIndex(
                          langModule->encodingCO->findData("custom"));
-               p = langModule->customEncodingCO->findData(toqstr(bp_.inputenc));
+               p = langModule->customEncodingCO->findData(inputenc);
                if (p != -1)
                        langModule->customEncodingCO->setCurrentIndex(p);
                else
index 77d5496cfeb47cd4c6c7c733b93906a5ad018296..e4e365da9adeba9315225d6ee8c6addd9e43c4db 100644 (file)
    </item>
    <item row="1" column="0" colspan="2">
     <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="2">
+      <widget class="QComboBox" name="customEncodingCO">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="toolTip">
+        <string>If you selected a custom output encoding to the left, yo can specifiy it here</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QComboBox" name="languagePackageCO">
+       <property name="toolTip">
+        <string>Select which language package LyX should use</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="languagePackageLA">
+       <property name="text">
+        <string>Language pa&amp;ckage:</string>
+       </property>
+       <property name="buddy">
+        <cstring>languagePackageCO</cstring>
+       </property>
+      </widget>
+     </item>
      <item row="0" column="0">
       <widget class="QLabel" name="encodingLA">
        <property name="text">
        </property>
       </widget>
      </item>
-     <item row="0" column="2">
-      <widget class="QComboBox" name="customEncodingCO">
-       <property name="enabled">
-        <bool>false</bool>
-       </property>
+     <item row="2" column="2">
+      <widget class="QLineEdit" name="languagePackageLE">
        <property name="toolTip">
-        <string>If you selected a custom output encoding to the left, yo can specifiy it here</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="languagePackageLA">
-       <property name="text">
-        <string>Language pa&amp;ckage:</string>
-       </property>
-       <property name="buddy">
-        <cstring>languagePackageCO</cstring>
+        <string>Enter the command to load the language package (default: \usepackage{babel})</string>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
-      <widget class="QComboBox" name="languagePackageCO">
+      <widget class="QCheckBox" name="noInputencCB">
        <property name="toolTip">
-        <string>Select which language package LyX should use</string>
+        <string>If this is checked, LyX does not load the inputenc LaTeX package</string>
        </property>
-      </widget>
-     </item>
-     <item row="1" column="2">
-      <widget class="QLineEdit" name="languagePackageLE">
-       <property name="toolTip">
-        <string>Enter the command to load the language package (default: \usepackage{babel})</string>
+       <property name="text">
+        <string>Do not load &amp;inputenc</string>
        </property>
       </widget>
      </item>