Harmonize input encoding selection widgets.

See #11115.
This commit is contained in:
Günter Milde 2019-06-18 15:42:18 +02:00
parent b0a73c0dfd
commit 53500242f9
2 changed files with 49 additions and 32 deletions

View File

@ -942,10 +942,10 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(encodingSwitched(int))); this, SLOT(encodingSwitched(int)));
connect(langModule->unicodeEncodingCO, SIGNAL(activated(int)), connect(langModule->unicodeEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(langModule->autoEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(langModule->customEncodingCO, SIGNAL(activated(int)), connect(langModule->customEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(langModule->noInputencCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(langModule->quoteStyleCO, SIGNAL(activated(int)), connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(langModule->languagePackageCO, SIGNAL(activated(int)), connect(langModule->languagePackageCO, SIGNAL(activated(int)),
@ -967,15 +967,15 @@ GuiDocument::GuiDocument(GuiView & lv)
langModule->languageCO->setModelColumn(0); langModule->languageCO->setModelColumn(0);
langModule->encodingCO->addItem(qt_("Unicode (utf8)")); langModule->encodingCO->addItem(qt_("Unicode (utf8)"));
langModule->encodingCO->addItem(qt_("Traditional (auto-selected)")); langModule->encodingCO->addItem(qt_("Legacy (auto-selected)"));
langModule->encodingCO->addItem(qt_("Custom")); langModule->encodingCO->addItem(qt_("Custom"));
langModule->encodingCO->setItemData(EncodingSets::unicode, langModule->encodingCO->setItemData(EncodingSets::unicode,
"Use Unicode (utf8) for the latex source.", Qt::ToolTipRole); "Select Unicode (utf8) encoding.", Qt::ToolTipRole);
langModule->encodingCO->setItemData(EncodingSets::legacy, langModule->encodingCO->setItemData(EncodingSets::legacy,
"Use legacy default encodings depending on text language.", Qt::ToolTipRole); "Use language-dependent legacy encodings.", Qt::ToolTipRole);
langModule->encodingCO->setItemData(EncodingSets::custom, langModule->encodingCO->setItemData(EncodingSets::custom,
"Select a custom, document-wide encoding.", Qt::ToolTipRole); "Select a custom, document-wide encoding.", Qt::ToolTipRole);
QMap<QString,QString> encodingmap_utf8; QMap<QString,QString> encodingmap_utf8;
for (auto const & encvar : encodings) { for (auto const & encvar : encodings) {
if (!encvar.unsafe() && !encvar.guiName().empty() if (!encvar.unsafe() && !encvar.guiName().empty()
@ -988,6 +988,17 @@ GuiDocument::GuiDocument(GuiView & lv)
++it8; ++it8;
} }
langModule->autoEncodingCO->addItem(qt_("Language Default"), toqstr("auto-legacy"));
langModule->autoEncodingCO->addItem(qt_("Language Default (no inputenc)"), toqstr("auto-legacy-plain"));
langModule->autoEncodingCO->setItemData(0,
"Use the legacy default encoding of the text language. "
"Switch encoding if a text part has a different default.",
Qt::ToolTipRole);
langModule->autoEncodingCO->setItemData(1,
"Do not load the 'inputenc' package "
"nor write input encoding switch commands to the source.",
Qt::ToolTipRole);
QMap<QString,QString> encodingmap; QMap<QString,QString> encodingmap;
for (auto const & encvar : encodings) { for (auto const & encvar : encodings) {
if (!encvar.unsafe() && !encvar.guiName().empty() if (!encvar.unsafe() && !encvar.guiName().empty()
@ -1000,10 +1011,10 @@ GuiDocument::GuiDocument(GuiView & lv)
++it; ++it;
} }
// equalise the width of encoding selectors // equalise the width of encoding selectors
langModule->unicodeEncodingCO->setMinimumSize( langModule->autoEncodingCO->setMinimumSize(
langModule->customEncodingCO->minimumSizeHint()); langModule->unicodeEncodingCO->minimumSizeHint());
langModule->noInputencCB->setMinimumSize( langModule->customEncodingCO->setMinimumSize(
langModule->customEncodingCO->minimumSizeHint()); langModule->unicodeEncodingCO->minimumSizeHint());
langModule->languagePackageCO->addItem( langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default")); qt_("Default"), toqstr("default"));
@ -2316,9 +2327,9 @@ void GuiDocument::encodingSwitched(int i)
bool const tex_fonts = !fontModule->osFontsCB->isChecked(); bool const tex_fonts = !fontModule->osFontsCB->isChecked();
langModule->unicodeEncodingCO->setEnabled(tex_fonts); langModule->unicodeEncodingCO->setEnabled(tex_fonts);
langModule->customEncodingCO->setEnabled(tex_fonts); langModule->customEncodingCO->setEnabled(tex_fonts);
langModule->noInputencCB->setEnabled(tex_fonts); langModule->autoEncodingCO->setEnabled(tex_fonts);
langModule->unicodeEncodingCO->setVisible(i == EncodingSets::unicode); langModule->unicodeEncodingCO->setVisible(i == EncodingSets::unicode);
langModule->noInputencCB->setVisible(i == EncodingSets::legacy); langModule->autoEncodingCO->setVisible(i == EncodingSets::legacy);
langModule->customEncodingCO->setVisible(i == EncodingSets::custom); langModule->customEncodingCO->setVisible(i == EncodingSets::custom);
} }
@ -2330,21 +2341,34 @@ void GuiDocument::inputencodingToDialog()
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode); langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
langModule->unicodeEncodingCO->setCurrentIndex( langModule->unicodeEncodingCO->setCurrentIndex(
langModule->unicodeEncodingCO->findData("utf8-plain")); langModule->unicodeEncodingCO->findData("utf8-plain"));
langModule->autoEncodingCO->setCurrentIndex(0);
langModule->customEncodingCO->setCurrentIndex(0);
} else if (inputenc.startsWith("utf8")) { } else if (inputenc.startsWith("utf8")) {
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode); langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
p = langModule->unicodeEncodingCO->findData(inputenc); p = langModule->unicodeEncodingCO->findData(inputenc);
if (p != -1) if (p == -1)
langModule->unicodeEncodingCO->setCurrentIndex(p); p = 0;
langModule->unicodeEncodingCO->setCurrentIndex(p);
langModule->autoEncodingCO->setCurrentIndex(0);
langModule->customEncodingCO->setCurrentIndex(0);
} else if (inputenc.startsWith("auto")) { } else if (inputenc.startsWith("auto")) {
langModule->encodingCO->setCurrentIndex(EncodingSets::legacy); langModule->encodingCO->setCurrentIndex(EncodingSets::legacy);
langModule->noInputencCB->setChecked(inputenc == "auto-legacy-plain"); p = langModule->autoEncodingCO->findData(inputenc);
if (p == -1)
p = 0;
langModule->unicodeEncodingCO->setCurrentIndex(0);
langModule->autoEncodingCO->setCurrentIndex(p);
langModule->customEncodingCO->setCurrentIndex(0);
} else { } else {
langModule->encodingCO->setCurrentIndex(EncodingSets::custom); langModule->encodingCO->setCurrentIndex(EncodingSets::custom);
p = langModule->customEncodingCO->findData(inputenc); p = langModule->customEncodingCO->findData(inputenc);
if (p != -1) if (p == -1) {
langModule->customEncodingCO->setCurrentIndex(p); p = 0;
else
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode); langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
}
langModule->unicodeEncodingCO->setCurrentIndex(0);
langModule->autoEncodingCO->setCurrentIndex(0);
langModule->customEncodingCO->setCurrentIndex(p);
} }
encodingSwitched(langModule->encodingCO->currentIndex()); encodingSwitched(langModule->encodingCO->currentIndex());
} }
@ -3300,8 +3324,8 @@ void GuiDocument::applyView()
} }
case EncodingSets::legacy: { case EncodingSets::legacy: {
bp_.inputenc = "auto-legacy"; bp_.inputenc = "auto-legacy";
if (langModule->noInputencCB->isChecked()) bp_.inputenc = fromqstr(langModule->autoEncodingCO->itemData(
bp_.inputenc = "auto-legacy-plain"; langModule->autoEncodingCO->currentIndex()).toString());
break; break;
} }
case EncodingSets::custom: { case EncodingSets::custom: {

View File

@ -113,24 +113,17 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Select Unicode (utf8) variant.</string> <string>Select Unicode encoding variant.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QCheckBox" name="noInputencCB"> <widget class="QComboBox" name="autoEncodingCO">
<property name="Checked"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Do not load inputenc</string>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Do not to load the 'inputenc' package <string>Specify whether to load the 'inputenc' package.</string>
nor write input encoding switch commands to the source.</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -140,7 +133,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Select encoding</string> <string>Select custom encoding.</string>
</property> </property>
</widget> </widget>
</item> </item>