mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
GuiDocument: Adapt to new encoding default
Also simplify the code.
This commit is contained in:
parent
4aa073c6f6
commit
a6116428c0
@ -931,11 +931,11 @@ 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->defaultencodingRB, SIGNAL(clicked()),
|
connect(langModule->encodingCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
|
||||||
connect(langModule->otherencodingRB, SIGNAL(clicked()),
|
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(langModule->encodingCO, SIGNAL(activated(int)),
|
connect(langModule->encodingCO, SIGNAL(activated(int)),
|
||||||
|
this, SLOT(encodingSwitched(int)));
|
||||||
|
connect(langModule->customEncodingCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
@ -957,15 +957,24 @@ 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) [default]"), 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"));
|
||||||
// Always put the default encoding in the first position.
|
// Always put the default encoding in the first position.
|
||||||
langModule->encodingCO->addItem(qt_("Language Default (no inputenc)"));
|
langModule->customEncodingCO->addItem(qt_("Language Default (no inputenc)"),
|
||||||
QStringList encodinglist;
|
toqstr("auto-legacy-plain"));
|
||||||
|
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())
|
||||||
encodinglist.append(qt_(encvar.guiName()));
|
encodingmap.insert(qt_(encvar.guiName()), qt_(encvar.name()));
|
||||||
|
}
|
||||||
|
QMap<QString, QString>::const_iterator it = encodingmap.constBegin();
|
||||||
|
while (it != encodingmap.constEnd()) {
|
||||||
|
langModule->customEncodingCO->addItem(it.key(), it.value());
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
encodinglist.sort();
|
|
||||||
langModule->encodingCO->addItems(encodinglist);
|
|
||||||
|
|
||||||
langModule->languagePackageCO->addItem(
|
langModule->languagePackageCO->addItem(
|
||||||
qt_("Default"), toqstr("default"));
|
qt_("Default"), toqstr("default"));
|
||||||
@ -2245,10 +2254,10 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
|
|||||||
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;
|
||||||
|
|
||||||
langModule->encodingCO->setEnabled(tex_fonts &&
|
langModule->customEncodingCO->setEnabled(tex_fonts &&
|
||||||
!langModule->defaultencodingRB->isChecked());
|
langModule->encodingCO->itemData(
|
||||||
langModule->defaultencodingRB->setEnabled(tex_fonts);
|
langModule->encodingCO->currentIndex()).toString() == "custom");
|
||||||
langModule->otherencodingRB->setEnabled(tex_fonts);
|
langModule->encodingCO->setEnabled(tex_fonts);
|
||||||
|
|
||||||
fontModule->fontsDefaultCO->setEnabled(tex_fonts);
|
fontModule->fontsDefaultCO->setEnabled(tex_fonts);
|
||||||
fontModule->fontsDefaultLA->setEnabled(tex_fonts);
|
fontModule->fontsDefaultLA->setEnabled(tex_fonts);
|
||||||
@ -2266,6 +2275,14 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiDocument::encodingSwitched(int i)
|
||||||
|
{
|
||||||
|
langModule->customEncodingCO->setEnabled(
|
||||||
|
!fontModule->osFontsCB->isChecked()
|
||||||
|
&& langModule->encodingCO->itemData(i).toString() == "custom");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiDocument::mathFontChanged(int)
|
void GuiDocument::mathFontChanged(int)
|
||||||
{
|
{
|
||||||
updateFontOptions();
|
updateFontOptions();
|
||||||
@ -3209,33 +3226,13 @@ void GuiDocument::applyView()
|
|||||||
indicesModule->apply(bp_);
|
indicesModule->apply(bp_);
|
||||||
|
|
||||||
// language & quotes
|
// language & quotes
|
||||||
if (langModule->defaultencodingRB->isChecked()) {
|
QString const encoding = langModule->encodingCO->itemData(
|
||||||
bp_.inputenc = "auto-legacy";
|
langModule->encodingCO->currentIndex()).toString();
|
||||||
} else {
|
if (encoding != "custom")
|
||||||
int i = langModule->encodingCO->currentIndex();
|
bp_.inputenc = fromqstr(encoding);
|
||||||
if (i == 0)
|
else
|
||||||
bp_.inputenc = "auto-legacy-plain";
|
bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
|
||||||
else {
|
langModule->customEncodingCO->currentIndex()).toString());
|
||||||
QString const enc_gui =
|
|
||||||
langModule->encodingCO->currentText();
|
|
||||||
Encodings::const_iterator it = encodings.begin();
|
|
||||||
Encodings::const_iterator const end = encodings.end();
|
|
||||||
bool found = false;
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
if (qt_(it->guiName()) == enc_gui &&
|
|
||||||
!it->unsafe()) {
|
|
||||||
bp_.inputenc = it->name();
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
// should not happen
|
|
||||||
lyxerr << "GuiDocument::apply: Unknown encoding! Resetting to utf8" << endl;
|
|
||||||
bp_.inputenc = "utf8";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
|
bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
|
||||||
langModule->quoteStyleCO->currentIndex()).toInt();
|
langModule->quoteStyleCO->currentIndex()).toInt();
|
||||||
@ -3727,35 +3724,20 @@ void GuiDocument::paramsToDialog()
|
|||||||
langModule->quoteStyleCO->findData(bp_.quotes_style));
|
langModule->quoteStyleCO->findData(bp_.quotes_style));
|
||||||
langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
|
langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
|
||||||
|
|
||||||
bool default_enc = true;
|
int p = langModule->encodingCO->findData(toqstr(bp_.inputenc));
|
||||||
if (bp_.inputenc != "auto-legacy") {
|
if (p != -1)
|
||||||
default_enc = false;
|
langModule->encodingCO->setCurrentIndex(p);
|
||||||
if (bp_.inputenc == "auto-legacy-plain") {
|
else {
|
||||||
|
langModule->encodingCO->setCurrentIndex(
|
||||||
|
langModule->encodingCO->findData("custom"));
|
||||||
|
p = langModule->customEncodingCO->findData(toqstr(bp_.inputenc));
|
||||||
|
if (p != -1)
|
||||||
|
langModule->customEncodingCO->setCurrentIndex(p);
|
||||||
|
else
|
||||||
langModule->encodingCO->setCurrentIndex(0);
|
langModule->encodingCO->setCurrentIndex(0);
|
||||||
} else {
|
|
||||||
string enc_gui;
|
|
||||||
Encodings::const_iterator it = encodings.begin();
|
|
||||||
Encodings::const_iterator const end = encodings.end();
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
if (it->name() == bp_.inputenc &&
|
|
||||||
!it->unsafe()) {
|
|
||||||
enc_gui = it->guiName();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int const i = langModule->encodingCO->findText(
|
|
||||||
qt_(enc_gui));
|
|
||||||
if (i >= 0)
|
|
||||||
langModule->encodingCO->setCurrentIndex(i);
|
|
||||||
else
|
|
||||||
// unknown encoding. Set to default.
|
|
||||||
default_enc = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
langModule->defaultencodingRB->setChecked(default_enc);
|
|
||||||
langModule->otherencodingRB->setChecked(!default_enc);
|
|
||||||
|
|
||||||
int const 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(
|
||||||
langModule->languagePackageCO->findData("custom"));
|
langModule->languagePackageCO->findData("custom"));
|
||||||
|
@ -152,6 +152,7 @@ private Q_SLOTS:
|
|||||||
void deleteBoxBackgroundColor();
|
void deleteBoxBackgroundColor();
|
||||||
void languageChanged(int);
|
void languageChanged(int);
|
||||||
void osFontsChanged(bool);
|
void osFontsChanged(bool);
|
||||||
|
void encodingSwitched(int);
|
||||||
void mathFontChanged(int);
|
void mathFontChanged(int);
|
||||||
void branchesRename(docstring const &, docstring const &);
|
void branchesRename(docstring const &, docstring const &);
|
||||||
void allPackagesAuto();
|
void allPackagesAuto();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>431</width>
|
<width>431</width>
|
||||||
<height>282</height>
|
<height>286</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -120,7 +120,7 @@
|
|||||||
<item row="3" column="0" colspan="3">
|
<item row="3" column="0" colspan="3">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Encoding</string>
|
<string>&Encoding</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -141,46 +141,42 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
<widget class="QRadioButton" name="defaultencodingRB">
|
|
||||||
<property name="text">
|
|
||||||
<string>Lan&guage default</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>81</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QRadioButton" name="otherencodingRB">
|
|
||||||
<property name="text">
|
|
||||||
<string>Othe&r:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="encodingCO">
|
<widget class="QComboBox" name="encodingCO">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Here you might adjust the output encoding (used for LaTeX files)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="duplicatesEnabled">
|
<property name="duplicatesEnabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<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="0" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -199,9 +195,6 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>languageCO</tabstop>
|
<tabstop>languageCO</tabstop>
|
||||||
<tabstop>quoteStyleCO</tabstop>
|
<tabstop>quoteStyleCO</tabstop>
|
||||||
<tabstop>defaultencodingRB</tabstop>
|
|
||||||
<tabstop>otherencodingRB</tabstop>
|
|
||||||
<tabstop>encodingCO</tabstop>
|
|
||||||
<tabstop>languagePackageCO</tabstop>
|
<tabstop>languagePackageCO</tabstop>
|
||||||
<tabstop>languagePackageLE</tabstop>
|
<tabstop>languagePackageLE</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
@ -209,22 +202,5 @@
|
|||||||
<include location="local">qt_i18n.h</include>
|
<include location="local">qt_i18n.h</include>
|
||||||
</includes>
|
</includes>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>otherencodingRB</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>encodingCO</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>34</x>
|
|
||||||
<y>149</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>107</x>
|
|
||||||
<y>145</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user