Revert 051de65db and implement alternative fix for remainder of #11115.

This commit is contained in:
Günter Milde 2019-06-12 11:48:47 +02:00
parent b881cf8fd7
commit c627507b3f
4 changed files with 143 additions and 139 deletions

View File

@ -47,12 +47,12 @@
# and pt254.
# inputenc's standard utf8 support:
Encoding utf8 utf8 "utf8 (default)" UTF-8 variable inputenc
Encoding utf8 utf8 "Default" UTF-8 variable inputenc
End
# extended utf8 support from the "ucs" package:
# Larger set of supported characters but conflicts with some packages.
Encoding utf8x utf8x "utf8 (extended) [ucs] (utf8x)" UTF-8 variable inputenc
Encoding utf8x utf8x "Extended [ucs] (utf8x)" UTF-8 variable inputenc
End
# from http://www.ctan.org/pkg/armtex
@ -212,7 +212,7 @@ Encoding euc-kr KS "Korean (EUC-KR)" EUC-KR variable CJK
End
# The CJK package has yet another name for utf8...
Encoding utf8-cjk UTF8 "utf8 [CJK] (Chinese/Japanese/Korean)" UTF-8 variable CJK
Encoding utf8-cjk UTF8 "Extended [CJK] (Chinese/Japanese/Korean)" UTF-8 variable CJK
End
# For traditional chinese
@ -233,13 +233,13 @@ Encoding jis-platex jis "Japanese (pLaTeX) (JIS)" ISO-2022-JP variable japanese
End
Encoding shift-jis-platex sjis "Japanese (pLaTeX) (SJIS)" CP932 variable japanese
End
Encoding utf8-platex utf8 "utf8 [pLaTeX] (Japanese)" UTF-8 variable japanese
Encoding utf8-platex utf8 "Extended [pLaTeX] (Japanese)" UTF-8 variable japanese
End
# A plain utf8 encoding that does not use the inputenc package
# nor the LyX-added conversions in lib/unicodesymbols.
# Such an encoding is required for XeTeX and LuaTeX.
Encoding utf8-plain utf8-plain "utf8 (pass-through)" UTF-8 variable none
Encoding utf8-plain utf8-plain "Pass-Through" UTF-8 variable none
End
# Pure 7bit ASCII encoding (partially hardcoded in LyX)

View File

