2 * \file GuiDocument.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Richard Heck (modules)
9 * Full author contact details are available in file CREDITS.
14 #include "GuiDocument.h"
16 #include "BulletsModule.h"
17 #include "CategorizedCombo.h"
18 #include "FancyLineEdit.h"
19 #include "GuiApplication.h"
20 #include "GuiBranches.h"
21 #include "GuiIndices.h"
22 #include "GuiSelectionManager.h"
23 #include "LaTeXHighlighter.h"
24 #include "Validator.h"
26 #include "LayoutFile.h"
27 #include "BranchList.h"
28 #include "buffer_funcs.h"
30 #include "BufferView.h"
31 #include "CiteEnginesList.h"
33 #include "ColorCache.h"
34 #include "Converter.h"
37 #include "FloatPlacement.h"
39 #include "FuncRequest.h"
40 #include "IndicesList.h"
42 #include "LaTeXFeatures.h"
43 #include "LaTeXFonts.h"
45 #include "LayoutEnums.h"
46 #include "LayoutModuleList.h"
48 #include "ModuleList.h"
49 #include "OutputParams.h"
50 #include "PDFOptions.h"
51 #include "qt_helpers.h"
54 #include "TextClass.h"
58 #include "insets/InsetListingsParams.h"
60 #include "support/debug.h"
61 #include "support/docstream.h"
62 #include "support/FileName.h"
63 #include "support/filetools.h"
64 #include "support/gettext.h"
65 #include "support/lassert.h"
66 #include "support/lstrings.h"
67 #include "support/Package.h"
68 #include "support/TempFile.h"
70 #include "frontends/alert.h"
72 #include <QAbstractItemModel>
73 #include <QButtonGroup>
75 #include <QColorDialog>
76 #include <QCloseEvent>
77 #include <QDirIterator>
78 #include <QFontDatabase>
79 #include <QHeaderView>
82 #include <QTextBoundaryFinder>
83 #include <QTextCursor>
89 // a style sheet for buttons
90 // this is for example used for the background color setting button
91 static inline QString colorButtonStyleSheet(QColor const & bgColor)
93 if (bgColor.isValid()) {
94 QString rc = QLatin1String("background-color:");
103 using namespace lyx::support;
108 char const * const tex_graphics[] =
110 "default", "dvialw", "dvilaser", "dvipdf", "dvipdfm", "dvipdfmx",
111 "dvips", "dvipsone", "dvitops", "dviwin", "dviwindo", "dvi2ps", "emtex",
112 "ln", "oztex", "pctexhp", "pctexps", "pctexwin", "pctex32", "pdftex",
113 "psprint", "pubps", "tcidvi", "textures", "truetex", "vtex", "xdvi",
118 char const * const tex_graphics_gui[] =
120 N_("Default"), "dvialw", "DviLaser", "dvipdf", "DVIPDFM", "DVIPDFMx",
121 "Dvips", "DVIPSONE", "DVItoPS", "DVIWIN", "DVIWindo", "dvi2ps", "EmTeX",
122 "LN", "OzTeX", "pctexhp", "pctexps", "pctexwin", "PCTeX32", "pdfTeX",
123 "psprint", "pubps", "tcidvi", "Textures", "TrueTeX", "VTeX", "xdvi",
124 "XeTeX", N_("None"), ""
128 char const * backref_opts[] =
130 "false", "section", "slide", "page", ""
134 char const * backref_opts_gui[] =
136 N_("Off"), N_("Section"), N_("Slide"), N_("Page"), ""
140 char const * lst_packages[] =
142 "Listings", "Minted", ""
146 vector<string> engine_types_;
147 vector<pair<string, QString> > pagestyles;
149 QMap<QString, QString> rmfonts_;
150 QMap<QString, QString> sffonts_;
151 QMap<QString, QString> ttfonts_;
152 QMap<QString, QString> mathfonts_;
160 lyx::RGBColor set_backgroundcolor;
161 bool is_backgroundcolor;
162 lyx::RGBColor set_fontcolor;
164 lyx::RGBColor set_notefontcolor;
165 lyx::RGBColor set_boxbgcolor;
166 bool forced_fontspec_activation;
168 } // anonymous namespace
173 // used when sorting the textclass list.
174 class less_textclass_avail_desc
177 bool operator()(string const & lhs, string const & rhs) const
179 // Ordering criteria:
180 // 1. Availability of text class
181 // 2. Description (lexicographic)
182 LayoutFile const & tc1 = LayoutFileList::get()[lhs];
183 LayoutFile const & tc2 = LayoutFileList::get()[rhs];
184 int const order = compare_no_case(
185 translateIfPossible(from_utf8(tc1.description())),
186 translateIfPossible(from_utf8(tc2.description())));
187 return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
188 (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() && order < 0);
197 vector<string> getRequiredList(string const & modName)
199 LyXModule const * const mod = theModuleList[modName];
201 return vector<string>(); //empty such thing
202 return mod->getRequiredModules();
206 vector<string> getExcludedList(string const & modName)
208 LyXModule const * const mod = theModuleList[modName];
210 return vector<string>(); //empty such thing
211 return mod->getExcludedModules();
215 docstring getModuleCategory(string const & modName)
217 LyXModule const * const mod = theModuleList[modName];
220 return from_utf8(mod->category());
224 docstring getModuleDescription(string const & modName)
226 LyXModule const * const mod = theModuleList[modName];
228 return _("Module not found!");
230 return translateIfPossible(from_utf8(mod->getDescription()));
234 vector<string> getPackageList(string const & modName)
236 LyXModule const * const mod = theModuleList[modName];
238 return vector<string>(); //empty such thing
239 return mod->getPackageList();
243 bool isModuleAvailable(string const & modName)
245 LyXModule const * const mod = theModuleList[modName];
248 return mod->isAvailable();
251 } // anonymous namespace
254 /////////////////////////////////////////////////////////////////////
256 // ModuleSelectionManager
258 /////////////////////////////////////////////////////////////////////
260 /// SelectionManager for use with modules
261 class ModuleSelectionManager : public GuiSelectionManager
265 ModuleSelectionManager(QObject * parent,
266 QTreeView * availableLVarg,
267 QTreeView * selectedLVarg,
268 QPushButton * addPBarg,
269 QPushButton * delPBarg,
270 QPushButton * upPBarg,
271 QPushButton * downPBarg,
272 QStandardItemModel * availableModelarg,
273 GuiIdListModel * selectedModelarg,
274 GuiDocument const * container)
275 : GuiSelectionManager(parent, availableLVarg, selectedLVarg, addPBarg, delPBarg,
276 upPBarg, downPBarg, availableModelarg, selectedModelarg),
277 container_(container)
280 void updateProvidedModules(LayoutModuleList const & pm)
281 { provided_modules_ = pm.list(); }
283 void updateExcludedModules(LayoutModuleList const & em)
284 { excluded_modules_ = em.list(); }
287 void updateAddPB() override;
289 void updateUpPB() override;
291 void updateDownPB() override;
293 void updateDelPB() override;
294 /// returns availableModel as a GuiIdListModel
295 QStandardItemModel * getAvailableModel()
297 return dynamic_cast<QStandardItemModel *>(availableModel);
299 /// returns selectedModel as a GuiIdListModel
300 GuiIdListModel * getSelectedModel()
302 return dynamic_cast<GuiIdListModel *>(selectedModel);
304 /// keeps a list of the modules the text class provides
305 list<string> provided_modules_;
307 list<string> excluded_modules_;
309 GuiDocument const * container_;
312 void ModuleSelectionManager::updateAddPB()
314 int const arows = availableModel->rowCount();
315 QModelIndexList const avail_sels =
316 availableLV->selectionModel()->selectedRows(0);
318 // disable if there aren't any modules (?), if none of them is chosen
319 // in the dialog, or if the chosen one is already selected for use.
320 if (arows == 0 || avail_sels.isEmpty() || isSelected(avail_sels.first())) {
321 addPB->setEnabled(false);
325 QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
327 if (getAvailableModel()->itemFromIndex(idx)->hasChildren()) {
328 // This is a category header
329 addPB->setEnabled(false);
333 string const modname = fromqstr(getAvailableModel()->data(idx, Qt::UserRole).toString());
336 container_->params().layoutModuleCanBeAdded(modname);
337 addPB->setEnabled(enable);
341 void ModuleSelectionManager::updateDownPB()
343 int const srows = selectedModel->rowCount();
345 downPB->setEnabled(false);
348 QModelIndex const & curidx = selectedLV->selectionModel()->currentIndex();
349 int const curRow = curidx.row();
350 if (curRow < 0 || curRow >= srows - 1) { // invalid or last item
351 downPB->setEnabled(false);
355 // determine whether immediately succeeding element requires this one
356 string const curmodname = getSelectedModel()->getIDString(curRow);
357 string const nextmodname = getSelectedModel()->getIDString(curRow + 1);
359 vector<string> reqs = getRequiredList(nextmodname);
361 // if it doesn't require anything....
363 downPB->setEnabled(true);
367 // Enable it if this module isn't required.
368 // FIXME This should perhaps be more flexible and check whether, even
369 // if the next one is required, there is also an earlier one that will do.
371 find(reqs.begin(), reqs.end(), curmodname) == reqs.end());
374 void ModuleSelectionManager::updateUpPB()
376 int const srows = selectedModel->rowCount();
378 upPB->setEnabled(false);
382 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
383 int curRow = curIdx.row();
384 if (curRow <= 0 || curRow > srows - 1) { // first item or invalid
385 upPB->setEnabled(false);
388 string const curmodname = getSelectedModel()->getIDString(curRow);
390 // determine whether immediately preceding element is required by this one
391 vector<string> reqs = getRequiredList(curmodname);
393 // if this one doesn't require anything....
395 upPB->setEnabled(true);
400 // Enable it if the preceding module isn't required.
401 // NOTE This is less flexible than it might be. We could check whether, even
402 // if the previous one is required, there is an earlier one that would do.
403 string const premod = getSelectedModel()->getIDString(curRow - 1);
404 upPB->setEnabled(find(reqs.begin(), reqs.end(), premod) == reqs.end());
407 void ModuleSelectionManager::updateDelPB()
409 int const srows = selectedModel->rowCount();
411 deletePB->setEnabled(false);
415 QModelIndex const & curidx =
416 selectedLV->selectionModel()->currentIndex();
417 int const curRow = curidx.row();
418 if (curRow < 0 || curRow >= srows) { // invalid index?
419 deletePB->setEnabled(false);
423 string const curmodname = getSelectedModel()->getIDString(curRow);
425 // We're looking here for a reason NOT to enable the button. If we
426 // find one, we disable it and return. If we don't, we'll end up at
427 // the end of the function, and then we enable it.
428 for (int i = curRow + 1; i < srows; ++i) {
429 string const thisMod = getSelectedModel()->getIDString(i);
430 vector<string> reqs = getRequiredList(thisMod);
431 //does this one require us?
432 if (find(reqs.begin(), reqs.end(), curmodname) == reqs.end())
436 // OK, so this module requires us
437 // is there an EARLIER module that also satisfies the require?
438 // NOTE We demand that it be earlier to keep the list of modules
439 // consistent with the rule that a module must be proceeded by a
440 // required module. There would be more flexible ways to proceed,
441 // but that would be a lot more complicated, and the logic here is
442 // already complicated. (That's why I've left the debugging code.)
443 // lyxerr << "Testing " << thisMod << endl;
444 bool foundone = false;
445 for (int j = 0; j < curRow; ++j) {
446 string const mod = getSelectedModel()->getIDString(j);
447 // lyxerr << "In loop: Testing " << mod << endl;
448 // do we satisfy the require?
449 if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
450 // lyxerr << mod << " does the trick." << endl;
455 // did we find a module to satisfy the require?
457 // lyxerr << "No matching module found." << endl;
458 deletePB->setEnabled(false);
462 // lyxerr << "All's well that ends well." << endl;
463 deletePB->setEnabled(true);
467 /////////////////////////////////////////////////////////////////////
471 /////////////////////////////////////////////////////////////////////
473 PreambleModule::PreambleModule(QWidget * parent)
474 : UiWidget<Ui::PreambleUi>(parent), current_id_(nullptr)
476 // This is not a memory leak. The object will be destroyed
478 // @ is letter in the LyX user preamble
479 (void) new LaTeXHighlighter(preambleTE->document(), true);
480 preambleTE->setFont(guiApp->typewriterSystemFont());
481 preambleTE->setWordWrapMode(QTextOption::NoWrap);
482 setFocusProxy(preambleTE);
483 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
484 connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
485 connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
486 connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
487 connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
489 // https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
490 const int tabStop = 4;
491 QFontMetrics metrics(preambleTE->currentFont());
492 #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
493 // horizontalAdvance() is available starting in 5.11.0
494 // setTabStopDistance() is available starting in 5.10.0
495 preambleTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' '));
497 preambleTE->setTabStopWidth(tabStop * metrics.width(' '));
502 void PreambleModule::checkFindButton()
504 findButtonPB->setEnabled(!findLE->text().isEmpty());
508 void PreambleModule::findText()
510 bool const found = preambleTE->find(findLE->text());
513 QTextCursor qtcur = preambleTE->textCursor();
514 qtcur.movePosition(QTextCursor::Start);
515 preambleTE->setTextCursor(qtcur);
516 preambleTE->find(findLE->text());
521 void PreambleModule::update(BufferParams const & params, BufferId id)
523 QString preamble = toqstr(params.preamble);
524 // Nothing to do if the params and preamble are unchanged.
525 if (id == current_id_
526 && preamble == preambleTE->document()->toPlainText())
529 QTextCursor cur = preambleTE->textCursor();
530 // Save the coords before switching to the new one.
531 preamble_coords_[current_id_] =
532 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
534 // Save the params address for further use.
536 preambleTE->document()->setPlainText(preamble);
537 Coords::const_iterator it = preamble_coords_.find(current_id_);
538 if (it == preamble_coords_.end())
539 // First time we open this one.
540 preamble_coords_[current_id_] = make_pair(0, 0);
542 // Restore saved coords.
543 cur = preambleTE->textCursor();
544 cur.setPosition(it->second.first);
545 preambleTE->setTextCursor(cur);
546 preambleTE->verticalScrollBar()->setValue(it->second.second);
551 void PreambleModule::apply(BufferParams & params)
553 params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
557 void PreambleModule::closeEvent(QCloseEvent * e)
559 // Save the coords before closing.
560 QTextCursor cur = preambleTE->textCursor();
561 preamble_coords_[current_id_] =
562 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
567 void PreambleModule::editExternal() {
572 preambleTE->setReadOnly(false);
573 FileName const tempfilename = tempfile_->name();
574 docstring const s = tempfilename.fileContents("UTF-8");
575 preambleTE->document()->setPlainText(toqstr(s));
577 editPB->setText(qt_("&Edit"));
582 string const format =
583 current_id_->params().documentClass().outputFormat();
584 string const ext = theFormats().extension(format);
585 tempfile_.reset(new TempFile("preamble_editXXXXXX." + ext));
586 FileName const tempfilename = tempfile_->name();
587 string const name = tempfilename.toFilesystemEncoding();
588 ofdocstream os(name.c_str());
589 os << qstring_to_ucs4(preambleTE->document()->toPlainText());
591 preambleTE->setReadOnly(true);
592 theFormats().edit(*current_id_, tempfilename, format);
593 editPB->setText(qt_("&End Edit"));
597 /////////////////////////////////////////////////////////////////////
601 /////////////////////////////////////////////////////////////////////
604 LocalLayout::LocalLayout(QWidget * parent)
605 : UiWidget<Ui::LocalLayoutUi>(parent), current_id_(nullptr), validated_(false)
607 locallayoutTE->setFont(guiApp->typewriterSystemFont());
608 locallayoutTE->setWordWrapMode(QTextOption::NoWrap);
609 connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
610 connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
611 connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
612 connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
616 void LocalLayout::update(BufferParams const & params, BufferId id)
618 QString layout = toqstr(params.getLocalLayout(false));
619 // Nothing to do if the params and preamble are unchanged.
620 if (id == current_id_
621 && layout == locallayoutTE->document()->toPlainText())
624 // Save the params address for further use.
626 locallayoutTE->document()->setPlainText(layout);
631 void LocalLayout::apply(BufferParams & params)
633 docstring const layout =
634 qstring_to_ucs4(locallayoutTE->document()->toPlainText());
635 params.setLocalLayout(layout, false);
639 void LocalLayout::hideConvert()
641 convertPB->setEnabled(false);
642 convertLB->setText("");
648 void LocalLayout::textChanged()
650 // Flashy red bold text
651 static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; text-align:left\">"
653 static const QString message = ivpar.arg(qt_("Validation required!"));
654 string const layout =
655 fromqstr(locallayoutTE->document()->toPlainText().trimmed());
657 if (layout.empty()) {
659 validatePB->setEnabled(false);
660 validLB->setText("");
663 } else if (!validatePB->isEnabled()) {
664 // if that's already enabled, we shouldn't need to do anything.
666 validLB->setText(message);
667 validatePB->setEnabled(true);
674 void LocalLayout::convert() {
675 string const layout =
676 fromqstr(locallayoutTE->document()->toPlainText().trimmed());
677 string const newlayout = TextClass::convert(layout);
678 if (!newlayout.empty())
679 locallayoutTE->setPlainText(toqstr(newlayout));
684 void LocalLayout::convertPressed() {
691 void LocalLayout::validate() {
693 static const QString vpar("<p style=\"font-weight: bold; text-align:left\">%1</p>");
694 // Flashy red bold text
695 static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; text-align:left\">"
697 string const layout =
698 fromqstr(locallayoutTE->document()->toPlainText().trimmed());
699 if (!layout.empty()) {
700 TextClass::ReturnValues const ret = TextClass::validate(layout);
701 validated_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
702 validatePB->setEnabled(false);
703 validLB->setText(validated_ ? vpar.arg(qt_("Layout is valid!"))
704 : ivpar.arg(qt_("Layout is invalid!")));
705 if (ret == TextClass::OK_OLDFORMAT) {
707 // Testing conversion to LYXFILE_LAYOUT_FORMAT at this point
709 if (TextClass::convert(layout).empty()) {
710 // Conversion failed. If LAYOUT_FORMAT > LYXFILE_LAYOUT_FORMAT,
711 // then maybe the layout is still valid, but its format is more
712 // recent than LYXFILE_LAYOUT_FORMAT. However, if LAYOUT_FORMAT
713 // == LYXFILE_LAYOUT_FORMAT then something is definitely wrong.
714 convertPB->setEnabled(false);
715 const QString text = (LAYOUT_FORMAT == LYXFILE_LAYOUT_FORMAT)
716 ? ivpar.arg(qt_("Conversion to current format impossible!"))
717 : vpar.arg(qt_("Conversion to current stable format "
719 convertLB->setText(text);
721 convertPB->setEnabled(true);
722 convertLB->setText(qt_("Convert to current format"));
733 void LocalLayout::validatePressed() {
739 void LocalLayout::editExternal() {
744 locallayoutTE->setReadOnly(false);
745 FileName const tempfilename = tempfile_->name();
746 docstring const s = tempfilename.fileContents("UTF-8");
747 locallayoutTE->document()->setPlainText(toqstr(s));
749 editPB->setText(qt_("&Edit"));
754 string const format =
755 current_id_->params().documentClass().outputFormat();
756 string const ext = theFormats().extension(format);
757 tempfile_.reset(new TempFile("preamble_editXXXXXX." + ext));
758 FileName const tempfilename = tempfile_->name();
759 string const name = tempfilename.toFilesystemEncoding();
760 ofdocstream os(name.c_str());
761 os << qstring_to_ucs4(locallayoutTE->document()->toPlainText());
763 locallayoutTE->setReadOnly(true);
764 theFormats().edit(*current_id_, tempfilename, format);
765 editPB->setText(qt_("&End Edit"));
766 validatePB->setEnabled(false);
771 /////////////////////////////////////////////////////////////////////
775 /////////////////////////////////////////////////////////////////////
778 GuiDocument::GuiDocument(GuiView & lv)
779 : GuiDialog(lv, "document", qt_("Document Settings")),
780 biblioChanged_(false), nonModuleChanged_(false),
781 modulesChanged_(false), shellescapeChanged_(false)
785 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
786 this, SLOT(slotButtonBox(QAbstractButton *)));
788 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
789 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
791 // Manage the restore, ok, apply, restore and cancel/close buttons
792 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
793 bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
794 bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
795 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
796 bc().setRestore(buttonBox->button(QDialogButtonBox::Reset));
800 textLayoutModule = new UiWidget<Ui::TextLayoutUi>(this);
801 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
802 this, SLOT(change_adaptor()));
803 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
804 this, SLOT(setLSpacing(int)));
805 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString &)),
806 this, SLOT(change_adaptor()));
808 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
809 this, SLOT(change_adaptor()));
810 connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
811 textLayoutModule->indentCO, SLOT(setEnabled(bool)));
812 connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
813 this, SLOT(change_adaptor()));
814 connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
815 this, SLOT(setIndent(int)));
816 connect(textLayoutModule->indentLE, SIGNAL(textChanged(const QString &)),
817 this, SLOT(change_adaptor()));
818 connect(textLayoutModule->indentLengthCO, SIGNAL(activated(int)),
819 this, SLOT(change_adaptor()));
821 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
822 this, SLOT(change_adaptor()));
823 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
824 textLayoutModule->skipCO, SLOT(setEnabled(bool)));
825 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
826 this, SLOT(change_adaptor()));
827 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
828 this, SLOT(setSkip(int)));
829 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
830 this, SLOT(change_adaptor()));
831 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
832 this, SLOT(change_adaptor()));
834 connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
835 this, SLOT(enableIndent(bool)));
836 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
837 this, SLOT(enableSkip(bool)));
839 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
840 this, SLOT(change_adaptor()));
841 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
842 this, SLOT(setColSep()));
843 connect(textLayoutModule->justCB, SIGNAL(clicked()),
844 this, SLOT(change_adaptor()));
846 connect(textLayoutModule->tableStyleCO, SIGNAL(activated(int)),
847 this, SLOT(change_adaptor()));
849 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
850 textLayoutModule->lspacingLE));
851 textLayoutModule->indentLE->setValidator(new LengthValidator(
852 textLayoutModule->indentLE));
853 textLayoutModule->skipLE->setValidator(new LengthValidator(
854 textLayoutModule->skipLE));
856 textLayoutModule->indentCO->addItem(qt_("Default"));
857 textLayoutModule->indentCO->addItem(qt_("Custom"));
858 textLayoutModule->skipCO->addItem(qt_("Half line height"), VSpace::HALFLINE);
859 textLayoutModule->skipCO->addItem(qt_("Line height"), VSpace::FULLLINE);
860 textLayoutModule->skipCO->addItem(qt_("SmallSkip"), VSpace::SMALLSKIP);
861 textLayoutModule->skipCO->addItem(qt_("MedSkip"), VSpace::MEDSKIP);
862 textLayoutModule->skipCO->addItem(qt_("BigSkip"), VSpace::BIGSKIP);
863 textLayoutModule->skipCO->addItem(qt_("Custom"), VSpace::LENGTH);
864 textLayoutModule->lspacingCO->insertItem(
865 Spacing::Single, qt_("Single"));
866 textLayoutModule->lspacingCO->insertItem(
867 Spacing::Onehalf, qt_("OneHalf"));
868 textLayoutModule->lspacingCO->insertItem(
869 Spacing::Double, qt_("Double"));
870 textLayoutModule->lspacingCO->insertItem(
871 Spacing::Other, qt_("Custom"));
872 // initialize the length validator
873 bc().addCheckedLineEdit(textLayoutModule->indentLE);
874 bc().addCheckedLineEdit(textLayoutModule->skipLE);
876 textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default"));
880 // master/child handling
881 masterChildModule = new UiWidget<Ui::MasterChildUi>(this);
883 connect(masterChildModule->childrenTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
884 this, SLOT(includeonlyClicked(QTreeWidgetItem *, int)));
885 connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
886 masterChildModule->childrenTW, SLOT(setEnabled(bool)));
887 connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
888 masterChildModule->maintainGB, SLOT(setEnabled(bool)));
889 connect(masterChildModule->includeallRB, SIGNAL(clicked()),
890 this, SLOT(change_adaptor()));
891 connect(masterChildModule->includeonlyRB, SIGNAL(clicked()),
892 this, SLOT(change_adaptor()));
893 connect(masterChildModule->maintainCRNoneRB, SIGNAL(clicked()),
894 this, SLOT(change_adaptor()));
895 connect(masterChildModule->maintainCRMostlyRB, SIGNAL(clicked()),
896 this, SLOT(change_adaptor()));
897 connect(masterChildModule->maintainCRStrictRB, SIGNAL(clicked()),
898 this, SLOT(change_adaptor()));
899 masterChildModule->childrenTW->setColumnCount(2);
900 masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
901 masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output"));
902 #if (QT_VERSION > 0x050000)
903 masterChildModule->childrenTW->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
904 masterChildModule->childrenTW->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
906 masterChildModule->childrenTW->header()->setResizeMode(0, QHeaderView::ResizeToContents);
907 masterChildModule->childrenTW->header()->setResizeMode(1, QHeaderView::ResizeToContents);
911 outputModule = new UiWidget<Ui::OutputUi>(this);
913 connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
914 this, SLOT(change_adaptor()));
915 connect(outputModule->mathimgSB, SIGNAL(valueChanged(double)),
916 this, SLOT(change_adaptor()));
917 connect(outputModule->strictCB, SIGNAL(stateChanged(int)),
918 this, SLOT(change_adaptor()));
919 connect(outputModule->cssCB, SIGNAL(stateChanged(int)),
920 this, SLOT(change_adaptor()));
921 connect(outputModule->mathoutCB, SIGNAL(currentIndexChanged(int)),
922 this, SLOT(change_adaptor()));
923 connect(outputModule->tableoutCB, SIGNAL(currentIndexChanged(int)),
924 this, SLOT(change_adaptor()));
926 connect(outputModule->shellescapeCB, SIGNAL(stateChanged(int)),
927 this, SLOT(shellescapeChanged()));
928 connect(outputModule->outputsyncCB, SIGNAL(toggled(bool)),
929 this, SLOT(setOutputSync(bool)));
930 connect(outputModule->synccustomCB, SIGNAL(editTextChanged(QString)),
931 this, SLOT(change_adaptor()));
932 outputModule->synccustomCB->addItem("");
933 outputModule->synccustomCB->addItem("\\synctex=1");
934 outputModule->synccustomCB->addItem("\\synctex=-1");
935 outputModule->synccustomCB->addItem("\\usepackage[active]{srcltx}");
937 outputModule->synccustomCB->setValidator(new NoNewLineValidator(
938 outputModule->synccustomCB));
940 connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
941 this, SLOT(change_adaptor()));
942 connect(outputModule->postponeFragileCB, SIGNAL(clicked()),
943 this, SLOT(change_adaptor()));
947 // this must precede font, since fonts depend on this
948 langModule = new UiWidget<Ui::LanguageUi>(this);
949 connect(langModule->languageCO, SIGNAL(activated(int)),
950 this, SLOT(change_adaptor()));
951 connect(langModule->languageCO, SIGNAL(activated(int)),
952 this, SLOT(languageChanged(int)));
953 connect(langModule->encodingCO, SIGNAL(activated(int)),
954 this, SLOT(change_adaptor()));
955 connect(langModule->encodingCO, SIGNAL(activated(int)),
956 this, SLOT(encodingSwitched(int)));
957 connect(langModule->unicodeEncodingCO, SIGNAL(activated(int)),
958 this, SLOT(change_adaptor()));
959 connect(langModule->autoEncodingCO, SIGNAL(activated(int)),
960 this, SLOT(change_adaptor()));
961 connect(langModule->customEncodingCO, SIGNAL(activated(int)),
962 this, SLOT(change_adaptor()));
963 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
964 this, SLOT(change_adaptor()));
965 connect(langModule->languagePackageCO, SIGNAL(activated(int)),
966 this, SLOT(change_adaptor()));
967 connect(langModule->languagePackageLE, SIGNAL(textChanged(QString)),
968 this, SLOT(change_adaptor()));
969 connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
970 this, SLOT(languagePackageChanged(int)));
971 connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
972 this, SLOT(change_adaptor()));
974 langModule->languagePackageLE->setValidator(new NoNewLineValidator(
975 langModule->languagePackageLE));
977 QAbstractItemModel * language_model = guiApp->languageModel();
978 // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
979 language_model->sort(0);
980 langModule->languageCO->setModel(language_model);
981 langModule->languageCO->setModelColumn(0);
983 langModule->encodingCO->addItem(qt_("Unicode (utf8)"));
984 langModule->encodingCO->addItem(qt_("Traditional (auto-selected)"));
985 langModule->encodingCO->addItem(qt_("Custom"));
986 langModule->encodingCO->setItemData(EncodingSets::unicode,
987 qt_("Select Unicode (utf8) encoding."), Qt::ToolTipRole);
988 langModule->encodingCO->setItemData(EncodingSets::legacy,
989 qt_("Use language-dependent traditional encodings."), Qt::ToolTipRole);
990 langModule->encodingCO->setItemData(EncodingSets::custom,
991 qt_("Select a custom, document-wide encoding."), Qt::ToolTipRole);
993 // basic Unicode encodings: keep order
994 const QStringList utf8_base_encodings = {"utf8", "utf8-plain", "utf8x"};
995 for (auto const & i : utf8_base_encodings) {
996 langModule->unicodeEncodingCO->addItem(
997 qt_(encodings.fromLyXName(fromqstr(i))->guiName()), i);
999 langModule->unicodeEncodingCO->setItemData(0,
1000 qt_("Standard Unicode support by the ``inputenc'' package."),
1002 langModule->unicodeEncodingCO->setItemData(1,
1003 qt_("Use UTF-8 'as-is': do not load any supporting packages, "
1004 "do not convert any characters to LaTeX macros. "
1005 "For use with non-TeX fonts (XeTeX/LuaTeX) or custom preamble code."),
1007 langModule->unicodeEncodingCO->setItemData(2,
1008 qt_("Load ``inputenc'' with option 'utf8x' "
1009 "for extended Unicode support by the ``ucs'' package."),
1011 langModule->autoEncodingCO->addItem(qt_("Language Default"), toqstr("auto-legacy"));
1012 langModule->autoEncodingCO->addItem(qt_("Language Default (no inputenc)"), toqstr("auto-legacy-plain"));
1013 langModule->autoEncodingCO->setItemData(0,
1014 qt_("Use the traditional default encoding of the text language. Switch encoding "
1015 "if a text part is set to a language with different default."),
1017 langModule->autoEncodingCO->setItemData(1,
1018 qt_("Do not load the 'inputenc' package. Switch encoding if required "
1019 "but do not write input encoding switch commands to the source."),
1022 QMap<QString,QString> encodingmap;
1023 QMap<QString,QString> encodingmap_utf8;
1024 for (auto const & encvar : encodings) {
1025 if (encvar.unsafe() ||encvar.guiName().empty()
1026 || utf8_base_encodings.contains(toqstr(encvar.name())))
1028 if (std::string(encvar.name()).find("utf8") == 0)
1029 encodingmap_utf8.insert(qt_(encvar.guiName()), toqstr(encvar.name()));
1031 encodingmap.insert(qt_(encvar.guiName()), toqstr(encvar.name()));
1033 for (auto const & i : encodingmap_utf8.keys()) {
1034 langModule->unicodeEncodingCO->addItem(i, encodingmap_utf8.value(i));
1036 for (auto const & i : encodingmap.keys()) {
1037 langModule->customEncodingCO->addItem(i, encodingmap.value(i));
1039 // equalise the width of encoding selectors
1040 langModule->autoEncodingCO->setMinimumSize(
1041 langModule->unicodeEncodingCO->minimumSizeHint());
1042 langModule->customEncodingCO->setMinimumSize(
1043 langModule->unicodeEncodingCO->minimumSizeHint());
1045 langModule->languagePackageCO->addItem(
1046 qt_("Default"), toqstr("default"));
1047 langModule->languagePackageCO->addItem(
1048 qt_("Automatic"), toqstr("auto"));
1049 langModule->languagePackageCO->addItem(
1050 qt_("Always Babel"), toqstr("babel"));
1051 langModule->languagePackageCO->addItem(
1052 qt_("Custom"), toqstr("custom"));
1053 langModule->languagePackageCO->addItem(
1054 qt_("None[[language package]]"), toqstr("none"));
1058 fontModule = new FontModule(this);
1059 connect(fontModule->osFontsCB, SIGNAL(clicked()),
1060 this, SLOT(change_adaptor()));
1061 connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
1062 this, SLOT(osFontsChanged(bool)));
1063 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
1064 this, SLOT(change_adaptor()));
1065 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
1066 this, SLOT(romanChanged(int)));
1067 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
1068 this, SLOT(change_adaptor()));
1069 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
1070 this, SLOT(sansChanged(int)));
1071 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
1072 this, SLOT(change_adaptor()));
1073 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
1074 this, SLOT(ttChanged(int)));
1075 connect(fontModule->fontsMathCO, SIGNAL(activated(int)),
1076 this, SLOT(change_adaptor()));
1077 connect(fontModule->fontsMathCO, SIGNAL(activated(int)),
1078 this, SLOT(mathFontChanged(int)));
1079 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
1080 this, SLOT(change_adaptor()));
1081 connect(fontModule->fontencCO, SIGNAL(activated(int)),
1082 this, SLOT(change_adaptor()));
1083 connect(fontModule->fontencCO, SIGNAL(activated(int)),
1084 this, SLOT(fontencChanged(int)));
1085 connect(fontModule->fontencLE, SIGNAL(textChanged(const QString &)),
1086 this, SLOT(change_adaptor()));
1087 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
1088 this, SLOT(change_adaptor()));
1089 connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
1090 this, SLOT(change_adaptor()));
1091 connect(fontModule->microtypeCB, SIGNAL(clicked()),
1092 this, SLOT(change_adaptor()));
1093 connect(fontModule->dashesCB, SIGNAL(clicked()),
1094 this, SLOT(change_adaptor()));
1095 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
1096 this, SLOT(change_adaptor()));
1097 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
1098 this, SLOT(change_adaptor()));
1099 connect(fontModule->fontScCB, SIGNAL(clicked()),
1100 this, SLOT(change_adaptor()));
1101 connect(fontModule->fontScCB, SIGNAL(toggled(bool)),
1102 this, SLOT(fontScToggled(bool)));
1103 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
1104 this, SLOT(change_adaptor()));
1105 connect(fontModule->fontOsfCB, SIGNAL(toggled(bool)),
1106 this, SLOT(fontOsfToggled(bool)));
1107 connect(fontModule->fontSansOsfCB, SIGNAL(clicked()),
1108 this, SLOT(change_adaptor()));
1109 connect(fontModule->fontTypewriterOsfCB, SIGNAL(clicked()),
1110 this, SLOT(change_adaptor()));
1111 connect(fontModule->fontspecRomanLE, SIGNAL(textChanged(const QString &)),
1112 this, SLOT(change_adaptor()));
1113 connect(fontModule->fontspecSansLE, SIGNAL(textChanged(const QString &)),
1114 this, SLOT(change_adaptor()));
1115 connect(fontModule->fontspecTypewriterLE, SIGNAL(textChanged(const QString &)),
1116 this, SLOT(change_adaptor()));
1118 fontModule->fontencLE->setValidator(new NoNewLineValidator(
1119 fontModule->fontencLE));
1120 fontModule->cjkFontLE->setValidator(new NoNewLineValidator(
1121 fontModule->cjkFontLE));
1122 fontModule->fontspecRomanLE->setValidator(new NoNewLineValidator(
1123 fontModule->fontspecRomanLE));
1124 fontModule->fontspecSansLE->setValidator(new NoNewLineValidator(
1125 fontModule->fontspecSansLE));
1126 fontModule->fontspecTypewriterLE->setValidator(new NoNewLineValidator(
1127 fontModule->fontspecTypewriterLE));
1131 fontModule->fontsizeCO->addItem(qt_("Default"));
1132 fontModule->fontsizeCO->addItem(qt_("10"));
1133 fontModule->fontsizeCO->addItem(qt_("11"));
1134 fontModule->fontsizeCO->addItem(qt_("12"));
1136 fontModule->fontencCO->addItem(qt_("Automatic[[encoding]]"), QString("auto"));
1137 fontModule->fontencCO->addItem(qt_("Class Default"), QString("default"));
1138 fontModule->fontencCO->addItem(qt_("Custom"), QString("custom"));
1140 for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
1141 fontModule->fontsDefaultCO->addItem(
1142 qt_(GuiDocument::fontfamilies_gui[n]));
1144 if (!LaTeXFeatures::isAvailable("fontspec"))
1145 fontModule->osFontsCB->setToolTip(
1146 qt_("Use OpenType and TrueType fonts directly (requires XeTeX or LuaTeX)\n"
1147 "You need to install the package \"fontspec\" to use this feature"));
1151 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>(this);
1152 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
1153 this, SLOT(papersizeChanged(int)));
1154 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
1155 this, SLOT(papersizeChanged(int)));
1156 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
1157 this, SLOT(change_adaptor()));
1158 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
1159 this, SLOT(change_adaptor()));
1160 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
1161 this, SLOT(change_adaptor()));
1162 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
1163 this, SLOT(change_adaptor()));
1164 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
1165 this, SLOT(change_adaptor()));
1166 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
1167 this, SLOT(change_adaptor()));
1168 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
1169 this, SLOT(change_adaptor()));
1170 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
1171 this, SLOT(change_adaptor()));
1172 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
1173 this, SLOT(change_adaptor()));
1174 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
1175 this, SLOT(change_adaptor()));
1177 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
1178 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
1179 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
1180 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
1181 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
1182 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
1183 pageLayoutModule->paperheightL);
1184 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
1185 pageLayoutModule->paperwidthL);
1187 QComboBox * cb = pageLayoutModule->papersizeCO;
1188 cb->addItem(qt_("Default"));
1189 cb->addItem(qt_("Custom"));
1190 cb->addItem(qt_("US letter"));
1191 cb->addItem(qt_("US legal"));
1192 cb->addItem(qt_("US executive"));
1193 cb->addItem(qt_("A0"));
1194 cb->addItem(qt_("A1"));
1195 cb->addItem(qt_("A2"));
1196 cb->addItem(qt_("A3"));
1197 cb->addItem(qt_("A4"));
1198 cb->addItem(qt_("A5"));
1199 cb->addItem(qt_("A6"));
1200 cb->addItem(qt_("B0"));
1201 cb->addItem(qt_("B1"));
1202 cb->addItem(qt_("B2"));
1203 cb->addItem(qt_("B3"));
1204 cb->addItem(qt_("B4"));
1205 cb->addItem(qt_("B5"));
1206 cb->addItem(qt_("B6"));
1207 cb->addItem(qt_("C0"));
1208 cb->addItem(qt_("C1"));
1209 cb->addItem(qt_("C2"));
1210 cb->addItem(qt_("C3"));
1211 cb->addItem(qt_("C4"));
1212 cb->addItem(qt_("C5"));
1213 cb->addItem(qt_("C6"));
1214 cb->addItem(qt_("JIS B0"));
1215 cb->addItem(qt_("JIS B1"));
1216 cb->addItem(qt_("JIS B2"));
1217 cb->addItem(qt_("JIS B3"));
1218 cb->addItem(qt_("JIS B4"));
1219 cb->addItem(qt_("JIS B5"));
1220 cb->addItem(qt_("JIS B6"));
1221 // remove the %-items from the unit choice
1222 pageLayoutModule->paperwidthUnitCO->noPercents();
1223 pageLayoutModule->paperheightUnitCO->noPercents();
1224 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
1225 pageLayoutModule->paperheightLE));
1226 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
1227 pageLayoutModule->paperwidthLE));
1231 marginsModule = new UiWidget<Ui::MarginsUi>(this);
1232 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
1233 this, SLOT(setCustomMargins(bool)));
1234 connect(marginsModule->marginCB, SIGNAL(clicked()),
1235 this, SLOT(change_adaptor()));
1236 connect(marginsModule->topLE, SIGNAL(textChanged(QString)),
1237 this, SLOT(change_adaptor()));
1238 connect(marginsModule->topUnit, SIGNAL(activated(int)),
1239 this, SLOT(change_adaptor()));
1240 connect(marginsModule->bottomLE, SIGNAL(textChanged(QString)),
1241 this, SLOT(change_adaptor()));
1242 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
1243 this, SLOT(change_adaptor()));
1244 connect(marginsModule->innerLE, SIGNAL(textChanged(QString)),
1245 this, SLOT(change_adaptor()));
1246 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
1247 this, SLOT(change_adaptor()));
1248 connect(marginsModule->outerLE, SIGNAL(textChanged(QString)),
1249 this, SLOT(change_adaptor()));
1250 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
1251 this, SLOT(change_adaptor()));
1252 connect(marginsModule->headheightLE, SIGNAL(textChanged(QString)),
1253 this, SLOT(change_adaptor()));
1254 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
1255 this, SLOT(change_adaptor()));
1256 connect(marginsModule->headsepLE, SIGNAL(textChanged(QString)),
1257 this, SLOT(change_adaptor()));
1258 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
1259 this, SLOT(change_adaptor()));
1260 connect(marginsModule->footskipLE, SIGNAL(textChanged(QString)),
1261 this, SLOT(change_adaptor()));
1262 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
1263 this, SLOT(change_adaptor()));
1264 connect(marginsModule->columnsepLE, SIGNAL(textChanged(QString)),
1265 this, SLOT(change_adaptor()));
1266 connect(marginsModule->columnsepUnit, SIGNAL(activated(int)),
1267 this, SLOT(change_adaptor()));
1268 marginsModule->topLE->setValidator(new LengthValidator(
1269 marginsModule->topLE));
1270 marginsModule->bottomLE->setValidator(new LengthValidator(
1271 marginsModule->bottomLE));
1272 marginsModule->innerLE->setValidator(new LengthValidator(
1273 marginsModule->innerLE));
1274 marginsModule->outerLE->setValidator(new LengthValidator(
1275 marginsModule->outerLE));
1276 marginsModule->headsepLE->setValidator(new LengthValidator(
1277 marginsModule->headsepLE));
1278 marginsModule->headheightLE->setValidator(new LengthValidator(
1279 marginsModule->headheightLE));
1280 marginsModule->footskipLE->setValidator(new LengthValidator(
1281 marginsModule->footskipLE));
1282 marginsModule->columnsepLE->setValidator(new LengthValidator(
1283 marginsModule->columnsepLE));
1285 bc().addCheckedLineEdit(marginsModule->topLE,
1286 marginsModule->topL);
1287 bc().addCheckedLineEdit(marginsModule->bottomLE,
1288 marginsModule->bottomL);
1289 bc().addCheckedLineEdit(marginsModule->innerLE,
1290 marginsModule->innerL);
1291 bc().addCheckedLineEdit(marginsModule->outerLE,
1292 marginsModule->outerL);
1293 bc().addCheckedLineEdit(marginsModule->headsepLE,
1294 marginsModule->headsepL);
1295 bc().addCheckedLineEdit(marginsModule->headheightLE,
1296 marginsModule->headheightL);
1297 bc().addCheckedLineEdit(marginsModule->footskipLE,
1298 marginsModule->footskipL);
1299 bc().addCheckedLineEdit(marginsModule->columnsepLE,
1300 marginsModule->columnsepL);
1304 colorModule = new UiWidget<Ui::ColorUi>(this);
1305 connect(colorModule->fontColorPB, SIGNAL(clicked()),
1306 this, SLOT(changeFontColor()));
1307 connect(colorModule->delFontColorTB, SIGNAL(clicked()),
1308 this, SLOT(deleteFontColor()));
1309 connect(colorModule->noteFontColorPB, SIGNAL(clicked()),
1310 this, SLOT(changeNoteFontColor()));
1311 connect(colorModule->delNoteFontColorTB, SIGNAL(clicked()),
1312 this, SLOT(deleteNoteFontColor()));
1313 connect(colorModule->backgroundPB, SIGNAL(clicked()),
1314 this, SLOT(changeBackgroundColor()));
1315 connect(colorModule->delBackgroundTB, SIGNAL(clicked()),
1316 this, SLOT(deleteBackgroundColor()));
1317 connect(colorModule->boxBackgroundPB, SIGNAL(clicked()),
1318 this, SLOT(changeBoxBackgroundColor()));
1319 connect(colorModule->delBoxBackgroundTB, SIGNAL(clicked()),
1320 this, SLOT(deleteBoxBackgroundColor()));
1323 changesModule = new UiWidget<Ui::ChangeTrackingUi>(this);
1324 connect(changesModule->trackChangesCB, SIGNAL(clicked()),
1325 this, SLOT(change_adaptor()));
1326 connect(changesModule->outputChangesCB, SIGNAL(toggled(bool)),
1327 this, SLOT(outputChangesToggled(bool)));
1328 connect(changesModule->changeBarsCB, SIGNAL(clicked()),
1329 this, SLOT(change_adaptor()));
1332 numberingModule = new UiWidget<Ui::NumberingUi>(this);
1333 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
1334 this, SLOT(change_adaptor()));
1335 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
1336 this, SLOT(change_adaptor()));
1337 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
1338 this, SLOT(updateNumbering()));
1339 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
1340 this, SLOT(updateNumbering()));
1341 numberingModule->tocTW->setColumnCount(3);
1342 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
1343 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
1344 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
1345 setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
1346 connect(numberingModule->linenoCB, SIGNAL(toggled(bool)),
1347 this, SLOT(linenoToggled(bool)));
1348 connect(numberingModule->linenoCB, SIGNAL(clicked()),
1349 this, SLOT(change_adaptor()));
1350 connect(numberingModule->linenoLE, SIGNAL(textChanged(QString)),
1351 this, SLOT(change_adaptor()));
1355 biblioModule = new UiWidget<Ui::BiblioUi>(this);
1356 connect(biblioModule->citeEngineCO, SIGNAL(activated(int)),
1357 this, SLOT(citeEngineChanged(int)));
1358 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
1359 this, SLOT(citeStyleChanged()));
1360 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
1361 this, SLOT(biblioChanged()));
1362 connect(biblioModule->bibunitsCO, SIGNAL(activated(int)),
1363 this, SLOT(biblioChanged()));
1364 connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
1365 this, SLOT(bibtexChanged(int)));
1366 connect(biblioModule->bibtexOptionsLE, SIGNAL(textChanged(QString)),
1367 this, SLOT(biblioChanged()));
1368 connect(biblioModule->citePackageOptionsLE, SIGNAL(textChanged(QString)),
1369 this, SLOT(biblioChanged()));
1370 connect(biblioModule->defaultBiblioCO, SIGNAL(activated(int)),
1371 this, SLOT(biblioChanged()));
1372 connect(biblioModule->defaultBiblioCO, SIGNAL(editTextChanged(QString)),
1373 this, SLOT(biblioChanged()));
1374 connect(biblioModule->defaultBiblioCO, SIGNAL(editTextChanged(QString)),
1375 this, SLOT(updateResetDefaultBiblio()));
1376 connect(biblioModule->biblatexBbxCO, SIGNAL(activated(int)),
1377 this, SLOT(biblioChanged()));
1378 connect(biblioModule->biblatexBbxCO, SIGNAL(editTextChanged(QString)),
1379 this, SLOT(biblioChanged()));
1380 connect(biblioModule->biblatexBbxCO, SIGNAL(editTextChanged(QString)),
1381 this, SLOT(updateResetDefaultBiblio()));
1382 connect(biblioModule->biblatexCbxCO, SIGNAL(activated(int)),
1383 this, SLOT(biblioChanged()));
1384 connect(biblioModule->biblatexCbxCO, SIGNAL(editTextChanged(QString)),
1385 this, SLOT(biblioChanged()));
1386 connect(biblioModule->biblatexCbxCO, SIGNAL(editTextChanged(QString)),
1387 this, SLOT(updateResetDefaultBiblio()));
1388 connect(biblioModule->rescanBibliosPB, SIGNAL(clicked()),
1389 this, SLOT(rescanBibFiles()));
1390 connect(biblioModule->resetDefaultBiblioPB, SIGNAL(clicked()),
1391 this, SLOT(resetDefaultBibfile()));
1392 connect(biblioModule->resetCbxPB, SIGNAL(clicked()),
1393 this, SLOT(resetDefaultCbxBibfile()));
1394 connect(biblioModule->resetBbxPB, SIGNAL(clicked()),
1395 this, SLOT(resetDefaultBbxBibfile()));
1396 connect(biblioModule->matchBbxPB, SIGNAL(clicked()),
1397 this, SLOT(matchBiblatexStyles()));
1399 biblioModule->citeEngineCO->clear();
1400 for (LyXCiteEngine const & cet : theCiteEnginesList) {
1401 biblioModule->citeEngineCO->addItem(qt_(cet.getName()), toqstr(cet.getID()));
1402 int const i = biblioModule->citeEngineCO->findData(toqstr(cet.getID()));
1403 biblioModule->citeEngineCO->setItemData(i, qt_(cet.getDescription()),
1407 biblioModule->bibtexOptionsLE->setValidator(new NoNewLineValidator(
1408 biblioModule->bibtexOptionsLE));
1409 biblioModule->defaultBiblioCO->lineEdit()->setValidator(new NoNewLineValidator(
1410 biblioModule->defaultBiblioCO->lineEdit()));
1411 biblioModule->citePackageOptionsLE->setValidator(new NoNewLineValidator(
1412 biblioModule->citePackageOptionsLE));
1414 // NOTE: we do not provide "custom" here for security reasons!
1415 biblioModule->bibtexCO->clear();
1416 biblioModule->bibtexCO->addItem(qt_("Default"), QString("default"));
1417 for (auto const & alts : lyxrc.bibtex_alternatives) {
1418 QString const command = toqstr(alts).left(toqstr(alts).indexOf(" "));
1419 biblioModule->bibtexCO->addItem(command, command);
1424 indicesModule = new GuiIndices;
1425 connect(indicesModule, SIGNAL(changed()),
1426 this, SLOT(change_adaptor()));
1430 mathsModule = new UiWidget<Ui::MathsUi>(this);
1431 QStringList headers;
1432 headers << qt_("Package") << qt_("Load automatically")
1433 << qt_("Load always") << qt_("Do not load");
1434 mathsModule->packagesTW->setHorizontalHeaderLabels(headers);
1435 setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
1436 map<string, string> const & packages = BufferParams::auto_packages();
1437 mathsModule->packagesTW->setRowCount(packages.size());
1439 for (auto const & pkgvar : packages) {
1440 docstring const package = from_ascii(pkgvar.first);
1441 QString autoTooltip = qt_(pkgvar.second);
1442 QString alwaysTooltip;
1443 if (package == "amsmath")
1445 qt_("The AMS LaTeX packages are always used");
1447 alwaysTooltip = toqstr(bformat(
1448 _("The LaTeX package %1$s is always used"),
1450 QString neverTooltip;
1451 if (package == "amsmath")
1453 qt_("The AMS LaTeX packages are never used");
1455 neverTooltip = toqstr(bformat(
1456 _("The LaTeX package %1$s is never used"),
1458 QRadioButton * autoRB = new QRadioButton(mathsModule);
1459 QRadioButton * alwaysRB = new QRadioButton(mathsModule);
1460 QRadioButton * neverRB = new QRadioButton(mathsModule);
1461 QButtonGroup * packageGroup = new QButtonGroup(mathsModule);
1462 packageGroup->addButton(autoRB);
1463 packageGroup->addButton(alwaysRB);
1464 packageGroup->addButton(neverRB);
1465 autoRB->setToolTip(autoTooltip);
1466 alwaysRB->setToolTip(alwaysTooltip);
1467 neverRB->setToolTip(neverTooltip);
1469 // Pack the buttons in a layout in order to get proper alignment
1470 QWidget * autoRBWidget = new QWidget();
1471 QHBoxLayout * autoRBLayout = new QHBoxLayout(autoRBWidget);
1472 autoRBLayout->addWidget(autoRB);
1473 autoRBLayout->setAlignment(Qt::AlignCenter);
1474 autoRBLayout->setContentsMargins(0, 0, 0, 0);
1475 autoRBWidget->setLayout(autoRBLayout);
1477 QWidget * alwaysRBWidget = new QWidget();
1478 QHBoxLayout * alwaysRBLayout = new QHBoxLayout(alwaysRBWidget);
1479 alwaysRBLayout->addWidget(alwaysRB);
1480 alwaysRBLayout->setAlignment(Qt::AlignCenter);
1481 alwaysRBLayout->setContentsMargins(0, 0, 0, 0);
1482 alwaysRBWidget->setLayout(alwaysRBLayout);
1484 QWidget * neverRBWidget = new QWidget();
1485 QHBoxLayout * neverRBLayout = new QHBoxLayout(neverRBWidget);
1486 neverRBLayout->addWidget(neverRB);
1487 neverRBLayout->setAlignment(Qt::AlignCenter);
1488 neverRBLayout->setContentsMargins(0, 0, 0, 0);
1489 neverRBWidget->setLayout(neverRBLayout);
1491 QTableWidgetItem * pack = new QTableWidgetItem(toqstr(package));
1492 mathsModule->packagesTW->setItem(packnum, 0, pack);
1493 mathsModule->packagesTW->setCellWidget(packnum, 1, autoRBWidget);
1494 mathsModule->packagesTW->setCellWidget(packnum, 2, alwaysRBWidget);
1495 mathsModule->packagesTW->setCellWidget(packnum, 3, neverRBWidget);
1497 connect(autoRB, SIGNAL(clicked()),
1498 this, SLOT(change_adaptor()));
1499 connect(alwaysRB, SIGNAL(clicked()),
1500 this, SLOT(change_adaptor()));
1501 connect(neverRB, SIGNAL(clicked()),
1502 this, SLOT(change_adaptor()));
1505 connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
1506 this, SLOT(allPackagesAuto()));
1507 connect(mathsModule->allPackagesAlwaysPB, SIGNAL(clicked()),
1508 this, SLOT(allPackagesAlways()));
1509 connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
1510 this, SLOT(allPackagesNot()));
1511 connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
1512 this, SLOT(change_adaptor()));
1513 connect(mathsModule->allPackagesAlwaysPB, SIGNAL(clicked()),
1514 this, SLOT(change_adaptor()));
1515 connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
1516 this, SLOT(change_adaptor()));
1517 connect(mathsModule->MathNumberingPosCO, SIGNAL(activated(int)),
1518 this, SLOT(change_adaptor()));
1520 connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
1521 this, SLOT(change_adaptor()));
1522 connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
1523 this, SLOT(allowMathIndent()));
1524 connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
1525 this, SLOT(change_adaptor()));
1526 connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
1527 this, SLOT(enableMathIndent(int)));
1528 connect(mathsModule->MathIndentLE, SIGNAL(textChanged(const QString &)),
1529 this, SLOT(change_adaptor()));
1530 connect(mathsModule->MathIndentLengthCO, SIGNAL(activated(int)),
1531 this, SLOT(change_adaptor()));
1534 mathsModule->MathIndentCO->addItem(qt_("Default"));
1535 mathsModule->MathIndentCO->addItem(qt_("Custom"));
1536 mathsModule->MathIndentLE->setValidator(new LengthValidator(
1537 mathsModule->MathIndentLE));
1538 // initialize the length validator
1539 bc().addCheckedLineEdit(mathsModule->MathIndentLE);
1540 mathsModule->MathNumberingPosCO->addItem(qt_("Left"));
1541 mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
1542 mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
1543 mathsModule->MathNumberingPosCO->setCurrentIndex(1);
1547 latexModule = new UiWidget<Ui::LaTeXUi>(this);
1548 connect(latexModule->optionsLE, SIGNAL(textChanged(QString)),
1549 this, SLOT(change_adaptor()));
1550 connect(latexModule->defaultOptionsCB, SIGNAL(clicked()),
1551 this, SLOT(change_adaptor()));
1552 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
1553 this, SLOT(change_adaptor()));
1554 connect(latexModule->classCO, SIGNAL(activated(int)),
1555 this, SLOT(classChanged_adaptor()));
1556 connect(latexModule->classCO, SIGNAL(activated(int)),
1557 this, SLOT(change_adaptor()));
1558 connect(latexModule->layoutPB, SIGNAL(clicked()),
1559 this, SLOT(browseLayout()));
1560 connect(latexModule->layoutPB, SIGNAL(clicked()),
1561 this, SLOT(change_adaptor()));
1562 connect(latexModule->childDocGB, SIGNAL(clicked()),
1563 this, SLOT(change_adaptor()));
1564 connect(latexModule->childDocLE, SIGNAL(textChanged(QString)),
1565 this, SLOT(change_adaptor()));
1566 connect(latexModule->childDocPB, SIGNAL(clicked()),
1567 this, SLOT(browseMaster()));
1568 connect(latexModule->suppressDateCB, SIGNAL(clicked()),
1569 this, SLOT(change_adaptor()));
1570 connect(latexModule->refstyleCB, SIGNAL(clicked()),
1571 this, SLOT(change_adaptor()));
1573 latexModule->optionsLE->setValidator(new NoNewLineValidator(
1574 latexModule->optionsLE));
1575 latexModule->childDocLE->setValidator(new NoNewLineValidator(
1576 latexModule->childDocLE));
1578 // postscript drivers
1579 for (int n = 0; tex_graphics[n][0]; ++n) {
1580 QString enc = qt_(tex_graphics_gui[n]);
1581 latexModule->psdriverCO->addItem(enc);
1584 LayoutFileList const & bcl = LayoutFileList::get();
1585 vector<LayoutFileIndex> classList = bcl.classList();
1586 sort(classList.begin(), classList.end(), less_textclass_avail_desc());
1588 for (auto const & cvar : classList) {
1589 LayoutFile const & tc = bcl[cvar];
1590 bool const available = tc.isTeXClassAvailable();
1591 docstring const guiname = translateIfPossible(from_utf8(tc.description()));
1592 // tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
1593 QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
1595 docstring const output_type = _("LaTeX");
1596 tooltip += '\n' + toqstr(bformat(_("Class not found by LyX. "
1597 "Please check if you have the matching %1$s class "
1598 "and all required packages (%2$s) installed."),
1599 output_type, from_utf8(tc.prerequisites(", "))));
1601 latexModule->classCO->addItemSort(toqstr(tc.name()),
1603 toqstr(translateIfPossible(from_utf8(tc.category()))),
1605 true, true, true, available);
1610 branchesModule = new GuiBranches(this);
1611 connect(branchesModule, SIGNAL(changed()),
1612 this, SLOT(change_adaptor()));
1613 connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)),
1614 this, SLOT(branchesRename(docstring const &, docstring const &)));
1615 connect(branchesModule, SIGNAL(okPressed()), this, SLOT(slotOK()));
1616 updateUnknownBranches();
1620 preambleModule = new PreambleModule(this);
1621 connect(preambleModule, SIGNAL(changed()),
1622 this, SLOT(change_adaptor()));
1624 localLayout = new LocalLayout(this);
1625 connect(localLayout, SIGNAL(changed()),
1626 this, SLOT(change_adaptor()));
1630 bulletsModule = new BulletsModule(this);
1631 connect(bulletsModule, SIGNAL(changed()),
1632 this, SLOT(change_adaptor()));
1636 modulesModule = new UiWidget<Ui::ModulesUi>(this);
1637 modulesModule->availableLV->header()->setVisible(false);
1638 setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents);
1639 modulesModule->availableLV->header()->setStretchLastSection(false);
1640 modulesModule->selectedLV->header()->setVisible(false);
1641 setSectionResizeMode(modulesModule->selectedLV->header(), QHeaderView::ResizeToContents);
1642 modulesModule->selectedLV->header()->setStretchLastSection(false);
1644 new ModuleSelectionManager(this, modulesModule->availableLV,
1645 modulesModule->selectedLV,
1646 modulesModule->addPB,
1647 modulesModule->deletePB,
1648 modulesModule->upPB,
1649 modulesModule->downPB,
1650 availableModel(), selectedModel(), this);
1651 connect(selectionManager, SIGNAL(updateHook()),
1652 this, SLOT(updateModuleInfo()));
1653 connect(selectionManager, SIGNAL(selectionChanged()),
1654 this, SLOT(modulesChanged()));
1656 filter_ = new FancyLineEdit(this);
1657 filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
1658 filter_->setButtonVisible(FancyLineEdit::Right, true);
1659 filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
1660 filter_->setAutoHideButton(FancyLineEdit::Right, true);
1661 filter_->setPlaceholderText(qt_("All avail. modules"));
1662 modulesModule->moduleFilterBarL->addWidget(filter_, 0);
1663 modulesModule->findModulesLA->setBuddy(filter_);
1665 connect(filter_, SIGNAL(rightButtonClicked()),
1666 this, SLOT(resetModuleFilter()));
1667 connect(filter_, SIGNAL(textEdited(QString)),
1668 this, SLOT(moduleFilterChanged(QString)));
1669 connect(filter_, SIGNAL(returnPressed()),
1670 this, SLOT(moduleFilterPressed()));
1671 #if (QT_VERSION < 0x050000)
1672 connect(filter_, SIGNAL(downPressed()),
1673 modulesModule->availableLV, SLOT(setFocus()));
1675 connect(filter_, &FancyLineEdit::downPressed,
1676 modulesModule->availableLV, [=](){ focusAndHighlight(modulesModule->availableLV); });
1681 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>(this);
1682 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
1683 this, SLOT(change_adaptor()));
1684 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(QString)),
1685 this, SLOT(change_adaptor()));
1686 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(QString)),
1687 this, SLOT(change_adaptor()));
1688 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(QString)),
1689 this, SLOT(change_adaptor()));
1690 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(QString)),
1691 this, SLOT(change_adaptor()));
1692 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
1693 this, SLOT(change_adaptor()));
1694 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
1695 this, SLOT(change_adaptor()));
1696 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
1697 this, SLOT(change_adaptor()));
1698 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
1699 this, SLOT(bookmarksopenChanged(bool)));
1700 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
1701 this, SLOT(change_adaptor()));
1702 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
1703 this, SLOT(change_adaptor()));
1704 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
1705 this, SLOT(change_adaptor()));
1706 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
1707 this, SLOT(change_adaptor()));
1708 connect(pdfSupportModule->backrefCO, SIGNAL(activated(int)),
1709 this, SLOT(change_adaptor()));
1710 connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
1711 this, SLOT(change_adaptor()));
1712 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
1713 this, SLOT(change_adaptor()));
1714 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)),
1715 this, SLOT(change_adaptor()));
1717 pdfSupportModule->titleLE->setValidator(new NoNewLineValidator(
1718 pdfSupportModule->titleLE));
1719 pdfSupportModule->authorLE->setValidator(new NoNewLineValidator(
1720 pdfSupportModule->authorLE));
1721 pdfSupportModule->subjectLE->setValidator(new NoNewLineValidator(
1722 pdfSupportModule->subjectLE));
1723 pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
1724 pdfSupportModule->keywordsLE));
1725 pdfSupportModule->optionsLE->setValidator(new NoNewLineValidator(
1726 pdfSupportModule->optionsLE));
1728 for (int i = 0; backref_opts[i][0]; ++i)
1729 pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
1733 floatModule = new FloatPlacement;
1734 connect(floatModule, SIGNAL(changed()),
1735 this, SLOT(change_adaptor()));
1739 listingsModule = new UiWidget<Ui::ListingsSettingsUi>(this);
1740 connect(listingsModule->listingsED, SIGNAL(textChanged()),
1741 this, SLOT(change_adaptor()));
1742 connect(listingsModule->bypassCB, SIGNAL(clicked()),
1743 this, SLOT(change_adaptor()));
1744 connect(listingsModule->bypassCB, SIGNAL(clicked()),
1745 this, SLOT(setListingsMessage()));
1746 connect(listingsModule->packageCO, SIGNAL(activated(int)),
1747 this, SLOT(change_adaptor()));
1748 connect(listingsModule->packageCO, SIGNAL(activated(int)),
1749 this, SLOT(listingsPackageChanged(int)));
1750 connect(listingsModule->listingsED, SIGNAL(textChanged()),
1751 this, SLOT(setListingsMessage()));
1752 listingsModule->listingsTB->setPlainText(
1753 qt_("Input listings parameters below. Enter ? for a list of parameters."));
1755 for (int i = 0; lst_packages[i][0]; ++i)
1756 listingsModule->packageCO->addItem(lst_packages[i]);
1760 docPS->addPanel(latexModule, N_("Document Class"));
1761 docPS->addPanel(masterChildModule, N_("Child Documents"));
1762 docPS->addPanel(modulesModule, N_("Modules"));
1763 docPS->addPanel(localLayout, N_("Local Layout"));
1764 docPS->addPanel(fontModule, N_("Fonts"));
1765 docPS->addPanel(textLayoutModule, N_("Text Layout"));
1766 docPS->addPanel(pageLayoutModule, N_("Page Layout"));
1767 docPS->addPanel(marginsModule, N_("Page Margins"));
1768 docPS->addPanel(langModule, N_("Language"));
1769 docPS->addPanel(colorModule, N_("Colors"));
1770 docPS->addPanel(changesModule, N_("Change Tracking"));
1771 docPS->addPanel(numberingModule, N_("Numbering & TOC"));
1772 docPS->addPanel(biblioModule, N_("Bibliography"));
1773 docPS->addPanel(indicesModule, N_("Indexes"));
1774 docPS->addPanel(pdfSupportModule, N_("PDF Properties"));
1775 docPS->addPanel(mathsModule, N_("Math Options"));
1776 docPS->addPanel(floatModule, N_("Float Settings"));
1777 docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
1778 docPS->addPanel(bulletsModule, N_("Bullets"));
1779 docPS->addPanel(branchesModule, N_("Branches"));
1780 docPS->addPanel(outputModule, N_("Formats[[output]]"));
1781 docPS->addPanel(preambleModule, N_("LaTeX Preamble"));
1782 docPS->setCurrentPanel("Document Class");
1783 // FIXME: hack to work around resizing bug in Qt >= 4.2
1784 // bug verified with Qt 4.2.{0-3} (JSpitzm)
1785 #if QT_VERSION >= 0x040200
1786 docPS->updateGeometry();
1791 void GuiDocument::onBufferViewChanged()
1793 if (isVisibleView())
1794 initialiseParams("");
1798 void GuiDocument::saveDefaultClicked()
1804 void GuiDocument::useDefaultsClicked()
1810 void GuiDocument::change_adaptor()
1812 nonModuleChanged_ = true;
1817 void GuiDocument::shellescapeChanged()
1819 shellescapeChanged_ = true;
1823 void GuiDocument::bookmarksopenChanged(bool state)
1825 pdfSupportModule->bookmarksopenlevelSB->setEnabled(state);
1826 pdfSupportModule->bookmarksopenlevelLA->setEnabled(state);
1830 void GuiDocument::slotApply()
1832 bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
1833 bool wasclean = buffer().isClean();
1834 GuiDialog::slotApply();
1835 if (wasclean && only_shellescape_changed)
1836 buffer().markClean();
1837 modulesChanged_ = false;
1841 void GuiDocument::slotOK()
1843 bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
1844 bool wasclean = buffer().isClean();
1845 GuiDialog::slotOK();
1846 if (wasclean && only_shellescape_changed)
1847 buffer().markClean();
1848 modulesChanged_ = false;
1852 void GuiDocument::slotButtonBox(QAbstractButton * button)
1854 switch (buttonBox->standardButton(button)) {
1855 case QDialogButtonBox::Ok:
1858 case QDialogButtonBox::Apply:
1861 case QDialogButtonBox::Cancel:
1864 case QDialogButtonBox::Reset:
1865 case QDialogButtonBox::RestoreDefaults:
1874 void GuiDocument::filterModules(QString const & str)
1876 updateAvailableModules();
1880 modules_av_model_.clear();
1881 list<modInfoStruct> modInfoList = getModuleInfo();
1882 // Sort names according to the locale
1883 modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
1884 return 0 < b.name.localeAwareCompare(a.name);
1887 QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
1888 QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
1891 for (modInfoStruct const & m : modInfoList) {
1892 if (m.name.contains(str, Qt::CaseInsensitive) || contains(m.id, fromqstr(str))) {
1893 QStandardItem * item = new QStandardItem();
1894 item->setData(m.name, Qt::DisplayRole);
1895 item->setData(toqstr(m.id), Qt::UserRole);
1896 item->setData(m.description, Qt::ToolTipRole);
1898 item->setIcon(user_icon);
1900 item->setIcon(system_icon);
1901 modules_av_model_.insertRow(i, item);
1908 void GuiDocument::moduleFilterChanged(const QString & text)
1910 if (!text.isEmpty()) {
1911 filterModules(filter_->text());
1914 filterModules(filter_->text());
1915 filter_->setFocus();
1919 void GuiDocument::moduleFilterPressed()
1921 filterModules(filter_->text());
1925 void GuiDocument::resetModuleFilter()
1927 filter_->setText(QString());
1928 filterModules(filter_->text());
1932 void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
1934 if (item == nullptr)
1937 string child = fromqstr(item->text(0));
1941 if (std::find(includeonlys_.begin(),
1942 includeonlys_.end(), child) != includeonlys_.end())
1943 includeonlys_.remove(child);
1945 includeonlys_.push_back(child);
1947 updateIncludeonlys();
1952 QString GuiDocument::validateListingsParameters()
1954 if (listingsModule->bypassCB->isChecked())
1956 string const package =
1957 lst_packages[listingsModule->packageCO->currentIndex()];
1958 string params = fromqstr(listingsModule->listingsED->toPlainText());
1959 InsetListingsParams lstparams(params);
1960 lstparams.setMinted(package == "Minted");
1961 return toqstr(lstparams.validate());
1965 void GuiDocument::setListingsMessage()
1968 static bool isOK = true;
1969 QString msg = validateListingsParameters();
1970 if (msg.isEmpty()) {
1974 // listingsModule->listingsTB->setTextColor("black");
1975 listingsModule->listingsTB->setPlainText(
1976 qt_("Input listings parameters below. "
1977 "Enter ? for a list of parameters."));
1980 // listingsModule->listingsTB->setTextColor("red");
1981 listingsModule->listingsTB->setPlainText(msg);
1986 void GuiDocument::listingsPackageChanged(int index)
1988 string const package = lst_packages[index];
1989 if (package == "Minted" && lyxrc.pygmentize_command.empty()) {
1990 Alert::warning(_("Pygments driver command not found!"),
1991 _("The driver command necessary to use the minted package\n"
1992 "(pygmentize) has not been found. Make sure you have\n"
1993 "the python-pygments module installed or, if the driver\n"
1994 "is named differently, to add the following line to the\n"
1995 "document preamble:\n\n"
1996 "\\AtBeginDocument{\\renewcommand{\\MintedPygmentize}{driver}}\n\n"
1997 "where 'driver' is name of the driver command."));
2002 void GuiDocument::setLSpacing(int item)
2004 textLayoutModule->lspacingLE->setEnabled(item == 3);
2008 void GuiDocument::setIndent(int item)
2010 bool const enable = (item == 1);
2011 textLayoutModule->indentLE->setEnabled(enable);
2012 textLayoutModule->indentLengthCO->setEnabled(enable);
2013 textLayoutModule->skipLE->setEnabled(false);
2014 textLayoutModule->skipLengthCO->setEnabled(false);
2019 void GuiDocument::enableIndent(bool indent)
2021 textLayoutModule->skipLE->setEnabled(!indent);
2022 textLayoutModule->skipLengthCO->setEnabled(!indent);
2024 setIndent(textLayoutModule->indentCO->currentIndex());
2028 void GuiDocument::setSkip(int item)
2030 VSpace::VSpaceKind kind =
2031 VSpace::VSpaceKind(textLayoutModule->skipCO->itemData(item).toInt());
2032 bool const enable = (kind == VSpace::LENGTH);
2033 textLayoutModule->skipLE->setEnabled(enable);
2034 textLayoutModule->skipLengthCO->setEnabled(enable);
2039 void GuiDocument::enableSkip(bool skip)
2041 textLayoutModule->indentLE->setEnabled(!skip);
2042 textLayoutModule->indentLengthCO->setEnabled(!skip);
2044 setSkip(textLayoutModule->skipCO->currentIndex());
2047 void GuiDocument::allowMathIndent() {
2048 // only disable when not checked, checked does not always allow enabling
2049 if (!mathsModule->MathIndentCB->isChecked()) {
2050 mathsModule->MathIndentLE->setEnabled(false);
2051 mathsModule->MathIndentLengthCO->setEnabled(false);
2053 if (mathsModule->MathIndentCB->isChecked()
2054 && mathsModule->MathIndentCO->currentIndex() == 1) {
2055 mathsModule->MathIndentLE->setEnabled(true);
2056 mathsModule->MathIndentLengthCO->setEnabled(true);
2061 void GuiDocument::enableMathIndent(int item)
2063 bool const enable = (item == 1);
2064 mathsModule->MathIndentLE->setEnabled(enable);
2065 mathsModule->MathIndentLengthCO->setEnabled(enable);
2070 void GuiDocument::setMargins()
2072 bool const extern_geometry =
2073 documentClass().provides("geometry");
2074 marginsModule->marginCB->setEnabled(!extern_geometry);
2075 if (extern_geometry) {
2076 marginsModule->marginCB->setChecked(false);
2077 setCustomMargins(true);
2079 marginsModule->marginCB->setChecked(!bp_.use_geometry);
2080 setCustomMargins(!bp_.use_geometry);
2085 void GuiDocument::papersizeChanged(int paper_size)
2087 setCustomPapersize(paper_size == 1);
2091 void GuiDocument::setCustomPapersize(bool custom)
2093 pageLayoutModule->paperwidthL->setEnabled(custom);
2094 pageLayoutModule->paperwidthLE->setEnabled(custom);
2095 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
2096 pageLayoutModule->paperheightL->setEnabled(custom);
2097 pageLayoutModule->paperheightLE->setEnabled(custom);
2098 pageLayoutModule->paperheightLE->setFocus();
2099 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
2103 void GuiDocument::setColSep()
2105 setCustomMargins(marginsModule->marginCB->checkState() == Qt::Checked);
2109 void GuiDocument::setCustomMargins(bool custom)
2111 marginsModule->topL->setEnabled(!custom);
2112 marginsModule->topLE->setEnabled(!custom);
2113 marginsModule->topUnit->setEnabled(!custom);
2115 marginsModule->bottomL->setEnabled(!custom);
2116 marginsModule->bottomLE->setEnabled(!custom);
2117 marginsModule->bottomUnit->setEnabled(!custom);
2119 marginsModule->innerL->setEnabled(!custom);
2120 marginsModule->innerLE->setEnabled(!custom);
2121 marginsModule->innerUnit->setEnabled(!custom);
2123 marginsModule->outerL->setEnabled(!custom);
2124 marginsModule->outerLE->setEnabled(!custom);
2125 marginsModule->outerUnit->setEnabled(!custom);
2127 marginsModule->headheightL->setEnabled(!custom);
2128 marginsModule->headheightLE->setEnabled(!custom);
2129 marginsModule->headheightUnit->setEnabled(!custom);
2131 marginsModule->headsepL->setEnabled(!custom);
2132 marginsModule->headsepLE->setEnabled(!custom);
2133 marginsModule->headsepUnit->setEnabled(!custom);
2135 marginsModule->footskipL->setEnabled(!custom);
2136 marginsModule->footskipLE->setEnabled(!custom);
2137 marginsModule->footskipUnit->setEnabled(!custom);
2139 bool const enableColSep = !custom &&
2140 textLayoutModule->twoColumnCB->checkState() == Qt::Checked;
2141 marginsModule->columnsepL->setEnabled(enableColSep);
2142 marginsModule->columnsepLE->setEnabled(enableColSep);
2143 marginsModule->columnsepUnit->setEnabled(enableColSep);
2147 void GuiDocument::changeBackgroundColor()
2149 QColor const & newColor = QColorDialog::getColor(
2150 rgb2qcolor(set_backgroundcolor), asQWidget());
2151 if (!newColor.isValid())
2153 // set the button color and text
2154 colorModule->backgroundPB->setStyleSheet(
2155 colorButtonStyleSheet(newColor));
2156 colorModule->backgroundPB->setText(qt_("&Change..."));
2158 set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name()));
2159 is_backgroundcolor = true;
2164 void GuiDocument::deleteBackgroundColor()
2166 // set the button color back to default by setting an empty StyleSheet
2167 colorModule->backgroundPB->setStyleSheet(QLatin1String(""));
2168 // change button text
2169 colorModule->backgroundPB->setText(qt_("&Default..."));
2170 // save default color (white)
2171 set_backgroundcolor = rgbFromHexName("#ffffff");
2172 is_backgroundcolor = false;
2177 void GuiDocument::changeFontColor()
2179 QColor const & newColor = QColorDialog::getColor(
2180 rgb2qcolor(set_fontcolor), asQWidget());
2181 if (!newColor.isValid())
2183 // set the button color and text
2184 colorModule->fontColorPB->setStyleSheet(
2185 colorButtonStyleSheet(newColor));
2186 colorModule->fontColorPB->setText(qt_("&Change..."));
2188 set_fontcolor = rgbFromHexName(fromqstr(newColor.name()));
2189 is_fontcolor = true;
2194 void GuiDocument::deleteFontColor()
2196 // set the button color back to default by setting an empty StyleSheet
2197 colorModule->fontColorPB->setStyleSheet(QLatin1String(""));
2198 // change button text
2199 colorModule->fontColorPB->setText(qt_("&Default..."));
2200 // save default color (black)
2201 set_fontcolor = rgbFromHexName("#000000");
2202 is_fontcolor = false;
2207 void GuiDocument::changeNoteFontColor()
2209 QColor const & newColor = QColorDialog::getColor(
2210 rgb2qcolor(set_notefontcolor), asQWidget());
2211 if (!newColor.isValid())
2213 // set the button color
2214 colorModule->noteFontColorPB->setStyleSheet(
2215 colorButtonStyleSheet(newColor));
2217 set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
2222 void GuiDocument::deleteNoteFontColor()
2224 // set the button color back to pref
2225 theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
2226 colorModule->noteFontColorPB->setStyleSheet(
2227 colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
2232 void GuiDocument::changeBoxBackgroundColor()
2234 QColor const & newColor = QColorDialog::getColor(
2235 rgb2qcolor(set_boxbgcolor), asQWidget());
2236 if (!newColor.isValid())
2238 // set the button color
2239 colorModule->boxBackgroundPB->setStyleSheet(
2240 colorButtonStyleSheet(newColor));
2242 set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name()));
2247 void GuiDocument::deleteBoxBackgroundColor()
2249 // set the button color back to pref
2250 theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor);
2251 colorModule->boxBackgroundPB->setStyleSheet(
2252 colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor)));
2257 void GuiDocument::updateQuoteStyles(bool const set)
2259 Language const * lang = lyx::languages.getLanguage(
2260 fromqstr(langModule->languageCO->itemData(
2261 langModule->languageCO->currentIndex()).toString()));
2263 InsetQuotesParams::QuoteStyle def = bp_.getQuoteStyle(lang->quoteStyle());
2265 langModule->quoteStyleCO->clear();
2267 bool has_default = false;
2268 for (int i = 0; i < quoteparams.stylescount(); ++i) {
2269 InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::QuoteStyle(i);
2270 if (qs == InsetQuotesParams::DynamicQuotes)
2272 bool const langdef = (qs == def);
2274 // add the default style on top
2275 langModule->quoteStyleCO->insertItem(0,
2276 toqstr(quoteparams.getGuiLabel(qs, langdef)), qs);
2280 langModule->quoteStyleCO->addItem(
2281 toqstr(quoteparams.getGuiLabel(qs, langdef)), qs);
2283 if (set && has_default)
2284 // (re)set to the default style
2285 langModule->quoteStyleCO->setCurrentIndex(0);
2289 void GuiDocument::languageChanged(int i)
2291 // some languages only work with Polyglossia
2292 Language const * lang = lyx::languages.getLanguage(
2293 fromqstr(langModule->languageCO->itemData(i).toString()));
2294 if (lang->babel().empty() && !lang->polyglossia().empty()
2295 && lang->required() != "CJK" && lang->required() != "japanese") {
2296 // If we force to switch fontspec on, store
2297 // current state (#8717)
2298 if (fontModule->osFontsCB->isEnabled())
2299 forced_fontspec_activation =
2300 !fontModule->osFontsCB->isChecked();
2301 fontModule->osFontsCB->setChecked(true);
2302 fontModule->osFontsCB->setEnabled(false);
2305 fontModule->osFontsCB->setEnabled(true);
2306 // If we have forced to switch fontspec on,
2307 // restore previous state (#8717)
2308 if (forced_fontspec_activation)
2309 fontModule->osFontsCB->setChecked(false);
2310 forced_fontspec_activation = false;
2313 // set appropriate quotation mark style
2314 updateQuoteStyles(true);
2318 void GuiDocument::osFontsChanged(bool nontexfonts)
2320 bool const tex_fonts = !nontexfonts;
2321 // store current fonts
2322 QString const font_roman = fontModule->fontsRomanCO->itemData(
2323 fontModule->fontsRomanCO->currentIndex()).toString();
2324 QString const font_sans = fontModule->fontsSansCO->itemData(
2325 fontModule->fontsSansCO->currentIndex()).toString();
2326 QString const font_typewriter = fontModule->fontsTypewriterCO->itemData(
2327 fontModule->fontsTypewriterCO->currentIndex()).toString();
2328 QString const font_math = fontModule->fontsMathCO->itemData(
2329 fontModule->fontsMathCO->currentIndex()).toString();
2330 int const font_sf_scale = fontModule->scaleSansSB->value();
2331 int const font_tt_scale = fontModule->scaleTypewriterSB->value();
2334 // store default format
2335 QString const dformat = outputModule->defaultFormatCO->itemData(
2336 outputModule->defaultFormatCO->currentIndex()).toString();
2337 updateDefaultFormat();
2338 // try to restore default format
2339 int index = outputModule->defaultFormatCO->findData(dformat);
2340 // set to default if format is not found
2343 outputModule->defaultFormatCO->setCurrentIndex(index);
2345 // try to restore fonts which were selected two toggles ago
2346 index = fontModule->fontsRomanCO->findData(fontModule->font_roman);
2348 fontModule->fontsRomanCO->setCurrentIndex(index);
2349 index = fontModule->fontsSansCO->findData(fontModule->font_sans);
2351 fontModule->fontsSansCO->setCurrentIndex(index);
2352 index = fontModule->fontsTypewriterCO->findData(fontModule->font_typewriter);
2354 fontModule->fontsTypewriterCO->setCurrentIndex(index);
2355 index = fontModule->fontsMathCO->findData(fontModule->font_math);
2357 fontModule->fontsMathCO->setCurrentIndex(index);
2358 // save fonts for next next toggle
2359 fontModule->font_roman = font_roman;
2360 fontModule->font_sans = font_sans;
2361 fontModule->font_typewriter = font_typewriter;
2362 fontModule->font_math = font_math;
2363 fontModule->font_sf_scale = font_sf_scale;
2364 fontModule->font_tt_scale = font_tt_scale;
2366 // non-tex fonts override the "\inputencoding" option with "utf8-plain"
2367 langModule->encodingCO->setEnabled(tex_fonts);
2368 inputencodingToDialog();
2370 fontModule->fontsDefaultCO->setEnabled(tex_fonts);
2371 fontModule->fontsDefaultLA->setEnabled(tex_fonts);
2372 fontModule->cjkFontLE->setEnabled(tex_fonts);
2373 fontModule->cjkFontLA->setEnabled(tex_fonts);
2375 updateFontOptions();
2377 fontModule->fontencLA->setEnabled(tex_fonts);
2378 fontModule->fontencCO->setEnabled(tex_fonts);
2380 fontModule->fontencLE->setEnabled(false);
2382 fontencChanged(fontModule->fontencCO->currentIndex());
2386 void GuiDocument::encodingSwitched(int i)
2388 bool const tex_fonts = !fontModule->osFontsCB->isChecked();
2389 langModule->unicodeEncodingCO->setEnabled(tex_fonts);
2390 langModule->customEncodingCO->setEnabled(tex_fonts);
2391 langModule->autoEncodingCO->setEnabled(tex_fonts);
2392 langModule->unicodeEncodingCO->setVisible(i == EncodingSets::unicode);
2393 langModule->autoEncodingCO->setVisible(i == EncodingSets::legacy);
2394 langModule->customEncodingCO->setVisible(i == EncodingSets::custom);
2396 langModule->unicodeEncodingCO->setItemText(1, qt_("Direct (No inputenc)"));
2398 langModule->unicodeEncodingCO->setItemText(1, qt_("Direct (XeTeX/LuaTeX)"));
2401 void GuiDocument::inputencodingToDialog()
2403 QString inputenc = toqstr(bp_.inputenc);
2405 if (fontModule->osFontsCB->isChecked()) { // non-tex fonts require utf8-plain
2406 langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
2407 langModule->unicodeEncodingCO->setCurrentIndex(
2408 langModule->unicodeEncodingCO->findData("utf8-plain"));
2409 } else if (inputenc.startsWith("utf8")) {
2410 langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
2411 p = langModule->unicodeEncodingCO->findData(inputenc);
2414 langModule->unicodeEncodingCO->setCurrentIndex(p);
2415 langModule->autoEncodingCO->setCurrentIndex(0);
2416 langModule->customEncodingCO->setCurrentIndex(0);
2417 } else if (inputenc.startsWith("auto")) {
2418 langModule->encodingCO->setCurrentIndex(EncodingSets::legacy);
2419 p = langModule->autoEncodingCO->findData(inputenc);
2422 langModule->unicodeEncodingCO->setCurrentIndex(0);
2423 langModule->autoEncodingCO->setCurrentIndex(p);
2424 langModule->customEncodingCO->setCurrentIndex(0);
2426 langModule->encodingCO->setCurrentIndex(EncodingSets::custom);
2427 p = langModule->customEncodingCO->findData(inputenc);
2430 langModule->encodingCO->setCurrentIndex(EncodingSets::unicode);
2432 langModule->unicodeEncodingCO->setCurrentIndex(0);
2433 langModule->autoEncodingCO->setCurrentIndex(0);
2434 langModule->customEncodingCO->setCurrentIndex(p);
2436 encodingSwitched(langModule->encodingCO->currentIndex());
2440 void GuiDocument::mathFontChanged(int)
2442 updateFontOptions();
2445 void GuiDocument::fontOsfToggled(bool state)
2447 if (fontModule->osFontsCB->isChecked())
2449 QString font = fontModule->fontsRomanCO->itemData(
2450 fontModule->fontsRomanCO->currentIndex()).toString();
2451 if (hasMonolithicExpertSet(font))
2452 fontModule->fontScCB->setChecked(state);
2456 void GuiDocument::fontScToggled(bool state)
2458 if (fontModule->osFontsCB->isChecked())
2460 QString font = fontModule->fontsRomanCO->itemData(
2461 fontModule->fontsRomanCO->currentIndex()).toString();
2462 if (hasMonolithicExpertSet(font))
2463 fontModule->fontOsfCB->setChecked(state);
2467 void GuiDocument::updateExtraOpts()
2469 bool const tex_fonts = !fontModule->osFontsCB->isChecked();
2472 font = fontModule->fontsRomanCO->itemData(
2473 fontModule->fontsRomanCO->currentIndex()).toString();
2474 bool const rm_opts = providesExtraOpts(font);
2476 font = fontModule->fontsSansCO->itemData(
2477 fontModule->fontsSansCO->currentIndex()).toString();
2478 bool const sf_opts = providesExtraOpts(font);
2480 font = fontModule->fontsTypewriterCO->itemData(
2481 fontModule->fontsTypewriterCO->currentIndex()).toString();
2482 bool const tt_opts = providesExtraOpts(font);
2483 fontModule->fontspecRomanLA->setEnabled(!tex_fonts || rm_opts);
2484 fontModule->fontspecRomanLE->setEnabled(!tex_fonts || rm_opts);
2485 fontModule->fontspecSansLA->setEnabled(!tex_fonts || sf_opts);
2486 fontModule->fontspecSansLE->setEnabled(!tex_fonts || sf_opts);
2487 fontModule->fontspecTypewriterLA->setEnabled(!tex_fonts || tt_opts);
2488 fontModule->fontspecTypewriterLE->setEnabled(!tex_fonts || tt_opts);
2492 void GuiDocument::updateFontOptions()
2494 bool const tex_fonts = !fontModule->osFontsCB->isChecked();
2497 font = fontModule->fontsSansCO->itemData(
2498 fontModule->fontsSansCO->currentIndex()).toString();
2499 bool scalable = providesScale(font);
2500 fontModule->scaleSansSB->setEnabled(scalable);
2501 fontModule->scaleSansLA->setEnabled(scalable);
2502 fontModule->fontSansOsfCB->setEnabled(providesOSF(font));
2504 font = fontModule->fontsTypewriterCO->itemData(
2505 fontModule->fontsTypewriterCO->currentIndex()).toString();
2506 scalable = providesScale(font);
2507 fontModule->scaleTypewriterSB->setEnabled(scalable);
2508 fontModule->scaleTypewriterLA->setEnabled(scalable);
2509 fontModule->fontTypewriterOsfCB->setEnabled(providesOSF(font));
2511 font = fontModule->fontsRomanCO->itemData(
2512 fontModule->fontsRomanCO->currentIndex()).toString();
2513 fontModule->fontScCB->setEnabled(providesSC(font));
2514 fontModule->fontOsfCB->setEnabled(providesOSF(font));
2516 updateMathFonts(font);
2520 void GuiDocument::updateFontsize(string const & items, string const & sel)
2522 fontModule->fontsizeCO->clear();
2523 fontModule->fontsizeCO->addItem(qt_("Default"));
2525 for (int n = 0; !token(items,'|',n).empty(); ++n)
2526 fontModule->fontsizeCO->
2527 addItem(toqstr(token(items,'|',n)));
2529 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
2530 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
2531 fontModule->fontsizeCO->setCurrentIndex(n);
2538 bool GuiDocument::ot1() const
2540 QString const fontenc =
2541 fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
2542 int const i = langModule->languageCO->currentIndex();
2545 QString const langname = langModule->languageCO->itemData(i).toString();
2546 Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
2547 return (fontenc == "default"
2548 || (fontenc == "auto" && newlang->fontenc(buffer().params()) == "OT1")
2549 || (fontenc == "custom" && fontModule->fontencLE->text() == "OT1"));
2553 bool GuiDocument::completeFontset() const
2555 return (fontModule->fontsSansCO->itemData(
2556 fontModule->fontsSansCO->currentIndex()).toString() == "default"
2557 && fontModule->fontsSansCO->itemData(
2558 fontModule->fontsTypewriterCO->currentIndex()).toString() == "default");
2562 bool GuiDocument::noMathFont() const
2564 return (fontModule->fontsMathCO->itemData(
2565 fontModule->fontsMathCO->currentIndex()).toString() == "default");
2569 void GuiDocument::updateTexFonts()
2571 LaTeXFonts::TexFontMap texfontmap = theLaTeXFonts().getLaTeXFonts();
2573 LaTeXFonts::TexFontMap::const_iterator it = texfontmap.begin();
2574 LaTeXFonts::TexFontMap::const_iterator end = texfontmap.end();
2575 for (; it != end; ++it) {
2576 LaTeXFont lf = it->second;
2577 if (lf.name().empty()) {
2578 LYXERR0("Error: Unnamed font: " << it->first);
2581 docstring const family = lf.family();
2582 docstring guiname = translateIfPossible(lf.guiname());
2583 if (!lf.available(ot1(), noMathFont()))
2584 guiname += _(" (not installed)");
2586 rmfonts_.insert(toqstr(guiname), toqstr(it->first));
2587 else if (family == "sf")
2588 sffonts_.insert(toqstr(guiname), toqstr(it->first));
2589 else if (family == "tt")
2590 ttfonts_.insert(toqstr(guiname), toqstr(it->first));
2591 else if (family == "math")
2592 mathfonts_.insert(toqstr(guiname), toqstr(it->first));
2597 void GuiDocument::updateFontlist()
2599 // reset the filters of the CategorizedCombos
2600 fontModule->fontsRomanCO->resetFilter();
2601 fontModule->fontsSansCO->resetFilter();
2602 fontModule->fontsTypewriterCO->resetFilter();
2603 fontModule->fontsRomanCO->clear();
2604 fontModule->fontsSansCO->clear();
2605 fontModule->fontsTypewriterCO->clear();
2606 fontModule->fontsMathCO->clear();
2608 // With fontspec (XeTeX, LuaTeX), we have access to all system fonts, but not the LaTeX fonts
2609 if (fontModule->osFontsCB->isChecked()) {
2610 fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
2611 fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
2612 fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
2613 QString unimath = qt_("Non-TeX Fonts Default");
2614 if (!LaTeXFeatures::isAvailable("unicode-math"))
2615 unimath += qt_(" (not available)");
2616 fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto"));
2617 fontModule->fontsMathCO->addItem(unimath, QString("default"));
2619 QFontDatabase fontdb;
2620 QStringList families(fontdb.families());
2621 for (auto const & family : families) {
2622 fontModule->fontsRomanCO->addItem(family, family);
2623 fontModule->fontsSansCO->addItem(family, family);
2624 fontModule->fontsTypewriterCO->addItem(family, family);
2629 if (rmfonts_.empty())
2632 fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
2633 QMap<QString, QString>::const_iterator rmi = rmfonts_.constBegin();
2634 while (rmi != rmfonts_.constEnd()) {
2635 fontModule->fontsRomanCO->addItem(rmi.key(), rmi.value());
2639 fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
2640 QMap<QString, QString>::const_iterator sfi = sffonts_.constBegin();
2641 while (sfi != sffonts_.constEnd()) {
2642 fontModule->fontsSansCO->addItem(sfi.key(), sfi.value());
2646 fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
2647 QMap<QString, QString>::const_iterator tti = ttfonts_.constBegin();
2648 while (tti != ttfonts_.constEnd()) {
2649 fontModule->fontsTypewriterCO->addItem(tti.key(), tti.value());
2653 fontModule->fontsMathCO->addItem(qt_("Automatic"), QString("auto"));
2654 fontModule->fontsMathCO->addItem(qt_("Class Default"), QString("default"));
2655 QMap<QString, QString>::const_iterator mmi = mathfonts_.constBegin();
2656 while (mmi != mathfonts_.constEnd()) {
2657 fontModule->fontsMathCO->addItem(mmi.key(), mmi.value());
2663 void GuiDocument::fontencChanged(int item)
2665 fontModule->fontencLE->setEnabled(
2666 fontModule->fontencCO->itemData(item).toString() == "custom");
2667 // The availability of TeX fonts depends on the font encoding
2669 updateFontOptions();
2673 void GuiDocument::updateMathFonts(QString const & rm)
2675 if (fontModule->osFontsCB->isChecked())
2677 QString const math =
2678 fontModule->fontsMathCO->itemData(fontModule->fontsMathCO->currentIndex()).toString();
2679 int const i = fontModule->fontsMathCO->findData("default");
2680 if (providesNoMath(rm) && i == -1)
2681 fontModule->fontsMathCO->insertItem(1, qt_("Class Default"), QString("default"));
2682 else if (!providesNoMath(rm) && i != -1) {
2683 int const c = fontModule->fontsMathCO->currentIndex();
2684 fontModule->fontsMathCO->removeItem(i);
2686 fontModule->fontsMathCO->setCurrentIndex(0);
2691 void GuiDocument::romanChanged(int item)
2693 if (fontModule->osFontsCB->isChecked())
2695 QString const font =
2696 fontModule->fontsRomanCO->itemData(item).toString();
2697 fontModule->fontScCB->setEnabled(providesSC(font));
2698 fontModule->fontOsfCB->setEnabled(providesOSF(font));
2700 updateMathFonts(font);
2704 void GuiDocument::sansChanged(int item)
2706 if (fontModule->osFontsCB->isChecked())
2708 QString const font =
2709 fontModule->fontsSansCO->itemData(item).toString();
2710 bool const scalable = providesScale(font);
2711 fontModule->scaleSansSB->setEnabled(scalable);
2712 fontModule->scaleSansLA->setEnabled(scalable);
2713 fontModule->fontSansOsfCB->setEnabled(providesOSF(font));
2718 void GuiDocument::ttChanged(int item)
2720 if (fontModule->osFontsCB->isChecked())
2722 QString const font =
2723 fontModule->fontsTypewriterCO->itemData(item).toString();
2724 bool scalable = providesScale(font);
2725 fontModule->scaleTypewriterSB->setEnabled(scalable);
2726 fontModule->scaleTypewriterLA->setEnabled(scalable);
2727 fontModule->fontTypewriterOsfCB->setEnabled(providesOSF(font));
2732 void GuiDocument::updatePagestyle(string const & items, string const & sel)
2735 pageLayoutModule->pagestyleCO->clear();
2736 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
2738 for (int n = 0; !token(items, '|', n).empty(); ++n) {
2739 string style = token(items, '|', n);
2740 QString style_gui = qt_(style);
2741 pagestyles.push_back(pair<string, QString>(style, style_gui));
2742 pageLayoutModule->pagestyleCO->addItem(style_gui);
2745 if (sel == "default") {
2746 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
2752 for (auto const & pagestyle : pagestyles)
2753 if (pagestyle.first == sel)
2754 nn = pageLayoutModule->pagestyleCO->findText(pagestyle.second);
2757 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
2761 void GuiDocument::browseLayout()
2763 QString const label1 = qt_("Lay&outs");
2764 QString const dir1 = toqstr(lyxrc.document_path);
2765 QStringList const filter(qt_("LyX Layout (*.layout)"));
2766 QString file = browseRelToParent(QString(), bufferFilePath(),
2767 qt_("Local layout file"), filter, false,
2770 if (!file.endsWith(".layout"))
2773 FileName layoutFile = support::makeAbsPath(fromqstr(file),
2774 fromqstr(bufferFilePath()));
2776 int const ret = Alert::prompt(_("Local layout file"),
2777 _("The layout file you have selected is a local layout\n"
2778 "file, not one in the system or user directory.\n"
2779 "Your document will not work with this layout if you\n"
2780 "move the layout file to a different directory."),
2781 1, 1, _("&Set Layout"), _("&Cancel"));
2785 // load the layout file
2786 LayoutFileList & bcl = LayoutFileList::get();
2787 string classname = layoutFile.onlyFileName();
2788 // this will update an existing layout if that layout has been loaded before.
2789 LayoutFileIndex name = support::onlyFileName(bcl.addLocalLayout(
2790 classname.substr(0, classname.size() - 7),
2791 layoutFile.onlyPath().absFileName()));
2794 Alert::error(_("Error"),
2795 _("Unable to read local layout file."));
2799 const_cast<Buffer &>(buffer()).setLayoutPos(layoutFile.onlyPath().absFileName());
2801 // do not trigger classChanged if there is no change.
2802 if (latexModule->classCO->currentText() == toqstr(name))
2806 bool const avail = latexModule->classCO->set(toqstr(name));
2808 LayoutFile const & tc = bcl[name];
2809 docstring const guiname = translateIfPossible(from_utf8(tc.description()));
2810 // tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
2811 QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
2812 tooltip += '\n' + qt_("This is a local layout file.");
2813 latexModule->classCO->addItemSort(toqstr(tc.name()), toqstr(guiname),
2814 toqstr(translateIfPossible(from_utf8(tc.category()))),
2816 true, true, true, true);
2817 latexModule->classCO->set(toqstr(name));
2824 void GuiDocument::browseMaster()
2826 QString const title = qt_("Select master document");
2827 QString const dir1 = toqstr(lyxrc.document_path);
2828 QString const old = latexModule->childDocLE->text();
2829 QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
2830 QStringList const filter(qt_("LyX Files (*.lyx)"));
2831 QString file = browseRelToSub(old, docpath, title, filter, false,
2832 qt_("D&ocuments"), toqstr(lyxrc.document_path));
2834 if (!file.isEmpty())
2835 latexModule->childDocLE->setText(file);
2839 void GuiDocument::classChanged_adaptor()
2841 const_cast<Buffer &>(buffer()).setLayoutPos(string());
2846 void GuiDocument::classChanged()
2848 int idx = latexModule->classCO->currentIndex();
2851 string const classname = fromqstr(latexModule->classCO->getData(idx));
2853 if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
2854 int const ret = Alert::prompt(_("Unapplied changes"),
2855 _("Some changes in the dialog were not yet applied.\n"
2856 "If you do not apply now, they will be lost after this action."),
2857 1, 1, _("&Apply"), _("&Dismiss"));
2862 // We load the TextClass as soon as it is selected. This is
2863 // necessary so that other options in the dialog can be updated
2864 // according to the new class. Note, however, that, if you use
2865 // the scroll wheel when sitting on the combo box, we'll load a
2866 // lot of TextClass objects very quickly....
2867 if (!bp_.setBaseClass(classname, buffer().layoutPos())) {
2868 Alert::error(_("Error"), _("Unable to set document class."));
2871 if (lyxrc.auto_reset_options)
2872 bp_.useClassDefaults();
2874 // With the introduction of modules came a distinction between the base
2875 // class and the document class. The former corresponds to the main layout
2876 // file; the latter is that plus the modules (or the document-specific layout,
2877 // or whatever else there could be). Our parameters come from the document
2878 // class. So when we set the base class, we also need to recreate the document
2879 // class. Otherwise, we still have the old one.
2880 bp_.makeDocumentClass();
2885 void GuiDocument::languagePackageChanged(int i)
2887 langModule->languagePackageLE->setEnabled(
2888 langModule->languagePackageCO->itemData(i).toString() == "custom");
2892 void GuiDocument::biblioChanged()
2894 biblioChanged_ = true;
2899 void GuiDocument::checkPossibleCiteEngines()
2901 // Check if the class provides a specific engine,
2902 // and if so, enforce this.
2903 string force_engine;
2904 if (documentClass().provides("natbib")
2905 || documentClass().provides("natbib-internal"))
2906 force_engine = "natbib";
2907 else if (documentClass().provides("jurabib"))
2908 force_engine = "jurabib";
2909 else if (documentClass().provides("biblatex"))
2910 force_engine = "biblatex";
2911 else if (documentClass().provides("biblatex-natbib"))
2912 force_engine = "biblatex-natbib";
2914 if (!force_engine.empty())
2915 biblioModule->citeEngineCO->setCurrentIndex(
2916 biblioModule->citeEngineCO->findData(toqstr(force_engine)));
2917 biblioModule->citeEngineCO->setEnabled(force_engine.empty());
2921 void GuiDocument::rescanBibFiles()
2924 rescanTexStyles("bbx cbx");
2926 rescanTexStyles("bst");
2930 void GuiDocument::resetDefaultBibfile(string const & which)
2932 QString const engine =
2933 biblioModule->citeEngineCO->itemData(
2934 biblioModule->citeEngineCO->currentIndex()).toString();
2936 CiteEngineType const cet =
2937 CiteEngineType(biblioModule->citeStyleCO->itemData(
2938 biblioModule->citeStyleCO->currentIndex()).toInt());
2940 updateDefaultBiblio(theCiteEnginesList[fromqstr(engine)]->getDefaultBiblio(cet), which);
2944 void GuiDocument::resetDefaultBbxBibfile()
2946 resetDefaultBibfile("bbx");
2950 void GuiDocument::resetDefaultCbxBibfile()
2952 resetDefaultBibfile("cbx");
2956 void GuiDocument::citeEngineChanged(int n)
2958 QString const engine =
2959 biblioModule->citeEngineCO->itemData(n).toString();
2961 vector<string> const engs =
2962 theCiteEnginesList[fromqstr(engine)]->getEngineType();
2964 updateCiteStyles(engs);
2965 updateEngineDependends();
2966 resetDefaultBibfile();
2971 void GuiDocument::updateEngineDependends()
2973 bool const biblatex = isBiblatex();
2975 // These are only useful with BibTeX
2976 biblioModule->defaultBiblioCO->setEnabled(!biblatex);
2977 biblioModule->bibtexStyleLA->setEnabled(!biblatex);
2978 biblioModule->resetDefaultBiblioPB->setEnabled(!biblatex);
2979 biblioModule->bibtopicCB->setEnabled(!biblatex);
2981 // These are only useful with Biblatex
2982 biblioModule->biblatexBbxCO->setEnabled(biblatex);
2983 biblioModule->biblatexBbxLA->setEnabled(biblatex);
2984 biblioModule->biblatexCbxCO->setEnabled(biblatex);
2985 biblioModule->biblatexCbxLA->setEnabled(biblatex);
2986 biblioModule->resetBbxPB->setEnabled(biblatex);
2987 biblioModule->resetCbxPB->setEnabled(biblatex);
2988 biblioModule->matchBbxPB->setEnabled(biblatex);
2990 // These are useful with biblatex, jurabib and natbib
2991 QString const engine =
2992 biblioModule->citeEngineCO->itemData(
2993 biblioModule->citeEngineCO->currentIndex()).toString();
2994 LyXCiteEngine const * ce = theCiteEnginesList[fromqstr(engine)];
2996 bool const citepack = ce->required("biblatex.sty") || ce->required("jurabib.sty")
2997 || ce->required("natbib.sty");
2998 biblioModule->citePackageOptionsLE->setEnabled(citepack);
2999 biblioModule->citePackageOptionsL->setEnabled(citepack);
3003 void GuiDocument::citeStyleChanged()
3005 QString const engine =
3006 biblioModule->citeEngineCO->itemData(
3007 biblioModule->citeEngineCO->currentIndex()).toString();
3008 QString const currentDef = isBiblatex() ?
3009 biblioModule->biblatexBbxCO->currentText()
3010 : biblioModule->defaultBiblioCO->currentText();
3011 if (theCiteEnginesList[fromqstr(engine)]->isDefaultBiblio(fromqstr(currentDef)))
3012 resetDefaultBibfile();
3018 void GuiDocument::bibtexChanged(int n)
3020 biblioModule->bibtexOptionsLE->setEnabled(
3021 biblioModule->bibtexCO->itemData(n).toString() != "default");
3026 void GuiDocument::updateCiteStyles(vector<string> const & engs, CiteEngineType const & sel)
3028 biblioModule->citeStyleCO->clear();
3030 vector<string>::const_iterator it = engs.begin();
3031 vector<string>::const_iterator end = engs.end();
3032 for (; it != end; ++it) {
3033 if (*it == "default")
3034 biblioModule->citeStyleCO->addItem(qt_("Basic numerical"),
3035 ENGINE_TYPE_DEFAULT);
3036 else if (*it == "authoryear")
3037 biblioModule->citeStyleCO->addItem(qt_("Author-year"),
3038 ENGINE_TYPE_AUTHORYEAR);
3039 else if (*it == "numerical")
3040 biblioModule->citeStyleCO->addItem(qt_("Author-number"),
3041 ENGINE_TYPE_NUMERICAL);
3043 int i = biblioModule->citeStyleCO->findData(sel);
3044 if (biblioModule->citeStyleCO->findData(sel) == -1)
3046 biblioModule->citeStyleCO->setCurrentIndex(i);
3048 biblioModule->citationStyleL->setEnabled(engs.size() > 1);
3049 biblioModule->citeStyleCO->setEnabled(engs.size() > 1);
3053 void GuiDocument::updateEngineType(string const & items, CiteEngineType const & sel)
3055 engine_types_.clear();
3059 for (int n = 0; !token(items, '|', n).empty(); ++n) {
3061 string style = token(items, '|', n);
3062 engine_types_.push_back(style);
3065 updateCiteStyles(engine_types_, sel);
3071 // both of these should take a vector<docstring>
3073 // This is an insanely complicated attempt to make this sort of thing
3074 // work with RTL languages.
3075 docstring formatStrVec(vector<string> const & v, docstring const & s)
3077 //this mess formats the list as "v[0], v[1], ..., [s] v[n]"
3081 return translateIfPossible(from_utf8(v[0]));
3082 if (v.size() == 2) {
3083 docstring retval = _("%1$s and %2$s");
3084 retval = subst(retval, _("and"), s);
3085 return bformat(retval, translateIfPossible(from_utf8(v[0])),
3086 translateIfPossible(from_utf8(v[1])));
3088 // The idea here is to format all but the last two items...
3089 int const vSize = v.size();
3090 docstring t2 = _("%1$s, %2$s");
3091 docstring retval = translateIfPossible(from_utf8(v[0]));
3092 for (int i = 1; i < vSize - 2; ++i)
3093 retval = bformat(t2, retval, translateIfPossible(from_utf8(v[i])));
3094 //...and then to plug them, and the last two, into this schema
3095 docstring t = _("%1$s, %2$s, and %3$s");
3096 t = subst(t, _("and"), s);
3097 return bformat(t, retval, translateIfPossible(from_utf8(v[vSize - 2])),
3098 translateIfPossible(from_utf8(v[vSize - 1])));
3101 vector<string> idsToNames(vector<string> const & idList)
3103 vector<string> retval;
3104 vector<string>::const_iterator it = idList.begin();
3105 vector<string>::const_iterator end = idList.end();
3106 for (; it != end; ++it) {
3107 LyXModule const * const mod = theModuleList[*it];
3109 retval.push_back(to_utf8(bformat(_("%1$s (unavailable)"),
3110 translateIfPossible(from_utf8(*it)))));
3112 retval.push_back(mod->getName());
3116 } // end anonymous namespace
3119 void GuiDocument::modulesToParams(BufferParams & bp)
3121 // update list of loaded modules
3122 bp.clearLayoutModules();
3123 int const srows = modules_sel_model_.rowCount();
3124 for (int i = 0; i < srows; ++i)
3125 bp.addLayoutModule(modules_sel_model_.getIDString(i));
3126 updateSelectedModules();
3128 // update the list of removed modules
3129 bp.clearRemovedModules();
3130 LayoutModuleList const & reqmods = bp.baseClass()->defaultModules();
3131 list<string>::const_iterator rit = reqmods.begin();
3132 list<string>::const_iterator ren = reqmods.end();
3134 // check each of the default modules
3135 for (; rit != ren; ++rit) {
3136 list<string>::const_iterator mit = bp.getModules().begin();
3137 list<string>::const_iterator men = bp.getModules().end();
3139 for (; mit != men; ++mit) {
3146 // the module isn't present so must have been removed by the user
3147 bp.addRemovedModule(*rit);
3152 void GuiDocument::modulesChanged()
3154 modulesToParams(bp_);
3156 if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()
3157 && (nonModuleChanged_ || shellescapeChanged_)) {
3158 int const ret = Alert::prompt(_("Unapplied changes"),
3159 _("Some changes in the dialog were not yet applied.\n"
3160 "If you do not apply now, they will be lost after this action."),
3161 1, 1, _("&Apply"), _("&Dismiss"));
3166 modulesChanged_ = true;
3167 bp_.makeDocumentClass();
3173 void GuiDocument::updateModuleInfo()
3175 selectionManager->update();
3177 //Module description
3178 bool const focus_on_selected = selectionManager->selectedFocused();
3179 QAbstractItemView * lv;
3180 bool category = false;
3181 if (focus_on_selected) {
3182 lv = modulesModule->selectedLV;
3185 lv = modulesModule->availableLV;
3186 if (lv->selectionModel()->selectedIndexes().isEmpty()) {
3187 modulesModule->infoML->document()->clear();
3190 QModelIndex const & idx = lv->selectionModel()->currentIndex();
3192 if (!focus_on_selected
3193 && modules_av_model_.itemFromIndex(idx)->hasChildren()) {
3194 // This is a category header
3195 modulesModule->infoML->document()->clear();
3199 string const modName = focus_on_selected ?
3200 modules_sel_model_.getIDString(idx.row())
3201 : fromqstr(modules_av_model_.data(idx, Qt::UserRole).toString());
3202 docstring desc = getModuleDescription(modName);
3204 LayoutModuleList const & provmods = bp_.baseClass()->providedModules();
3205 if (std::find(provmods.begin(), provmods.end(), modName) != provmods.end()) {
3208 desc += _("Module provided by document class.");
3212 docstring cat = getModuleCategory(modName);
3216 desc += bformat(_("<p><b>Category:</b> %1$s.</p>"),
3217 translateIfPossible(cat));
3221 vector<string> pkglist = getPackageList(modName);
3222 docstring pkgdesc = formatStrVec(pkglist, _("and"));
3223 if (!pkgdesc.empty()) {
3226 desc += bformat(_("<p><b>Package(s) required:</b> %1$s.</p>"), pkgdesc);
3229 pkglist = getRequiredList(modName);
3230 if (!pkglist.empty()) {
3231 vector<string> const reqdescs = idsToNames(pkglist);
3232 pkgdesc = formatStrVec(reqdescs, _("or"));
3235 desc += bformat(_("<p><b>Modules required:</b> %1$s.</p>"), pkgdesc);
3238 pkglist = getExcludedList(modName);
3239 if (!pkglist.empty()) {
3240 vector<string> const reqdescs = idsToNames(pkglist);
3241 pkgdesc = formatStrVec(reqdescs, _( "and"));
3244 desc += bformat(_("<p><b>Modules excluded:</b> %1$s.</p>"), pkgdesc);
3249 desc += bformat(_("<p><b>Filename:</b> <tt>%1$s.module</tt>.</p>"), from_utf8(modName));
3251 if (!isModuleAvailable(modName)) {
3254 desc += _("<p><font color=red><b>WARNING: Some required packages are unavailable!</b></font></p>");
3257 modulesModule->infoML->document()->setHtml(toqstr(desc));
3261 void GuiDocument::updateNumbering()
3263 DocumentClass const & tclass = documentClass();
3265 numberingModule->tocTW->setUpdatesEnabled(false);
3266 numberingModule->tocTW->clear();
3268 int const depth = numberingModule->depthSL->value();
3269 int const toc = numberingModule->tocSL->value();
3270 QString const no = qt_("No");
3271 QString const yes = qt_("Yes");
3272 QTreeWidgetItem * item = nullptr;
3274 DocumentClass::const_iterator lit = tclass.begin();
3275 DocumentClass::const_iterator len = tclass.end();
3276 for (; lit != len; ++lit) {
3277 int const toclevel = lit->toclevel;
3278 if (toclevel != Layout::NOT_IN_TOC && !lit->counter.empty()) {
3279 item = new QTreeWidgetItem(numberingModule->tocTW);
3280 item->setText(0, toqstr(translateIfPossible(lit->name())));
3281 item->setText(1, (toclevel <= depth) ? yes : no);
3282 item->setText(2, (toclevel <= toc) ? yes : no);
3286 numberingModule->tocTW->setUpdatesEnabled(true);
3287 numberingModule->tocTW->update();
3291 void GuiDocument::getTableStyles()
3293 // We look for lyx files in the subdirectory dir of
3295 // 2) build_lyxdir (if not empty)
3297 // in this order. Files with a given sub-hierarchy will
3298 // only be listed once.
3299 // We also consider i18n subdirectories and store them separately.
3302 // The three locations to look at.
3303 string const user = addPath(package().user_support().absFileName(), "tabletemplates");
3304 string const build = addPath(package().build_support().absFileName(), "tabletemplates");
3305 string const system = addPath(package().system_support().absFileName(), "tabletemplates");
3307 dirs << toqstr(user)
3311 for (int i = 0; i < dirs.size(); ++i) {
3312 QString const & dir = dirs.at(i);
3313 QDirIterator it(dir, QDir::Files, QDirIterator::Subdirectories);
3314 while (it.hasNext()) {
3315 QString fn = QFileInfo(it.next()).fileName();
3316 if (!fn.endsWith(".lyx") || fn.contains("_1x"))
3318 QString data = fn.left(fn.lastIndexOf(".lyx"));
3319 QString guiname = data;
3320 guiname = toqstr(translateIfPossible(qstring_to_ucs4(guiname.replace('_', ' '))));
3321 QString relpath = toqstr(makeRelPath(qstring_to_ucs4(fn),
3322 qstring_to_ucs4(dir)));
3323 if (textLayoutModule->tableStyleCO->findData(data) == -1)
3324 textLayoutModule->tableStyleCO->addItem(guiname, data);
3330 void GuiDocument::updateDefaultFormat()
3334 // make a copy in order to consider unapplied changes
3335 BufferParams param_copy = buffer().params();
3336 param_copy.useNonTeXFonts = fontModule->osFontsCB->isChecked();
3337 int const idx = latexModule->classCO->currentIndex();
3339 string const classname = fromqstr(latexModule->classCO->getData(idx));
3340 param_copy.setBaseClass(classname, buffer().layoutPos());
3341 param_copy.makeDocumentClass(true);
3343 outputModule->defaultFormatCO->blockSignals(true);
3344 outputModule->defaultFormatCO->clear();
3345 outputModule->defaultFormatCO->addItem(qt_("Default"),
3346 QVariant(QString("default")));
3347 FormatList const & formats =
3348 param_copy.exportableFormats(true);
3349 for (Format const * f : formats)
3350 outputModule->defaultFormatCO->addItem
3351 (toqstr(translateIfPossible(f->prettyname())),
3352 QVariant(toqstr(f->name())));
3353 outputModule->defaultFormatCO->blockSignals(false);
3357 bool GuiDocument::isChildIncluded(string const & child)
3359 if (includeonlys_.empty())
3361 return (std::find(includeonlys_.begin(),
3362 includeonlys_.end(), child) != includeonlys_.end());
3366 void GuiDocument::applyView()
3369 preambleModule->apply(bp_);
3370 localLayout->apply(bp_);
3373 bp_.suppress_date = latexModule->suppressDateCB->isChecked();
3374 bp_.use_refstyle = latexModule->refstyleCB->isChecked();
3377 string const engine =
3378 fromqstr(biblioModule->citeEngineCO->itemData(
3379 biblioModule->citeEngineCO->currentIndex()).toString());
3380 bp_.setCiteEngine(engine);
3382 CiteEngineType const style = CiteEngineType(biblioModule->citeStyleCO->itemData(
3383 biblioModule->citeStyleCO->currentIndex()).toInt());
3384 if (theCiteEnginesList[engine]->hasEngineType(style))
3385 bp_.setCiteEngineType(style);
3387 bp_.setCiteEngineType(ENGINE_TYPE_DEFAULT);
3389 bp_.splitbib(biblioModule->bibtopicCB->isChecked());
3391 bp_.multibib = fromqstr(biblioModule->bibunitsCO->itemData(
3392 biblioModule->bibunitsCO->currentIndex()).toString());
3394 bp_.setDefaultBiblioStyle(fromqstr(biblioModule->defaultBiblioCO->currentText()));
3396 bp_.biblatex_bibstyle = fromqstr(biblioModule->biblatexBbxCO->currentText());
3397 bp_.biblatex_citestyle = fromqstr(biblioModule->biblatexCbxCO->currentText());
3398 bp_.biblio_opts = fromqstr(biblioModule->citePackageOptionsLE->text());
3400 string const bibtex_command =
3401 fromqstr(biblioModule->bibtexCO->itemData(
3402 biblioModule->bibtexCO->currentIndex()).toString());
3403 string const bibtex_options =
3404 fromqstr(biblioModule->bibtexOptionsLE->text());
3405 if (bibtex_command == "default" || bibtex_options.empty())
3406 bp_.bibtex_command = bibtex_command;
3408 bp_.bibtex_command = bibtex_command + " " + bibtex_options;
3410 if (biblioChanged_) {
3411 buffer().invalidateBibinfoCache();
3412 buffer().removeBiblioTempFiles();
3416 indicesModule->apply(bp_);
3418 // language & quotes
3419 switch (langModule->encodingCO->currentIndex()) {
3420 case EncodingSets::unicode: {
3421 if (!fontModule->osFontsCB->isChecked())
3422 bp_.inputenc = fromqstr(langModule->unicodeEncodingCO->itemData(
3423 langModule->unicodeEncodingCO->currentIndex()).toString());
3426 case EncodingSets::legacy: {
3427 bp_.inputenc = "auto-legacy";
3428 bp_.inputenc = fromqstr(langModule->autoEncodingCO->itemData(
3429 langModule->autoEncodingCO->currentIndex()).toString());
3432 case EncodingSets::custom: {
3433 bp_.inputenc = fromqstr(langModule->customEncodingCO->itemData(
3434 langModule->customEncodingCO->currentIndex()).toString());
3438 // this should never happen
3439 bp_.inputenc = "utf8";
3441 bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
3442 langModule->quoteStyleCO->currentIndex()).toInt();
3443 bp_.dynamic_quotes = langModule->dynamicQuotesCB->isChecked();
3445 QString const langname = langModule->languageCO->itemData(
3446 langModule->languageCO->currentIndex()).toString();
3447 Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
3448 Cursor & cur = const_cast<BufferView *>(bufferview())->cursor();
3449 // If current cursor language was the document language, then update it too.
3450 if (cur.current_font.language() == bp_.language) {
3451 cur.current_font.setLanguage(newlang);
3452 cur.real_current_font.setLanguage(newlang);
3454 bp_.language = newlang;
3456 QString const pack = langModule->languagePackageCO->itemData(
3457 langModule->languagePackageCO->currentIndex()).toString();
3458 if (pack == "custom")
3460 fromqstr(langModule->languagePackageLE->text());
3462 bp_.lang_package = fromqstr(pack);
3465 bp_.backgroundcolor = set_backgroundcolor;
3466 bp_.isbackgroundcolor = is_backgroundcolor;
3467 bp_.fontcolor = set_fontcolor;
3468 bp_.isfontcolor = is_fontcolor;
3469 bp_.notefontcolor = set_notefontcolor;
3470 bp_.boxbgcolor = set_boxbgcolor;
3473 if (bp_.documentClass().hasTocLevels()) {
3474 bp_.tocdepth = numberingModule->tocSL->value();
3475 bp_.secnumdepth = numberingModule->depthSL->value();
3477 bp_.use_lineno = numberingModule->linenoCB->isChecked();
3478 bp_.lineno_opts = fromqstr(numberingModule->linenoLE->text());
3481 bp_.user_defined_bullet(0) = bulletsModule->bullet(0);
3482 bp_.user_defined_bullet(1) = bulletsModule->bullet(1);
3483 bp_.user_defined_bullet(2) = bulletsModule->bullet(2);
3484 bp_.user_defined_bullet(3) = bulletsModule->bullet(3);
3487 bp_.graphics_driver =
3488 tex_graphics[latexModule->psdriverCO->currentIndex()];
3491 int idx = latexModule->classCO->currentIndex();
3493 string const classname = fromqstr(latexModule->classCO->getData(idx));
3494 bp_.setBaseClass(classname, buffer().layoutPos());
3498 modulesToParams(bp_);
3501 map<string, string> const & packages = BufferParams::auto_packages();
3502 for (map<string, string>::const_iterator it = packages.begin();
3503 it != packages.end(); ++it) {
3504 QTableWidgetItem * item = mathsModule->packagesTW->findItems(toqstr(it->first), Qt::MatchExactly)[0];
3507 int row = mathsModule->packagesTW->row(item);
3510 (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
3511 if (rb->isChecked()) {
3512 bp_.use_package(it->first, BufferParams::package_auto);
3515 rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
3516 if (rb->isChecked()) {
3517 bp_.use_package(it->first, BufferParams::package_on);
3520 rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
3521 if (rb->isChecked())
3522 bp_.use_package(it->first, BufferParams::package_off);
3524 // if math is indented
3525 bp_.is_math_indent = mathsModule->MathIndentCB->isChecked();
3526 if (bp_.is_math_indent) {
3527 // if formulas are indented
3528 switch (mathsModule->MathIndentCO->currentIndex()) {
3530 bp_.setMathIndent(Length());
3533 Length mathindent(widgetsToLength(mathsModule->MathIndentLE,
3534 mathsModule->MathIndentLengthCO));
3535 bp_.setMathIndent(mathindent);
3539 // this should never happen
3540 bp_.setMathIndent(Length());
3544 switch (mathsModule->MathNumberingPosCO->currentIndex()) {
3546 bp_.math_numbering_side = BufferParams::LEFT;
3549 bp_.math_numbering_side = BufferParams::DEFAULT;
3552 bp_.math_numbering_side = BufferParams::RIGHT;
3555 // this should never happen
3556 bp_.math_numbering_side = BufferParams::DEFAULT;
3561 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
3562 bp_.pagestyle = "default";
3564 QString style_gui = pageLayoutModule->pagestyleCO->currentText();
3565 for (size_t i = 0; i != pagestyles.size(); ++i)
3566 if (pagestyles[i].second == style_gui)
3567 bp_.pagestyle = pagestyles[i].first;
3571 switch (textLayoutModule->lspacingCO->currentIndex()) {
3573 bp_.spacing().set(Spacing::Single);
3576 bp_.spacing().set(Spacing::Onehalf);
3579 bp_.spacing().set(Spacing::Double);
3582 string s = widgetToDoubleStr(textLayoutModule->lspacingLE);
3584 bp_.spacing().set(Spacing::Single);
3586 bp_.spacing().set(Spacing::Other, s);
3591 if (textLayoutModule->twoColumnCB->isChecked())
3596 bp_.justification = textLayoutModule->justCB->isChecked();
3598 if (textLayoutModule->indentRB->isChecked()) {
3599 // if paragraphs are separated by an indentation
3600 bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation;
3601 switch (textLayoutModule->indentCO->currentIndex()) {
3603 bp_.setParIndent(Length());
3606 Length parindent(widgetsToLength(textLayoutModule->indentLE,
3607 textLayoutModule->indentLengthCO));
3608 bp_.setParIndent(parindent);
3612 // this should never happen
3613 bp_.setParIndent(Length());
3617 // if paragraphs are separated by a skip
3618 bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation;
3619 VSpace::VSpaceKind spacekind =
3620 VSpace::VSpaceKind(textLayoutModule->skipCO->itemData(textLayoutModule->skipCO->currentIndex()).toInt());
3621 switch (spacekind) {
3622 case VSpace::SMALLSKIP:
3623 case VSpace::MEDSKIP:
3624 case VSpace::BIGSKIP:
3625 case VSpace::HALFLINE:
3626 case VSpace::FULLLINE:
3627 bp_.setDefSkip(VSpace(spacekind));
3629 case VSpace::LENGTH: {
3631 widgetsToLength(textLayoutModule->skipLE,
3632 textLayoutModule->skipLengthCO)
3638 // this should never happen
3639 bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
3643 bp_.tablestyle = fromqstr(textLayoutModule->tableStyleCO->itemData(
3644 textLayoutModule->tableStyleCO->currentIndex()).toString());
3647 fromqstr(latexModule->optionsLE->text());
3649 bp_.use_default_options =
3650 latexModule->defaultOptionsCB->isChecked();
3652 if (latexModule->childDocGB->isChecked())
3654 fromqstr(latexModule->childDocLE->text());
3656 bp_.master = string();
3659 bp_.clearIncludedChildren();
3660 if (masterChildModule->includeonlyRB->isChecked()) {
3661 list<string>::const_iterator it = includeonlys_.begin();
3662 for (; it != includeonlys_.end() ; ++it) {
3663 bp_.addIncludedChildren(*it);
3666 if (masterChildModule->maintainCRNoneRB->isChecked())
3667 bp_.maintain_unincluded_children =
3668 BufferParams::CM_None;
3669 else if (masterChildModule->maintainCRMostlyRB->isChecked())
3670 bp_.maintain_unincluded_children =
3671 BufferParams::CM_Mostly;
3673 bp_.maintain_unincluded_children =
3674 BufferParams::CM_Strict;
3675 updateIncludeonlyDisplay();
3678 bp_.float_placement = floatModule->getPlacement();
3679 bp_.float_alignment = floatModule->getAlignment();
3682 // text should have passed validation
3683 idx = listingsModule->packageCO->currentIndex();
3684 bp_.use_minted = string(lst_packages[idx]) == "Minted";
3685 bp_.listings_params =
3686 InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
3689 bp_.default_output_format = fromqstr(outputModule->defaultFormatCO->itemData(
3690 outputModule->defaultFormatCO->currentIndex()).toString());
3692 bool const nontexfonts = fontModule->osFontsCB->isChecked();
3693 bp_.useNonTeXFonts = nontexfonts;
3695 bp_.shell_escape = outputModule->shellescapeCB->isChecked();
3696 if (!bp_.shell_escape)
3697 theSession().shellescapeFiles().remove(buffer().absFileName());
3698 else if (!theSession().shellescapeFiles().find(buffer().absFileName()))
3699 theSession().shellescapeFiles().insert(buffer().absFileName());
3700 Buffer & buf = const_cast<Buffer &>(buffer());
3701 buf.params().shell_escape = bp_.shell_escape;
3703 bp_.output_sync = outputModule->outputsyncCB->isChecked();
3705 bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText());
3707 int mathfmt = outputModule->mathoutCB->currentIndex();
3710 BufferParams::MathOutput const mo =
3711 static_cast<BufferParams::MathOutput>(mathfmt);
3712 bp_.html_math_output = mo;
3713 bp_.html_be_strict = outputModule->strictCB->isChecked();
3714 bp_.html_css_as_file = outputModule->cssCB->isChecked();
3715 bp_.html_math_img_scale = outputModule->mathimgSB->value();
3716 bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
3718 int tablefmt = outputModule->tableoutCB->currentIndex();
3721 BufferParams::TableOutput const to =
3722 static_cast<BufferParams::TableOutput>(tablefmt);
3723 bp_.docbook_table_output = to;
3725 bp_.save_transient_properties =
3726 outputModule->saveTransientPropertiesCB->isChecked();
3727 bp_.postpone_fragile_content =
3728 outputModule->postponeFragileCB->isChecked();
3731 bp_.fonts_roman[nontexfonts] =
3732 fromqstr(fontModule->fontsRomanCO->
3733 itemData(fontModule->fontsRomanCO->currentIndex()).toString());
3734 bp_.fonts_roman[!nontexfonts] = fromqstr(fontModule->font_roman);
3735 bp_.font_roman_opts = fromqstr(fontModule->fontspecRomanLE->text());
3737 bp_.fonts_sans[nontexfonts] =
3738 fromqstr(fontModule->fontsSansCO->
3739 itemData(fontModule->fontsSansCO->currentIndex()).toString());
3740 bp_.fonts_sans[!nontexfonts] = fromqstr(fontModule->font_sans);
3741 bp_.font_sans_opts = fromqstr(fontModule->fontspecSansLE->text());
3743 bp_.fonts_typewriter[nontexfonts] =
3744 fromqstr(fontModule->fontsTypewriterCO->
3745 itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
3746 bp_.fonts_typewriter[!nontexfonts] = fromqstr(fontModule->font_typewriter);
3747 bp_.font_typewriter_opts = fromqstr(fontModule->fontspecTypewriterLE->text());
3749 bp_.fonts_math[nontexfonts] =
3750 fromqstr(fontModule->fontsMathCO->
3751 itemData(fontModule->fontsMathCO->currentIndex()).toString());
3752 bp_.fonts_math[!nontexfonts] = fromqstr(fontModule->font_math);
3754 QString const fontenc =
3755 fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
3756 if (fontenc == "custom")
3757 bp_.fontenc = fromqstr(fontModule->fontencLE->text());
3759 bp_.fontenc = fromqstr(fontenc);
3762 fromqstr(fontModule->cjkFontLE->text());
3764 bp_.use_microtype = fontModule->microtypeCB->isChecked();
3765 bp_.use_dash_ligatures = !fontModule->dashesCB->isChecked();
3767 bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
3768 bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
3770 bp_.fonts_typewriter_scale[nontexfonts] = fontModule->scaleTypewriterSB->value();
3771 bp_.fonts_typewriter_scale[!nontexfonts] = fontModule->font_tt_scale;
3773 bp_.fonts_expert_sc = fontModule->fontScCB->isChecked();
3775 bp_.fonts_roman_osf = fontModule->fontOsfCB->isChecked();
3776 bp_.fonts_sans_osf = fontModule->fontSansOsfCB->isChecked();
3777 bp_.fonts_typewriter_osf = fontModule->fontTypewriterOsfCB->isChecked();
3780 bp_.fonts_default_family = "default";
3782 bp_.fonts_default_family = GuiDocument::fontfamilies[
3783 fontModule->fontsDefaultCO->currentIndex()];
3785 if (fontModule->fontsizeCO->currentIndex() == 0)
3786 bp_.fontsize = "default";
3789 fromqstr(fontModule->fontsizeCO->currentText());
3792 bp_.papersize = PAPER_SIZE(
3793 pageLayoutModule->papersizeCO->currentIndex());
3795 bp_.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
3796 pageLayoutModule->paperwidthUnitCO);
3798 bp_.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
3799 pageLayoutModule->paperheightUnitCO);
3801 if (pageLayoutModule->facingPagesCB->isChecked())
3802 bp_.sides = TwoSides;
3804 bp_.sides = OneSide;
3806 if (pageLayoutModule->landscapeRB->isChecked())
3807 bp_.orientation = ORIENTATION_LANDSCAPE;
3809 bp_.orientation = ORIENTATION_PORTRAIT;
3812 bp_.use_geometry = !marginsModule->marginCB->isChecked();
3814 Ui::MarginsUi const * m = marginsModule;
3816 bp_.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
3817 bp_.topmargin = widgetsToLength(m->topLE, m->topUnit);
3818 bp_.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
3819 bp_.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
3820 bp_.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
3821 bp_.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
3822 bp_.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
3823 bp_.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit);
3826 branchesModule->apply(bp_);
3829 PDFOptions & pdf = bp_.pdfoptions();
3830 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
3831 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
3832 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
3833 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
3834 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
3836 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
3837 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
3838 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
3839 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
3841 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
3842 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
3843 pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
3844 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
3846 backref_opts[pdfSupportModule->backrefCO->currentIndex()];
3847 if (pdfSupportModule->fullscreenCB->isChecked())
3848 pdf.pagemode = pdf.pagemode_fullscreen;
3850 pdf.pagemode.clear();
3851 pdf.quoted_options = pdf.quoted_options_check(
3852 fromqstr(pdfSupportModule->optionsLE->text()));
3855 bp_.track_changes = changesModule->trackChangesCB->isChecked();
3856 bp_.output_changes = changesModule->outputChangesCB->isChecked();
3857 bool const cb_switched_off = (bp_.change_bars
3858 && !changesModule->changeBarsCB->isChecked());
3859 bp_.change_bars = changesModule->changeBarsCB->isChecked();
3860 if (cb_switched_off)
3861 // if change bars have been switched off,
3862 // we need to ditch the aux file
3863 buffer().requireFreshStart(true);
3866 nonModuleChanged_ = false;
3867 shellescapeChanged_ = false;
3871 void GuiDocument::paramsToDialog()
3873 // set the default unit
3874 Length::UNIT const default_unit = Length::defaultUnit();
3877 preambleModule->update(bp_, id());
3878 localLayout->update(bp_, id());
3881 latexModule->suppressDateCB->setChecked(bp_.suppress_date);
3882 latexModule->refstyleCB->setChecked(bp_.use_refstyle);
3885 string const cite_engine = bp_.citeEngine();
3887 biblioModule->citeEngineCO->setCurrentIndex(
3888 biblioModule->citeEngineCO->findData(toqstr(cite_engine)));
3890 updateEngineType(documentClass().opt_enginetype(),
3891 bp_.citeEngineType());
3893 checkPossibleCiteEngines();
3895 biblioModule->citeStyleCO->setCurrentIndex(
3896 biblioModule->citeStyleCO->findData(bp_.citeEngineType()));
3898 biblioModule->bibtopicCB->setChecked(bp_.splitbib());
3900 biblioModule->bibunitsCO->clear();
3901 biblioModule->bibunitsCO->addItem(qt_("No"), QString());
3902 if (documentClass().hasLaTeXLayout("part"))
3903 biblioModule->bibunitsCO->addItem(qt_("per part"), toqstr("part"));
3904 if (documentClass().hasLaTeXLayout("chapter"))
3905 biblioModule->bibunitsCO->addItem(qt_("per chapter"), toqstr("chapter"));
3906 if (documentClass().hasLaTeXLayout("section"))
3907 biblioModule->bibunitsCO->addItem(qt_("per section"), toqstr("section"));
3908 if (documentClass().hasLaTeXLayout("subsection"))
3909 biblioModule->bibunitsCO->addItem(qt_("per subsection"), toqstr("subsection"));
3910 biblioModule->bibunitsCO->addItem(qt_("per child document"), toqstr("child"));
3912 int const mbpos = biblioModule->bibunitsCO->findData(toqstr(bp_.multibib));
3914 biblioModule->bibunitsCO->setCurrentIndex(mbpos);
3916 biblioModule->bibunitsCO->setCurrentIndex(0);
3918 updateEngineDependends();
3921 updateDefaultBiblio(bp_.biblatex_bibstyle, "bbx");
3922 updateDefaultBiblio(bp_.biblatex_citestyle, "cbx");
3924 updateDefaultBiblio(bp_.defaultBiblioStyle());
3926 biblioModule->citePackageOptionsLE->setText(toqstr(bp_.biblio_opts));
3930 split(bp_.bibtex_command, command, ' ');
3932 int const bpos = biblioModule->bibtexCO->findData(toqstr(command));
3934 biblioModule->bibtexCO->setCurrentIndex(bpos);
3935 biblioModule->bibtexOptionsLE->setText(toqstr(options).trimmed());
3937 // We reset to default if we do not know the specified compiler
3938 // This is for security reasons
3939 biblioModule->bibtexCO->setCurrentIndex(
3940 biblioModule->bibtexCO->findData(toqstr("default")));
3941 biblioModule->bibtexOptionsLE->clear();
3943 biblioModule->bibtexOptionsLE->setEnabled(
3944 biblioModule->bibtexCO->currentIndex() != 0);
3946 biblioChanged_ = false;
3949 // We may be called when there is no Buffer, e.g., when
3950 // the last view has just been closed.
3951 bool const isReadOnly = isBufferAvailable() ? buffer().isReadonly() : false;
3952 indicesModule->update(bp_, isReadOnly);
3954 // language & quotes
3955 int const pos = langModule->languageCO->findData(toqstr(
3956 bp_.language->lang()));
3957 langModule->languageCO->setCurrentIndex(pos);
3959 updateQuoteStyles();
3961 langModule->quoteStyleCO->setCurrentIndex(
3962 langModule->quoteStyleCO->findData(bp_.quotes_style));
3963 langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
3965 // LaTeX input encoding: set after the fonts (see below)
3967 int p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
3969 langModule->languagePackageCO->setCurrentIndex(
3970 langModule->languagePackageCO->findData("custom"));
3971 langModule->languagePackageLE->setText(toqstr(bp_.lang_package));
3973 langModule->languagePackageCO->setCurrentIndex(p);
3974 langModule->languagePackageLE->clear();
3978 if (bp_.isfontcolor) {
3979 colorModule->fontColorPB->setStyleSheet(
3980 colorButtonStyleSheet(rgb2qcolor(bp_.fontcolor)));
3982 set_fontcolor = bp_.fontcolor;
3983 is_fontcolor = bp_.isfontcolor;
3985 colorModule->noteFontColorPB->setStyleSheet(
3986 colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
3987 set_notefontcolor = bp_.notefontcolor;
3989 if (bp_.isbackgroundcolor) {
3990 colorModule->backgroundPB->setStyleSheet(
3991 colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
3993 set_backgroundcolor = bp_.backgroundcolor;
3994 is_backgroundcolor = bp_.isbackgroundcolor;
3996 colorModule->boxBackgroundPB->setStyleSheet(
3997 colorButtonStyleSheet(rgb2qcolor(bp_.boxbgcolor)));
3998 set_boxbgcolor = bp_.boxbgcolor;
4001 int const min_toclevel = documentClass().min_toclevel();
4002 int const max_toclevel = documentClass().max_toclevel();
4003 if (documentClass().hasTocLevels()) {
4004 numberingModule->setEnabled(true);
4005 numberingModule->depthSL->setMinimum(min_toclevel - 1);
4006 numberingModule->depthSL->setMaximum(max_toclevel);
4007 numberingModule->depthSL->setValue(bp_.secnumdepth);
4008 numberingModule->tocSL->setMaximum(min_toclevel - 1);
4009 numberingModule->tocSL->setMaximum(max_toclevel);
4010 numberingModule->tocSL->setValue(bp_.tocdepth);
4013 numberingModule->setEnabled(false);
4014 numberingModule->tocTW->clear();
4017 numberingModule->linenoCB->setChecked(bp_.use_lineno);
4018 numberingModule->linenoLE->setEnabled(bp_.use_lineno);
4019 numberingModule->linenoLA->setEnabled(bp_.use_lineno);
4020 numberingModule->linenoLE->setText(toqstr(bp_.lineno_opts));
4023 bulletsModule->setBullet(0, bp_.user_defined_bullet(0));
4024 bulletsModule->setBullet(1, bp_.user_defined_bullet(1));
4025 bulletsModule->setBullet(2, bp_.user_defined_bullet(2));
4026 bulletsModule->setBullet(3, bp_.user_defined_bullet(3));
4027 bulletsModule->init();
4030 int nitem = findToken(tex_graphics, bp_.graphics_driver);
4032 latexModule->psdriverCO->setCurrentIndex(nitem);
4036 mathsModule->MathIndentCB->setChecked(bp_.is_math_indent);
4037 if (bp_.is_math_indent) {
4038 Length const mathindent = bp_.getMathIndent();
4040 if (!mathindent.empty()) {
4041 lengthToWidgets(mathsModule->MathIndentLE,
4042 mathsModule->MathIndentLengthCO,
4043 mathindent, default_unit);
4046 mathsModule->MathIndentCO->setCurrentIndex(indent);
4047 enableMathIndent(indent);
4049 switch(bp_.math_numbering_side) {
4050 case BufferParams::LEFT:
4051 mathsModule->MathNumberingPosCO->setCurrentIndex(0);
4053 case BufferParams::DEFAULT:
4054 mathsModule->MathNumberingPosCO->setCurrentIndex(1);
4056 case BufferParams::RIGHT:
4057 mathsModule->MathNumberingPosCO->setCurrentIndex(2);
4060 map<string, string> const & packages = BufferParams::auto_packages();
4061 for (map<string, string>::const_iterator it = packages.begin();
4062 it != packages.end(); ++it) {
4063 QTableWidgetItem * item = mathsModule->packagesTW->findItems(toqstr(it->first), Qt::MatchExactly)[0];
4066 int row = mathsModule->packagesTW->row(item);
4067 switch (bp_.use_package(it->first)) {
4068 case BufferParams::package_off: {
4070 (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
4071 rb->setChecked(true);
4074 case BufferParams::package_on: {
4076 (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
4077 rb->setChecked(true);
4080 case BufferParams::package_auto: {
4082 (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
4083 rb->setChecked(true);
4089 switch (bp_.spacing().getSpace()) {
4090 case Spacing::Other: nitem = 3; break;
4091 case Spacing::Double: nitem = 2; break;
4092 case Spacing::Onehalf: nitem = 1; break;
4093 case Spacing::Default: case Spacing::Single: nitem = 0; break;
4097 string const & layoutID = bp_.baseClassID();
4098 setLayoutComboByIDString(layoutID);
4100 updatePagestyle(documentClass().opt_pagestyle(),
4103 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
4104 if (bp_.spacing().getSpace() == Spacing::Other) {
4105 doubleToWidget(textLayoutModule->lspacingLE,
4106 bp_.spacing().getValueAsString());
4109 int ts = textLayoutModule->tableStyleCO->findData(toqstr(bp_.tablestyle));
4111 textLayoutModule->tableStyleCO->setCurrentIndex(ts);
4113 if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
4114 textLayoutModule->indentRB->setChecked(true);
4115 string parindent = bp_.getParIndent().asString();
4117 if (!parindent.empty()) {
4118 lengthToWidgets(textLayoutModule->indentLE,
4119 textLayoutModule->indentLengthCO,
4120 parindent, default_unit);
4123 textLayoutModule->indentCO->setCurrentIndex(indent);
4126 textLayoutModule->skipRB->setChecked(true);
4127 VSpace::VSpaceKind skip = bp_.getDefSkip().kind();
4128 textLayoutModule->skipCO->setCurrentIndex(textLayoutModule->skipCO->findData(skip));
4129 if (skip == VSpace::LENGTH) {
4130 string const length = bp_.getDefSkip().asLyXCommand();
4131 lengthToWidgets(textLayoutModule->skipLE,
4132 textLayoutModule->skipLengthCO,
4133 length, default_unit);
4135 setSkip(textLayoutModule->skipCO->currentIndex());
4138 textLayoutModule->twoColumnCB->setChecked(
4140 textLayoutModule->justCB->setChecked(bp_.justification);
4142 if (!bp_.options.empty()) {
4143 latexModule->optionsLE->setText(
4144 toqstr(bp_.options));
4146 latexModule->optionsLE->setText(QString());
4150 latexModule->defaultOptionsCB->setChecked(
4151 bp_.use_default_options);
4152 updateSelectedModules();
4153 selectionManager->updateProvidedModules(
4154 bp_.baseClass()->providedModules());
4155 selectionManager->updateExcludedModules(
4156 bp_.baseClass()->excludedModules());
4158 if (!documentClass().options().empty()) {
4159 latexModule->defaultOptionsLE->setText(
4160 toqstr(documentClass().options()));
4162 latexModule->defaultOptionsLE->setText(
4163 toqstr(_("[No options predefined]")));
4166 latexModule->defaultOptionsLE->setEnabled(
4167 bp_.use_default_options
4168 && !documentClass().options().empty());
4170 latexModule->defaultOptionsCB->setEnabled(
4171 !documentClass().options().empty());
4173 if (!bp_.master.empty()) {
4174 latexModule->childDocGB->setChecked(true);
4175 latexModule->childDocLE->setText(
4176 toqstr(bp_.master));
4178 latexModule->childDocLE->setText(QString());
4179 latexModule->childDocGB->setChecked(false);
4183 if (!bufferview() || !buffer().hasChildren()) {
4184 masterChildModule->childrenTW->clear();
4185 includeonlys_.clear();
4186 docPS->showPanel("Child Documents", false);
4187 if (docPS->isCurrentPanel("Child Documents"))
4188 docPS->setCurrentPanel("Document Class");
4190 docPS->showPanel("Child Documents", true);
4191 masterChildModule->setEnabled(true);
4192 includeonlys_ = bp_.getIncludedChildren();
4193 updateIncludeonlys();
4194 updateIncludeonlyDisplay();
4196 switch (bp_.maintain_unincluded_children) {
4197 case BufferParams::CM_None:
4198 masterChildModule->maintainCRNoneRB->setChecked(true);
4200 case BufferParams::CM_Mostly:
4201 masterChildModule->maintainCRMostlyRB->setChecked(true);
4203 case BufferParams::CM_Strict:
4205 masterChildModule->maintainCRStrictRB->setChecked(true);
4210 floatModule->setPlacement(bp_.float_placement);
4211 floatModule->setAlignment(bp_.float_alignment);
4214 // break listings_params to multiple lines
4216 InsetListingsParams(bp_.listings_params).separatedParams();
4217 listingsModule->listingsED->setPlainText(toqstr(lstparams));
4218 int nn = findToken(lst_packages, bp_.use_minted ? "Minted" : "Listings");
4220 listingsModule->packageCO->setCurrentIndex(nn);
4223 // some languages only work with Polyglossia (which requires non-TeX fonts)
4224 Language const * lang = lyx::languages.getLanguage(
4225 fromqstr(langModule->languageCO->itemData(
4226 langModule->languageCO->currentIndex()).toString()));
4227 bool const need_fontspec =
4228 lang->babel().empty() && !lang->polyglossia().empty()
4229 && lang->required() != "CJK" && lang->required() != "japanese";
4230 bool const os_fonts_available =
4231 bp_.baseClass()->outputType() == lyx::LATEX
4232 && LaTeXFeatures::isAvailable("fontspec");
4233 fontModule->osFontsCB->setEnabled(os_fonts_available && !need_fontspec);
4234 fontModule->osFontsCB->setChecked(
4235 (os_fonts_available && bp_.useNonTeXFonts) || need_fontspec);
4236 updateFontsize(documentClass().opt_fontsize(),
4239 QString font = toqstr(bp_.fontsRoman());
4240 int rpos = fontModule->fontsRomanCO->findData(font);
4242 rpos = fontModule->fontsRomanCO->count();
4243 fontModule->fontsRomanCO->addItem(font + qt_(" (not installed)"), font);
4245 fontModule->fontsRomanCO->setCurrentIndex(rpos);
4246 fontModule->font_roman = toqstr(bp_.fonts_roman[!bp_.useNonTeXFonts]);
4248 font = toqstr(bp_.fontsSans());
4249 int spos = fontModule->fontsSansCO->findData(font);
4251 spos = fontModule->fontsSansCO->count();
4252 fontModule->fontsSansCO->addItem(font + qt_(" (not installed)"), font);
4254 fontModule->fontsSansCO->setCurrentIndex(spos);
4255 fontModule->font_sans = toqstr(bp_.fonts_sans[!bp_.useNonTeXFonts]);
4257 font = toqstr(bp_.fontsTypewriter());
4258 int tpos = fontModule->fontsTypewriterCO->findData(font);
4260 tpos = fontModule->fontsTypewriterCO->count();
4261 fontModule->fontsTypewriterCO->addItem(font + qt_(" (not installed)"), font);
4263 fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
4264 fontModule->font_typewriter = toqstr(bp_.fonts_typewriter[!bp_.useNonTeXFonts]);
4266 font = toqstr(bp_.fontsMath());
4267 int mpos = fontModule->fontsMathCO->findData(font);
4269 mpos = fontModule->fontsMathCO->count();
4270 fontModule->fontsMathCO->addItem(font + qt_(" (not installed)"), font);
4272 fontModule->fontsMathCO->setCurrentIndex(mpos);
4273 fontModule->font_math = toqstr(bp_.fonts_math[!bp_.useNonTeXFonts]);
4275 if (bp_.useNonTeXFonts && os_fonts_available) {
4276 fontModule->fontencLA->setEnabled(false);
4277 fontModule->fontencCO->setEnabled(false);
4278 fontModule->fontencLE->setEnabled(false);
4280 fontModule->fontencLA->setEnabled(true);
4281 fontModule->fontencCO->setEnabled(true);
4282 fontModule->fontencLE->setEnabled(true);
4288 if (!bp_.fonts_cjk.empty())
4289 fontModule->cjkFontLE->setText(
4290 toqstr(bp_.fonts_cjk));
4292 fontModule->cjkFontLE->setText(QString());
4294 fontModule->microtypeCB->setChecked(bp_.use_microtype);
4295 fontModule->dashesCB->setChecked(!bp_.use_dash_ligatures);
4297 fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
4298 fontModule->fontOsfCB->setChecked(bp_.fonts_roman_osf);
4299 fontModule->fontSansOsfCB->setChecked(bp_.fonts_sans_osf);
4300 fontModule->fontTypewriterOsfCB->setChecked(bp_.fonts_typewriter_osf);
4301 fontModule->scaleSansSB->setValue(bp_.fontsSansScale());
4302 fontModule->font_sf_scale = bp_.fonts_sans_scale[!bp_.useNonTeXFonts];
4303 fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale());
4304 fontModule->font_tt_scale = bp_.fonts_typewriter_scale[!bp_.useNonTeXFonts];
4305 if (!bp_.font_roman_opts.empty())
4306 fontModule->fontspecRomanLE->setText(
4307 toqstr(bp_.font_roman_opts));
4309 fontModule->fontspecRomanLE->setText(QString());
4310 if (!bp_.font_sans_opts.empty())
4311 fontModule->fontspecSansLE->setText(
4312 toqstr(bp_.font_sans_opts));
4314 fontModule->fontspecSansLE->setText(QString());
4315 if (!bp_.font_typewriter_opts.empty())
4316 fontModule->fontspecTypewriterLE->setText(
4317 toqstr(bp_.font_typewriter_opts));
4319 fontModule->fontspecTypewriterLE->setText(QString());
4321 nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
4323 fontModule->fontsDefaultCO->setCurrentIndex(nn);
4325 if (bp_.fontenc == "auto" || bp_.fontenc == "default") {
4326 fontModule->fontencCO->setCurrentIndex(
4327 fontModule->fontencCO->findData(toqstr(bp_.fontenc)));
4328 fontModule->fontencLE->setEnabled(false);
4330 fontModule->fontencCO->setCurrentIndex(
4331 fontModule->fontencCO->findData("custom"));
4332 fontModule->fontencLE->setText(toqstr(bp_.fontenc));
4335 // LaTeX input encoding
4336 // Set after fonts because non-tex fonts override "\inputencoding".
4337 inputencodingToDialog();
4340 // This must be set _after_ fonts since updateDefaultFormat()
4341 // checks osFontsCB settings.
4342 // update combobox with formats
4343 updateDefaultFormat();
4344 int index = outputModule->defaultFormatCO->findData(toqstr(
4345 bp_.default_output_format));
4346 // set to default if format is not found
4349 outputModule->defaultFormatCO->setCurrentIndex(index);
4351 outputModule->shellescapeCB->setChecked(bp_.shell_escape);
4352 outputModule->outputsyncCB->setChecked(bp_.output_sync);
4353 outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
4354 outputModule->synccustomCB->setEnabled(bp_.output_sync);
4355 outputModule->synccustomLA->setEnabled(bp_.output_sync);
4357 outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
4358 outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
4359 outputModule->strictCB->setChecked(bp_.html_be_strict);
4360 outputModule->cssCB->setChecked(bp_.html_css_as_file);
4362 outputModule->tableoutCB->setCurrentIndex(bp_.docbook_table_output);
4364 outputModule->saveTransientPropertiesCB
4365 ->setChecked(bp_.save_transient_properties);
4366 outputModule->postponeFragileCB
4367 ->setChecked(bp_.postpone_fragile_content);
4370 bool const extern_geometry =
4371 documentClass().provides("geometry");
4372 int const psize = bp_.papersize;
4373 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
4374 setCustomPapersize(!extern_geometry && psize == 1);
4375 pageLayoutModule->papersizeCO->setEnabled(!extern_geometry);
4377 bool const landscape =
4378 bp_.orientation == ORIENTATION_LANDSCAPE;
4379 pageLayoutModule->landscapeRB->setChecked(landscape);
4380 pageLayoutModule->portraitRB->setChecked(!landscape);
4381 pageLayoutModule->landscapeRB->setEnabled(!extern_geometry);
4382 pageLayoutModule->portraitRB->setEnabled(!extern_geometry);
4384 pageLayoutModule->facingPagesCB->setChecked(
4385 bp_.sides == TwoSides);
4387 lengthToWidgets(pageLayoutModule->paperwidthLE,
4388 pageLayoutModule->paperwidthUnitCO, bp_.paperwidth, default_unit);
4389 lengthToWidgets(pageLayoutModule->paperheightLE,
4390 pageLayoutModule->paperheightUnitCO, bp_.paperheight, default_unit);
4393 Ui::MarginsUi * m = marginsModule;
4397 lengthToWidgets(m->topLE, m->topUnit,
4398 bp_.topmargin, default_unit);
4400 lengthToWidgets(m->bottomLE, m->bottomUnit,
4401 bp_.bottommargin, default_unit);
4403 lengthToWidgets(m->innerLE, m->innerUnit,
4404 bp_.leftmargin, default_unit);
4406 lengthToWidgets(m->outerLE, m->outerUnit,
4407 bp_.rightmargin, default_unit);
4409 lengthToWidgets(m->headheightLE, m->headheightUnit,
4410 bp_.headheight, default_unit);
4412 lengthToWidgets(m->headsepLE, m->headsepUnit,
4413 bp_.headsep, default_unit);
4415 lengthToWidgets(m->footskipLE, m->footskipUnit,
4416 bp_.footskip, default_unit);
4418 lengthToWidgets(m->columnsepLE, m->columnsepUnit,
4419 bp_.columnsep, default_unit);
4422 updateUnknownBranches();
4423 branchesModule->update(bp_);
4426 PDFOptions const & pdf = bp_.pdfoptions();
4427 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
4428 if (bp_.documentClass().provides("hyperref"))
4429 pdfSupportModule->use_hyperrefGB->setTitle(qt_("C&ustomize Hyperref Options"));
4431 pdfSupportModule->use_hyperrefGB->setTitle(qt_("&Use Hyperref Support"));
4432 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
4433 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
4434 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
4435 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
4437 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
4438 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
4439 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
4441 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
4442 pdfSupportModule->bookmarksopenlevelSB->setEnabled(pdf.bookmarksopen);
4443 pdfSupportModule->bookmarksopenlevelLA->setEnabled(pdf.bookmarksopen);
4445 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
4446 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
4447 pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
4448 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
4450 nn = findToken(backref_opts, pdf.backref);
4452 pdfSupportModule->backrefCO->setCurrentIndex(nn);
4454 pdfSupportModule->fullscreenCB->setChecked
4455 (pdf.pagemode == pdf.pagemode_fullscreen);
4457 pdfSupportModule->optionsLE->setText(
4458 toqstr(pdf.quoted_options));
4461 changesModule->trackChangesCB->setChecked(bp_.track_changes);
4462 changesModule->outputChangesCB->setChecked(bp_.output_changes);
4463 changesModule->changeBarsCB->setChecked(bp_.change_bars);
4464 changesModule->changeBarsCB->setEnabled(bp_.output_changes);
4466 // Make sure that the bc is in the INITIAL state
4467 if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
4470 // clear changed branches cache
4471 changedBranches_.clear();
4474 nonModuleChanged_ = false;
4475 shellescapeChanged_ = false;
4479 void GuiDocument::saveDocDefault()
4481 // we have to apply the params first
4487 void GuiDocument::updateAvailableModules()
4489 modules_av_model_.clear();
4490 list<modInfoStruct> modInfoList = getModuleInfo();
4491 // Sort names according to the locale
4492 modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
4493 return 0 < b.name.localeAwareCompare(a.name);
4495 QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
4496 QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
4499 catfont.setBold(true);
4501 unavbrush.setColor(Qt::gray);
4502 for (modInfoStruct const & m : modInfoList) {
4503 QStandardItem * item = new QStandardItem();
4504 QStandardItem * catItem;
4505 QString const catname = m.category;
4506 QList<QStandardItem *> fcats = modules_av_model_.findItems(catname, Qt::MatchExactly);
4508 catItem = fcats.first();
4510 catItem = new QStandardItem();
4511 catItem->setText(catname);
4512 catItem->setFont(catfont);
4513 modules_av_model_.insertRow(i, catItem);
4516 item->setEditable(false);
4517 catItem->setEditable(false);
4518 item->setData(m.name, Qt::DisplayRole);
4520 item->setForeground(unavbrush);
4521 item->setData(toqstr(m.id), Qt::UserRole);
4522 item->setData(m.description, Qt::ToolTipRole);
4524 item->setIcon(user_icon);
4526 item->setIcon(system_icon);
4527 catItem->appendRow(item);
4529 modules_av_model_.sort(0);
4533 void GuiDocument::updateSelectedModules()
4535 modules_sel_model_.clear();
4536 list<modInfoStruct> const selModList = getSelectedModules();
4538 for (modInfoStruct const & m : selModList) {
4539 modules_sel_model_.insertRow(i, m.name, m.id, m.description);
4545 void GuiDocument::updateIncludeonlyDisplay()
4547 if (includeonlys_.empty()) {
4548 masterChildModule->includeallRB->setChecked(true);
4549 masterChildModule->childrenTW->setEnabled(false);
4550 masterChildModule->maintainGB->setEnabled(false);
4552 masterChildModule->includeonlyRB->setChecked(true);
4553 masterChildModule->childrenTW->setEnabled(true);
4554 masterChildModule->maintainGB->setEnabled(true);
4559 void GuiDocument::updateIncludeonlys()
4561 masterChildModule->childrenTW->clear();
4562 QString const no = qt_("No");
4563 QString const yes = qt_("Yes");
4565 ListOfBuffers children = buffer().getChildren();
4566 ListOfBuffers::const_iterator it = children.begin();
4567 ListOfBuffers::const_iterator end = children.end();
4568 bool has_unincluded = false;
4569 bool all_unincluded = true;
4570 for (; it != end; ++it) {
4571 QTreeWidgetItem * item = new QTreeWidgetItem(masterChildModule->childrenTW);
4574 to_utf8(makeRelPath(from_utf8((*it)->fileName().absFileName()),
4575 from_utf8(buffer().filePath())));
4576 item->setText(0, toqstr(name));
4577 item->setText(1, isChildIncluded(name) ? yes : no);
4578 if (!isChildIncluded(name))
4579 has_unincluded = true;
4581 all_unincluded = false;
4583 // Both if all children are included and if none is included
4584 // is equal to "include all" (i.e., omit \includeonly).
4585 if (!has_unincluded || all_unincluded)
4586 includeonlys_.clear();
4590 bool GuiDocument::isBiblatex() const
4592 QString const engine =
4593 biblioModule->citeEngineCO->itemData(
4594 biblioModule->citeEngineCO->currentIndex()).toString();
4596 // this can happen if the cite engine is unknown, which can happen
4597 // if one is using a file that came from someone else, etc. in that
4598 // case, we crash if we proceed.
4599 if (engine.isEmpty())
4602 return theCiteEnginesList[fromqstr(engine)]->getCiteFramework() == "biblatex";
4606 void GuiDocument::updateDefaultBiblio(string const & style,
4607 string const & which)
4609 QString const bibstyle = toqstr(style);
4610 biblioModule->defaultBiblioCO->clear();
4615 if (which != "cbx") {
4616 // First the bbx styles
4617 biblioModule->biblatexBbxCO->clear();
4618 QStringList str = texFileList("bbxFiles.lst");
4619 // test whether we have a valid list, otherwise run rescan
4620 if (str.isEmpty()) {
4621 rescanTexStyles("bbx");
4622 str = texFileList("bbxFiles.lst");
4624 for (int i = 0; i != str.size(); ++i)
4625 str[i] = onlyFileName(str[i]);
4626 // sort on filename only (no path)
4629 for (int i = 0; i != str.count(); ++i) {
4630 QString item = changeExtension(str[i], "");
4631 if (item == bibstyle)
4633 biblioModule->biblatexBbxCO->addItem(item);
4636 if (item_nr == -1 && !bibstyle.isEmpty()) {
4637 biblioModule->biblatexBbxCO->addItem(bibstyle);
4638 item_nr = biblioModule->biblatexBbxCO->count() - 1;
4642 biblioModule->biblatexBbxCO->setCurrentIndex(item_nr);
4644 biblioModule->biblatexBbxCO->clearEditText();
4647 if (which != "bbx") {
4648 // now the cbx styles
4649 biblioModule->biblatexCbxCO->clear();
4650 QStringList str = texFileList("cbxFiles.lst");
4651 // test whether we have a valid list, otherwise run rescan
4652 if (str.isEmpty()) {
4653 rescanTexStyles("cbx");
4654 str = texFileList("cbxFiles.lst");
4656 for (int i = 0; i != str.size(); ++i)
4657 str[i] = onlyFileName(str[i]);
4658 // sort on filename only (no path)
4661 for (int i = 0; i != str.count(); ++i) {
4662 QString item = changeExtension(str[i], "");
4663 if (item == bibstyle)
4665 biblioModule->biblatexCbxCO->addItem(item);
4668 if (item_nr == -1 && !bibstyle.isEmpty()) {
4669 biblioModule->biblatexCbxCO->addItem(bibstyle);
4670 item_nr = biblioModule->biblatexCbxCO->count() - 1;
4674 biblioModule->biblatexCbxCO->setCurrentIndex(item_nr);
4676 biblioModule->biblatexCbxCO->clearEditText();
4679 biblioModule->biblatexBbxCO->clear();
4680 biblioModule->biblatexCbxCO->clear();
4681 QStringList str = texFileList("bstFiles.lst");
4682 // test whether we have a valid list, otherwise run rescan
4683 if (str.isEmpty()) {
4684 rescanTexStyles("bst");
4685 str = texFileList("bstFiles.lst");
4687 for (int i = 0; i != str.size(); ++i)
4688 str[i] = onlyFileName(str[i]);
4689 // sort on filename only (no path)
4692 for (int i = 0; i != str.count(); ++i) {
4693 QString item = changeExtension(str[i], "");
4694 if (item == bibstyle)
4696 biblioModule->defaultBiblioCO->addItem(item);
4699 if (item_nr == -1 && !bibstyle.isEmpty()) {
4700 biblioModule->defaultBiblioCO->addItem(bibstyle);
4701 item_nr = biblioModule->defaultBiblioCO->count() - 1;
4705 biblioModule->defaultBiblioCO->setCurrentIndex(item_nr);
4707 biblioModule->defaultBiblioCO->clearEditText();
4710 updateResetDefaultBiblio();
4714 void GuiDocument::updateResetDefaultBiblio()
4716 QString const engine =
4717 biblioModule->citeEngineCO->itemData(
4718 biblioModule->citeEngineCO->currentIndex()).toString();
4719 CiteEngineType const cet =
4720 CiteEngineType(biblioModule->citeStyleCO->itemData(
4721 biblioModule->citeStyleCO->currentIndex()).toInt());
4723 string const defbib = theCiteEnginesList[fromqstr(engine)]->getDefaultBiblio(cet);
4725 QString const bbx = biblioModule->biblatexBbxCO->currentText();
4726 QString const cbx = biblioModule->biblatexCbxCO->currentText();
4727 biblioModule->resetCbxPB->setEnabled(defbib != fromqstr(cbx));
4728 biblioModule->resetBbxPB->setEnabled(defbib != fromqstr(bbx));
4729 biblioModule->matchBbxPB->setEnabled(bbx != cbx && !cbx.isEmpty()
4730 && biblioModule->biblatexBbxCO->findText(cbx) != -1);
4732 biblioModule->resetDefaultBiblioPB->setEnabled(
4733 defbib != fromqstr(biblioModule->defaultBiblioCO->currentText()));
4737 void GuiDocument::matchBiblatexStyles()
4739 updateDefaultBiblio(fromqstr(biblioModule->biblatexCbxCO->currentText()), "bbx");
4744 void GuiDocument::updateContents()
4746 // Nothing to do here as the document settings is not cursor dependent.
4751 void GuiDocument::useClassDefaults()
4753 if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
4754 int const ret = Alert::prompt(_("Unapplied changes"),
4755 _("Some changes in the dialog were not yet applied.\n"
4756 "If you do not apply now, they will be lost after this action."),
4757 1, 1, _("&Apply"), _("&Dismiss"));
4762 int idx = latexModule->classCO->currentIndex();
4763 string const classname = fromqstr(latexModule->classCO->getData(idx));
4764 if (!bp_.setBaseClass(classname, buffer().layoutPos())) {
4765 Alert::error(_("Error"), _("Unable to set document class."));
4768 bp_.useClassDefaults();
4774 void GuiDocument::setLayoutComboByIDString(string const & idString)
4776 if (!latexModule->classCO->set(toqstr(idString)))
4777 Alert::warning(_("Can't set layout!"),
4778 bformat(_("Unable to set layout for ID: %1$s"), from_utf8(idString)));
4782 bool GuiDocument::isValid()
4785 validateListingsParameters().isEmpty() &&
4786 localLayout->isValid() &&
4787 !localLayout->editing() &&
4788 !preambleModule->editing() &&
4790 // if we're asking for skips between paragraphs
4791 !textLayoutModule->skipRB->isChecked() ||
4792 // then either we haven't chosen custom
4793 textLayoutModule->skipCO->currentIndex() != 3 ||
4794 // or else a length has been given
4795 !textLayoutModule->skipLE->text().isEmpty()
4798 // if we're asking for indentation
4799 !textLayoutModule->indentRB->isChecked() ||
4800 // then either we haven't chosen custom
4801 textLayoutModule->indentCO->currentIndex() != 1 ||
4802 // or else a length has been given
4803 !textLayoutModule->indentLE->text().isEmpty()
4806 // if we're asking for math indentation
4807 !mathsModule->MathIndentCB->isChecked() ||
4808 // then either we haven't chosen custom
4809 mathsModule->MathIndentCO->currentIndex() != 1 ||
4810 // or else a length has been given
4811 !mathsModule->MathIndentLE->text().isEmpty()
4816 char const * const GuiDocument::fontfamilies[5] = {
4817 "default", "rmdefault", "sfdefault", "ttdefault", ""
4821 char const * GuiDocument::fontfamilies_gui[5] = {
4822 N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
4826 bool GuiDocument::initialiseParams(string const &)
4828 BufferView const * view = bufferview();
4830 bp_ = BufferParams();
4834 bp_ = view->buffer().params();
4836 updateAvailableModules();
4837 //FIXME It'd be nice to make sure here that the selected
4838 //modules are consistent: That required modules are actually
4839 //selected, and that we don't have conflicts. If so, we could
4840 //at least pop up a warning.
4846 void GuiDocument::clearParams()
4848 bp_ = BufferParams();
4852 BufferId GuiDocument::id() const
4854 BufferView const * const view = bufferview();
4855 return view? &view->buffer() : nullptr;
4859 list<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
4861 return moduleNames_;
4865 list<GuiDocument::modInfoStruct> const
4866 GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
4868 list<modInfoStruct> mInfo;
4869 for (string const & name : mods) {
4871 LyXModule const * const mod = theModuleList[name];
4876 m.name = toqstr(name + " (") + qt_("Not Found") + toqstr(")");
4878 m.missingreqs = true;
4886 list<GuiDocument::modInfoStruct> const GuiDocument::getSelectedModules()
4888 return makeModuleInfo(params().getModules());
4892 list<GuiDocument::modInfoStruct> const GuiDocument::getProvidedModules()
4894 return makeModuleInfo(params().baseClass()->providedModules());
4898 DocumentClass const & GuiDocument::documentClass() const
4900 return bp_.documentClass();
4904 static void dispatch_bufferparams(Dialog const & dialog,
4905 BufferParams const & bp, FuncCode lfun, Buffer const * buf)
4908 ss << "\\begin_header\n";
4909 bp.writeFile(ss, buf);
4910 ss << "\\end_header\n";
4911 dialog.dispatch(FuncRequest(lfun, ss.str()));
4915 void GuiDocument::dispatchParams()
4917 // We need a non-const buffer object.
4918 Buffer & buf = const_cast<BufferView *>(bufferview())->buffer();
4919 // There may be several undo records; group them (bug #8998)
4920 // This handles undo groups automagically
4921 UndoGroupHelper ugh(&buf);
4923 // This must come first so that a language change is correctly noticed
4926 // We need to load the master before we formally update the params,
4927 // since otherwise we run updateBuffer, etc, before the child's master
4929 if (!params().master.empty()) {
4930 FileName const master_file = support::makeAbsPath(params().master,
4931 support::onlyPath(buffer().absFileName()));
4932 if (isLyXFileName(master_file.absFileName())) {
4933 Buffer * master = checkAndLoadLyXFile(master_file);
4935 if (master->isChild(const_cast<Buffer *>(&buffer())))
4936 const_cast<Buffer &>(buffer()).setParent(master);
4938 Alert::warning(_("Assigned master does not include this file"),
4939 bformat(_("You must include this file in the document\n"
4940 "'%1$s' in order to use the master document\n"
4941 "feature."), from_utf8(params().master)));
4943 Alert::warning(_("Could not load master"),
4944 bformat(_("The master document '%1$s'\n"
4945 "could not be loaded."),
4946 from_utf8(params().master)));
4950 // Apply the BufferParams. Note that this will set the base class
4951 // and then update the buffer's layout.
4952 dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY, &buffer());
4954 // Generate the colours requested by each new branch.
4955 BranchList & branchlist = params().branchlist();
4956 if (!branchlist.empty()) {
4957 BranchList::const_iterator it = branchlist.begin();
4958 BranchList::const_iterator const end = branchlist.end();
4959 for (; it != end; ++it) {
4960 docstring const & current_branch = it->branch();
4961 Branch const * branch = branchlist.find(current_branch);
4962 string const x11hexname = X11hexname(branch->color());
4963 // display the new color
4964 docstring const str = current_branch + ' ' + from_ascii(x11hexname);
4965 dispatch(FuncRequest(LFUN_SET_COLOR, str));
4968 // rename branches in the document
4969 executeBranchRenaming();
4970 // and clear changed branches cache
4971 changedBranches_.clear();
4973 // Generate the colours requested by indices.
4974 IndicesList & indiceslist = params().indiceslist();
4975 if (!indiceslist.empty()) {
4976 IndicesList::const_iterator it = indiceslist.begin();
4977 IndicesList::const_iterator const end = indiceslist.end();
4978 for (; it != end; ++it) {
4979 docstring const & current_index = it->shortcut();
4980 Index const * index = indiceslist.findShortcut(current_index);
4981 string const x11hexname = X11hexname(index->color());
4982 // display the new color
4983 docstring const str = current_index + ' ' + from_ascii(x11hexname);
4984 dispatch(FuncRequest(LFUN_SET_COLOR, str));
4988 // If we used an LFUN, we would not need these two lines:
4989 BufferView * bv = const_cast<BufferView *>(bufferview());
4990 bv->processUpdateFlags(Update::Force | Update::FitCursor);
4994 void GuiDocument::setLanguage() const
4996 Language const * const newL = bp_.language;
4997 if (buffer().params().language == newL)
5000 string const & lang_name = newL->lang();
5001 dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
5005 void GuiDocument::saveAsDefault() const
5007 dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT, &buffer());
5011 bool GuiDocument::providesOSF(QString const & font) const
5013 if (fontModule->osFontsCB->isChecked())
5014 // FIXME: we should check if the fonts really
5015 // have OSF support. But how?
5017 return theLaTeXFonts().getLaTeXFont(
5018 qstring_to_ucs4(font)).providesOSF(ot1(),
5024 bool GuiDocument::providesSC(QString const & font) const
5026 if (fontModule->osFontsCB->isChecked())
5028 return theLaTeXFonts().getLaTeXFont(
5029 qstring_to_ucs4(font)).providesSC(ot1(),
5035 bool GuiDocument::providesScale(QString const & font) const
5037 if (fontModule->osFontsCB->isChecked())
5039 return theLaTeXFonts().getLaTeXFont(
5040 qstring_to_ucs4(font)).providesScale(ot1(),
5046 bool GuiDocument::providesExtraOpts(QString const & font) const
5048 if (fontModule->osFontsCB->isChecked())
5050 return theLaTeXFonts().getLaTeXFont(
5051 qstring_to_ucs4(font)).providesMoreOptions(ot1(),
5057 bool GuiDocument::providesNoMath(QString const & font) const
5059 if (fontModule->osFontsCB->isChecked())
5061 return theLaTeXFonts().getLaTeXFont(
5062 qstring_to_ucs4(font)).providesNoMath(ot1(),
5067 bool GuiDocument::hasMonolithicExpertSet(QString const & font) const
5069 if (fontModule->osFontsCB->isChecked())
5071 return theLaTeXFonts().getLaTeXFont(
5072 qstring_to_ucs4(font)).hasMonolithicExpertSet(ot1(),
5079 GuiDocument::modInfoStruct GuiDocument::modInfo(LyXModule const & mod)
5081 // FIXME Unicode: docstrings would be better for these parameters but this
5082 // change requires a lot of others
5085 QString const guiname = toqstr(translateIfPossible(from_utf8(mod.getName())));
5086 m.missingreqs = !isModuleAvailable(mod.getID());
5087 if (m.missingreqs) {
5088 m.name = QString(qt_("%1 (missing req.)")).arg(guiname);
5091 m.category = mod.category().empty() ? qt_("Miscellaneous")
5092 : toqstr(translateIfPossible(from_utf8(mod.category())));
5093 QString desc = toqstr(translateIfPossible(from_utf8(mod.getDescription())));
5094 // Find the first sentence of the description
5095 QTextBoundaryFinder bf(QTextBoundaryFinder::Sentence, desc);
5096 int pos = bf.toNextBoundary();
5099 m.local = mod.isLocal();
5100 QString const mtype = m.local ? qt_("personal module") : qt_("distributed module");
5101 QString modulename = QString(qt_("<b>Module name:</b> <i>%1</i> (%2)")).arg(toqstr(m.id)).arg(mtype);
5102 // Tooltip is the desc followed by the module name and the type
5103 m.description = QString("%1%2")
5104 .arg(desc.isEmpty() ? QString() : QString("<p>%1</p>").arg(desc),
5107 m.description += QString("<p>%1</p>").arg(qt_("<b>Note:</b> Some requirements for this module are missing!"));
5112 void GuiDocument::loadModuleInfo()
5114 moduleNames_.clear();
5115 for (LyXModule const & mod : theModuleList)
5116 moduleNames_.push_back(modInfo(mod));
5120 void GuiDocument::updateUnknownBranches()
5124 list<docstring> used_branches;
5125 buffer().getUsedBranches(used_branches);
5126 list<docstring>::const_iterator it = used_branches.begin();
5127 QStringList unknown_branches;
5128 for (; it != used_branches.end() ; ++it) {
5129 if (!buffer().params().branchlist().find(*it))
5130 unknown_branches.append(toqstr(*it));
5132 branchesModule->setUnknownBranches(unknown_branches);
5136 void GuiDocument::branchesRename(docstring const & oldname, docstring const & newname)
5138 map<docstring, docstring>::iterator it = changedBranches_.begin();
5139 for (; it != changedBranches_.end() ; ++it) {
5140 if (it->second == oldname) {
5141 // branch has already been renamed
5142 it->second = newname;
5147 changedBranches_[oldname] = newname;
5151 void GuiDocument::executeBranchRenaming() const
5153 map<docstring, docstring>::const_iterator it = changedBranches_.begin();
5154 for (; it != changedBranches_.end() ; ++it) {
5155 docstring const arg = '"' + it->first + '"' + " " + '"' + it->second + '"';
5156 dispatch(FuncRequest(LFUN_BRANCHES_RENAME, arg));
5161 void GuiDocument::allPackagesAuto()
5167 void GuiDocument::allPackagesAlways()
5173 void GuiDocument::allPackagesNot()
5179 void GuiDocument::allPackages(int col)
5181 for (int row = 0; row < mathsModule->packagesTW->rowCount(); ++row) {
5183 (QRadioButton*)mathsModule->packagesTW->cellWidget(row, col)->layout()->itemAt(0)->widget();
5184 rb->setChecked(true);
5189 void GuiDocument::linenoToggled(bool on)
5191 numberingModule->linenoLE->setEnabled(on);
5192 numberingModule->linenoLA->setEnabled(on);
5196 void GuiDocument::outputChangesToggled(bool on)
5198 changesModule->changeBarsCB->setEnabled(on);
5202 void GuiDocument::setOutputSync(bool on)
5204 outputModule->synccustomCB->setEnabled(on);
5205 outputModule->synccustomLA->setEnabled(on);
5211 Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
5214 } // namespace frontend
5217 #include "moc_GuiDocument.cpp"