#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
+#include "support/lassert.h"
#include "support/lstrings.h"
#include "frontends/alert.h"
};
+char const * packages_gui[][4] =
+{
+ {"amsmath",
+ N_("&Use AMS math package automatically"),
+ N_("Use AMS &math package"),
+ N_("The AMS LaTeX packages are only used if symbols from the AMS math toolbars are inserted into formulas")},
+ {"esint",
+ N_("Use esint package &automatically"),
+ N_("Use &esint package"),
+ N_("The LaTeX package esint is only used if special integral symbols are inserted into formulas")},
+ {"mathdots",
+ N_("Use math&dots package automatically"),
+ N_("Use mathdo&ts package"),
+ N_("The LaTeX package mathdots is only used if the command \\iddots is inserted into formulas")},
+ {"mathtools",
+ N_("Use mathtools package automatically"),
+ N_("Use mathtools package"),
+ N_("The LaTeX package mathtools is only used if some mathematical relations are inserted into formulas")},
+ {"mhchem",
+ N_("Use mhchem &package automatically"),
+ N_("Use mh&chem package"),
+ N_("The LaTeX package mhchem is only used if either the command \\ce or \\cf is inserted into formulas")},
+ {"undertilde",
+ N_("Use u&ndertilde package automatically"),
+ N_("Use undertilde pac&kage"),
+ N_("The LaTeX package undertilde is only used if you use the math frame decoration 'utilde'")},
+ {"", "", "", ""}
+};
+
+
vector<pair<string, QString> > pagestyles;
// biblio
biblioModule = new UiWidget<Ui::BiblioUi>;
+ connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)),
+ this, SLOT(setNumerical(bool)));
+ connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)),
+ this, SLOT(setAuthorYear(bool)));
connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
biblioModule->citationStyleL, SLOT(setEnabled(bool)));
connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
this, SLOT(bibtexChanged(int)));
connect(biblioModule->bibtexOptionsLE, SIGNAL(textChanged(QString)),
- this, SLOT(change_adaptor()));
+ this, SLOT(biblioChanged()));
+ connect(biblioModule->bibtexStyleLE, SIGNAL(textChanged(QString)),
+ this, SLOT(biblioChanged()));
biblioModule->bibtexOptionsLE->setValidator(new NoNewLineValidator(
biblioModule->bibtexOptionsLE));
+ biblioModule->bibtexStyleLE->setValidator(new NoNewLineValidator(
+ biblioModule->bibtexStyleLE));
biblioModule->citeStyleCO->addItem(qt_("Author-year"));
biblioModule->citeStyleCO->addItem(qt_("Numerical"));
// maths
+ // FIXME This UI has problems:
+ // 1) It is not generic, packages_gui needs to be changed for each new package
+ // 2) Two checkboxes have 4 states, but one is invalid (both pressed)
+ // 3) The auto cb is not disabled if the use cb is checked
mathsModule = new UiWidget<Ui::MathsUi>;
- connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
- mathsModule->amsCB, SLOT(setDisabled(bool)));
- connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
- mathsModule->esintCB, SLOT(setDisabled(bool)));
- connect(mathsModule->mhchemautoCB, SIGNAL(toggled(bool)),
- mathsModule->mhchemCB, SLOT(setDisabled(bool)));
- connect(mathsModule->mathdotsautoCB, SIGNAL(toggled(bool)),
- mathsModule->mathdotsCB, SLOT(setDisabled(bool)));
- connect(mathsModule->undertildeautoCB, SIGNAL(toggled(bool)),
- mathsModule->undertildeCB, SLOT(setDisabled(bool)));
-
- connect(mathsModule->amsCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->amsautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->esintCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->esintautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->mhchemCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->mhchemautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->mathdotsCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->mathdotsautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->undertildeCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(mathsModule->undertildeautoCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
+ vector<string> const & packages = BufferParams::auto_packages();
+ for (size_t i = 0; i < packages.size(); ++i) {
+ // Use the order of BufferParams::auto_packages() for easier
+ // access in applyView() and paramsToDialog()
+ int n = 0;
+ for (n = 0; packages_gui[n][0][0]; n++)
+ if (packages_gui[n][0] == packages[i])
+ break;
+ // If this fires somebody changed
+ // BufferParams::auto_packages() without adjusting packages_gui
+ LASSERT(packages_gui[n][0][0], /**/);
+ QString autoText = qt_(packages_gui[n][1]);
+ QString alwaysText = qt_(packages_gui[n][2]);
+ QString autoTooltip = qt_(packages_gui[n][3]);
+ QString alwaysTooltip;
+ if (packages[i] == "amsmath")
+ alwaysTooltip =
+ qt_("The AMS LaTeX packages are always used");
+ else
+ alwaysTooltip = toqstr(bformat(
+ _("The LaTeX package %1$s is always used"),
+ from_ascii(packages[i])));
+ QCheckBox * autoCB = new QCheckBox(autoText, mathsModule);
+ QCheckBox * alwaysCB = new QCheckBox(alwaysText, mathsModule);
+ mathsModule->gridLayout->addWidget(autoCB, 2 * i, 0);
+ mathsModule->gridLayout->addWidget(alwaysCB, 2 * i + 1, 0);
+ autoCB->setToolTip(autoTooltip);
+ alwaysCB->setToolTip(alwaysTooltip);
+ connect(autoCB, SIGNAL(toggled(bool)),
+ alwaysCB, SLOT(setDisabled(bool)));
+ connect(autoCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(alwaysCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ }
+ QSpacerItem * spacer = new QSpacerItem(20, 20, QSizePolicy::Minimum,
+ QSizePolicy::Expanding);
+ mathsModule->gridLayout->addItem(spacer, 2 * packages.size(), 0);
// latex class
}
+void GuiDocument::biblioChanged()
+{
+ biblioChanged_ = true;
+ changed();
+}
+
+
void GuiDocument::bibtexChanged(int n)
{
biblioModule->bibtexOptionsLE->setEnabled(
biblioModule->bibtexCO->itemData(n).toString() != "default");
- changed();
+ biblioChanged();
+}
+
+
+void GuiDocument::setAuthorYear(bool authoryear)
+{
+ if (authoryear)
+ biblioModule->citeStyleCO->setCurrentIndex(0);
+ biblioChanged();
+}
+
+
+void GuiDocument::setNumerical(bool numerical)
+{
+ if (numerical)
+ biblioModule->citeStyleCO->setCurrentIndex(1);
+ biblioChanged();
}
// biblio
bp_.setCiteEngine(ENGINE_BASIC);
- if (biblioModule->citeNatbibRB->isChecked()) {
- bool const use_numerical_citations =
- biblioModule->citeStyleCO->currentIndex();
- if (use_numerical_citations)
- bp_.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
- else
- bp_.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
-
- } else if (biblioModule->citeJurabibRB->isChecked())
+ if (biblioModule->citeNatbibRB->isChecked())
+ bp_.setCiteEngine(ENGINE_NATBIB);
+ else if (biblioModule->citeJurabibRB->isChecked())
bp_.setCiteEngine(ENGINE_JURABIB);
+ if (biblioModule->citeStyleCO->currentIndex())
+ bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
+ else
+ bp_.setCiteEngineType(ENGINE_TYPE_AUTHORYEAR);
+
bp_.use_bibtopic =
biblioModule->bibtopicCB->isChecked();
+ bp_.biblio_style = fromqstr(biblioModule->bibtexStyleLE->text());
+
string const bibtex_command =
fromqstr(biblioModule->bibtexCO->itemData(
biblioModule->bibtexCO->currentIndex()).toString());
else
bp_.bibtex_command = bibtex_command + " " + bibtex_options;
- buffer().removeBiblioTempFiles();
+ if (biblioChanged_) {
+ buffer().invalidateBibinfoCache();
+ buffer().removeBiblioTempFiles();
+ }
// Indices
indicesModule->apply(bp_);
modulesToParams(bp_);
// Math
- if (mathsModule->amsautoCB->isChecked())
- bp_.use_amsmath = BufferParams::package_auto;
- else {
- if (mathsModule->amsCB->isChecked())
- bp_.use_amsmath = BufferParams::package_on;
- else
- bp_.use_amsmath = BufferParams::package_off;
- }
- if (mathsModule->esintautoCB->isChecked())
- bp_.use_esint = BufferParams::package_auto;
- else {
- if (mathsModule->esintCB->isChecked())
- bp_.use_esint = BufferParams::package_on;
- else
- bp_.use_esint = BufferParams::package_off;
- }
- if (mathsModule->mhchemautoCB->isChecked())
- bp_.use_mhchem = BufferParams::package_auto;
- else {
- if (mathsModule->mhchemCB->isChecked())
- bp_.use_mhchem = BufferParams::package_on;
- else
- bp_.use_mhchem = BufferParams::package_off;
- }
- if (mathsModule->mathdotsautoCB->isChecked())
- bp_.use_mathdots = BufferParams::package_auto;
- else {
- if (mathsModule->mathdotsCB->isChecked())
- bp_.use_mathdots = BufferParams::package_on;
- else
- bp_.use_mathdots = BufferParams::package_off;
- }
- if (mathsModule->undertildeautoCB->isChecked())
- bp_.use_undertilde = BufferParams::package_auto;
- else {
- if (mathsModule->undertildeCB->isChecked())
- bp_.use_undertilde = BufferParams::package_on;
- else
- bp_.use_undertilde = BufferParams::package_off;
+ vector<string> const & packages = BufferParams::auto_packages();
+ for (size_t n = 0; n < packages.size(); ++n) {
+ QCheckBox * autoCB = static_cast<QCheckBox *>(
+ mathsModule->gridLayout->itemAtPosition(2 * n, 0)->widget());
+ if (autoCB->isChecked())
+ bp_.use_package(packages[n], BufferParams::package_auto);
+ else {
+ QCheckBox * alwaysCB = static_cast<QCheckBox *>(
+ mathsModule->gridLayout->itemAtPosition(2 * n + 1, 0)->widget());
+ if (alwaysCB->isChecked())
+ bp_.use_package(packages[n], BufferParams::package_on);
+ else
+ bp_.use_package(packages[n], BufferParams::package_off);
+ }
}
// Page Layout
bp_.citeEngine() == ENGINE_BASIC);
biblioModule->citeNatbibRB->setChecked(
- bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
- bp_.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
+ bp_.citeEngine() == ENGINE_NATBIB);
biblioModule->citeStyleCO->setCurrentIndex(
- bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL);
+ bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
biblioModule->citeJurabibRB->setChecked(
bp_.citeEngine() == ENGINE_JURABIB);
biblioModule->bibtopicCB->setChecked(
bp_.use_bibtopic);
+ biblioModule->bibtexStyleLE->setText(toqstr(bp_.biblio_style));
+
string command;
string options =
split(bp_.bibtex_command, command, ' ');
biblioModule->bibtexOptionsLE->setEnabled(
biblioModule->bibtexCO->currentIndex() != 0);
+ biblioChanged_ = false;
+
// indices
indicesModule->update(bp_);
latexModule->psdriverCO->setCurrentIndex(nitem);
updateModuleInfo();
- mathsModule->amsCB->setChecked(
- bp_.use_amsmath == BufferParams::package_on);
- mathsModule->amsautoCB->setChecked(
- bp_.use_amsmath == BufferParams::package_auto);
-
- mathsModule->esintCB->setChecked(
- bp_.use_esint == BufferParams::package_on);
- mathsModule->esintautoCB->setChecked(
- bp_.use_esint == BufferParams::package_auto);
-
- mathsModule->mhchemCB->setChecked(
- bp_.use_mhchem == BufferParams::package_on);
- mathsModule->mhchemautoCB->setChecked(
- bp_.use_mhchem == BufferParams::package_auto);
-
- mathsModule->mathdotsCB->setChecked(
- bp_.use_mathdots == BufferParams::package_on);
- mathsModule->mathdotsautoCB->setChecked(
- bp_.use_mathdots == BufferParams::package_auto);
-
- mathsModule->undertildeCB->setChecked(
- bp_.use_undertilde == BufferParams::package_on);
- mathsModule->undertildeautoCB->setChecked(
- bp_.use_undertilde == BufferParams::package_auto);
+ vector<string> const & packages = BufferParams::auto_packages();
+ for (size_t n = 0; n < packages.size(); ++n) {
+ QCheckBox * alwaysCB = static_cast<QCheckBox *>(
+ mathsModule->gridLayout->itemAtPosition(2 * n + 1, 0)->widget());
+ alwaysCB->setChecked(bp_.use_package(packages[n]) == BufferParams::package_on);
+ QCheckBox * autoCB = static_cast<QCheckBox *>(
+ mathsModule->gridLayout->itemAtPosition(2 * n, 0)->widget());
+ autoCB->setChecked(bp_.use_package(packages[n]) == BufferParams::package_auto);
+ }
switch (bp_.spacing().getSpace()) {
case Spacing::Other: nitem = 3; break;
InsetListingsParams(bp_.listings_params).separatedParams();
listingsModule->listingsED->setPlainText(toqstr(lstparams));
- // Output
- // update combobox with formats
- updateDefaultFormat();
- int index = outputModule->defaultFormatCO->findData(toqstr(
- bp_.default_output_format));
- // set to default if format is not found
- if (index == -1)
- index = 0;
- outputModule->defaultFormatCO->setCurrentIndex(index);
+ // Fonts
bool const os_fonts_available =
bp_.baseClass()->outputType() == lyx::LATEX
&& LaTeXFeatures::isAvailable("fontspec");
fontModule->osFontsCB->setEnabled(os_fonts_available);
fontModule->osFontsCB->setChecked(
os_fonts_available && bp_.useNonTeXFonts);
-
- outputModule->outputsyncCB->setChecked(bp_.output_sync);
- outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
-
- outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
- outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
- outputModule->strictCB->setChecked(bp_.html_be_strict);
- outputModule->cssCB->setChecked(bp_.html_css_as_file);
-
- // Fonts
updateFontsize(documentClass().opt_fontsize(),
bp_.fontsize);
fontModule->fontencLE->setText(toqstr(bp_.fontenc));
}
+ // Output
+ // This must be set _after_ fonts since updateDefaultFormat()
+ // checks osFontsCB settings.
+ // update combobox with formats
+ updateDefaultFormat();
+ int index = outputModule->defaultFormatCO->findData(toqstr(
+ bp_.default_output_format));
+ // set to default if format is not found
+ if (index == -1)
+ index = 0;
+ outputModule->defaultFormatCO->setCurrentIndex(index);
+
+ outputModule->outputsyncCB->setChecked(bp_.output_sync);
+ outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
+
+ outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
+ outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
+ outputModule->strictCB->setChecked(bp_.html_be_strict);
+ outputModule->cssCB->setChecked(bp_.html_css_as_file);
+
// paper
bool const extern_geometry =
documentClass().provides("geometry");