@ -156,6 +156,11 @@ QMap<QString, QString> sffonts_;
QMap<QString, QString> ttfonts_;
QMap<QString, QString> mathfonts_;
enum EncodingSets {
unicode = 0,
legacy = 1,
custom = 2
};
} // anonymous namespace
@ -931,18 +936,16 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(langModule->languageCO, SIGNAL(activated(int)),
this, SLOT(languageChanged(int)));
connect(langModule->encodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(langModule->encodingCO, SIGNAL(activated(int)),
this, SLOT(encodingSwitched(int)));
connect(langModule->unicodeEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(langModule->autoEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
this, SLOT(change_adaptor()));
connect(langModule->customEncodingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(langModule->autoEncodingRB, SIGNAL(toggled(bool)),
this, SLOT(change_encoding()));
connect(langModule->unicodeEncodingRB, SIGNAL(toggled(bool)),
this, SLOT(change_encoding()));
connect(langModule->customEncodingRB, SIGNAL(toggled(bool)),
this, SLOT(change_encoding()));
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)),
@ -963,6 +966,16 @@ GuiDocument::GuiDocument(GuiView & lv)
langModule->languageCO->setModel(language_model);
langModule->languageCO->setModelColumn(0);
langModule->encodingCO->addItem(qt_("Unicode (utf8)"));
langModule->encodingCO->addItem(qt_("Traditional (auto-selected)"));
langModule->encodingCO->addItem(qt_("Custom"));
langModule->encodingCO->setItemData(EncodingSets::unicode,
"Use Unicode (utf8) for the latex source.", Qt::ToolTipRole);
langModule->encodingCO->setItemData(EncodingSets::legacy,
"Use legacy default encodings depending on text language.", Qt::ToolTipRole);
langModule->encodingCO->setItemData(EncodingSets::custom,
"Select a custom, document-wide encoding.", Qt::ToolTipRole);
QMap<QString,QString> encodingmap_utf8;
for (auto const & encvar : encodings) {
if (!encvar.unsafe() && !encvar.guiName().empty()
@ -975,9 +988,6 @@ GuiDocument::GuiDocument(GuiView & lv)
++it8;
}
langModule->autoEncodingCO->addItem(qt_("legacy language default"), toqstr("auto-legacy"));
langModule->autoEncodingCO->addItem(qt_("legacy language default (no inputenc)"), toqstr("auto-legacy-plain"));
QMap<QString,QString> encodingmap;
for (auto const & encvar : encodings) {
if (!encvar.unsafe() && !encvar.guiName().empty()
@ -989,6 +999,11 @@ GuiDocument::GuiDocument(GuiView & lv)
langModule->customEncodingCO->addItem(it.key(), it.value());
++it;
}
// equalise the width of encoding selectors
langModule->unicodeEncodingCO->setMinimumSize(
langModule->customEncodingCO->minimumSizeHint());
langModule->noInputencCB->setMinimumSize(
langModule->customEncodingCO->minimumSizeHint());
langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default"));
@ -1734,12 +1749,6 @@ void GuiDocument::change_adaptor()
changed();
}
void GuiDocument::change_encoding()
{
encodingSwitched();
nonModuleChanged_ = true;
changed();
}
void GuiDocument::shellescapeChanged()
{
@ -2281,11 +2290,10 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
fontModule->font_math = font_math;
fontModule->font_sf_scale = font_sf_scale;
fontModule->font_tt_scale = font_tt_scale;
// enable/disable input encoding selection
langModule->unicodeEncodingRB->setEnabled(tex_fonts);
langModule->autoEncodingRB->setEnabled(tex_fonts);
langModule->customEncodingRB->setEnabled(tex_fonts);
encodingSwitched();
// non-tex fonts override the "\inputencoding" option with "utf8-plain"
langModule->encodingCO->setEnabled(tex_fonts);
inputencodingToDialog();
fontModule->fontsDefaultCO->setEnabled(tex_fonts);
fontModule->fontsDefaultLA->setEnabled(tex_fonts);
@ -2303,15 +2311,42 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
}
void GuiDocument::encodingSwitched()
void GuiDocument::encodingSwitched(int i)
{
bool const tex_fonts = !fontModule->osFontsCB->isChecked();
langModule->unicodeEncodingCO->setEnabled(tex_fonts
&& langModule->unicodeEncodingRB->isChecked());
langModule->autoEncodingCO->setEnabled(tex_fonts
&& langModule->autoEncodingRB->isChecked());
langModule->customEncodingCO->setEnabled(tex_fonts
&& langModule->customEncodingRB->isChecked());
langModule->unicodeEncodingCO->setEnabled(tex_fonts);
langModule->customEncodingCO->setEnabled(tex_fonts);
langModule->noInputencCB->setEnabled(tex_fonts);
langModule->unicodeEncodingCO->setVisible(i == EncodingSets::unicode);
langModule->noInputencCB->setVisible(i == EncodingSets::legacy);
langModule->customEncodingCO->setVisible(i == EncodingSets::custom);
}
void GuiDocument::inputencodingToDialog()
{
QString inputenc = toqstr(bp_.inputenc);
int p;
if (fontModule->osFontsCB->isChecked()) { // non-tex fonts require utf8-plain
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
langModule->unicodeEncodingCO->setCurrentIndex(
langModule->unicodeEncodingCO->findData("utf8-plain"));
} else if (inputenc.startsWith("utf8")) {
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
p = langModule->unicodeEncodingCO->findData(inputenc);
if (p != -1)
langModule->unicodeEncodingCO->setCurrentIndex(p);
} else if (inputenc.startsWith("auto")) {
langModule->encodingCO->setCurrentIndex(EncodingSets::legacy);
langModule->noInputencCB->setChecked(inputenc == "auto-legacy-plain");
} else {
langModule->encodingCO->setCurrentIndex(EncodingSets::custom);
p = langModule->customEncodingCO->findData(inputenc);
if (p != -1)
langModule->customEncodingCO->setCurrentIndex(p);
else
langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
}
encodingSwitched(langModule->encodingCO->currentIndex());
}
@ -3257,18 +3292,27 @@ void GuiDocument::applyView()
indicesModule->apply(bp_);
// language & quotes
if (langModule->unicodeEncodingRB->isChecked())
bp_.inputenc = fromqstr(langModule->unicodeEncodingCO->itemData(
langModule->unicodeEncodingCO->currentIndex()).toString());
else if (langModule->autoEncodingRB->isChecked())
bp_.inputenc = fromqstr(langModule->autoEncodingCO->itemData(
langModule->autoEncodingCO->currentIndex()).toString());
else if (langModule->customEncodingRB->isChecked())
bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
langModule->customEncodingCO->currentIndex()).toString());
else // this should never happen
bp_.inputenc = "utf8";
switch (langModule->encodingCO->currentIndex()) {
case EncodingSets::unicode: {
bp_.inputenc = fromqstr(langModule->unicodeEncodingCO->itemData(
langModule->unicodeEncodingCO->currentIndex()).toString());
break;
}
case EncodingSets::legacy: {
bp_.inputenc = "auto-legacy";
if (langModule->noInputencCB->isChecked())
bp_.inputenc = "auto-legacy-plain";
break;
}
case EncodingSets::custom: {
bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
langModule->customEncodingCO->currentIndex()).toString());
break;
}
default:
// this should never happen
bp_.inputenc = "utf8";
}
bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
langModule->quoteStyleCO->currentIndex()).toInt();
bp_.dynamic_quotes = langModule->dynamicQuotesCB->isChecked();
@ -3760,31 +3804,10 @@ void GuiDocument::paramsToDialog()
langModule->quoteStyleCO->setCurrentIndex(
langModule->quoteStyleCO->findData(bp_.quotes_style));
langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
// LaTeX input encoding
QString inputenc = toqstr(bp_.inputenc);
int p;
if (inputenc.startsWith("utf8")) {
langModule->unicodeEncodingRB->setChecked(true);
p = langModule->unicodeEncodingCO->findData(inputenc);
if (p != -1) {
langModule->unicodeEncodingCO->setCurrentIndex(p);
}
} else if (inputenc.startsWith("auto")) {
langModule->autoEncodingRB->setChecked(true);
p = langModule->autoEncodingCO->findData(inputenc);
if (p != -1) {
langModule->autoEncodingCO->setCurrentIndex(p);
}
} else {
langModule->customEncodingRB->setChecked(true);
p = langModule->customEncodingCO->findData(inputenc);
if (p != -1) {
langModule->customEncodingCO->setCurrentIndex(p);
}
}
encodingSwitched();
// language package
p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
// LaTeX input encoding: set after the fonts (see below)
int p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
if (p == -1) {
langModule->languagePackageCO->setCurrentIndex(
langModule->languagePackageCO->findData("custom"));
@ -4141,6 +4164,10 @@ void GuiDocument::paramsToDialog()
fontModule->fontencLE->setText(toqstr(bp_.fontenc));
}
// LaTeX input encoding
// Set after fonts because non-tex fonts override "\inputencoding".
inputencodingToDialog();
// Formats
// This must be set _after_ fonts since updateDefaultFormat()
// checks osFontsCB settings.

