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.
# inputenc's standard utf8 support:
Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc
Encoding utf8 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 "Unicode (ucs-extended) (utf8x)" UTF-8 variable inputenc
Encoding utf8x utf8x "utf8 (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 "Unicode (CJK) (utf8)" UTF-8 variable CJK
Encoding utf8-cjk UTF8 "utf8 [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 "Japanese (pLaTeX) (UTF8)" UTF-8 variable japanese
Encoding utf8-platex utf8 "utf8 [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 "Unicode (XeTeX) (utf8)" UTF-8 variable none
Encoding utf8-plain utf8-plain "utf8 (pass-through)" UTF-8 variable none
End
# Pure 7bit ASCII encoding (partially hardcoded in LyX)

View File

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

View File

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

View File

@ -44,7 +44,11 @@
</widget>
</item>
<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 row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"/>
@ -80,23 +84,44 @@
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<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">
<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>
<string>Select encoding</string>
</property>
</widget>
</item>
<item row="2" column="1">
<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="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="languagePackageLA">
<property name="text">
<string>Language pa&amp;ckage:</string>
@ -111,38 +136,58 @@
<property name="text">
<string>&amp;Encoding:</string>
</property>
<property name="toolTip">
<string>Encoding of the generated LaTeX source
(LaTeX input encoding).</string>
</property>
<property name="buddy">
<cstring>encodingCO</cstring>
<cstring>unicodeEncodingRB</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="encodingCO">
<widget class="QRadioButton" name="unicodeEncodingRB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Here you might adjust the output encoding (used for LaTeX files)</string>
<property name="text">
<string>Unicode</string>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="languagePackageLE">
<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>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="noInputencCB">
<property name="toolTip">
<string>If this is checked, LyX does not load the inputenc LaTeX package</string>
<widget class="QRadioButton" name="autoEncodingRB">
<property name="enabled">
<bool>true</bool>
</property>
<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>
</widget>
</item>