Fix remainder of #11115.

Implement GUI suggestions from
https://www.lyx.org/trac/ticket/11115#comment:26
This commit is contained in:
Günter Milde 2019-06-05 11:16:25 +02:00
parent 4268a9e812
commit 051de65db9
4 changed files with 146 additions and 81 deletions

View File

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

View File

@ -865,7 +865,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// initialize the length validator // initialize the length validator
bc().addCheckedLineEdit(textLayoutModule->indentLE); bc().addCheckedLineEdit(textLayoutModule->indentLE);
bc().addCheckedLineEdit(textLayoutModule->skipLE); bc().addCheckedLineEdit(textLayoutModule->skipLE);
textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default")); textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default"));
getTableStyles(); getTableStyles();
@ -931,14 +931,18 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(langModule->languageCO, SIGNAL(activated(int)), connect(langModule->languageCO, SIGNAL(activated(int)),
this, SLOT(languageChanged(int))); this, SLOT(languageChanged(int)));
connect(langModule->encodingCO, SIGNAL(activated(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->encodingCO, SIGNAL(activated(int)),
this, SLOT(encodingSwitched(int)));
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()), connect(langModule->autoEncodingRB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor())); 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->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)),
@ -959,15 +963,25 @@ GuiDocument::GuiDocument(GuiView & lv)
langModule->languageCO->setModel(language_model); langModule->languageCO->setModel(language_model);
langModule->languageCO->setModelColumn(0); langModule->languageCO->setModelColumn(0);
langModule->encodingCO->addItem(qt_("Unicode (utf8)"), toqstr("utf8")); QMap<QString,QString> encodingmap_utf8;
langModule->encodingCO->addItem(qt_("Traditional (auto-selected)"), for (auto const & encvar : encodings) {
toqstr("auto-legacy")); if (!encvar.unsafe() && !encvar.guiName().empty()
// langModule->encodingCO->addItem(qt_("ASCII"), toqstr("ascii")); && std::string(encvar.name()).find("utf8") == 0)
langModule->encodingCO->addItem(qt_("Custom"), toqstr("custom")); encodingmap_utf8.insert(qt_(encvar.guiName()), qt_(encvar.name()));
}
QMap<QString, QString>::const_iterator it8 = encodingmap_utf8.constBegin();
while (it8 != encodingmap_utf8.constEnd()) {
langModule->unicodeEncodingCO->addItem(it8.key(), it8.value());
++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; 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()
&& std::string(encvar.name()).find("utf8") != 0)
encodingmap.insert(qt_(encvar.guiName()), qt_(encvar.name())); encodingmap.insert(qt_(encvar.guiName()), qt_(encvar.name()));
} }
QMap<QString, QString>::const_iterator it = encodingmap.constBegin(); QMap<QString, QString>::const_iterator it = encodingmap.constBegin();
@ -1720,6 +1734,12 @@ void GuiDocument::change_adaptor()
changed(); changed();
} }
void GuiDocument::change_encoding()
{
encodingSwitched();
nonModuleChanged_ = true;
changed();
}
void GuiDocument::shellescapeChanged() void GuiDocument::shellescapeChanged()
{ {
@ -2261,15 +2281,11 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
fontModule->font_math = font_math; fontModule->font_math = font_math;
fontModule->font_sf_scale = font_sf_scale; fontModule->font_sf_scale = font_sf_scale;
fontModule->font_tt_scale = font_tt_scale; fontModule->font_tt_scale = font_tt_scale;
// enable/disable input encoding selection
langModule->customEncodingCO->setEnabled(tex_fonts && langModule->unicodeEncodingRB->setEnabled(tex_fonts);
langModule->encodingCO->itemData( langModule->autoEncodingRB->setEnabled(tex_fonts);
langModule->encodingCO->currentIndex()).toString() == "custom"); langModule->customEncodingRB->setEnabled(tex_fonts);
langModule->encodingCO->setEnabled(tex_fonts); encodingSwitched();
langModule->noInputencCB->setEnabled(tex_fonts
&& langModule->encodingCO->currentIndex() < 2);
if (!tex_fonts)
langModule->noInputencCB->setChecked(false);
fontModule->fontsDefaultCO->setEnabled(tex_fonts); fontModule->fontsDefaultCO->setEnabled(tex_fonts);
fontModule->fontsDefaultLA->setEnabled(tex_fonts); fontModule->fontsDefaultLA->setEnabled(tex_fonts);
@ -2287,16 +2303,15 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
} }
void GuiDocument::encodingSwitched(int i) void GuiDocument::encodingSwitched()
{ {
langModule->customEncodingCO->setEnabled( bool const tex_fonts = !fontModule->osFontsCB->isChecked();
!fontModule->osFontsCB->isChecked() langModule->unicodeEncodingCO->setEnabled(tex_fonts
&& langModule->encodingCO->itemData(i).toString() == "custom"); && langModule->unicodeEncodingRB->isChecked());
langModule->noInputencCB->setEnabled(!fontModule->osFontsCB->isChecked() langModule->autoEncodingCO->setEnabled(tex_fonts
&& langModule->encodingCO->currentIndex() < 2); && langModule->autoEncodingRB->isChecked());
if (!langModule->noInputencCB->isEnabled()) langModule->customEncodingCO->setEnabled(tex_fonts
langModule->noInputencCB->setChecked(false); && langModule->customEncodingRB->isChecked());
} }
@ -3242,16 +3257,17 @@ void GuiDocument::applyView()
indicesModule->apply(bp_); indicesModule->apply(bp_);
// language & quotes // language & quotes
QString const encoding = langModule->encodingCO->itemData( if (langModule->unicodeEncodingRB->isChecked())
langModule->encodingCO->currentIndex()).toString(); bp_.inputenc = fromqstr(langModule->unicodeEncodingCO->itemData(
if (encoding != "custom") langModule->unicodeEncodingCO->currentIndex()).toString());
bp_.inputenc = fromqstr(encoding); else if (langModule->autoEncodingRB->isChecked())
else bp_.inputenc = fromqstr(langModule->autoEncodingCO->itemData(
langModule->autoEncodingCO->currentIndex()).toString());
else if (langModule->customEncodingRB->isChecked())
bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData( bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
langModule->customEncodingCO->currentIndex()).toString()); langModule->customEncodingCO->currentIndex()).toString());
if (langModule->noInputencCB->isChecked() else // this should never happen
&& (encoding == "auto-legacy" || encoding == "utf8")) bp_.inputenc = "utf8";
bp_.inputenc += "-plain";
bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData( bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
langModule->quoteStyleCO->currentIndex()).toInt(); langModule->quoteStyleCO->currentIndex()).toInt();
@ -3744,27 +3760,30 @@ void GuiDocument::paramsToDialog()
langModule->quoteStyleCO->setCurrentIndex( langModule->quoteStyleCO->setCurrentIndex(
langModule->quoteStyleCO->findData(bp_.quotes_style)); langModule->quoteStyleCO->findData(bp_.quotes_style));
langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes); langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
// LaTeX input encoding
QString inputenc = toqstr(bp_.inputenc); QString inputenc = toqstr(bp_.inputenc);
bool plain = false; int p;
if (inputenc.endsWith("-plain")) { if (inputenc.startsWith("utf8")) {
inputenc = inputenc.left(inputenc.lastIndexOf("-plain")); langModule->unicodeEncodingRB->setChecked(true);
plain = true; p = langModule->unicodeEncodingCO->findData(inputenc);
} if (p != -1) {
langModule->noInputencCB->setChecked(plain); langModule->unicodeEncodingCO->setCurrentIndex(p);
int p = langModule->encodingCO->findData(inputenc); }
if (p != -1) } else if (inputenc.startsWith("auto")) {
langModule->encodingCO->setCurrentIndex(p); langModule->autoEncodingRB->setChecked(true);
else { p = langModule->autoEncodingCO->findData(inputenc);
langModule->encodingCO->setCurrentIndex( if (p != -1) {
langModule->encodingCO->findData("custom")); langModule->autoEncodingCO->setCurrentIndex(p);
}
} else {
langModule->customEncodingRB->setChecked(true);
p = langModule->customEncodingCO->findData(inputenc); p = langModule->customEncodingCO->findData(inputenc);
if (p != -1) if (p != -1) {
langModule->customEncodingCO->setCurrentIndex(p); langModule->customEncodingCO->setCurrentIndex(p);
else }
langModule->encodingCO->setCurrentIndex(0);
} }
encodingSwitched();
// language package
p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package)); p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
if (p == -1) { if (p == -1) {
langModule->languagePackageCO->setCurrentIndex( langModule->languagePackageCO->setCurrentIndex(

View File

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

View File

@ -44,7 +44,11 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="quoteStyleCO"/> <widget class="QComboBox" name="quoteStyleCO">
<property name="toolTip">
<string>Select the default style of Quote insets.</string>
</property>
</widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"/> <layout class="QHBoxLayout" name="horizontalLayout"/>
@ -80,23 +84,44 @@
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="2"> <item row="0" column="2">
<widget class="QComboBox" name="unicodeEncodingCO">
<property name="enabled">
<bool>false</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">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Specify whether to load the 'inputenc' package
and write input encoding switch commands to the source.</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="customEncodingCO"> <widget class="QComboBox" name="customEncodingCO">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>If you selected a custom output encoding to the left, yo can specifiy it here</string> <string>Select encoding</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="languagePackageCO"> <widget class="QComboBox" name="languagePackageCO">
<property name="toolTip"> <property name="toolTip">
<string>Select which language package LyX should use</string> <string>Select which language package LyX should use</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="languagePackageLA"> <widget class="QLabel" name="languagePackageLA">
<property name="text"> <property name="text">
<string>Language pa&amp;ckage:</string> <string>Language pa&amp;ckage:</string>
@ -111,38 +136,58 @@
<property name="text"> <property name="text">
<string>&amp;Encoding:</string> <string>&amp;Encoding:</string>
</property> </property>
<property name="toolTip">
<string>Encoding of the generated LaTeX source
(LaTeX input encoding).</string>
</property>
<property name="buddy"> <property name="buddy">
<cstring>encodingCO</cstring> <cstring>unicodeEncodingRB</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="encodingCO"> <widget class="QRadioButton" name="unicodeEncodingRB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="text">
<string>Here you might adjust the output encoding (used for LaTeX files)</string> <string>Unicode</string>
</property> </property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="languagePackageLE">
<property name="toolTip"> <property name="toolTip">
<string>Enter the command to load the language package (default: \usepackage{babel})</string> <string>Set input encoding to Unicode (utf8).</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="noInputencCB"> <widget class="QRadioButton" name="autoEncodingRB">
<property name="toolTip"> <property name="enabled">
<string>If this is checked, LyX does not load the inputenc LaTeX package</string> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Do not load &amp;inputenc</string> <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>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="languagePackageLE">
<property name="toolTip">
<string>Enter the command to load the language package (default: \usepackage{babel})</string>
</property> </property>
</widget> </widget>
</item> </item>