View File

@ -101,7 +101,6 @@ public Q_SLOTS:
private Q_SLOTS:
void updateNumbering();
void change_adaptor();
void change_encoding();
void shellescapeChanged();
void includeonlyClicked(QTreeWidgetItem * item, int);
void setListingsMessage();
@ -153,7 +152,8 @@ private Q_SLOTS:
void deleteBoxBackgroundColor();
void languageChanged(int);
void osFontsChanged(bool);
void encodingSwitched();
void encodingSwitched(int);
void inputencodingToDialog();
void mathFontChanged(int);
void branchesRename(docstring const &, docstring const &);
void allPackagesAuto();

View File

@ -83,30 +83,60 @@
</item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="encodingLA">
<property name="text">
<string>&amp;Encoding:</string>
</property>
<property name="buddy">
<cstring>encodingCO</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="encodingCO">
<property name="enabled">
<bool>true</bool>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Select encoding of the generated LaTeX source
(LaTeX input encoding).</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="unicodeEncodingCO">
<property name="enabled">
<bool>false</bool>
<property name="visible">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select Unicode (utf8) variant.</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="autoEncodingCO">
<property name="enabled">
<item row="0" column="2">
<widget class="QCheckBox" name="noInputencCB">
<property name="Checked">
<bool>false</bool>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Do not load inputenc</string>
</property>
<property name="toolTip">
<string>Specify whether to load the 'inputenc' package
and write input encoding switch commands to the source.</string>
<string>Do not to load the 'inputenc' package
nor write input encoding switch commands to the source.</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="0" column="2">
<widget class="QComboBox" name="customEncodingCO">
<property name="enabled">
<property name="visible">
<bool>false</bool>
</property>
<property name="toolTip">
@ -114,13 +144,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="languagePackageCO">
<property name="toolTip">
<string>Select which language package LyX should use</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="languagePackageLA">
<property name="text">
@ -131,56 +154,10 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="encodingLA">
<property name="text">
<string>&amp;Encoding:</string>
</property>
<item row="3" column="1">
<widget class="QComboBox" name="languagePackageCO">
<property name="toolTip">
<string>Encoding of the generated LaTeX source
(LaTeX input encoding).</string>
</property>
<property name="buddy">
<cstring>unicodeEncodingRB</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="unicodeEncodingRB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Unicode</string>
</property>
<property name="toolTip">
<string>Set input encoding to Unicode (utf8).</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="autoEncodingRB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Automatic</string>
</property>
<property name="toolTip">
<string>Use language specific legacy encodings.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="customEncodingRB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Custom</string>
</property>
<property name="toolTip">
<string>Use custom document-wide encoding.</string>
<string>Select which language package LyX should use</string>
</property>
</widget>
</item>