#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<string> engine_types_;
vector<pair<string, QString> > pagestyles;
}
+docstring getModuleCategory(string const & modName)
+{
+ LyXModule const * const mod = theModuleList[modName];
+ if (!mod)
+ return docstring();
+ return from_utf8(mod->category());
+}
+
+
docstring getModuleDescription(string const & modName)
{
LyXModule const * const mod = theModuleList[modName];
// 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)),
// 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
this, SLOT(change_adaptor()));
connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)),
this, SLOT(branchesRename(docstring const &, docstring const &)));
+ connect(branchesModule, SIGNAL(okPressed()), this, SLOT(slotOK()));
updateUnknownBranches();
docPS->addPanel(pdfSupportModule, qt_("PDF Properties"));
docPS->addPanel(mathsModule, qt_("Math Options"));
docPS->addPanel(floatModule, qt_("Float Placement"));
- docPS->addPanel(listingsModule, qt_("Listings"));
+ docPS->addPanel(listingsModule, qt_("Listings[[inset]]"));
docPS->addPanel(bulletsModule, qt_("Bullets"));
docPS->addPanel(branchesModule, qt_("Branches"));
docPS->addPanel(outputModule, qt_("Output"));
}
+void GuiDocument::setAuthorYear(bool authoryear)
+{
+ if (authoryear)
+ biblioModule->citeStyleCO->setCurrentIndex(0);
+ biblioChanged();
+}
+
+
+void GuiDocument::setNumerical(bool numerical)
+{
+ if (numerical)
+ biblioModule->citeStyleCO->setCurrentIndex(1);
+ biblioChanged();
+}
+
+
+void GuiDocument::updateEngineType(string const & items, CiteEngineType const & sel)
+{
+ engine_types_.clear();
+
+ int nn = 0;
+
+ for (int n = 0; !token(items, '|', n).empty(); ++n) {
+ nn += 1;
+ string style = token(items, '|', n);
+ engine_types_.push_back(style);
+ }
+
+ switch (sel) {
+ case ENGINE_TYPE_AUTHORYEAR:
+ biblioModule->citeStyleCO->setCurrentIndex(0);
+ break;
+ case ENGINE_TYPE_NUMERICAL:
+ biblioModule->citeStyleCO->setCurrentIndex(1);
+ break;
+ }
+
+ biblioModule->citationStyleL->setEnabled(nn > 1);
+ biblioModule->citeStyleCO->setEnabled(nn > 1);
+
+ if (nn != 1)
+ return;
+
+ // If the textclass allows only one of authoryear or numerical,
+ // we have no choice but to force that engine type.
+ if (engine_types_[0] == "authoryear")
+ biblioModule->citeStyleCO->setCurrentIndex(0);
+ else
+ biblioModule->citeStyleCO->setCurrentIndex(1);
+}
+
+
namespace {
// FIXME unicode
// both of these should take a vector<docstring>
if (focus_on_selected)
lv = modulesModule->selectedLV;
else
- lv= modulesModule->availableLV;
+ lv = modulesModule->availableLV;
if (lv->selectionModel()->selectedIndexes().isEmpty()) {
modulesModule->infoML->document()->clear();
return;
desc += _("Module provided by document class.");
}
+ docstring cat = getModuleCategory(modName);
+ if (!cat.empty()) {
+ if (!desc.empty())
+ desc += "\n";
+ desc += bformat(_("Category: %1$s."), cat);
+ }
+
vector<string> pkglist = getPackageList(modName);
docstring pkgdesc = formatStrVec(pkglist, _("and"));
if (!pkgdesc.empty()) {
bp_.use_refstyle = latexModule->refstyleCB->isChecked();
// 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);
+ if (biblioModule->citeNatbibRB->isChecked())
+ bp_.setCiteEngine("natbib");
+ else if (biblioModule->citeJurabibRB->isChecked())
+ bp_.setCiteEngine("jurabib");
+ else
+ bp_.setCiteEngine("basic");
- } 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();
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
latexModule->refstyleCB->setChecked(bp_.use_refstyle);
// biblio
+ string const cite_engine = bp_.citeEngine().list().front();
+
biblioModule->citeDefaultRB->setChecked(
- bp_.citeEngine() == ENGINE_BASIC);
+ cite_engine == "basic");
+
+ biblioModule->citeJurabibRB->setChecked(
+ cite_engine == "jurabib");
biblioModule->citeNatbibRB->setChecked(
- bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
- bp_.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
+ cite_engine == "natbib");
biblioModule->citeStyleCO->setCurrentIndex(
- bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL);
+ bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
- biblioModule->citeJurabibRB->setChecked(
- bp_.citeEngine() == ENGINE_JURABIB);
+ updateEngineType(documentClass().opt_enginetype(),
+ bp_.citeEngineType());
biblioModule->bibtopicCB->setChecked(
bp_.use_bibtopic);
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");
if (pos > 0)
desc.truncate(pos + 1);
m.description = desc;
- moduleNames_.push_back(m);
+ if (it->category().substr(0, 8) != "Citation")
+ moduleNames_.push_back(m);
}
}