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 "GuiApplication.h"
17 #include "GuiBranches.h"
18 #include "GuiIndices.h"
19 #include "GuiSelectionManager.h"
20 #include "LaTeXHighlighter.h"
21 #include "LengthCombo.h"
22 #include "PanelStack.h"
23 #include "Validator.h"
25 #include "LayoutFile.h"
26 #include "BranchList.h"
27 #include "buffer_funcs.h"
29 #include "BufferParams.h"
30 #include "BufferView.h"
32 #include "ColorCache.h"
34 #include "FloatPlacement.h"
36 #include "FuncRequest.h"
38 #include "IndicesList.h"
40 #include "LaTeXFeatures.h"
42 #include "LayoutModuleList.h"
44 #include "ModuleList.h"
45 #include "OutputParams.h"
46 #include "PDFOptions.h"
47 #include "qt_helpers.h"
49 #include "TextClass.h"
51 #include "insets/InsetListingsParams.h"
53 #include "support/debug.h"
54 #include "support/FileName.h"
55 #include "support/filetools.h"
56 #include "support/gettext.h"
57 #include "support/lstrings.h"
59 #include "frontends/alert.h"
61 #include <QAbstractItemModel>
62 #include <QHeaderView>
64 #include <QColorDialog>
65 #include <QCloseEvent>
66 #include <QFontDatabase>
68 #include <QTextCursor>
78 // a style sheet for buttons
79 // this is for example used for the background color setting button
80 static inline QString colorButtonStyleSheet(QColor const & bgColor)
82 if (bgColor.isValid()) {
83 QString rc = QLatin1String("background-color:");
92 using namespace lyx::support;
97 char const * const tex_graphics[] =
99 "default", "dvialw", "dvilaser", "dvipdf", "dvipdfm", "dvipdfmx",
100 "dvips", "dvipsone", "dvitops", "dviwin", "dviwindo", "dvi2ps", "emtex",
101 "ln", "oztex", "pctexhp", "pctexps", "pctexwin", "pctex32", "pdftex",
102 "psprint", "pubps", "tcidvi", "textures", "truetex", "vtex", "xdvi",
107 char const * const tex_graphics_gui[] =
109 N_("Default"), "dvialw", "DviLaser", "dvipdf", "DVIPDFM", "DVIPDFMx",
110 "Dvips", "DVIPSONE", "DVItoPS", "DVIWIN", "DVIWindo", "dvi2ps", "EmTeX",
111 "LN", "OzTeX", "pctexhp", "pctexps", "pctexwin", "PCTeX32", "pdfTeX",
112 "psprint", "pubps", "tcidvi", "Textures", "TrueTeX", "VTeX", "xdvi",
113 "XeTeX", N_("None"), ""
117 char const * const tex_fonts_roman[] =
119 "default", "cmr", "lmodern", "ae", "times", "palatino",
120 "charter", "newcent", "bookman", "utopia", "beraserif",
121 "ccfonts", "chancery", ""
125 char const * tex_fonts_roman_gui[] =
127 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
128 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
129 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
130 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
135 char const * const tex_fonts_sans[] =
137 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
141 char const * tex_fonts_sans_gui[] =
143 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
144 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
148 char const * const tex_fonts_monospaced[] =
150 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
154 char const * tex_fonts_monospaced_gui[] =
156 N_("Default"), N_("Computer Modern Typewriter"),
157 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
158 N_("LuxiMono"), N_("CM Typewriter Light"), ""
162 char const * backref_opts[] =
164 "false", "section", "slide", "page", ""
168 char const * backref_opts_gui[] =
170 N_("Off"), N_("Section"), N_("Slide"), N_("Page"), ""
174 vector<pair<string, QString> > pagestyles;
177 } // anonymous namespace
181 RGBColor set_backgroundcolor;
182 bool is_backgroundcolor;
183 RGBColor set_fontcolor;
185 RGBColor set_notefontcolor;
186 RGBColor set_boxbgcolor;
189 // used when sorting the textclass list.
190 class less_textclass_avail_desc
191 : public binary_function<string, string, int>
194 bool operator()(string const & lhs, string const & rhs) const
196 // Ordering criteria:
197 // 1. Availability of text class
198 // 2. Description (lexicographic)
199 LayoutFile const & tc1 = LayoutFileList::get()[lhs];
200 LayoutFile const & tc2 = LayoutFileList::get()[rhs];
201 int const order = compare_no_case(
202 translateIfPossible(from_utf8(tc1.description())),
203 translateIfPossible(from_utf8(tc2.description())));
204 return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
205 (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() && order < 0);
214 vector<string> getRequiredList(string const & modName)
216 LyXModule const * const mod = theModuleList[modName];
218 return vector<string>(); //empty such thing
219 return mod->getRequiredModules();
223 vector<string> getExcludedList(string const & modName)
225 LyXModule const * const mod = theModuleList[modName];
227 return vector<string>(); //empty such thing
228 return mod->getExcludedModules();
232 docstring getModuleDescription(string const & modName)
234 LyXModule const * const mod = theModuleList[modName];
236 return _("Module not found!");
238 return translateIfPossible(from_utf8(mod->getDescription()));
242 vector<string> getPackageList(string const & modName)
244 LyXModule const * const mod = theModuleList[modName];
246 return vector<string>(); //empty such thing
247 return mod->getPackageList();
251 bool isModuleAvailable(string const & modName)
253 LyXModule const * const mod = theModuleList[modName];
256 return mod->isAvailable();
259 } // anonymous namespace
262 /////////////////////////////////////////////////////////////////////
264 // ModuleSelectionManager
266 /////////////////////////////////////////////////////////////////////
268 /// SelectionManager for use with modules
269 class ModuleSelectionManager : public GuiSelectionManager
273 ModuleSelectionManager(
274 QTreeView * availableLV,
275 QListView * selectedLV,
279 QPushButton * downPB,
280 GuiIdListModel * availableModel,
281 GuiIdListModel * selectedModel,
282 GuiDocument const * container)
283 : GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
284 upPB, downPB, availableModel, selectedModel), container_(container)
287 void updateProvidedModules(LayoutModuleList const & pm)
288 { provided_modules_ = pm.list(); }
290 void updateExcludedModules(LayoutModuleList const & em)
291 { excluded_modules_ = em.list(); }
294 virtual void updateAddPB();
296 virtual void updateUpPB();
298 virtual void updateDownPB();
300 virtual void updateDelPB();
301 /// returns availableModel as a GuiIdListModel
302 GuiIdListModel * getAvailableModel()
304 return dynamic_cast<GuiIdListModel *>(availableModel);
306 /// returns selectedModel as a GuiIdListModel
307 GuiIdListModel * getSelectedModel()
309 return dynamic_cast<GuiIdListModel *>(selectedModel);
311 /// keeps a list of the modules the text class provides
312 list<string> provided_modules_;
314 list<string> excluded_modules_;
316 GuiDocument const * container_;
319 void ModuleSelectionManager::updateAddPB()
321 int const arows = availableModel->rowCount();
322 QModelIndexList const avail_sels =
323 availableLV->selectionModel()->selectedIndexes();
325 // disable if there aren't any modules (?), if none of them is chosen
326 // in the dialog, or if the chosen one is already selected for use.
327 if (arows == 0 || avail_sels.isEmpty() || isSelected(avail_sels.first())) {
328 addPB->setEnabled(false);
332 QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
333 string const modname = getAvailableModel()->getIDString(idx.row());
336 container_->params().moduleCanBeAdded(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 succeding 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() : current_id_(0)
475 // This is not a memory leak. The object will be destroyed
477 (void) new LaTeXHighlighter(preambleTE->document());
478 setFocusProxy(preambleTE);
479 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
483 void PreambleModule::update(BufferParams const & params, BufferId id)
485 QString preamble = toqstr(params.preamble);
486 // Nothing to do if the params and preamble are unchanged.
487 if (id == current_id_
488 && preamble == preambleTE->document()->toPlainText())
491 QTextCursor cur = preambleTE->textCursor();
492 // Save the coords before switching to the new one.
493 preamble_coords_[current_id_] =
494 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
496 // Save the params address for further use.
498 preambleTE->document()->setPlainText(preamble);
499 Coords::const_iterator it = preamble_coords_.find(current_id_);
500 if (it == preamble_coords_.end())
501 // First time we open this one.
502 preamble_coords_[current_id_] = make_pair(0, 0);
504 // Restore saved coords.
505 QTextCursor cur = preambleTE->textCursor();
506 cur.setPosition(it->second.first);
507 preambleTE->setTextCursor(cur);
508 preambleTE->verticalScrollBar()->setValue(it->second.second);
513 void PreambleModule::apply(BufferParams & params)
515 params.preamble = fromqstr(preambleTE->document()->toPlainText());
519 void PreambleModule::closeEvent(QCloseEvent * e)
521 // Save the coords before closing.
522 QTextCursor cur = preambleTE->textCursor();
523 preamble_coords_[current_id_] =
524 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
529 /////////////////////////////////////////////////////////////////////
533 /////////////////////////////////////////////////////////////////////
536 LocalLayout::LocalLayout() : current_id_(0), is_valid_(false)
538 connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
539 connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
540 connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
544 void LocalLayout::update(BufferParams const & params, BufferId id)
546 QString layout = toqstr(params.local_layout);
547 // Nothing to do if the params and preamble are unchanged.
548 if (id == current_id_
549 && layout == locallayoutTE->document()->toPlainText())
552 // Save the params address for further use.
554 locallayoutTE->document()->setPlainText(layout);
559 void LocalLayout::apply(BufferParams & params)
561 string const layout = fromqstr(locallayoutTE->document()->toPlainText());
562 params.local_layout = layout;
566 void LocalLayout::textChanged()
568 static const QString unknown = qt_("Press button to check validity...");
571 validLB->setText(unknown);
572 validatePB->setEnabled(true);
573 convertPB->setEnabled(false);
578 void LocalLayout::convert() {
579 string const layout =
580 fromqstr(locallayoutTE->document()->toPlainText().trimmed());
581 string const newlayout = TextClass::convert(layout);
583 if (newlayout.empty()) {
584 Alert::error(_("Conversion Failed!"),
585 _("Failed to convert local layout to current format."));
587 locallayoutTE->setPlainText(toqstr(newlayout));
593 void LocalLayout::convertPressed() {
599 void LocalLayout::validate() {
600 static const QString valid = qt_("Layout is valid!");
601 static const QString vtext =
602 toqstr("<p style=\"font-weight: bold; \">")
603 + valid + toqstr("</p>");
604 static const QString invalid = qt_("Layout is invalid!");
605 static const QString ivtext =
606 toqstr("<p style=\"color: #c00000; font-weight: bold; \">")
607 + invalid + toqstr("</p>");
609 string const layout =
610 fromqstr(locallayoutTE->document()->toPlainText().trimmed());
611 if (layout.empty()) {
613 validatePB->setEnabled(false);
614 validLB->setText("");
618 TextClass::ReturnValues const ret = TextClass::validate(layout);
619 is_valid_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
620 validatePB->setEnabled(false);
621 validLB->setText(is_valid_ ? vtext : ivtext);
622 if (ret == TextClass::OK_OLDFORMAT) {
624 convertPB->setEnabled(true);
625 convertLB->setText(qt_("Convert to current format"));
635 void LocalLayout::validatePressed() {
641 /////////////////////////////////////////////////////////////////////
645 /////////////////////////////////////////////////////////////////////
648 GuiDocument::GuiDocument(GuiView & lv)
649 : GuiDialog(lv, "document", qt_("Document Settings"))
653 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
654 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
655 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
656 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
658 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
659 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
661 // Manage the restore, ok, apply, restore and cancel/close buttons
662 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
664 bc().setApply(applyPB);
665 bc().setCancel(closePB);
666 bc().setRestore(restorePB);
670 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
671 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
672 this, SLOT(change_adaptor()));
673 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
674 this, SLOT(setLSpacing(int)));
675 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString &)),
676 this, SLOT(change_adaptor()));
678 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
679 this, SLOT(change_adaptor()));
680 connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
681 textLayoutModule->indentCO, SLOT(setEnabled(bool)));
682 connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
683 this, SLOT(change_adaptor()));
684 connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
685 this, SLOT(setIndent(int)));
686 connect(textLayoutModule->indentLE, SIGNAL(textChanged(const QString &)),
687 this, SLOT(change_adaptor()));
688 connect(textLayoutModule->indentLengthCO, SIGNAL(activated(int)),
689 this, SLOT(change_adaptor()));
691 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
692 this, SLOT(change_adaptor()));
693 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
694 textLayoutModule->skipCO, SLOT(setEnabled(bool)));
695 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
696 this, SLOT(change_adaptor()));
697 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
698 this, SLOT(setSkip(int)));
699 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
700 this, SLOT(change_adaptor()));
701 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
702 this, SLOT(change_adaptor()));
704 connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
705 this, SLOT(enableIndent(bool)));
706 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
707 this, SLOT(enableSkip(bool)));
709 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
710 this, SLOT(change_adaptor()));
711 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
712 this, SLOT(setColSep()));
714 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
715 textLayoutModule->lspacingLE));
716 textLayoutModule->indentLE->setValidator(unsignedLengthValidator(
717 textLayoutModule->indentLE));
718 textLayoutModule->skipLE->setValidator(unsignedGlueLengthValidator(
719 textLayoutModule->skipLE));
721 textLayoutModule->indentCO->addItem(qt_("Default"));
722 textLayoutModule->indentCO->addItem(qt_("Custom"));
723 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
724 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
725 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
726 textLayoutModule->skipCO->addItem(qt_("Custom"));
727 textLayoutModule->lspacingCO->insertItem(
728 Spacing::Single, qt_("Single"));
729 textLayoutModule->lspacingCO->insertItem(
730 Spacing::Onehalf, qt_("OneHalf"));
731 textLayoutModule->lspacingCO->insertItem(
732 Spacing::Double, qt_("Double"));
733 textLayoutModule->lspacingCO->insertItem(
734 Spacing::Other, qt_("Custom"));
735 // initialize the length validator
736 bc().addCheckedLineEdit(textLayoutModule->indentLE);
737 bc().addCheckedLineEdit(textLayoutModule->skipLE);
740 // master/child handling
741 masterChildModule = new UiWidget<Ui::MasterChildUi>;
743 connect(masterChildModule->childrenTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
744 this, SLOT(includeonlyClicked(QTreeWidgetItem *, int)));
745 connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
746 masterChildModule->childrenTW, SLOT(setEnabled(bool)));
747 connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
748 masterChildModule->maintainAuxCB, SLOT(setEnabled(bool)));
749 connect(masterChildModule->includeallRB, SIGNAL(clicked()),
750 this, SLOT(change_adaptor()));
751 connect(masterChildModule->includeonlyRB, SIGNAL(clicked()),
752 this, SLOT(change_adaptor()));
753 connect(masterChildModule->maintainAuxCB, SIGNAL(clicked()),
754 this, SLOT(change_adaptor()));
755 masterChildModule->childrenTW->setColumnCount(2);
756 masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
757 masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output"));
758 masterChildModule->childrenTW->resizeColumnToContents(1);
759 masterChildModule->childrenTW->resizeColumnToContents(2);
763 outputModule = new UiWidget<Ui::OutputUi>;
765 connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
766 this, SLOT(change_adaptor()));
767 connect(outputModule->mathimgSB, SIGNAL(valueChanged(double)),
768 this, SLOT(change_adaptor()));
769 connect(outputModule->strictCB, SIGNAL(stateChanged(int)),
770 this, SLOT(change_adaptor()));
771 connect(outputModule->mathoutCB, SIGNAL(currentIndexChanged(int)),
772 this, SLOT(change_adaptor()));
774 connect(outputModule->outputsyncCB, SIGNAL(clicked()),
775 this, SLOT(change_adaptor()));
776 connect(outputModule->synccustomCB, SIGNAL(editTextChanged(QString)),
777 this, SLOT(change_adaptor()));
778 outputModule->synccustomCB->addItem("");
779 outputModule->synccustomCB->addItem("\\synctex=1");
780 outputModule->synccustomCB->addItem("\\synctex=-1");
781 outputModule->synccustomCB->addItem("\\usepackage[active]{srcltx}");
784 fontModule = new UiWidget<Ui::FontUi>;
785 connect(fontModule->osFontsCB, SIGNAL(clicked()),
786 this, SLOT(change_adaptor()));
787 connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
788 this, SLOT(osFontsChanged(bool)));
789 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
790 this, SLOT(change_adaptor()));
791 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
792 this, SLOT(romanChanged(int)));
793 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
794 this, SLOT(change_adaptor()));
795 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
796 this, SLOT(sansChanged(int)));
797 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
798 this, SLOT(change_adaptor()));
799 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
800 this, SLOT(ttChanged(int)));
801 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
802 this, SLOT(change_adaptor()));
803 connect(fontModule->fontencCO, SIGNAL(activated(int)),
804 this, SLOT(change_adaptor()));
805 connect(fontModule->fontencCO, SIGNAL(activated(int)),
806 this, SLOT(fontencChanged(int)));
807 connect(fontModule->fontencLE, SIGNAL(textChanged(const QString &)),
808 this, SLOT(change_adaptor()));
809 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
810 this, SLOT(change_adaptor()));
811 connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
812 this, SLOT(change_adaptor()));
813 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
814 this, SLOT(change_adaptor()));
815 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
816 this, SLOT(change_adaptor()));
817 connect(fontModule->fontScCB, SIGNAL(clicked()),
818 this, SLOT(change_adaptor()));
819 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
820 this, SLOT(change_adaptor()));
824 fontModule->fontsizeCO->addItem(qt_("Default"));
825 fontModule->fontsizeCO->addItem(qt_("10"));
826 fontModule->fontsizeCO->addItem(qt_("11"));
827 fontModule->fontsizeCO->addItem(qt_("12"));
829 fontModule->fontencCO->addItem(qt_("Default"));
830 fontModule->fontencCO->addItem(qt_("Custom"));
831 fontModule->fontencCO->addItem(qt_("None (no fontenc)"));
833 for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
834 fontModule->fontsDefaultCO->addItem(
835 qt_(GuiDocument::fontfamilies_gui[n]));
837 if (!LaTeXFeatures::isAvailable("fontspec"))
838 fontModule->osFontsCB->setToolTip(
839 qt_("Use OpenType and TrueType fonts directly (requires XeTeX or LuaTeX)\n"
840 "You need to install the package \"fontspec\" to use this feature"));
844 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
845 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
846 this, SLOT(papersizeChanged(int)));
847 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
848 this, SLOT(papersizeChanged(int)));
849 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
850 this, SLOT(change_adaptor()));
851 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
852 this, SLOT(change_adaptor()));
853 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
854 this, SLOT(change_adaptor()));
855 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
856 this, SLOT(change_adaptor()));
857 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
858 this, SLOT(change_adaptor()));
859 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
860 this, SLOT(change_adaptor()));
861 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
862 this, SLOT(change_adaptor()));
863 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
864 this, SLOT(change_adaptor()));
865 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
866 this, SLOT(change_adaptor()));
867 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
868 this, SLOT(change_adaptor()));
870 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
871 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
872 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
873 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
874 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
875 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
876 pageLayoutModule->paperheightL);
877 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
878 pageLayoutModule->paperwidthL);
880 QComboBox * cb = pageLayoutModule->papersizeCO;
881 cb->addItem(qt_("Default"));
882 cb->addItem(qt_("Custom"));
883 cb->addItem(qt_("US letter"));
884 cb->addItem(qt_("US legal"));
885 cb->addItem(qt_("US executive"));
886 cb->addItem(qt_("A0"));
887 cb->addItem(qt_("A1"));
888 cb->addItem(qt_("A2"));
889 cb->addItem(qt_("A3"));
890 cb->addItem(qt_("A4"));
891 cb->addItem(qt_("A5"));
892 cb->addItem(qt_("A6"));
893 cb->addItem(qt_("B0"));
894 cb->addItem(qt_("B1"));
895 cb->addItem(qt_("B2"));
896 cb->addItem(qt_("B3"));
897 cb->addItem(qt_("B4"));
898 cb->addItem(qt_("B5"));
899 cb->addItem(qt_("B6"));
900 cb->addItem(qt_("C0"));
901 cb->addItem(qt_("C1"));
902 cb->addItem(qt_("C2"));
903 cb->addItem(qt_("C3"));
904 cb->addItem(qt_("C4"));
905 cb->addItem(qt_("C5"));
906 cb->addItem(qt_("C6"));
907 cb->addItem(qt_("JIS B0"));
908 cb->addItem(qt_("JIS B1"));
909 cb->addItem(qt_("JIS B2"));
910 cb->addItem(qt_("JIS B3"));
911 cb->addItem(qt_("JIS B4"));
912 cb->addItem(qt_("JIS B5"));
913 cb->addItem(qt_("JIS B6"));
914 // remove the %-items from the unit choice
915 pageLayoutModule->paperwidthUnitCO->noPercents();
916 pageLayoutModule->paperheightUnitCO->noPercents();
917 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
918 pageLayoutModule->paperheightLE));
919 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
920 pageLayoutModule->paperwidthLE));
924 marginsModule = new UiWidget<Ui::MarginsUi>;
925 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
926 this, SLOT(setCustomMargins(bool)));
927 connect(marginsModule->marginCB, SIGNAL(clicked()),
928 this, SLOT(change_adaptor()));
929 connect(marginsModule->topLE, SIGNAL(textChanged(QString)),
930 this, SLOT(change_adaptor()));
931 connect(marginsModule->topUnit, SIGNAL(activated(int)),
932 this, SLOT(change_adaptor()));
933 connect(marginsModule->bottomLE, SIGNAL(textChanged(QString)),
934 this, SLOT(change_adaptor()));
935 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
936 this, SLOT(change_adaptor()));
937 connect(marginsModule->innerLE, SIGNAL(textChanged(QString)),
938 this, SLOT(change_adaptor()));
939 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
940 this, SLOT(change_adaptor()));
941 connect(marginsModule->outerLE, SIGNAL(textChanged(QString)),
942 this, SLOT(change_adaptor()));
943 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
944 this, SLOT(change_adaptor()));
945 connect(marginsModule->headheightLE, SIGNAL(textChanged(QString)),
946 this, SLOT(change_adaptor()));
947 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
948 this, SLOT(change_adaptor()));
949 connect(marginsModule->headsepLE, SIGNAL(textChanged(QString)),
950 this, SLOT(change_adaptor()));
951 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
952 this, SLOT(change_adaptor()));
953 connect(marginsModule->footskipLE, SIGNAL(textChanged(QString)),
954 this, SLOT(change_adaptor()));
955 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
956 this, SLOT(change_adaptor()));
957 connect(marginsModule->columnsepLE, SIGNAL(textChanged(QString)),
958 this, SLOT(change_adaptor()));
959 connect(marginsModule->columnsepUnit, SIGNAL(activated(int)),
960 this, SLOT(change_adaptor()));
961 marginsModule->topLE->setValidator(unsignedLengthValidator(
962 marginsModule->topLE));
963 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
964 marginsModule->bottomLE));
965 marginsModule->innerLE->setValidator(unsignedLengthValidator(
966 marginsModule->innerLE));
967 marginsModule->outerLE->setValidator(unsignedLengthValidator(
968 marginsModule->outerLE));
969 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
970 marginsModule->headsepLE));
971 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
972 marginsModule->headheightLE));
973 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
974 marginsModule->footskipLE));
975 marginsModule->columnsepLE->setValidator(unsignedLengthValidator(
976 marginsModule->columnsepLE));
978 bc().addCheckedLineEdit(marginsModule->topLE,
979 marginsModule->topL);
980 bc().addCheckedLineEdit(marginsModule->bottomLE,
981 marginsModule->bottomL);
982 bc().addCheckedLineEdit(marginsModule->innerLE,
983 marginsModule->innerL);
984 bc().addCheckedLineEdit(marginsModule->outerLE,
985 marginsModule->outerL);
986 bc().addCheckedLineEdit(marginsModule->headsepLE,
987 marginsModule->headsepL);
988 bc().addCheckedLineEdit(marginsModule->headheightLE,
989 marginsModule->headheightL);
990 bc().addCheckedLineEdit(marginsModule->footskipLE,
991 marginsModule->footskipL);
992 bc().addCheckedLineEdit(marginsModule->columnsepLE,
993 marginsModule->columnsepL);
997 langModule = new UiWidget<Ui::LanguageUi>;
998 connect(langModule->languageCO, SIGNAL(activated(int)),
999 this, SLOT(change_adaptor()));
1000 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
1001 this, SLOT(change_adaptor()));
1002 connect(langModule->otherencodingRB, SIGNAL(clicked()),
1003 this, SLOT(change_adaptor()));
1004 connect(langModule->encodingCO, SIGNAL(activated(int)),
1005 this, SLOT(change_adaptor()));
1006 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
1007 this, SLOT(change_adaptor()));
1008 connect(langModule->languagePackageCO, SIGNAL(activated(int)),
1009 this, SLOT(change_adaptor()));
1010 connect(langModule->languagePackageED, SIGNAL(textChanged(QString)),
1011 this, SLOT(change_adaptor()));
1012 connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
1013 this, SLOT(languagePackageChanged(int)));
1015 QAbstractItemModel * language_model = guiApp->languageModel();
1016 // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
1017 language_model->sort(0);
1018 langModule->languageCO->setModel(language_model);
1019 langModule->languageCO->setModelColumn(0);
1021 // Always put the default encoding in the first position.
1022 langModule->encodingCO->addItem(qt_("Language Default (no inputenc)"));
1023 QStringList encodinglist;
1024 Encodings::const_iterator it = encodings.begin();
1025 Encodings::const_iterator const end = encodings.end();
1026 for (; it != end; ++it)
1027 encodinglist.append(qt_(it->guiName()));
1028 encodinglist.sort();
1029 langModule->encodingCO->addItems(encodinglist);
1031 langModule->quoteStyleCO->addItem(qt_("``text''"));
1032 langModule->quoteStyleCO->addItem(qt_("''text''"));
1033 langModule->quoteStyleCO->addItem(qt_(",,text``"));
1034 langModule->quoteStyleCO->addItem(qt_(",,text''"));
1035 langModule->quoteStyleCO->addItem(qt_("<<text>>"));
1036 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
1038 langModule->languagePackageCO->addItem(
1039 qt_("Default"), toqstr("default"));
1040 langModule->languagePackageCO->addItem(
1041 qt_("Automatic"), toqstr("auto"));
1042 langModule->languagePackageCO->addItem(
1043 qt_("Always Babel"), toqstr("babel"));
1044 langModule->languagePackageCO->addItem(
1045 qt_("Custom"), toqstr("custom"));
1046 langModule->languagePackageCO->addItem(
1047 qt_("None[[language package]]"), toqstr("none"));
1051 colorModule = new UiWidget<Ui::ColorUi>;
1052 connect(colorModule->fontColorPB, SIGNAL(clicked()),
1053 this, SLOT(changeFontColor()));
1054 connect(colorModule->delFontColorTB, SIGNAL(clicked()),
1055 this, SLOT(deleteFontColor()));
1056 connect(colorModule->noteFontColorPB, SIGNAL(clicked()),
1057 this, SLOT(changeNoteFontColor()));
1058 connect(colorModule->delNoteFontColorTB, SIGNAL(clicked()),
1059 this, SLOT(deleteNoteFontColor()));
1060 connect(colorModule->backgroundPB, SIGNAL(clicked()),
1061 this, SLOT(changeBackgroundColor()));
1062 connect(colorModule->delBackgroundTB, SIGNAL(clicked()),
1063 this, SLOT(deleteBackgroundColor()));
1064 connect(colorModule->boxBackgroundPB, SIGNAL(clicked()),
1065 this, SLOT(changeBoxBackgroundColor()));
1066 connect(colorModule->delBoxBackgroundTB, SIGNAL(clicked()),
1067 this, SLOT(deleteBoxBackgroundColor()));
1071 numberingModule = new UiWidget<Ui::NumberingUi>;
1072 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
1073 this, SLOT(change_adaptor()));
1074 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
1075 this, SLOT(change_adaptor()));
1076 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
1077 this, SLOT(updateNumbering()));
1078 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
1079 this, SLOT(updateNumbering()));
1080 numberingModule->tocTW->setColumnCount(3);
1081 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
1082 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
1083 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
1084 numberingModule->tocTW->header()->setResizeMode(QHeaderView::ResizeToContents);
1088 biblioModule = new UiWidget<Ui::BiblioUi>;
1089 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
1090 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
1091 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
1092 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
1093 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
1094 this, SLOT(change_adaptor()));
1095 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
1096 this, SLOT(change_adaptor()));
1097 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
1098 this, SLOT(change_adaptor()));
1099 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
1100 this, SLOT(change_adaptor()));
1101 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
1102 this, SLOT(change_adaptor()));
1103 connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
1104 this, SLOT(bibtexChanged(int)));
1105 connect(biblioModule->bibtexOptionsED, SIGNAL(textChanged(QString)),
1106 this, SLOT(change_adaptor()));
1108 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
1109 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
1110 biblioModule->citeStyleCO->setCurrentIndex(0);
1112 // NOTE: we do not provide "custom" here for security reasons!
1113 biblioModule->bibtexCO->clear();
1114 biblioModule->bibtexCO->addItem(qt_("Default"), QString("default"));
1115 for (set<string>::const_iterator it = lyxrc.bibtex_alternatives.begin();
1116 it != lyxrc.bibtex_alternatives.end(); ++it) {
1117 QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
1118 biblioModule->bibtexCO->addItem(command, command);
1123 indicesModule = new GuiIndices;
1124 connect(indicesModule, SIGNAL(changed()),
1125 this, SLOT(change_adaptor()));
1129 mathsModule = new UiWidget<Ui::MathsUi>;
1130 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
1131 mathsModule->amsCB, SLOT(setDisabled(bool)));
1132 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
1133 mathsModule->esintCB, SLOT(setDisabled(bool)));
1134 connect(mathsModule->mhchemautoCB, SIGNAL(toggled(bool)),
1135 mathsModule->mhchemCB, SLOT(setDisabled(bool)));
1136 connect(mathsModule->mathdotsautoCB, SIGNAL(toggled(bool)),
1137 mathsModule->mathdotsCB, SLOT(setDisabled(bool)));
1138 connect(mathsModule->undertildeautoCB, SIGNAL(toggled(bool)),
1139 mathsModule->undertildeCB, SLOT(setDisabled(bool)));
1141 connect(mathsModule->amsCB, SIGNAL(clicked()),
1142 this, SLOT(change_adaptor()));
1143 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
1144 this, SLOT(change_adaptor()));
1145 connect(mathsModule->esintCB, SIGNAL(clicked()),
1146 this, SLOT(change_adaptor()));
1147 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
1148 this, SLOT(change_adaptor()));
1149 connect(mathsModule->mhchemCB, SIGNAL(clicked()),
1150 this, SLOT(change_adaptor()));
1151 connect(mathsModule->mhchemautoCB, SIGNAL(clicked()),
1152 this, SLOT(change_adaptor()));
1153 connect(mathsModule->mathdotsCB, SIGNAL(clicked()),
1154 this, SLOT(change_adaptor()));
1155 connect(mathsModule->mathdotsautoCB, SIGNAL(clicked()),
1156 this, SLOT(change_adaptor()));
1157 connect(mathsModule->undertildeCB, SIGNAL(clicked()),
1158 this, SLOT(change_adaptor()));
1159 connect(mathsModule->undertildeautoCB, SIGNAL(clicked()),
1160 this, SLOT(change_adaptor()));
1164 latexModule = new UiWidget<Ui::LaTeXUi>;
1165 connect(latexModule->optionsLE, SIGNAL(textChanged(QString)),
1166 this, SLOT(change_adaptor()));
1167 connect(latexModule->defaultOptionsCB, SIGNAL(clicked()),
1168 this, SLOT(change_adaptor()));
1169 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
1170 this, SLOT(change_adaptor()));
1171 connect(latexModule->classCO, SIGNAL(activated(int)),
1172 this, SLOT(classChanged()));
1173 connect(latexModule->classCO, SIGNAL(activated(int)),
1174 this, SLOT(change_adaptor()));
1175 connect(latexModule->layoutPB, SIGNAL(clicked()),
1176 this, SLOT(browseLayout()));
1177 connect(latexModule->layoutPB, SIGNAL(clicked()),
1178 this, SLOT(change_adaptor()));
1179 connect(latexModule->childDocGB, SIGNAL(clicked()),
1180 this, SLOT(change_adaptor()));
1181 connect(latexModule->childDocLE, SIGNAL(textChanged(QString)),
1182 this, SLOT(change_adaptor()));
1183 connect(latexModule->childDocPB, SIGNAL(clicked()),
1184 this, SLOT(browseMaster()));
1185 connect(latexModule->suppressDateCB, SIGNAL(clicked()),
1186 this, SLOT(change_adaptor()));
1187 connect(latexModule->refstyleCB, SIGNAL(clicked()),
1188 this, SLOT(change_adaptor()));
1190 // postscript drivers
1191 for (int n = 0; tex_graphics[n][0]; ++n) {
1192 QString enc = qt_(tex_graphics_gui[n]);
1193 latexModule->psdriverCO->addItem(enc);
1196 latexModule->classCO->setModel(&classes_model_);
1197 LayoutFileList const & bcl = LayoutFileList::get();
1198 vector<LayoutFileIndex> classList = bcl.classList();
1199 sort(classList.begin(), classList.end(), less_textclass_avail_desc());
1201 vector<LayoutFileIndex>::const_iterator cit = classList.begin();
1202 vector<LayoutFileIndex>::const_iterator cen = classList.end();
1203 for (int i = 0; cit != cen; ++cit, ++i) {
1204 LayoutFile const & tc = bcl[*cit];
1205 docstring item = (tc.isTeXClassAvailable()) ?
1206 from_utf8(tc.description()) :
1207 bformat(_("Unavailable: %1$s"), from_utf8(tc.description()));
1208 classes_model_.insertRow(i, toqstr(item), *cit);
1213 branchesModule = new GuiBranches;
1214 connect(branchesModule, SIGNAL(changed()),
1215 this, SLOT(change_adaptor()));
1216 connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)),
1217 this, SLOT(branchesRename(docstring const &, docstring const &)));
1218 updateUnknownBranches();
1222 preambleModule = new PreambleModule;
1223 connect(preambleModule, SIGNAL(changed()),
1224 this, SLOT(change_adaptor()));
1226 localLayout = new LocalLayout;
1227 connect(localLayout, SIGNAL(changed()),
1228 this, SLOT(change_adaptor()));
1232 bulletsModule = new BulletsModule;
1233 connect(bulletsModule, SIGNAL(changed()),
1234 this, SLOT(change_adaptor()));
1238 modulesModule = new UiWidget<Ui::ModulesUi>;
1239 modulesModule->availableLV->header()->setVisible(false);
1240 modulesModule->availableLV->header()->setResizeMode(QHeaderView::ResizeToContents);
1241 modulesModule->availableLV->header()->setStretchLastSection(false);
1243 new ModuleSelectionManager(modulesModule->availableLV,
1244 modulesModule->selectedLV,
1245 modulesModule->addPB, modulesModule->deletePB,
1246 modulesModule->upPB, modulesModule->downPB,
1247 availableModel(), selectedModel(), this);
1248 connect(selectionManager, SIGNAL(updateHook()),
1249 this, SLOT(updateModuleInfo()));
1250 connect(selectionManager, SIGNAL(updateHook()),
1251 this, SLOT(change_adaptor()));
1252 connect(selectionManager, SIGNAL(selectionChanged()),
1253 this, SLOT(modulesChanged()));
1257 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
1258 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
1259 this, SLOT(change_adaptor()));
1260 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(QString)),
1261 this, SLOT(change_adaptor()));
1262 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(QString)),
1263 this, SLOT(change_adaptor()));
1264 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(QString)),
1265 this, SLOT(change_adaptor()));
1266 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(QString)),
1267 this, SLOT(change_adaptor()));
1268 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
1269 this, SLOT(change_adaptor()));
1270 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
1271 this, SLOT(change_adaptor()));
1272 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
1273 this, SLOT(change_adaptor()));
1274 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
1275 this, SLOT(change_adaptor()));
1276 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
1277 this, SLOT(change_adaptor()));
1278 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
1279 this, SLOT(change_adaptor()));
1280 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
1281 this, SLOT(change_adaptor()));
1282 connect(pdfSupportModule->backrefCO, SIGNAL(activated(int)),
1283 this, SLOT(change_adaptor()));
1284 connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
1285 this, SLOT(change_adaptor()));
1286 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
1287 this, SLOT(change_adaptor()));
1288 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)),
1289 this, SLOT(change_adaptor()));
1291 for (int i = 0; backref_opts[i][0]; ++i)
1292 pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
1296 floatModule = new FloatPlacement;
1297 connect(floatModule, SIGNAL(changed()),
1298 this, SLOT(change_adaptor()));
1302 listingsModule = new UiWidget<Ui::ListingsSettingsUi>;
1303 connect(listingsModule->listingsED, SIGNAL(textChanged()),
1304 this, SLOT(change_adaptor()));
1305 connect(listingsModule->bypassCB, SIGNAL(clicked()),
1306 this, SLOT(change_adaptor()));
1307 connect(listingsModule->bypassCB, SIGNAL(clicked()),
1308 this, SLOT(setListingsMessage()));
1309 connect(listingsModule->listingsED, SIGNAL(textChanged()),
1310 this, SLOT(setListingsMessage()));
1311 listingsModule->listingsTB->setPlainText(
1312 qt_("Input listings parameters below. Enter ? for a list of parameters."));
1316 docPS->addPanel(latexModule, qt_("Document Class"));
1317 docPS->addPanel(masterChildModule, qt_("Child Documents"));
1318 docPS->addPanel(modulesModule, qt_("Modules"));
1319 docPS->addPanel(localLayout, qt_("Local Layout"));
1320 docPS->addPanel(fontModule, qt_("Fonts"));
1321 docPS->addPanel(textLayoutModule, qt_("Text Layout"));
1322 docPS->addPanel(pageLayoutModule, qt_("Page Layout"));
1323 docPS->addPanel(marginsModule, qt_("Page Margins"));
1324 docPS->addPanel(langModule, qt_("Language"));
1325 docPS->addPanel(colorModule, qt_("Colors"));
1326 docPS->addPanel(numberingModule, qt_("Numbering & TOC"));
1327 docPS->addPanel(biblioModule, qt_("Bibliography"));
1328 docPS->addPanel(indicesModule, qt_("Indexes"));
1329 docPS->addPanel(pdfSupportModule, qt_("PDF Properties"));
1330 docPS->addPanel(mathsModule, qt_("Math Options"));
1331 docPS->addPanel(floatModule, qt_("Float Placement"));
1332 docPS->addPanel(listingsModule, qt_("Listings"));
1333 docPS->addPanel(bulletsModule, qt_("Bullets"));
1334 docPS->addPanel(branchesModule, qt_("Branches"));
1335 docPS->addPanel(outputModule, qt_("Output"));
1336 docPS->addPanel(preambleModule, qt_("LaTeX Preamble"));
1337 docPS->setCurrentPanel(qt_("Document Class"));
1338 // FIXME: hack to work around resizing bug in Qt >= 4.2
1339 // bug verified with Qt 4.2.{0-3} (JSpitzm)
1340 #if QT_VERSION >= 0x040200
1341 docPS->updateGeometry();
1346 void GuiDocument::saveDefaultClicked()
1352 void GuiDocument::useDefaultsClicked()
1358 void GuiDocument::change_adaptor()
1364 void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
1369 string child = fromqstr(item->text(0));
1373 if (std::find(includeonlys_.begin(),
1374 includeonlys_.end(), child) != includeonlys_.end())
1375 includeonlys_.remove(child);
1377 includeonlys_.push_back(child);
1379 updateIncludeonlys();
1384 QString GuiDocument::validateListingsParameters()
1386 // use a cache here to avoid repeated validation
1387 // of the same parameters
1388 static string param_cache;
1389 static QString msg_cache;
1391 if (listingsModule->bypassCB->isChecked())
1394 string params = fromqstr(listingsModule->listingsED->toPlainText());
1395 if (params != param_cache) {
1396 param_cache = params;
1397 msg_cache = toqstr(InsetListingsParams(params).validate());
1403 void GuiDocument::setListingsMessage()
1405 static bool isOK = true;
1406 QString msg = validateListingsParameters();
1407 if (msg.isEmpty()) {
1411 // listingsTB->setTextColor("black");
1412 listingsModule->listingsTB->setPlainText(
1413 qt_("Input listings parameters below. "
1414 "Enter ? for a list of parameters."));
1417 // listingsTB->setTextColor("red");
1418 listingsModule->listingsTB->setPlainText(msg);
1423 void GuiDocument::setLSpacing(int item)
1425 textLayoutModule->lspacingLE->setEnabled(item == 3);
1429 void GuiDocument::setIndent(int item)
1431 bool const enable = (item == 1);
1432 textLayoutModule->indentLE->setEnabled(enable);
1433 textLayoutModule->indentLengthCO->setEnabled(enable);
1434 textLayoutModule->skipLE->setEnabled(false);
1435 textLayoutModule->skipLengthCO->setEnabled(false);
1440 void GuiDocument::enableIndent(bool indent)
1442 textLayoutModule->skipLE->setEnabled(!indent);
1443 textLayoutModule->skipLengthCO->setEnabled(!indent);
1445 setIndent(textLayoutModule->indentCO->currentIndex());
1449 void GuiDocument::setSkip(int item)
1451 bool const enable = (item == 3);
1452 textLayoutModule->skipLE->setEnabled(enable);
1453 textLayoutModule->skipLengthCO->setEnabled(enable);
1458 void GuiDocument::enableSkip(bool skip)
1460 textLayoutModule->indentLE->setEnabled(!skip);
1461 textLayoutModule->indentLengthCO->setEnabled(!skip);
1463 setSkip(textLayoutModule->skipCO->currentIndex());
1467 void GuiDocument::setMargins()
1469 bool const extern_geometry =
1470 documentClass().provides("geometry");
1471 marginsModule->marginCB->setEnabled(!extern_geometry);
1472 if (extern_geometry) {
1473 marginsModule->marginCB->setChecked(false);
1474 setCustomMargins(true);
1476 marginsModule->marginCB->setChecked(!bp_.use_geometry);
1477 setCustomMargins(!bp_.use_geometry);
1482 void GuiDocument::papersizeChanged(int paper_size)
1484 setCustomPapersize(paper_size == 1);
1488 void GuiDocument::setCustomPapersize(bool custom)
1490 pageLayoutModule->paperwidthL->setEnabled(custom);
1491 pageLayoutModule->paperwidthLE->setEnabled(custom);
1492 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
1493 pageLayoutModule->paperheightL->setEnabled(custom);
1494 pageLayoutModule->paperheightLE->setEnabled(custom);
1495 pageLayoutModule->paperheightLE->setFocus();
1496 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
1500 void GuiDocument::setColSep()
1502 setCustomMargins(marginsModule->marginCB->checkState() == Qt::Checked);
1506 void GuiDocument::setCustomMargins(bool custom)
1508 marginsModule->topL->setEnabled(!custom);
1509 marginsModule->topLE->setEnabled(!custom);
1510 marginsModule->topUnit->setEnabled(!custom);
1512 marginsModule->bottomL->setEnabled(!custom);
1513 marginsModule->bottomLE->setEnabled(!custom);
1514 marginsModule->bottomUnit->setEnabled(!custom);
1516 marginsModule->innerL->setEnabled(!custom);
1517 marginsModule->innerLE->setEnabled(!custom);
1518 marginsModule->innerUnit->setEnabled(!custom);
1520 marginsModule->outerL->setEnabled(!custom);
1521 marginsModule->outerLE->setEnabled(!custom);
1522 marginsModule->outerUnit->setEnabled(!custom);
1524 marginsModule->headheightL->setEnabled(!custom);
1525 marginsModule->headheightLE->setEnabled(!custom);
1526 marginsModule->headheightUnit->setEnabled(!custom);
1528 marginsModule->headsepL->setEnabled(!custom);
1529 marginsModule->headsepLE->setEnabled(!custom);
1530 marginsModule->headsepUnit->setEnabled(!custom);
1532 marginsModule->footskipL->setEnabled(!custom);
1533 marginsModule->footskipLE->setEnabled(!custom);
1534 marginsModule->footskipUnit->setEnabled(!custom);
1536 bool const enableColSep = !custom &&
1537 textLayoutModule->twoColumnCB->checkState() == Qt::Checked;
1538 marginsModule->columnsepL->setEnabled(enableColSep);
1539 marginsModule->columnsepLE->setEnabled(enableColSep);
1540 marginsModule->columnsepUnit->setEnabled(enableColSep);
1544 void GuiDocument::changeBackgroundColor()
1546 QColor const & newColor = QColorDialog::getColor(
1547 rgb2qcolor(set_backgroundcolor), asQWidget());
1548 if (!newColor.isValid())
1550 // set the button color and text
1551 colorModule->backgroundPB->setStyleSheet(
1552 colorButtonStyleSheet(newColor));
1553 colorModule->backgroundPB->setText(qt_("&Change..."));
1555 set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name()));
1556 is_backgroundcolor = true;
1561 void GuiDocument::deleteBackgroundColor()
1563 // set the button color back to default by setting an empty StyleSheet
1564 colorModule->backgroundPB->setStyleSheet(QLatin1String(""));
1565 // change button text
1566 colorModule->backgroundPB->setText(qt_("&Default..."));
1567 // save default color (white)
1568 set_backgroundcolor = rgbFromHexName("#ffffff");
1569 is_backgroundcolor = false;
1574 void GuiDocument::changeFontColor()
1576 QColor const & newColor = QColorDialog::getColor(
1577 rgb2qcolor(set_fontcolor), asQWidget());
1578 if (!newColor.isValid())
1580 // set the button color and text
1581 colorModule->fontColorPB->setStyleSheet(
1582 colorButtonStyleSheet(newColor));
1583 colorModule->fontColorPB->setText(qt_("&Change..."));
1585 set_fontcolor = rgbFromHexName(fromqstr(newColor.name()));
1586 is_fontcolor = true;
1591 void GuiDocument::deleteFontColor()
1593 // set the button color back to default by setting an empty StyleSheet
1594 colorModule->fontColorPB->setStyleSheet(QLatin1String(""));
1595 // change button text
1596 colorModule->fontColorPB->setText(qt_("&Default..."));
1597 // save default color (black)
1598 set_fontcolor = rgbFromHexName("#000000");
1599 is_fontcolor = false;
1604 void GuiDocument::changeNoteFontColor()
1606 QColor const & newColor = QColorDialog::getColor(
1607 rgb2qcolor(set_notefontcolor), asQWidget());
1608 if (!newColor.isValid())
1610 // set the button color
1611 colorModule->noteFontColorPB->setStyleSheet(
1612 colorButtonStyleSheet(newColor));
1614 set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
1619 void GuiDocument::deleteNoteFontColor()
1621 // set the button color back to pref
1622 theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
1623 colorModule->noteFontColorPB->setStyleSheet(
1624 colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
1629 void GuiDocument::changeBoxBackgroundColor()
1631 QColor const & newColor = QColorDialog::getColor(
1632 rgb2qcolor(set_boxbgcolor), asQWidget());
1633 if (!newColor.isValid())
1635 // set the button color
1636 colorModule->boxBackgroundPB->setStyleSheet(
1637 colorButtonStyleSheet(newColor));
1639 set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name()));
1644 void GuiDocument::deleteBoxBackgroundColor()
1646 // set the button color back to pref
1647 theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor);
1648 colorModule->boxBackgroundPB->setStyleSheet(
1649 colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor)));
1654 void GuiDocument::osFontsChanged(bool nontexfonts)
1656 bool const tex_fonts = !nontexfonts;
1658 updateDefaultFormat();
1659 langModule->encodingCO->setEnabled(tex_fonts &&
1660 !langModule->defaultencodingRB->isChecked());
1661 langModule->defaultencodingRB->setEnabled(tex_fonts);
1662 langModule->otherencodingRB->setEnabled(tex_fonts);
1664 fontModule->fontsDefaultCO->setEnabled(tex_fonts);
1665 fontModule->fontsDefaultLA->setEnabled(tex_fonts);
1666 fontModule->cjkFontLE->setEnabled(tex_fonts);
1667 fontModule->cjkFontLA->setEnabled(tex_fonts);
1670 font = tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1671 bool scaleable = providesScale(font);
1672 fontModule->scaleSansSB->setEnabled(scaleable);
1673 fontModule->scaleSansLA->setEnabled(scaleable);
1675 font = tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1676 scaleable = providesScale(font);
1677 fontModule->scaleTypewriterSB->setEnabled(scaleable);
1678 fontModule->scaleTypewriterLA->setEnabled(scaleable);
1680 font = tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1681 fontModule->fontScCB->setEnabled(providesSC(font));
1682 fontModule->fontOsfCB->setEnabled(providesOSF(font));
1684 fontModule->fontencLA->setEnabled(tex_fonts);
1685 fontModule->fontencCO->setEnabled(tex_fonts);
1687 fontModule->fontencLE->setEnabled(false);
1689 fontencChanged(fontModule->fontencCO->currentIndex());
1693 void GuiDocument::updateFontsize(string const & items, string const & sel)
1695 fontModule->fontsizeCO->clear();
1696 fontModule->fontsizeCO->addItem(qt_("Default"));
1698 for (int n = 0; !token(items,'|',n).empty(); ++n)
1699 fontModule->fontsizeCO->
1700 addItem(toqstr(token(items,'|',n)));
1702 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
1703 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
1704 fontModule->fontsizeCO->setCurrentIndex(n);
1711 void GuiDocument::updateFontlist()
1713 fontModule->fontsRomanCO->clear();
1714 fontModule->fontsSansCO->clear();
1715 fontModule->fontsTypewriterCO->clear();
1717 // With XeTeX, we have access to all system fonts, but not the LaTeX fonts
1718 if (fontModule->osFontsCB->isChecked()) {
1719 fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
1720 fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
1721 fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
1723 QFontDatabase fontdb;
1724 QStringList families(fontdb.families());
1725 for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
1726 fontModule->fontsRomanCO->addItem(*it, *it);
1727 fontModule->fontsSansCO->addItem(*it, *it);
1728 fontModule->fontsTypewriterCO->addItem(*it, *it);
1733 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
1734 QString font = qt_(tex_fonts_roman_gui[n]);
1735 if (!isFontAvailable(tex_fonts_roman[n]))
1736 font += qt_(" (not installed)");
1737 fontModule->fontsRomanCO->addItem(font, qt_(tex_fonts_roman[n]));
1739 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
1740 QString font = qt_(tex_fonts_sans_gui[n]);
1741 if (!isFontAvailable(tex_fonts_sans[n]))
1742 font += qt_(" (not installed)");
1743 fontModule->fontsSansCO->addItem(font, qt_(tex_fonts_sans[n]));
1745 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
1746 QString font = qt_(tex_fonts_monospaced_gui[n]);
1747 if (!isFontAvailable(tex_fonts_monospaced[n]))
1748 font += qt_(" (not installed)");
1749 fontModule->fontsTypewriterCO->addItem(font, qt_(tex_fonts_monospaced[n]));
1754 void GuiDocument::fontencChanged(int item)
1756 fontModule->fontencLE->setEnabled(item == 1);
1760 void GuiDocument::romanChanged(int item)
1762 if (fontModule->osFontsCB->isChecked())
1764 string const font = tex_fonts_roman[item];
1765 fontModule->fontScCB->setEnabled(providesSC(font));
1766 fontModule->fontOsfCB->setEnabled(providesOSF(font));
1770 void GuiDocument::sansChanged(int item)
1772 if (fontModule->osFontsCB->isChecked())
1774 string const font = tex_fonts_sans[item];
1775 bool scaleable = providesScale(font);
1776 fontModule->scaleSansSB->setEnabled(scaleable);
1777 fontModule->scaleSansLA->setEnabled(scaleable);
1781 void GuiDocument::ttChanged(int item)
1783 if (fontModule->osFontsCB->isChecked())
1785 string const font = tex_fonts_monospaced[item];
1786 bool scaleable = providesScale(font);
1787 fontModule->scaleTypewriterSB->setEnabled(scaleable);
1788 fontModule->scaleTypewriterLA->setEnabled(scaleable);
1792 void GuiDocument::updatePagestyle(string const & items, string const & sel)
1795 pageLayoutModule->pagestyleCO->clear();
1796 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
1798 for (int n = 0; !token(items, '|', n).empty(); ++n) {
1799 string style = token(items, '|', n);
1800 QString style_gui = qt_(style);
1801 pagestyles.push_back(pair<string, QString>(style, style_gui));
1802 pageLayoutModule->pagestyleCO->addItem(style_gui);
1805 if (sel == "default") {
1806 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
1812 for (size_t i = 0; i < pagestyles.size(); ++i)
1813 if (pagestyles[i].first == sel)
1814 nn = pageLayoutModule->pagestyleCO->findText(pagestyles[i].second);
1817 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
1821 void GuiDocument::browseLayout()
1823 QString const label1 = qt_("Layouts|#o#O");
1824 QString const dir1 = toqstr(lyxrc.document_path);
1825 QStringList const filter(qt_("LyX Layout (*.layout)"));
1826 QString file = browseRelToParent(QString(), bufferFilePath(),
1827 qt_("Local layout file"), filter, false,
1830 if (!file.endsWith(".layout"))
1833 FileName layoutFile = support::makeAbsPath(fromqstr(file),
1834 fromqstr(bufferFilePath()));
1836 int const ret = Alert::prompt(_("Local layout file"),
1837 _("The layout file you have selected is a local layout\n"
1838 "file, not one in the system or user directory. Your\n"
1839 "document may not work with this layout if you do not\n"
1840 "keep the layout file in the document directory."),
1841 1, 1, _("&Set Layout"), _("&Cancel"));
1845 // load the layout file
1846 LayoutFileList & bcl = LayoutFileList::get();
1847 string classname = layoutFile.onlyFileName();
1848 // this will update an existing layout if that layout has been loaded before.
1849 LayoutFileIndex name = bcl.addLocalLayout(
1850 classname.substr(0, classname.size() - 7),
1851 layoutFile.onlyPath().absFileName());
1854 Alert::error(_("Error"),
1855 _("Unable to read local layout file."));
1859 // do not trigger classChanged if there is no change.
1860 if (latexModule->classCO->currentText() == toqstr(name))
1864 int idx = latexModule->classCO->findText(toqstr(name));
1866 classes_model_.insertRow(0, toqstr(name), name);
1867 latexModule->classCO->setCurrentIndex(0);
1869 latexModule->classCO->setCurrentIndex(idx);
1875 void GuiDocument::browseMaster()
1877 QString const title = qt_("Select master document");
1878 QString const dir1 = toqstr(lyxrc.document_path);
1879 QString const old = latexModule->childDocLE->text();
1880 QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
1881 QStringList const filter(qt_("LyX Files (*.lyx)"));
1882 QString file = browseRelToSub(old, docpath, title, filter, false,
1883 qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
1885 if (!file.isEmpty())
1886 latexModule->childDocLE->setText(file);
1890 void GuiDocument::classChanged()
1892 int idx = latexModule->classCO->currentIndex();
1895 string const classname = classes_model_.getIDString(idx);
1897 // check whether the selected modules have changed.
1898 bool modules_changed = false;
1899 unsigned int const srows = selectedModel()->rowCount();
1900 if (srows != bp_.getModules().size())
1901 modules_changed = true;
1903 list<string>::const_iterator mit = bp_.getModules().begin();
1904 list<string>::const_iterator men = bp_.getModules().end();
1905 for (unsigned int i = 0; i < srows && mit != men; ++i, ++mit)
1906 if (selectedModel()->getIDString(i) != *mit) {
1907 modules_changed = true;
1912 if (modules_changed || lyxrc.auto_reset_options) {
1913 if (applyPB->isEnabled()) {
1914 int const ret = Alert::prompt(_("Unapplied changes"),
1915 _("Some changes in the dialog were not yet applied.\n"
1916 "If you do not apply now, they will be lost after this action."),
1917 1, 1, _("&Apply"), _("&Dismiss"));
1923 // We load the TextClass as soon as it is selected. This is
1924 // necessary so that other options in the dialog can be updated
1925 // according to the new class. Note, however, that, if you use
1926 // the scroll wheel when sitting on the combo box, we'll load a
1927 // lot of TextClass objects very quickly....
1928 if (!bp_.setBaseClass(classname)) {
1929 Alert::error(_("Error"), _("Unable to set document class."));
1932 if (lyxrc.auto_reset_options)
1933 bp_.useClassDefaults();
1935 // With the introduction of modules came a distinction between the base
1936 // class and the document class. The former corresponds to the main layout
1937 // file; the latter is that plus the modules (or the document-specific layout,
1938 // or whatever else there could be). Our parameters come from the document
1939 // class. So when we set the base class, we also need to recreate the document
1940 // class. Otherwise, we still have the old one.
1941 bp_.makeDocumentClass();
1946 void GuiDocument::languagePackageChanged(int i)
1948 langModule->languagePackageED->setEnabled(
1949 langModule->languagePackageCO->itemData(i).toString() == "custom");
1953 void GuiDocument::bibtexChanged(int n)
1955 biblioModule->bibtexOptionsED->setEnabled(
1956 biblioModule->bibtexCO->itemData(n).toString() != "default");
1963 // both of these should take a vector<docstring>
1965 // This is an insanely complicated attempt to make this sort of thing
1966 // work with RTL languages.
1967 docstring formatStrVec(vector<string> const & v, docstring const & s)
1969 //this mess formats the list as "v[0], v[1], ..., [s] v[n]"
1973 return translateIfPossible(from_utf8(v[0]));
1974 if (v.size() == 2) {
1975 docstring retval = _("%1$s and %2$s");
1976 retval = subst(retval, _("and"), s);
1977 return bformat(retval, translateIfPossible(from_utf8(v[0])),
1978 translateIfPossible(from_utf8(v[1])));
1980 // The idea here is to format all but the last two items...
1981 int const vSize = v.size();
1982 docstring t2 = _("%1$s, %2$s");
1983 docstring retval = translateIfPossible(from_utf8(v[0]));
1984 for (int i = 1; i < vSize - 2; ++i)
1985 retval = bformat(t2, retval, translateIfPossible(from_utf8(v[i])));
1986 //...and then to plug them, and the last two, into this schema
1987 docstring t = _("%1$s, %2$s, and %3$s");
1988 t = subst(t, _("and"), s);
1989 return bformat(t, retval, translateIfPossible(from_utf8(v[vSize - 2])),
1990 translateIfPossible(from_utf8(v[vSize - 1])));
1993 vector<string> idsToNames(vector<string> const & idList)
1995 vector<string> retval;
1996 vector<string>::const_iterator it = idList.begin();
1997 vector<string>::const_iterator end = idList.end();
1998 for (; it != end; ++it) {
1999 LyXModule const * const mod = theModuleList[*it];
2001 retval.push_back(to_utf8(bformat(_("%1$s (unavailable)"),
2002 translateIfPossible(from_utf8(*it)))));
2004 retval.push_back(mod->getName());
2008 } // end anonymous namespace
2011 void GuiDocument::modulesToParams(BufferParams & bp)
2013 // update list of loaded modules
2014 bp.clearLayoutModules();
2015 int const srows = modules_sel_model_.rowCount();
2016 for (int i = 0; i < srows; ++i)
2017 bp.addLayoutModule(modules_sel_model_.getIDString(i));
2019 // update the list of removed modules
2020 bp.clearRemovedModules();
2021 LayoutModuleList const & reqmods = bp.baseClass()->defaultModules();
2022 list<string>::const_iterator rit = reqmods.begin();
2023 list<string>::const_iterator ren = reqmods.end();
2025 // check each of the default modules
2026 for (; rit != ren; rit++) {
2027 list<string>::const_iterator mit = bp.getModules().begin();
2028 list<string>::const_iterator men = bp.getModules().end();
2030 for (; mit != men; mit++) {
2037 // the module isn't present so must have been removed by the user
2038 bp.addRemovedModule(*rit);
2043 void GuiDocument::modulesChanged()
2045 modulesToParams(bp_);
2046 bp_.makeDocumentClass();
2051 void GuiDocument::updateModuleInfo()
2053 selectionManager->update();
2055 //Module description
2056 bool const focus_on_selected = selectionManager->selectedFocused();
2057 QAbstractItemView * lv;
2058 if (focus_on_selected)
2059 lv = modulesModule->selectedLV;
2061 lv= modulesModule->availableLV;
2062 if (lv->selectionModel()->selectedIndexes().isEmpty()) {
2063 modulesModule->infoML->document()->clear();
2066 QModelIndex const & idx = lv->selectionModel()->currentIndex();
2067 GuiIdListModel const & id_model =
2068 focus_on_selected ? modules_sel_model_ : modules_av_model_;
2069 string const modName = id_model.getIDString(idx.row());
2070 docstring desc = getModuleDescription(modName);
2072 LayoutModuleList const & provmods = bp_.baseClass()->providedModules();
2073 if (std::find(provmods.begin(), provmods.end(), modName) != provmods.end()) {
2076 desc += _("Module provided by document class.");
2079 vector<string> pkglist = getPackageList(modName);
2080 docstring pkgdesc = formatStrVec(pkglist, _("and"));
2081 if (!pkgdesc.empty()) {
2084 desc += bformat(_("Package(s) required: %1$s."), pkgdesc);
2087 pkglist = getRequiredList(modName);
2088 if (!pkglist.empty()) {
2089 vector<string> const reqdescs = idsToNames(pkglist);
2090 pkgdesc = formatStrVec(reqdescs, _("or"));
2093 desc += bformat(_("Modules required: %1$s."), pkgdesc);
2096 pkglist = getExcludedList(modName);
2097 if (!pkglist.empty()) {
2098 vector<string> const reqdescs = idsToNames(pkglist);
2099 pkgdesc = formatStrVec(reqdescs, _( "and"));
2102 desc += bformat(_("Modules excluded: %1$s."), pkgdesc);
2105 if (!isModuleAvailable(modName)) {
2108 desc += _("WARNING: Some required packages are unavailable!");
2111 modulesModule->infoML->document()->setPlainText(toqstr(desc));
2115 void GuiDocument::updateNumbering()
2117 DocumentClass const & tclass = documentClass();
2119 numberingModule->tocTW->setUpdatesEnabled(false);
2120 numberingModule->tocTW->clear();
2122 int const depth = numberingModule->depthSL->value();
2123 int const toc = numberingModule->tocSL->value();
2124 QString const no = qt_("No");
2125 QString const yes = qt_("Yes");
2126 QTreeWidgetItem * item = 0;
2128 DocumentClass::const_iterator lit = tclass.begin();
2129 DocumentClass::const_iterator len = tclass.end();
2130 for (; lit != len; ++lit) {
2131 int const toclevel = lit->toclevel;
2132 if (toclevel != Layout::NOT_IN_TOC && lit->labeltype == LABEL_COUNTER) {
2133 item = new QTreeWidgetItem(numberingModule->tocTW);
2134 item->setText(0, toqstr(translateIfPossible(lit->name())));
2135 item->setText(1, (toclevel <= depth) ? yes : no);
2136 item->setText(2, (toclevel <= toc) ? yes : no);
2140 numberingModule->tocTW->setUpdatesEnabled(true);
2141 numberingModule->tocTW->update();
2145 void GuiDocument::updateDefaultFormat()
2149 // make a copy in order to consider unapplied changes
2150 BufferParams param_copy = buffer().params();
2151 param_copy.useNonTeXFonts = fontModule->osFontsCB->isChecked();
2152 int const idx = latexModule->classCO->currentIndex();
2154 string const classname = classes_model_.getIDString(idx);
2155 param_copy.setBaseClass(classname);
2156 param_copy.makeDocumentClass();
2158 outputModule->defaultFormatCO->blockSignals(true);
2159 outputModule->defaultFormatCO->clear();
2160 outputModule->defaultFormatCO->addItem(qt_("Default"),
2161 QVariant(QString("default")));
2162 typedef vector<Format const *> Formats;
2163 Formats formats = param_copy.exportableFormats(true);
2164 Formats::const_iterator cit = formats.begin();
2165 Formats::const_iterator end = formats.end();
2166 for (; cit != end; ++cit)
2167 outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
2168 QVariant(toqstr((*cit)->name())));
2169 outputModule->defaultFormatCO->blockSignals(false);
2173 bool GuiDocument::isChildIncluded(string const & child)
2175 if (includeonlys_.empty())
2177 return (std::find(includeonlys_.begin(),
2178 includeonlys_.end(), child) != includeonlys_.end());
2182 void GuiDocument::applyView()
2185 preambleModule->apply(bp_);
2186 localLayout->apply(bp_);
2189 bp_.suppress_date = latexModule->suppressDateCB->isChecked();
2190 bp_.use_refstyle = latexModule->refstyleCB->isChecked();
2193 bp_.setCiteEngine(ENGINE_BASIC);
2195 if (biblioModule->citeNatbibRB->isChecked()) {
2196 bool const use_numerical_citations =
2197 biblioModule->citeStyleCO->currentIndex();
2198 if (use_numerical_citations)
2199 bp_.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
2201 bp_.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
2203 } else if (biblioModule->citeJurabibRB->isChecked())
2204 bp_.setCiteEngine(ENGINE_JURABIB);
2207 biblioModule->bibtopicCB->isChecked();
2209 string const bibtex_command =
2210 fromqstr(biblioModule->bibtexCO->itemData(
2211 biblioModule->bibtexCO->currentIndex()).toString());
2212 string const bibtex_options =
2213 fromqstr(biblioModule->bibtexOptionsED->text());
2214 if (bibtex_command == "default" || bibtex_options.empty())
2215 bp_.bibtex_command = bibtex_command;
2217 bp_.bibtex_command = bibtex_command + " " + bibtex_options;
2220 indicesModule->apply(bp_);
2222 // language & quotes
2223 if (langModule->defaultencodingRB->isChecked()) {
2224 bp_.inputenc = "auto";
2226 int i = langModule->encodingCO->currentIndex();
2228 bp_.inputenc = "default";
2230 QString const enc_gui =
2231 langModule->encodingCO->currentText();
2232 Encodings::const_iterator it = encodings.begin();
2233 Encodings::const_iterator const end = encodings.end();
2235 for (; it != end; ++it) {
2236 if (qt_(it->guiName()) == enc_gui) {
2237 bp_.inputenc = it->latexName();
2243 // should not happen
2244 lyxerr << "GuiDocument::apply: Unknown encoding! Resetting to default" << endl;
2245 bp_.inputenc = "default";
2250 InsetQuotes::QuoteLanguage lga = InsetQuotes::EnglishQuotes;
2251 switch (langModule->quoteStyleCO->currentIndex()) {
2253 lga = InsetQuotes::EnglishQuotes;
2256 lga = InsetQuotes::SwedishQuotes;
2259 lga = InsetQuotes::GermanQuotes;
2262 lga = InsetQuotes::PolishQuotes;
2265 lga = InsetQuotes::FrenchQuotes;
2268 lga = InsetQuotes::DanishQuotes;
2271 bp_.quotes_language = lga;
2273 QString const lang = langModule->languageCO->itemData(
2274 langModule->languageCO->currentIndex()).toString();
2275 bp_.language = lyx::languages.getLanguage(fromqstr(lang));
2277 QString const pack = langModule->languagePackageCO->itemData(
2278 langModule->languagePackageCO->currentIndex()).toString();
2279 if (pack == "custom")
2281 fromqstr(langModule->languagePackageED->text());
2283 bp_.lang_package = fromqstr(pack);
2286 bp_.backgroundcolor = set_backgroundcolor;
2287 bp_.isbackgroundcolor = is_backgroundcolor;
2288 bp_.fontcolor = set_fontcolor;
2289 bp_.isfontcolor = is_fontcolor;
2290 bp_.notefontcolor = set_notefontcolor;
2291 bp_.boxbgcolor = set_boxbgcolor;
2294 if (bp_.documentClass().hasTocLevels()) {
2295 bp_.tocdepth = numberingModule->tocSL->value();
2296 bp_.secnumdepth = numberingModule->depthSL->value();
2300 bp_.user_defined_bullet(0) = bulletsModule->bullet(0);
2301 bp_.user_defined_bullet(1) = bulletsModule->bullet(1);
2302 bp_.user_defined_bullet(2) = bulletsModule->bullet(2);
2303 bp_.user_defined_bullet(3) = bulletsModule->bullet(3);
2306 bp_.graphics_driver =
2307 tex_graphics[latexModule->psdriverCO->currentIndex()];
2310 int idx = latexModule->classCO->currentIndex();
2312 string const classname = classes_model_.getIDString(idx);
2313 bp_.setBaseClass(classname);
2317 modulesToParams(bp_);
2320 if (mathsModule->amsautoCB->isChecked())
2321 bp_.use_amsmath = BufferParams::package_auto;
2323 if (mathsModule->amsCB->isChecked())
2324 bp_.use_amsmath = BufferParams::package_on;
2326 bp_.use_amsmath = BufferParams::package_off;
2328 if (mathsModule->esintautoCB->isChecked())
2329 bp_.use_esint = BufferParams::package_auto;
2331 if (mathsModule->esintCB->isChecked())
2332 bp_.use_esint = BufferParams::package_on;
2334 bp_.use_esint = BufferParams::package_off;
2336 if (mathsModule->mhchemautoCB->isChecked())
2337 bp_.use_mhchem = BufferParams::package_auto;
2339 if (mathsModule->mhchemCB->isChecked())
2340 bp_.use_mhchem = BufferParams::package_on;
2342 bp_.use_mhchem = BufferParams::package_off;
2344 if (mathsModule->mathdotsautoCB->isChecked())
2345 bp_.use_mathdots = BufferParams::package_auto;
2347 if (mathsModule->mathdotsCB->isChecked())
2348 bp_.use_mathdots = BufferParams::package_on;
2350 bp_.use_mathdots = BufferParams::package_off;
2352 if (mathsModule->undertildeautoCB->isChecked())
2353 bp_.use_undertilde = BufferParams::package_auto;
2355 if (mathsModule->undertildeCB->isChecked())
2356 bp_.use_undertilde = BufferParams::package_on;
2358 bp_.use_undertilde = BufferParams::package_off;
2362 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
2363 bp_.pagestyle = "default";
2365 QString style_gui = pageLayoutModule->pagestyleCO->currentText();
2366 for (size_t i = 0; i != pagestyles.size(); ++i)
2367 if (pagestyles[i].second == style_gui)
2368 bp_.pagestyle = pagestyles[i].first;
2372 switch (textLayoutModule->lspacingCO->currentIndex()) {
2374 bp_.spacing().set(Spacing::Single);
2377 bp_.spacing().set(Spacing::Onehalf);
2380 bp_.spacing().set(Spacing::Double);
2383 string s = widgetToDoubleStr(textLayoutModule->lspacingLE);
2385 bp_.spacing().set(Spacing::Single);
2387 bp_.spacing().set(Spacing::Other, s);
2392 if (textLayoutModule->twoColumnCB->isChecked())
2397 if (textLayoutModule->indentRB->isChecked()) {
2398 // if paragraphs are separated by an indentation
2399 bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation;
2400 switch (textLayoutModule->indentCO->currentIndex()) {
2402 bp_.setIndentation(HSpace(HSpace::DEFAULT));
2405 HSpace indent = HSpace(
2406 widgetsToLength(textLayoutModule->indentLE,
2407 textLayoutModule->indentLengthCO)
2409 bp_.setIndentation(indent);
2413 // this should never happen
2414 bp_.setIndentation(HSpace(HSpace::DEFAULT));
2418 // if paragraphs are separated by a skip
2419 bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation;
2420 switch (textLayoutModule->skipCO->currentIndex()) {
2422 bp_.setDefSkip(VSpace(VSpace::SMALLSKIP));
2425 bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
2428 bp_.setDefSkip(VSpace(VSpace::BIGSKIP));
2433 widgetsToLength(textLayoutModule->skipLE,
2434 textLayoutModule->skipLengthCO)
2440 // this should never happen
2441 bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
2447 fromqstr(latexModule->optionsLE->text());
2449 bp_.use_default_options =
2450 latexModule->defaultOptionsCB->isChecked();
2452 if (latexModule->childDocGB->isChecked())
2454 fromqstr(latexModule->childDocLE->text());
2456 bp_.master = string();
2459 bp_.clearIncludedChildren();
2460 if (masterChildModule->includeonlyRB->isChecked()) {
2461 list<string>::const_iterator it = includeonlys_.begin();
2462 for (; it != includeonlys_.end() ; ++it) {
2463 bp_.addIncludedChildren(*it);
2466 bp_.maintain_unincluded_children =
2467 masterChildModule->maintainAuxCB->isChecked();
2470 bp_.float_placement = floatModule->get();
2473 // text should have passed validation
2474 bp_.listings_params =
2475 InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
2478 bp_.default_output_format = fromqstr(outputModule->defaultFormatCO->itemData(
2479 outputModule->defaultFormatCO->currentIndex()).toString());
2481 bool const nontexfonts = fontModule->osFontsCB->isChecked();
2482 bp_.useNonTeXFonts = nontexfonts;
2484 bp_.output_sync = outputModule->outputsyncCB->isChecked();
2485 bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText());
2487 int mathfmt = outputModule->mathoutCB->currentIndex();
2490 BufferParams::MathOutput const mo =
2491 static_cast<BufferParams::MathOutput>(mathfmt);
2492 bp_.html_math_output = mo;
2493 bp_.html_be_strict = outputModule->strictCB->isChecked();
2494 bp_.html_math_img_scale = outputModule->mathimgSB->value();
2498 fromqstr(fontModule->fontsRomanCO->
2499 itemData(fontModule->fontsRomanCO->currentIndex()).toString());
2502 fromqstr(fontModule->fontsSansCO->
2503 itemData(fontModule->fontsSansCO->currentIndex()).toString());
2505 bp_.fonts_typewriter =
2506 fromqstr(fontModule->fontsTypewriterCO->
2507 itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
2509 if (fontModule->fontencCO->currentIndex() == 0)
2510 bp_.fontenc = "global";
2511 else if (fontModule->fontencCO->currentIndex() == 1)
2512 bp_.fontenc = fromqstr(fontModule->fontencLE->text());
2513 else if (fontModule->fontencCO->currentIndex() == 2)
2514 bp_.fontenc = "default";
2517 fromqstr(fontModule->cjkFontLE->text());
2519 bp_.fonts_sans_scale = fontModule->scaleSansSB->value();
2521 bp_.fonts_typewriter_scale = fontModule->scaleTypewriterSB->value();
2523 bp_.fonts_expert_sc = fontModule->fontScCB->isChecked();
2525 bp_.fonts_old_figures = fontModule->fontOsfCB->isChecked();
2528 bp_.fonts_default_family = "default";
2530 bp_.fonts_default_family = GuiDocument::fontfamilies[
2531 fontModule->fontsDefaultCO->currentIndex()];
2533 if (fontModule->fontsizeCO->currentIndex() == 0)
2534 bp_.fontsize = "default";
2537 fromqstr(fontModule->fontsizeCO->currentText());
2540 bp_.papersize = PAPER_SIZE(
2541 pageLayoutModule->papersizeCO->currentIndex());
2543 bp_.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
2544 pageLayoutModule->paperwidthUnitCO);
2546 bp_.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
2547 pageLayoutModule->paperheightUnitCO);
2549 if (pageLayoutModule->facingPagesCB->isChecked())
2550 bp_.sides = TwoSides;
2552 bp_.sides = OneSide;
2554 if (pageLayoutModule->landscapeRB->isChecked())
2555 bp_.orientation = ORIENTATION_LANDSCAPE;
2557 bp_.orientation = ORIENTATION_PORTRAIT;
2560 bp_.use_geometry = !marginsModule->marginCB->isChecked();
2562 Ui::MarginsUi const * m = marginsModule;
2564 bp_.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
2565 bp_.topmargin = widgetsToLength(m->topLE, m->topUnit);
2566 bp_.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
2567 bp_.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
2568 bp_.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
2569 bp_.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
2570 bp_.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
2571 bp_.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit);
2574 branchesModule->apply(bp_);
2577 PDFOptions & pdf = bp_.pdfoptions();
2578 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
2579 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
2580 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
2581 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
2582 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
2584 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
2585 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
2586 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
2587 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
2589 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
2590 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
2591 pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
2592 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
2594 backref_opts[pdfSupportModule->backrefCO->currentIndex()];
2595 if (pdfSupportModule->fullscreenCB->isChecked())
2596 pdf.pagemode = pdf.pagemode_fullscreen;
2598 pdf.pagemode.clear();
2599 pdf.quoted_options = pdf.quoted_options_check(
2600 fromqstr(pdfSupportModule->optionsLE->text()));
2604 void GuiDocument::paramsToDialog()
2606 // set the default unit
2607 Length::UNIT const defaultUnit = Length::defaultUnit();
2610 preambleModule->update(bp_, id());
2611 localLayout->update(bp_, id());
2614 latexModule->suppressDateCB->setChecked(bp_.suppress_date);
2615 latexModule->refstyleCB->setChecked(bp_.use_refstyle);
2618 biblioModule->citeDefaultRB->setChecked(
2619 bp_.citeEngine() == ENGINE_BASIC);
2621 biblioModule->citeNatbibRB->setChecked(
2622 bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
2623 bp_.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
2625 biblioModule->citeStyleCO->setCurrentIndex(
2626 bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL);
2628 biblioModule->citeJurabibRB->setChecked(
2629 bp_.citeEngine() == ENGINE_JURABIB);
2631 biblioModule->bibtopicCB->setChecked(
2636 split(bp_.bibtex_command, command, ' ');
2638 int const bpos = biblioModule->bibtexCO->findData(toqstr(command));
2640 biblioModule->bibtexCO->setCurrentIndex(bpos);
2641 biblioModule->bibtexOptionsED->setText(toqstr(options).trimmed());
2643 // We reset to default if we do not know the specified compiler
2644 // This is for security reasons
2645 biblioModule->bibtexCO->setCurrentIndex(
2646 biblioModule->bibtexCO->findData(toqstr("default")));
2647 biblioModule->bibtexOptionsED->clear();
2649 biblioModule->bibtexOptionsED->setEnabled(
2650 biblioModule->bibtexCO->currentIndex() != 0);
2653 indicesModule->update(bp_);
2655 // language & quotes
2656 int const pos = langModule->languageCO->findData(toqstr(
2657 bp_.language->lang()));
2658 langModule->languageCO->setCurrentIndex(pos);
2660 langModule->quoteStyleCO->setCurrentIndex(
2661 bp_.quotes_language);
2663 bool default_enc = true;
2664 if (bp_.inputenc != "auto") {
2665 default_enc = false;
2666 if (bp_.inputenc == "default") {
2667 langModule->encodingCO->setCurrentIndex(0);
2670 Encodings::const_iterator it = encodings.begin();
2671 Encodings::const_iterator const end = encodings.end();
2672 for (; it != end; ++it) {
2673 if (it->latexName() == bp_.inputenc) {
2674 enc_gui = it->guiName();
2678 int const i = langModule->encodingCO->findText(
2681 langModule->encodingCO->setCurrentIndex(i);
2683 // unknown encoding. Set to default.
2687 langModule->defaultencodingRB->setChecked(default_enc);
2688 langModule->otherencodingRB->setChecked(!default_enc);
2690 int const p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
2692 langModule->languagePackageCO->setCurrentIndex(
2693 langModule->languagePackageCO->findData("custom"));
2694 langModule->languagePackageED->setText(toqstr(bp_.lang_package));
2696 langModule->languagePackageCO->setCurrentIndex(p);
2697 langModule->languagePackageED->clear();
2701 if (bp_.isfontcolor) {
2702 colorModule->fontColorPB->setStyleSheet(
2703 colorButtonStyleSheet(rgb2qcolor(bp_.fontcolor)));
2705 set_fontcolor = bp_.fontcolor;
2706 is_fontcolor = bp_.isfontcolor;
2708 colorModule->noteFontColorPB->setStyleSheet(
2709 colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
2710 set_notefontcolor = bp_.notefontcolor;
2712 if (bp_.isbackgroundcolor) {
2713 colorModule->backgroundPB->setStyleSheet(
2714 colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
2716 set_backgroundcolor = bp_.backgroundcolor;
2717 is_backgroundcolor = bp_.isbackgroundcolor;
2719 colorModule->boxBackgroundPB->setStyleSheet(
2720 colorButtonStyleSheet(rgb2qcolor(bp_.boxbgcolor)));
2721 set_boxbgcolor = bp_.boxbgcolor;
2724 int const min_toclevel = documentClass().min_toclevel();
2725 int const max_toclevel = documentClass().max_toclevel();
2726 if (documentClass().hasTocLevels()) {
2727 numberingModule->setEnabled(true);
2728 numberingModule->depthSL->setMinimum(min_toclevel - 1);
2729 numberingModule->depthSL->setMaximum(max_toclevel);
2730 numberingModule->depthSL->setValue(bp_.secnumdepth);
2731 numberingModule->tocSL->setMaximum(min_toclevel - 1);
2732 numberingModule->tocSL->setMaximum(max_toclevel);
2733 numberingModule->tocSL->setValue(bp_.tocdepth);
2736 numberingModule->setEnabled(false);
2737 numberingModule->tocTW->clear();
2741 bulletsModule->setBullet(0, bp_.user_defined_bullet(0));
2742 bulletsModule->setBullet(1, bp_.user_defined_bullet(1));
2743 bulletsModule->setBullet(2, bp_.user_defined_bullet(2));
2744 bulletsModule->setBullet(3, bp_.user_defined_bullet(3));
2745 bulletsModule->init();
2748 int nitem = findToken(tex_graphics, bp_.graphics_driver);
2750 latexModule->psdriverCO->setCurrentIndex(nitem);
2753 mathsModule->amsCB->setChecked(
2754 bp_.use_amsmath == BufferParams::package_on);
2755 mathsModule->amsautoCB->setChecked(
2756 bp_.use_amsmath == BufferParams::package_auto);
2758 mathsModule->esintCB->setChecked(
2759 bp_.use_esint == BufferParams::package_on);
2760 mathsModule->esintautoCB->setChecked(
2761 bp_.use_esint == BufferParams::package_auto);
2763 mathsModule->mhchemCB->setChecked(
2764 bp_.use_mhchem == BufferParams::package_on);
2765 mathsModule->mhchemautoCB->setChecked(
2766 bp_.use_mhchem == BufferParams::package_auto);
2768 mathsModule->mathdotsCB->setChecked(
2769 bp_.use_mathdots == BufferParams::package_on);
2770 mathsModule->mathdotsautoCB->setChecked(
2771 bp_.use_mathdots == BufferParams::package_auto);
2773 mathsModule->undertildeCB->setChecked(
2774 bp_.use_undertilde == BufferParams::package_on);
2775 mathsModule->undertildeautoCB->setChecked(
2776 bp_.use_undertilde == BufferParams::package_auto);
2778 switch (bp_.spacing().getSpace()) {
2779 case Spacing::Other: nitem = 3; break;
2780 case Spacing::Double: nitem = 2; break;
2781 case Spacing::Onehalf: nitem = 1; break;
2782 case Spacing::Default: case Spacing::Single: nitem = 0; break;
2786 string const & layoutID = bp_.baseClassID();
2787 setLayoutComboByIDString(layoutID);
2789 updatePagestyle(documentClass().opt_pagestyle(),
2792 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
2793 if (bp_.spacing().getSpace() == Spacing::Other) {
2794 doubleToWidget(textLayoutModule->lspacingLE,
2795 bp_.spacing().getValueAsString());
2799 if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
2800 textLayoutModule->indentRB->setChecked(true);
2801 string indentation = bp_.getIndentation().asLyXCommand();
2803 if (indentation != "default") {
2804 lengthToWidgets(textLayoutModule->indentLE,
2805 textLayoutModule->indentLengthCO,
2806 indentation, defaultUnit);
2809 textLayoutModule->indentCO->setCurrentIndex(indent);
2812 textLayoutModule->skipRB->setChecked(true);
2814 switch (bp_.getDefSkip().kind()) {
2815 case VSpace::SMALLSKIP:
2818 case VSpace::MEDSKIP:
2821 case VSpace::BIGSKIP:
2824 case VSpace::LENGTH:
2827 string const length = bp_.getDefSkip().asLyXCommand();
2828 lengthToWidgets(textLayoutModule->skipLE,
2829 textLayoutModule->skipLengthCO,
2830 length, defaultUnit);
2837 textLayoutModule->skipCO->setCurrentIndex(skip);
2841 textLayoutModule->twoColumnCB->setChecked(
2844 if (!bp_.options.empty()) {
2845 latexModule->optionsLE->setText(
2846 toqstr(bp_.options));
2848 latexModule->optionsLE->setText(QString());
2852 latexModule->defaultOptionsCB->setChecked(
2853 bp_.use_default_options);
2854 updateSelectedModules();
2855 selectionManager->updateProvidedModules(
2856 bp_.baseClass()->providedModules());
2857 selectionManager->updateExcludedModules(
2858 bp_.baseClass()->excludedModules());
2860 if (!documentClass().options().empty()) {
2861 latexModule->defaultOptionsLE->setText(
2862 toqstr(documentClass().options()));
2864 latexModule->defaultOptionsLE->setText(
2865 toqstr(_("[No options predefined]")));
2868 latexModule->defaultOptionsLE->setEnabled(
2869 bp_.use_default_options
2870 && !documentClass().options().empty());
2872 latexModule->defaultOptionsCB->setEnabled(
2873 !documentClass().options().empty());
2875 if (!bp_.master.empty()) {
2876 latexModule->childDocGB->setChecked(true);
2877 latexModule->childDocLE->setText(
2878 toqstr(bp_.master));
2880 latexModule->childDocLE->setText(QString());
2881 latexModule->childDocGB->setChecked(false);
2885 if (!bufferview() || !buffer().hasChildren()) {
2886 masterChildModule->childrenTW->clear();
2887 includeonlys_.clear();
2888 docPS->showPanel(qt_("Child Documents"), false);
2889 if (docPS->isCurrentPanel(qt_("Child Documents")))
2890 docPS->setCurrentPanel(qt_("Document Class"));
2892 docPS->showPanel(qt_("Child Documents"), true);
2893 masterChildModule->setEnabled(true);
2894 includeonlys_ = bp_.getIncludedChildren();
2895 updateIncludeonlys();
2897 masterChildModule->maintainAuxCB->setChecked(
2898 bp_.maintain_unincluded_children);
2901 floatModule->set(bp_.float_placement);
2904 // break listings_params to multiple lines
2906 InsetListingsParams(bp_.listings_params).separatedParams();
2907 listingsModule->listingsED->setPlainText(toqstr(lstparams));
2910 // update combobox with formats
2911 updateDefaultFormat();
2912 int index = outputModule->defaultFormatCO->findData(toqstr(
2913 bp_.default_output_format));
2914 // set to default if format is not found
2917 outputModule->defaultFormatCO->setCurrentIndex(index);
2918 bool const os_fonts_available =
2919 bp_.baseClass()->outputType() == lyx::LATEX
2920 && LaTeXFeatures::isAvailable("fontspec");
2921 fontModule->osFontsCB->setEnabled(os_fonts_available);
2922 fontModule->osFontsCB->setChecked(
2923 os_fonts_available && bp_.useNonTeXFonts);
2925 outputModule->outputsyncCB->setChecked(bp_.output_sync);
2926 outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
2928 outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
2929 outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
2930 outputModule->strictCB->setChecked(bp_.html_be_strict);
2933 updateFontsize(documentClass().opt_fontsize(),
2936 QString font = toqstr(bp_.fonts_roman);
2937 int rpos = fontModule->fontsRomanCO->findData(font);
2939 rpos = fontModule->fontsRomanCO->count();
2940 fontModule->fontsRomanCO->addItem(font + qt_(" (not installed)"), font);
2942 fontModule->fontsRomanCO->setCurrentIndex(rpos);
2944 font = toqstr(bp_.fonts_sans);
2945 int spos = fontModule->fontsSansCO->findData(font);
2947 spos = fontModule->fontsSansCO->count();
2948 fontModule->fontsSansCO->addItem(font + qt_(" (not installed)"), font);
2950 fontModule->fontsSansCO->setCurrentIndex(spos);
2952 font = toqstr(bp_.fonts_typewriter);
2953 int tpos = fontModule->fontsTypewriterCO->findData(font);
2955 tpos = fontModule->fontsTypewriterCO->count();
2956 fontModule->fontsTypewriterCO->addItem(font + qt_(" (not installed)"), font);
2958 fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
2960 if (bp_.useNonTeXFonts && os_fonts_available) {
2961 fontModule->fontencLA->setEnabled(false);
2962 fontModule->fontencCO->setEnabled(false);
2963 fontModule->fontencLE->setEnabled(false);
2965 fontModule->fontencLA->setEnabled(true);
2966 fontModule->fontencCO->setEnabled(true);
2967 fontModule->fontencLE->setEnabled(true);
2973 if (!bp_.fonts_cjk.empty())
2974 fontModule->cjkFontLE->setText(
2975 toqstr(bp_.fonts_cjk));
2977 fontModule->cjkFontLE->setText(QString());
2979 fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
2980 fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
2981 fontModule->scaleSansSB->setValue(bp_.fonts_sans_scale);
2982 fontModule->scaleTypewriterSB->setValue(bp_.fonts_typewriter_scale);
2984 int nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
2986 fontModule->fontsDefaultCO->setCurrentIndex(nn);
2988 if (bp_.fontenc == "global") {
2989 fontModule->fontencCO->setCurrentIndex(0);
2990 fontModule->fontencLE->setEnabled(false);
2991 } else if (bp_.fontenc == "default") {
2992 fontModule->fontencCO->setCurrentIndex(2);
2993 fontModule->fontencLE->setEnabled(false);
2995 fontModule->fontencCO->setCurrentIndex(1);
2996 fontModule->fontencLE->setText(toqstr(bp_.fontenc));
3000 bool const extern_geometry =
3001 documentClass().provides("geometry");
3002 int const psize = bp_.papersize;
3003 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
3004 setCustomPapersize(!extern_geometry && psize == 1);
3005 pageLayoutModule->papersizeCO->setEnabled(!extern_geometry);
3007 bool const landscape =
3008 bp_.orientation == ORIENTATION_LANDSCAPE;
3009 pageLayoutModule->landscapeRB->setChecked(landscape);
3010 pageLayoutModule->portraitRB->setChecked(!landscape);
3011 pageLayoutModule->landscapeRB->setEnabled(!extern_geometry);
3012 pageLayoutModule->portraitRB->setEnabled(!extern_geometry);
3014 pageLayoutModule->facingPagesCB->setChecked(
3015 bp_.sides == TwoSides);
3017 lengthToWidgets(pageLayoutModule->paperwidthLE,
3018 pageLayoutModule->paperwidthUnitCO, bp_.paperwidth, defaultUnit);
3019 lengthToWidgets(pageLayoutModule->paperheightLE,
3020 pageLayoutModule->paperheightUnitCO, bp_.paperheight, defaultUnit);
3023 Ui::MarginsUi * m = marginsModule;
3027 lengthToWidgets(m->topLE, m->topUnit,
3028 bp_.topmargin, defaultUnit);
3030 lengthToWidgets(m->bottomLE, m->bottomUnit,
3031 bp_.bottommargin, defaultUnit);
3033 lengthToWidgets(m->innerLE, m->innerUnit,
3034 bp_.leftmargin, defaultUnit);
3036 lengthToWidgets(m->outerLE, m->outerUnit,
3037 bp_.rightmargin, defaultUnit);
3039 lengthToWidgets(m->headheightLE, m->headheightUnit,
3040 bp_.headheight, defaultUnit);
3042 lengthToWidgets(m->headsepLE, m->headsepUnit,
3043 bp_.headsep, defaultUnit);
3045 lengthToWidgets(m->footskipLE, m->footskipUnit,
3046 bp_.footskip, defaultUnit);
3048 lengthToWidgets(m->columnsepLE, m->columnsepUnit,
3049 bp_.columnsep, defaultUnit);
3052 updateUnknownBranches();
3053 branchesModule->update(bp_);
3056 PDFOptions const & pdf = bp_.pdfoptions();
3057 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
3058 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
3059 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
3060 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
3061 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
3063 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
3064 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
3065 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
3067 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
3069 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
3070 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
3071 pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
3072 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
3074 nn = findToken(backref_opts, pdf.backref);
3076 pdfSupportModule->backrefCO->setCurrentIndex(nn);
3078 pdfSupportModule->fullscreenCB->setChecked
3079 (pdf.pagemode == pdf.pagemode_fullscreen);
3081 pdfSupportModule->optionsLE->setText(
3082 toqstr(pdf.quoted_options));
3084 // Make sure that the bc is in the INITIAL state
3085 if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
3088 // clear changed branches cache
3089 changedBranches_.clear();
3093 void GuiDocument::saveDocDefault()
3095 // we have to apply the params first
3101 void GuiDocument::updateAvailableModules()
3103 modules_av_model_.clear();
3104 list<modInfoStruct> const & modInfoList = getModuleInfo();
3105 list<modInfoStruct>::const_iterator mit = modInfoList.begin();
3106 list<modInfoStruct>::const_iterator men = modInfoList.end();
3107 for (int i = 0; mit != men; ++mit, ++i)
3108 modules_av_model_.insertRow(i, mit->name, mit->id,
3113 void GuiDocument::updateSelectedModules()
3115 modules_sel_model_.clear();
3116 list<modInfoStruct> const selModList = getSelectedModules();
3117 list<modInfoStruct>::const_iterator mit = selModList.begin();
3118 list<modInfoStruct>::const_iterator men = selModList.end();
3119 for (int i = 0; mit != men; ++mit, ++i)
3120 modules_sel_model_.insertRow(i, mit->name, mit->id,
3125 void GuiDocument::updateIncludeonlys()
3127 masterChildModule->childrenTW->clear();
3128 QString const no = qt_("No");
3129 QString const yes = qt_("Yes");
3131 if (includeonlys_.empty()) {
3132 masterChildModule->includeallRB->setChecked(true);
3133 masterChildModule->childrenTW->setEnabled(false);
3134 masterChildModule->maintainAuxCB->setEnabled(false);
3136 masterChildModule->includeonlyRB->setChecked(true);
3137 masterChildModule->childrenTW->setEnabled(true);
3138 masterChildModule->maintainAuxCB->setEnabled(true);
3140 QTreeWidgetItem * item = 0;
3141 ListOfBuffers children = buffer().getChildren();
3142 ListOfBuffers::const_iterator it = children.begin();
3143 ListOfBuffers::const_iterator end = children.end();
3144 bool has_unincluded = false;
3145 bool all_unincluded = true;
3146 for (; it != end; ++it) {
3147 item = new QTreeWidgetItem(masterChildModule->childrenTW);
3150 to_utf8(makeRelPath(from_utf8((*it)->fileName().absFileName()),
3151 from_utf8(buffer().filePath())));
3152 item->setText(0, toqstr(name));
3153 item->setText(1, isChildIncluded(name) ? yes : no);
3154 if (!isChildIncluded(name))
3155 has_unincluded = true;
3157 all_unincluded = false;
3159 // Both if all childs are included and if none is included
3160 // is equal to "include all" (i.e., ommit \includeonly).
3161 // Thus, reset the GUI.
3162 if (!has_unincluded || all_unincluded) {
3163 masterChildModule->includeallRB->setChecked(true);
3164 masterChildModule->childrenTW->setEnabled(false);
3165 includeonlys_.clear();
3167 // If all are included, we need to update again.
3168 if (!has_unincluded)
3169 updateIncludeonlys();
3173 void GuiDocument::updateContents()
3175 // Nothing to do here as the document settings is not cursor dependant.
3180 void GuiDocument::useClassDefaults()
3182 if (applyPB->isEnabled()) {
3183 int const ret = Alert::prompt(_("Unapplied changes"),
3184 _("Some changes in the dialog were not yet applied.\n"
3185 "If you do not apply now, they will be lost after this action."),
3186 1, 1, _("&Apply"), _("&Dismiss"));
3191 int idx = latexModule->classCO->currentIndex();
3192 string const classname = classes_model_.getIDString(idx);
3193 if (!bp_.setBaseClass(classname)) {
3194 Alert::error(_("Error"), _("Unable to set document class."));
3197 bp_.useClassDefaults();
3202 void GuiDocument::setLayoutComboByIDString(string const & idString)
3204 int idx = classes_model_.findIDString(idString);
3206 Alert::warning(_("Can't set layout!"),
3207 bformat(_("Unable to set layout for ID: %1$s"), from_utf8(idString)));
3209 latexModule->classCO->setCurrentIndex(idx);
3213 bool GuiDocument::isValid()
3216 validateListingsParameters().isEmpty() &&
3217 localLayout->isValid() &&
3219 // if we're asking for skips between paragraphs
3220 !textLayoutModule->skipRB->isChecked() ||
3221 // then either we haven't chosen custom
3222 textLayoutModule->skipCO->currentIndex() != 3 ||
3223 // or else a length has been given
3224 !textLayoutModule->skipLE->text().isEmpty()
3227 // if we're asking for indentation
3228 !textLayoutModule->indentRB->isChecked() ||
3229 // then either we haven't chosen custom
3230 textLayoutModule->indentCO->currentIndex() != 1 ||
3231 // or else a length has been given
3232 !textLayoutModule->indentLE->text().isEmpty()
3237 char const * const GuiDocument::fontfamilies[5] = {
3238 "default", "rmdefault", "sfdefault", "ttdefault", ""
3242 char const * GuiDocument::fontfamilies_gui[5] = {
3243 N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
3247 bool GuiDocument::initialiseParams(string const &)
3249 BufferView const * view = bufferview();
3251 bp_ = BufferParams();
3255 bp_ = view->buffer().params();
3257 updateAvailableModules();
3258 //FIXME It'd be nice to make sure here that the selected
3259 //modules are consistent: That required modules are actually
3260 //selected, and that we don't have conflicts. If so, we could
3261 //at least pop up a warning.
3267 void GuiDocument::clearParams()
3269 bp_ = BufferParams();
3273 BufferId GuiDocument::id() const
3275 BufferView const * const view = bufferview();
3276 return view? &view->buffer() : 0;
3280 list<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
3282 return moduleNames_;
3286 list<GuiDocument::modInfoStruct> const
3287 GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
3289 LayoutModuleList::const_iterator it = mods.begin();
3290 LayoutModuleList::const_iterator end = mods.end();
3291 list<modInfoStruct> mInfo;
3292 for (; it != end; ++it) {
3295 LyXModule const * const mod = theModuleList[*it];
3298 m.name = toqstr(translateIfPossible(from_utf8(mod->getName())));
3300 m.name = toqstr(*it) + toqstr(" (") + qt_("Not Found") + toqstr(")");
3307 list<GuiDocument::modInfoStruct> const GuiDocument::getSelectedModules()
3309 return makeModuleInfo(params().getModules());
3313 list<GuiDocument::modInfoStruct> const GuiDocument::getProvidedModules()
3315 return makeModuleInfo(params().baseClass()->providedModules());
3319 DocumentClass const & GuiDocument::documentClass() const
3321 return bp_.documentClass();
3325 static void dispatch_bufferparams(Dialog const & dialog,
3326 BufferParams const & bp, FuncCode lfun)
3329 ss << "\\begin_header\n";
3331 ss << "\\end_header\n";
3332 dialog.dispatch(FuncRequest(lfun, ss.str()));
3336 void GuiDocument::dispatchParams()
3338 // This must come first so that a language change is correctly noticed
3341 // Apply the BufferParams. Note that this will set the base class
3342 // and then update the buffer's layout.
3343 dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
3345 if (!params().master.empty()) {
3346 FileName const master_file = support::makeAbsPath(params().master,
3347 support::onlyPath(buffer().absFileName()));
3348 if (isLyXFileName(master_file.absFileName())) {
3349 Buffer * master = checkAndLoadLyXFile(master_file);
3351 if (master->isChild(const_cast<Buffer *>(&buffer())))
3352 const_cast<Buffer &>(buffer()).setParent(master);
3354 Alert::warning(_("Assigned master does not include this file"),
3355 bformat(_("You must include this file in the document\n"
3356 "'%1$s' in order to use the master document\n"
3357 "feature."), from_utf8(params().master)));
3359 Alert::warning(_("Could not load master"),
3360 bformat(_("The master document '%1$s'\n"
3361 "could not be loaded."),
3362 from_utf8(params().master)));
3366 // Generate the colours requested by each new branch.
3367 BranchList & branchlist = params().branchlist();
3368 if (!branchlist.empty()) {
3369 BranchList::const_iterator it = branchlist.begin();
3370 BranchList::const_iterator const end = branchlist.end();
3371 for (; it != end; ++it) {
3372 docstring const & current_branch = it->branch();
3373 Branch const * branch = branchlist.find(current_branch);
3374 string const x11hexname = X11hexname(branch->color());
3375 // display the new color
3376 docstring const str = current_branch + ' ' + from_ascii(x11hexname);
3377 dispatch(FuncRequest(LFUN_SET_COLOR, str));
3380 // Open insets of selected branches, close deselected ones
3381 dispatch(FuncRequest(LFUN_INSET_FORALL,
3382 "Branch inset-toggle assign"));
3384 // rename branches in the document
3385 executeBranchRenaming();
3386 // and clear changed branches cache
3387 changedBranches_.clear();
3389 // Generate the colours requested by indices.
3390 IndicesList & indiceslist = params().indiceslist();
3391 if (!indiceslist.empty()) {
3392 IndicesList::const_iterator it = indiceslist.begin();
3393 IndicesList::const_iterator const end = indiceslist.end();
3394 for (; it != end; ++it) {
3395 docstring const & current_index = it->shortcut();
3396 Index const * index = indiceslist.findShortcut(current_index);
3397 string const x11hexname = X11hexname(index->color());
3398 // display the new color
3399 docstring const str = current_index + ' ' + from_ascii(x11hexname);
3400 dispatch(FuncRequest(LFUN_SET_COLOR, str));
3404 // If we used an LFUN, we would not need these two lines:
3405 BufferView * bv = const_cast<BufferView *>(bufferview());
3406 bv->processUpdateFlags(Update::Force | Update::FitCursor);
3410 void GuiDocument::setLanguage() const
3412 Language const * const newL = bp_.language;
3413 if (buffer().params().language == newL)
3416 string const & lang_name = newL->lang();
3417 dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
3421 void GuiDocument::saveAsDefault() const
3423 dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
3427 bool GuiDocument::isFontAvailable(string const & font) const
3429 if (font == "default" || font == "cmr"
3430 || font == "cmss" || font == "cmtt")
3431 // these are standard
3433 if (font == "lmodern" || font == "lmss" || font == "lmtt")
3434 return LaTeXFeatures::isAvailable("lmodern");
3435 if (font == "times" || font == "palatino"
3436 || font == "helvet" || font == "courier")
3437 return LaTeXFeatures::isAvailable("psnfss");
3438 if (font == "cmbr" || font == "cmtl")
3439 return LaTeXFeatures::isAvailable("cmbright");
3440 if (font == "utopia")
3441 return LaTeXFeatures::isAvailable("utopia")
3442 || LaTeXFeatures::isAvailable("fourier");
3443 if (font == "beraserif" || font == "berasans"
3444 || font == "beramono")
3445 return LaTeXFeatures::isAvailable("bera");
3446 return LaTeXFeatures::isAvailable(font);
3450 bool GuiDocument::providesOSF(string const & font) const
3452 if (fontModule->osFontsCB->isChecked())
3453 // FIXME: we should check if the fonts really
3454 // have OSF support. But how?
3457 return isFontAvailable("eco");
3458 if (font == "palatino")
3459 return isFontAvailable("mathpazo");
3464 bool GuiDocument::providesSC(string const & font) const
3466 if (fontModule->osFontsCB->isChecked())
3468 if (font == "palatino")
3469 return isFontAvailable("mathpazo");
3470 if (font == "utopia")
3471 return isFontAvailable("fourier");
3476 bool GuiDocument::providesScale(string const & font) const
3478 if (fontModule->osFontsCB->isChecked())
3480 return font == "helvet" || font == "luximono"
3481 || font == "berasans" || font == "beramono";
3485 void GuiDocument::loadModuleInfo()
3487 moduleNames_.clear();
3488 LyXModuleList::const_iterator it = theModuleList.begin();
3489 LyXModuleList::const_iterator end = theModuleList.end();
3490 for (; it != end; ++it) {
3494 m.name = toqstr(translateIfPossible(from_utf8(it->getName())));
3495 // this is supposed to give us the first sentence of the description
3498 toqstr(translateIfPossible(from_utf8(it->getDescription())));
3499 int const pos = desc.indexOf(".");
3501 desc.truncate(pos + 1);
3502 m.description = desc;
3503 moduleNames_.push_back(m);
3508 void GuiDocument::updateUnknownBranches()
3512 list<docstring> used_branches;
3513 buffer().getUsedBranches(used_branches);
3514 list<docstring>::const_iterator it = used_branches.begin();
3515 QStringList unknown_branches;
3516 for (; it != used_branches.end() ; ++it) {
3517 if (!buffer().params().branchlist().find(*it))
3518 unknown_branches.append(toqstr(*it));
3520 branchesModule->setUnknownBranches(unknown_branches);
3524 void GuiDocument::branchesRename(docstring const & oldname, docstring const & newname)
3526 map<docstring, docstring>::iterator it = changedBranches_.begin();
3527 for (; it != changedBranches_.end() ; ++it) {
3528 if (it->second == oldname) {
3529 // branch has already been renamed
3530 it->second = newname;
3535 changedBranches_[oldname] = newname;
3539 void GuiDocument::executeBranchRenaming() const
3541 map<docstring, docstring>::const_iterator it = changedBranches_.begin();
3542 for (; it != changedBranches_.end() ; ++it) {
3543 docstring const arg = '"' + it->first + '"' + " " + '"' + it->second + '"';
3544 dispatch(FuncRequest(LFUN_BRANCHES_RENAME, arg));
3549 Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
3552 } // namespace frontend
3555 #include "moc_GuiDocument.cpp"