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 "FloatPlacement.h"
17 #include "LengthCombo.h"
18 #include "PanelStack.h"
19 #include "qt_helpers.h"
20 #include "Validator.h"
22 // For the Branches module
23 #include "GuiBranches.h"
25 #include "GuiViewSource.h" // For latexHighlighter use in the preamble.
27 #include "frontend_helpers.h"
28 #include "BufferParams.h"
32 #include "LyXRC.h" // defaultUnit
33 #include "TextClassList.h"
35 #include "PDFOptions.h"
37 #include "insets/InsetListingsParams.h"
39 #include "support/lstrings.h"
41 #include <boost/bind.hpp>
43 #include <QCloseEvent>
45 #include <QTextCursor>
49 using lyx::support::token;
50 using lyx::support::bformat;
51 using lyx::support::findToken;
52 using lyx::support::getVectorFromString;
63 std::vector<typename Pair::second_type> const
64 getSecond(std::vector<Pair> const & pr)
66 std::vector<typename Pair::second_type> tmp(pr.size());
67 std::transform(pr.begin(), pr.end(), tmp.begin(),
68 boost::bind(&Pair::second, _1));
72 char const * const tex_graphics[] =
74 "default", "dvips", "dvitops", "emtex",
75 "ln", "oztex", "textures", "none", ""
79 char const * const tex_graphics_gui[] =
81 N_("Default"), "Dvips", "DVItoPS", "EmTeX",
82 "LN", "OzTeX", "Textures", N_("None"), ""
86 char const * const tex_fonts_roman[] =
88 "default", "cmr", "lmodern", "ae", "times", "palatino",
89 "charter", "newcent", "bookman", "utopia", "beraserif",
90 "ccfonts", "chancery", ""
94 char const * tex_fonts_roman_gui[] =
96 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
97 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
98 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
99 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
104 char const * const tex_fonts_sans[] =
106 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
110 char const * tex_fonts_sans_gui[] =
112 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
113 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
117 char const * const tex_fonts_monospaced[] =
119 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
123 char const * tex_fonts_monospaced_gui[] =
125 N_("Default"), N_("Computer Modern Typewriter"),
126 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
127 N_("LuxiMono"), N_("CM Typewriter Light"), ""
131 vector<pair<string, lyx::docstring> > pagestyles;
137 /////////////////////////////////////////////////////////////////////
141 /////////////////////////////////////////////////////////////////////
143 PreambleModule::PreambleModule(): current_id_(0)
145 // This is not a memory leak. The object will be destroyed
147 (void) new LaTeXHighlighter(preambleTE->document());
148 setFocusProxy(preambleTE);
149 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
153 void PreambleModule::update(BufferParams const & params, BufferId id)
155 QString preamble = toqstr(params.preamble);
156 // Nothing to do if the params and preamble are unchanged.
157 if (id == current_id_
158 && preamble == preambleTE->document()->toPlainText())
161 QTextCursor cur = preambleTE->textCursor();
162 // Save the coords before switching to the new one.
163 preamble_coords_[current_id_] =
164 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
166 // Save the params address for further use.
168 preambleTE->document()->setPlainText(preamble);
169 Coords::const_iterator it = preamble_coords_.find(current_id_);
170 if (it == preamble_coords_.end())
171 // First time we open this one.
172 preamble_coords_[current_id_] = make_pair(0,0);
174 // Restore saved coords.
175 QTextCursor cur = preambleTE->textCursor();
176 cur.setPosition(it->second.first);
177 preambleTE->setTextCursor(cur);
178 preambleTE->verticalScrollBar()->setValue(it->second.second);
183 void PreambleModule::apply(BufferParams & params)
185 params.preamble = fromqstr(preambleTE->document()->toPlainText());
189 void PreambleModule::closeEvent(QCloseEvent * e)
191 // Save the coords before closing.
192 QTextCursor cur = preambleTE->textCursor();
193 preamble_coords_[current_id_] =
194 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
199 /////////////////////////////////////////////////////////////////////
203 /////////////////////////////////////////////////////////////////////
207 GuiDocumentDialog::GuiDocumentDialog(LyXView & lv)
208 : GuiDialog(lv, "document")
211 setController(new ControlDocument(*this));
212 setViewTitle(_("Document Settings"));
214 lang_ = getSecond(getLanguageData(false));
216 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
217 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
218 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
219 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
221 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
222 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
224 // Manage the restore, ok, apply, restore and cancel/close buttons
225 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
227 bc().setApply(applyPB);
228 bc().setCancel(closePB);
229 bc().setRestore(restorePB);
231 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
233 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
234 this, SLOT(change_adaptor()));
235 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
236 this, SLOT(setLSpacing(int)));
237 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
238 this, SLOT(change_adaptor()));
239 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
240 this, SLOT(change_adaptor()));
241 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
242 this, SLOT(change_adaptor()));
243 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
244 this, SLOT(change_adaptor()));
245 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
246 this, SLOT(change_adaptor()));
247 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
248 this, SLOT(change_adaptor()));
249 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
250 this, SLOT(setSkip(int)));
251 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
252 this, SLOT(enableSkip(bool)));
253 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
254 this, SLOT(change_adaptor()));
255 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
256 this, SLOT(change_adaptor()));
257 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
258 this, SLOT(change_adaptor()));
259 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
260 this, SLOT(set_listings_msg()));
261 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
262 this, SLOT(set_listings_msg()));
263 textLayoutModule->listingsTB->setPlainText(
264 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
265 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
266 textLayoutModule->lspacingLE));
267 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
268 textLayoutModule->skipLE));
270 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
271 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
272 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
273 textLayoutModule->skipCO->addItem(qt_("Length"));
274 // remove the %-items from the unit choice
275 textLayoutModule->skipLengthCO->noPercents();
276 textLayoutModule->lspacingCO->insertItem(
277 Spacing::Single, qt_("Single"));
278 textLayoutModule->lspacingCO->insertItem(
279 Spacing::Onehalf, qt_("OneHalf"));
280 textLayoutModule->lspacingCO->insertItem(
281 Spacing::Double, qt_("Double"));
282 textLayoutModule->lspacingCO->insertItem(
283 Spacing::Other, qt_("Custom"));
285 // initialize the length validator
286 bc().addCheckedLineEdit(textLayoutModule->skipLE);
288 fontModule = new UiWidget<Ui::FontUi>;
290 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
291 this, SLOT(change_adaptor()));
292 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
293 this, SLOT(romanChanged(int)));
294 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
295 this, SLOT(change_adaptor()));
296 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
297 this, SLOT(sansChanged(int)));
298 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
299 this, SLOT(change_adaptor()));
300 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
301 this, SLOT(ttChanged(int)));
302 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
303 this, SLOT(change_adaptor()));
304 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
305 this, SLOT(change_adaptor()));
306 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
307 this, SLOT(change_adaptor()));
308 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
309 this, SLOT(change_adaptor()));
310 connect(fontModule->fontScCB, SIGNAL(clicked()),
311 this, SLOT(change_adaptor()));
312 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
313 this, SLOT(change_adaptor()));
315 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
316 QString font = qt_(tex_fonts_roman_gui[n]);
317 if (!controller().isFontAvailable(tex_fonts_roman[n]))
318 font += qt_(" (not installed)");
319 fontModule->fontsRomanCO->addItem(font);
321 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
322 QString font = qt_(tex_fonts_sans_gui[n]);
323 if (!controller().isFontAvailable(tex_fonts_sans[n]))
324 font += qt_(" (not installed)");
325 fontModule->fontsSansCO->addItem(font);
327 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
328 QString font = qt_(tex_fonts_monospaced_gui[n]);
329 if (!controller().isFontAvailable(tex_fonts_monospaced[n]))
330 font += qt_(" (not installed)");
331 fontModule->fontsTypewriterCO->addItem(font);
334 fontModule->fontsizeCO->addItem(qt_("Default"));
335 fontModule->fontsizeCO->addItem(qt_("10"));
336 fontModule->fontsizeCO->addItem(qt_("11"));
337 fontModule->fontsizeCO->addItem(qt_("12"));
339 for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
340 fontModule->fontsDefaultCO->addItem(
341 qt_(ControlDocument::fontfamilies_gui[n]));
344 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
346 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
347 this, SLOT(setCustomPapersize(int)));
348 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
349 this, SLOT(setCustomPapersize(int)));
350 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
351 this, SLOT(portraitChanged()));
352 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
353 this, SLOT(change_adaptor()));
354 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
355 this, SLOT(change_adaptor()));
356 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
357 this, SLOT(change_adaptor()));
358 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
359 this, SLOT(change_adaptor()));
360 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
361 this, SLOT(change_adaptor()));
362 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
363 this, SLOT(change_adaptor()));
364 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
365 this, SLOT(change_adaptor()));
366 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
367 this, SLOT(change_adaptor()));
368 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
369 this, SLOT(change_adaptor()));
371 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
372 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
373 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
374 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
375 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
376 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
377 pageLayoutModule->paperheightL);
378 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
379 pageLayoutModule->paperwidthL);
382 QComboBox * cb = pageLayoutModule->papersizeCO;
383 cb->addItem(qt_("Default"));
384 cb->addItem(qt_("Custom"));
385 cb->addItem(qt_("US letter"));
386 cb->addItem(qt_("US legal"));
387 cb->addItem(qt_("US executive"));
388 cb->addItem(qt_("A3"));
389 cb->addItem(qt_("A4"));
390 cb->addItem(qt_("A5"));
391 cb->addItem(qt_("B3"));
392 cb->addItem(qt_("B4"));
393 cb->addItem(qt_("B5"));
394 // remove the %-items from the unit choice
395 pageLayoutModule->paperwidthUnitCO->noPercents();
396 pageLayoutModule->paperheightUnitCO->noPercents();
397 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
398 pageLayoutModule->paperheightLE));
399 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
400 pageLayoutModule->paperwidthLE));
403 marginsModule = new UiWidget<Ui::MarginsUi>;
405 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
406 this, SLOT(setCustomMargins(bool)));
407 connect(marginsModule->marginCB, SIGNAL(clicked()),
408 this, SLOT(change_adaptor()));
409 connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
410 this, SLOT(change_adaptor()));
411 connect(marginsModule->topUnit, SIGNAL(activated(int)),
412 this, SLOT(change_adaptor()));
413 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
414 this, SLOT(change_adaptor()));
415 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
416 this, SLOT(change_adaptor()));
417 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
418 this, SLOT(change_adaptor()));
419 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
420 this, SLOT(change_adaptor()));
421 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
422 this, SLOT(change_adaptor()));
423 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
424 this, SLOT(change_adaptor()));
425 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
426 this, SLOT(change_adaptor()));
427 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
428 this, SLOT(change_adaptor()));
429 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
430 this, SLOT(change_adaptor()));
431 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
432 this, SLOT(change_adaptor()));
433 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
434 this, SLOT(change_adaptor()));
435 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
436 this, SLOT(change_adaptor()));
437 marginsModule->topLE->setValidator(unsignedLengthValidator(
438 marginsModule->topLE));
439 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
440 marginsModule->bottomLE));
441 marginsModule->innerLE->setValidator(unsignedLengthValidator(
442 marginsModule->innerLE));
443 marginsModule->outerLE->setValidator(unsignedLengthValidator(
444 marginsModule->outerLE));
445 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
446 marginsModule->headsepLE));
447 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
448 marginsModule->headheightLE));
449 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
450 marginsModule->footskipLE));
452 bc().addCheckedLineEdit(marginsModule->topLE,
453 marginsModule->topL);
454 bc().addCheckedLineEdit(marginsModule->bottomLE,
455 marginsModule->bottomL);
456 bc().addCheckedLineEdit(marginsModule->innerLE,
457 marginsModule->innerL);
458 bc().addCheckedLineEdit(marginsModule->outerLE,
459 marginsModule->outerL);
460 bc().addCheckedLineEdit(marginsModule->headsepLE,
461 marginsModule->headsepL);
462 bc().addCheckedLineEdit(marginsModule->headheightLE,
463 marginsModule->headheightL);
464 bc().addCheckedLineEdit(marginsModule->footskipLE,
465 marginsModule->footskipL);
468 langModule = new UiWidget<Ui::LanguageUi>;
470 connect(langModule->languageCO, SIGNAL(activated(int)),
471 this, SLOT(change_adaptor()));
472 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
473 this, SLOT(change_adaptor()));
474 connect(langModule->otherencodingRB, SIGNAL(clicked()),
475 this, SLOT(change_adaptor()));
476 connect(langModule->encodingCO, SIGNAL(activated(int)),
477 this, SLOT(change_adaptor()));
478 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
479 this, SLOT(change_adaptor()));
481 vector<LanguagePair> const langs = getLanguageData(false);
482 vector<LanguagePair>::const_iterator lit = langs.begin();
483 vector<LanguagePair>::const_iterator lend = langs.end();
484 for (; lit != lend; ++lit) {
485 langModule->languageCO->addItem(toqstr(lit->first));
488 // Always put the default encoding in the first position.
489 // It is special because the displayed text is translated.
490 langModule->encodingCO->addItem(qt_("LaTeX default"));
491 Encodings::const_iterator it = encodings.begin();
492 Encodings::const_iterator const end = encodings.end();
493 for (; it != end; ++it)
494 langModule->encodingCO->addItem(toqstr(it->latexName()));
496 langModule->quoteStyleCO->addItem(qt_("``text''"));
497 langModule->quoteStyleCO->addItem(qt_("''text''"));
498 langModule->quoteStyleCO->addItem(qt_(",,text``"));
499 langModule->quoteStyleCO->addItem(qt_(",,text''"));
500 langModule->quoteStyleCO->addItem(qt_("<<text>>"));
501 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
505 numberingModule = new UiWidget<Ui::NumberingUi>;
507 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
508 this, SLOT(change_adaptor()));
509 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
510 this, SLOT(change_adaptor()));
511 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
512 this, SLOT(updateNumbering()));
513 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
514 this, SLOT(updateNumbering()));
515 numberingModule->tocTW->setColumnCount(3);
516 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
517 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
518 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
521 biblioModule = new UiWidget<Ui::BiblioUi>;
522 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
523 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
524 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
525 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
527 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
528 this, SLOT(change_adaptor()));
529 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
530 this, SLOT(change_adaptor()));
531 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
532 this, SLOT(change_adaptor()));
533 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
534 this, SLOT(change_adaptor()));
535 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
536 this, SLOT(change_adaptor()));
538 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
539 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
540 biblioModule->citeStyleCO->setCurrentIndex(0);
543 mathsModule = new UiWidget<Ui::MathsUi>;
544 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
545 mathsModule->amsCB, SLOT(setDisabled(bool)));
546 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
547 mathsModule->esintCB, SLOT(setDisabled(bool)));
549 connect(mathsModule->amsCB, SIGNAL(clicked()),
550 this, SLOT(change_adaptor()));
551 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
552 this, SLOT(change_adaptor()));
553 connect(mathsModule->esintCB, SIGNAL(clicked()),
554 this, SLOT(change_adaptor()));
555 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
556 this, SLOT(change_adaptor()));
558 latexModule = new UiWidget<Ui::LaTeXUi>;
560 connect(latexModule->classCO, SIGNAL(activated(int)),
561 this, SLOT(change_adaptor()));
562 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
563 this, SLOT(change_adaptor()));
564 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
565 this, SLOT(change_adaptor()));
566 connect(latexModule->classCO, SIGNAL(activated(int)),
567 this, SLOT(classChanged()));
570 new GuiSelectionManager(latexModule->availableLV, latexModule->selectedLV,
571 latexModule->addPB, latexModule->deletePB,
572 latexModule->upPB, latexModule->downPB,
573 availableModel(), selectedModel());
574 connect(selectionManager, SIGNAL(updateHook()),
575 this, SLOT(updateModuleInfo()));
576 connect(selectionManager, SIGNAL(updateHook()),
577 this, SLOT(change_adaptor()));
579 // postscript drivers
580 for (int n = 0; tex_graphics[n][0]; ++n) {
581 QString enc = qt_(tex_graphics_gui[n]);
582 latexModule->psdriverCO->addItem(enc);
585 //FIXME This seems too involved with the kernel. Some of this
586 //should be moved to the controller---which should perhaps just
587 //give us a list of entries or something of the sort.
588 for (TextClassList::const_iterator cit = textclasslist.begin();
589 cit != textclasslist.end(); ++cit) {
590 if (cit->isTeXClassAvailable()) {
591 latexModule->classCO->addItem(toqstr(cit->description()));
594 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
595 latexModule->classCO->addItem(toqstr(item));
600 branchesModule = new GuiBranches;
601 connect(branchesModule, SIGNAL(changed()),
602 this, SLOT(change_adaptor()));
605 preambleModule = new PreambleModule;
606 connect(preambleModule, SIGNAL(changed()),
607 this, SLOT(change_adaptor()));
610 bulletsModule = new BulletsModule;
611 connect(bulletsModule, SIGNAL(changed()),
612 this, SLOT(change_adaptor()));
615 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
617 connect(pdfSupportModule->use_hyperrefCB, SIGNAL(toggled(bool)),
618 this, SLOT(change_adaptor()));
619 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
620 this, SLOT(change_adaptor()));
621 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
622 this, SLOT(change_adaptor()));
623 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
624 this, SLOT(change_adaptor()));
625 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
626 this, SLOT(change_adaptor()));
627 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
628 this, SLOT(change_adaptor()));
629 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
630 this, SLOT(change_adaptor()));
631 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
632 this, SLOT(change_adaptor()));
633 connect(pdfSupportModule->bookmarksopenlevelLE, SIGNAL(textChanged(const QString &)),
634 this, SLOT(change_adaptor()));
635 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
636 this, SLOT(change_adaptor()));
637 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
638 this, SLOT(change_adaptor()));
639 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
640 this, SLOT(change_adaptor()));
641 connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
642 this, SLOT(change_adaptor()));
643 connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
644 this, SLOT(change_adaptor()));
645 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
646 this, SLOT(change_adaptor()));
647 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
648 this, SLOT(change_adaptor()));
651 floatModule = new FloatPlacement;
652 connect(floatModule, SIGNAL(changed()),
653 this, SLOT(change_adaptor()));
655 docPS->addPanel(latexModule, _("Document Class"));
656 docPS->addPanel(fontModule, _("Fonts"));
657 docPS->addPanel(textLayoutModule, _("Text Layout"));
658 docPS->addPanel(pageLayoutModule, _("Page Layout"));
659 docPS->addPanel(marginsModule, _("Page Margins"));
660 docPS->addPanel(langModule, _("Language"));
661 docPS->addPanel(numberingModule, _("Numbering & TOC"));
662 docPS->addPanel(biblioModule, _("Bibliography"));
663 docPS->addPanel(pdfSupportModule, _("PDF Properties"));
664 docPS->addPanel(mathsModule, _("Math Options"));
665 docPS->addPanel(floatModule, _("Float Placement"));
666 docPS->addPanel(bulletsModule, _("Bullets"));
667 docPS->addPanel(branchesModule, _("Branches"));
668 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
669 docPS->setCurrentPanel(_("Document Class"));
670 // FIXME: hack to work around resizing bug in Qt >= 4.2
671 // bug verified with Qt 4.2.{0-3} (JSpitzm)
672 #if QT_VERSION >= 0x040200
673 docPS->updateGeometry();
678 ControlDocument & GuiDocumentDialog::controller()
680 return static_cast<ControlDocument &>(GuiDialog::controller());
684 void GuiDocumentDialog::showPreamble()
686 docPS->setCurrentPanel(_("LaTeX Preamble"));
690 void GuiDocumentDialog::saveDefaultClicked()
696 void GuiDocumentDialog::useDefaultsClicked()
702 void GuiDocumentDialog::change_adaptor()
708 docstring GuiDocumentDialog::validate_listings_params()
710 // use a cache here to avoid repeated validation
711 // of the same parameters
712 static string param_cache = string();
713 static docstring msg_cache = docstring();
715 if (textLayoutModule->bypassCB->isChecked())
718 string params = fromqstr(textLayoutModule->listingsED->toPlainText());
719 if (params != param_cache) {
720 param_cache = params;
721 msg_cache = InsetListingsParams(params).validate();
727 void GuiDocumentDialog::set_listings_msg()
729 static bool isOK = true;
730 docstring msg = validate_listings_params();
735 // listingsTB->setTextColor("black");
736 textLayoutModule->listingsTB->setPlainText(
737 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
740 // listingsTB->setTextColor("red");
741 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
746 void GuiDocumentDialog::closeEvent(QCloseEvent * e)
753 void GuiDocumentDialog::setLSpacing(int item)
755 textLayoutModule->lspacingLE->setEnabled(item == 3);
759 void GuiDocumentDialog::setSkip(int item)
761 bool const enable = (item == 3);
762 textLayoutModule->skipLE->setEnabled(enable);
763 textLayoutModule->skipLengthCO->setEnabled(enable);
767 void GuiDocumentDialog::enableSkip(bool skip)
769 textLayoutModule->skipCO->setEnabled(skip);
770 textLayoutModule->skipLE->setEnabled(skip);
771 textLayoutModule->skipLengthCO->setEnabled(skip);
773 setSkip(textLayoutModule->skipCO->currentIndex());
776 void GuiDocumentDialog::portraitChanged()
778 setMargins(pageLayoutModule->papersizeCO->currentIndex());
781 void GuiDocumentDialog::setMargins(bool custom)
783 marginsModule->marginCB->setChecked(custom);
784 setCustomMargins(custom);
788 void GuiDocumentDialog::setCustomPapersize(int papersize)
790 bool const custom = (papersize == 1);
792 pageLayoutModule->paperwidthL->setEnabled(custom);
793 pageLayoutModule->paperwidthLE->setEnabled(custom);
794 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
795 pageLayoutModule->paperheightL->setEnabled(custom);
796 pageLayoutModule->paperheightLE->setEnabled(custom);
797 pageLayoutModule->paperheightLE->setFocus();
798 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
802 void GuiDocumentDialog::setCustomMargins(bool custom)
804 marginsModule->topL->setEnabled(!custom);
805 marginsModule->topLE->setEnabled(!custom);
806 marginsModule->topUnit->setEnabled(!custom);
808 marginsModule->bottomL->setEnabled(!custom);
809 marginsModule->bottomLE->setEnabled(!custom);
810 marginsModule->bottomUnit->setEnabled(!custom);
812 marginsModule->innerL->setEnabled(!custom);
813 marginsModule->innerLE->setEnabled(!custom);
814 marginsModule->innerUnit->setEnabled(!custom);
816 marginsModule->outerL->setEnabled(!custom);
817 marginsModule->outerLE->setEnabled(!custom);
818 marginsModule->outerUnit->setEnabled(!custom);
820 marginsModule->headheightL->setEnabled(!custom);
821 marginsModule->headheightLE->setEnabled(!custom);
822 marginsModule->headheightUnit->setEnabled(!custom);
824 marginsModule->headsepL->setEnabled(!custom);
825 marginsModule->headsepLE->setEnabled(!custom);
826 marginsModule->headsepUnit->setEnabled(!custom);
828 marginsModule->footskipL->setEnabled(!custom);
829 marginsModule->footskipLE->setEnabled(!custom);
830 marginsModule->footskipUnit->setEnabled(!custom);
834 void GuiDocumentDialog::updateFontsize(string const & items, string const & sel)
836 fontModule->fontsizeCO->clear();
837 fontModule->fontsizeCO->addItem(qt_("Default"));
839 for (int n = 0; !token(items,'|',n).empty(); ++n)
840 fontModule->fontsizeCO->
841 addItem(toqstr(token(items,'|',n)));
843 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
844 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
845 fontModule->fontsizeCO->setCurrentIndex(n);
852 void GuiDocumentDialog::romanChanged(int item)
854 string const font = tex_fonts_roman[item];
855 fontModule->fontScCB->setEnabled(controller().providesSC(font));
856 fontModule->fontOsfCB->setEnabled(controller().providesOSF(font));
860 void GuiDocumentDialog::sansChanged(int item)
862 string const font = tex_fonts_sans[item];
863 bool scaleable = controller().providesScale(font);
864 fontModule->scaleSansSB->setEnabled(scaleable);
865 fontModule->scaleSansLA->setEnabled(scaleable);
869 void GuiDocumentDialog::ttChanged(int item)
871 string const font = tex_fonts_monospaced[item];
872 bool scaleable = controller().providesScale(font);
873 fontModule->scaleTypewriterSB->setEnabled(scaleable);
874 fontModule->scaleTypewriterLA->setEnabled(scaleable);
878 void GuiDocumentDialog::updatePagestyle(string const & items, string const & sel)
881 pageLayoutModule->pagestyleCO->clear();
882 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
884 for (int n = 0; !token(items,'|',n).empty(); ++n) {
885 string style = token(items, '|', n);
886 docstring style_gui = _(style);
887 pagestyles.push_back(pair<string, docstring>(style, style_gui));
888 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
891 if (sel == "default") {
892 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
898 for (size_t i = 0; i < pagestyles.size(); ++i)
899 if (pagestyles[i].first == sel)
900 nn = pageLayoutModule->pagestyleCO->findText(
901 toqstr(pagestyles[i].second));
904 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
908 void GuiDocumentDialog::classChanged()
910 BufferParams & params = controller().params();
911 textclass_type const tc = latexModule->classCO->currentIndex();
912 params.setJustBaseClass(tc);
913 if (lyxrc.auto_reset_options)
914 params.useClassDefaults();
919 void GuiDocumentDialog::updateModuleInfo()
921 selectionManager->update();
923 QListView const * const lv = selectionManager->selectedFocused() ?
924 latexModule->selectedLV :
925 latexModule->availableLV;
926 if (lv->selectionModel()->selectedIndexes().isEmpty())
927 latexModule->infoML->document()->clear();
929 QModelIndex const idx = lv->selectionModel()->currentIndex();
930 string const modName = fromqstr(idx.data().toString());
931 string desc = controller().getModuleDescription(modName);
932 vector<string> pkgList = controller().getPackageList(modName);
934 //this mess formats the package list as "pkg1, pkg2, and pkg3"
935 int const pkgListSize = pkgList.size();
936 for (int i = 0; i < pkgListSize; ++i) {
938 if (i == pkgListSize - 1) //last element
943 if (i == pkgListSize - 1) //last element
948 pkgdesc += pkgList[i];
950 if (!pkgdesc.empty())
951 desc += " Requires " + pkgdesc + ".";
952 latexModule->infoML->document()->setPlainText(toqstr(desc));
957 void GuiDocumentDialog::updateNumbering()
959 TextClass const & tclass = controller().params().getTextClass();
961 numberingModule->tocTW->setUpdatesEnabled(false);
962 numberingModule->tocTW->clear();
964 int const depth = numberingModule->depthSL->value();
965 int const toc = numberingModule->tocSL->value();
966 QString const no = qt_("No");
967 QString const yes = qt_("Yes");
968 TextClass::const_iterator end = tclass.end();
969 TextClass::const_iterator cit = tclass.begin();
970 QTreeWidgetItem * item = 0;
971 for ( ; cit != end ; ++cit) {
972 int const toclevel = (*cit)->toclevel;
973 if (toclevel != Layout::NOT_IN_TOC
974 && (*cit)->labeltype == LABEL_COUNTER) {
975 item = new QTreeWidgetItem(numberingModule->tocTW);
976 item->setText(0, toqstr(translateIfPossible((*cit)->name())));
977 item->setText(1, (toclevel <= depth) ? yes : no);
978 item->setText(2, (toclevel <= toc) ? yes : no);
982 numberingModule->tocTW->setUpdatesEnabled(true);
983 numberingModule->tocTW->update();
987 void GuiDocumentDialog::apply(BufferParams & params)
990 preambleModule->apply(params);
993 params.setCiteEngine(biblio::ENGINE_BASIC);
995 if (biblioModule->citeNatbibRB->isChecked()) {
996 bool const use_numerical_citations =
997 biblioModule->citeStyleCO->currentIndex();
998 if (use_numerical_citations)
999 params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1001 params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1003 } else if (biblioModule->citeJurabibRB->isChecked())
1004 params.setCiteEngine(biblio::ENGINE_JURABIB);
1006 params.use_bibtopic =
1007 biblioModule->bibtopicCB->isChecked();
1009 // language & quotes
1010 if (langModule->defaultencodingRB->isChecked()) {
1011 params.inputenc = "auto";
1013 int i = langModule->encodingCO->currentIndex();
1015 params.inputenc = "default";
1018 fromqstr(langModule->encodingCO->currentText());
1021 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1022 switch (langModule->quoteStyleCO->currentIndex()) {
1024 lga = InsetQuotes::EnglishQ;
1027 lga = InsetQuotes::SwedishQ;
1030 lga = InsetQuotes::GermanQ;
1033 lga = InsetQuotes::PolishQ;
1036 lga = InsetQuotes::FrenchQ;
1039 lga = InsetQuotes::DanishQ;
1042 params.quotes_language = lga;
1044 int const pos = langModule->languageCO->currentIndex();
1045 params.language = lyx::languages.getLanguage(lang_[pos]);
1048 if (params.getTextClass().hasTocLevels()) {
1049 params.tocdepth = numberingModule->tocSL->value();
1050 params.secnumdepth = numberingModule->depthSL->value();
1054 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1055 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1056 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1057 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1060 params.graphicsDriver =
1061 tex_graphics[latexModule->psdriverCO->currentIndex()];
1064 params.clearLayoutModules();
1065 QStringList const selMods = selectedModel()->stringList();
1066 for (int i = 0; i != selMods.size(); ++i)
1067 params.addLayoutModule(lyx::fromqstr(selMods[i]));
1070 if (mathsModule->amsautoCB->isChecked()) {
1071 params.use_amsmath = BufferParams::package_auto;
1073 if (mathsModule->amsCB->isChecked())
1074 params.use_amsmath = BufferParams::package_on;
1076 params.use_amsmath = BufferParams::package_off;
1079 if (mathsModule->esintautoCB->isChecked())
1080 params.use_esint = BufferParams::package_auto;
1082 if (mathsModule->esintCB->isChecked())
1083 params.use_esint = BufferParams::package_on;
1085 params.use_esint = BufferParams::package_off;
1089 params.setJustBaseClass(latexModule->classCO->currentIndex());
1091 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1092 params.pagestyle = "default";
1094 docstring style_gui =
1095 qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1096 for (size_t i = 0; i < pagestyles.size(); ++i)
1097 if (pagestyles[i].second == style_gui)
1098 params.pagestyle = pagestyles[i].first;
1101 switch (textLayoutModule->lspacingCO->currentIndex()) {
1103 params.spacing().set(Spacing::Single);
1106 params.spacing().set(Spacing::Onehalf);
1109 params.spacing().set(Spacing::Double);
1112 params.spacing().set(Spacing::Other,
1113 fromqstr(textLayoutModule->lspacingLE->text()));
1117 if (textLayoutModule->twoColumnCB->isChecked())
1122 // text should have passed validation
1123 params.listings_params =
1124 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1126 if (textLayoutModule->indentRB->isChecked())
1127 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1129 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1131 switch (textLayoutModule->skipCO->currentIndex()) {
1133 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1136 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1139 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1144 widgetsToLength(textLayoutModule->skipLE,
1145 textLayoutModule->skipLengthCO)
1147 params.setDefSkip(vs);
1151 // DocumentDefskipCB assures that this never happens
1152 // so Assert then !!! - jbl
1153 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1158 fromqstr(latexModule->optionsLE->text());
1160 params.float_placement = floatModule->get();
1164 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1167 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1169 params.fontsTypewriter =
1170 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1172 params.fontsSansScale = fontModule->scaleSansSB->value();
1174 params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1176 params.fontsSC = fontModule->fontScCB->isChecked();
1178 params.fontsOSF = fontModule->fontOsfCB->isChecked();
1180 params.fontsDefaultFamily = ControlDocument::fontfamilies[
1181 fontModule->fontsDefaultCO->currentIndex()];
1183 if (fontModule->fontsizeCO->currentIndex() == 0)
1184 params.fontsize = "default";
1187 fromqstr(fontModule->fontsizeCO->currentText());
1190 params.papersize = PAPER_SIZE(
1191 pageLayoutModule->papersizeCO->currentIndex());
1193 // custom, A3, B3 and B4 paper sizes need geometry
1194 int psize = pageLayoutModule->papersizeCO->currentIndex();
1195 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1197 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1198 pageLayoutModule->paperwidthUnitCO);
1200 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1201 pageLayoutModule->paperheightUnitCO);
1203 if (pageLayoutModule->facingPagesCB->isChecked())
1204 params.sides = TextClass::TwoSides;
1206 params.sides = TextClass::OneSide;
1208 if (pageLayoutModule->landscapeRB->isChecked())
1209 params.orientation = ORIENTATION_LANDSCAPE;
1211 params.orientation = ORIENTATION_PORTRAIT;
1214 params.use_geometry =
1215 (!marginsModule->marginCB->isChecked()
1218 Ui::MarginsUi const * m(marginsModule);
1220 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1221 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1222 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1223 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1224 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1225 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1226 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1228 branchesModule->apply(params);
1231 PDFOptions & pdf = params.pdfoptions();
1232 pdf.use_hyperref = pdfSupportModule->use_hyperrefCB->isChecked();
1233 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1234 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1235 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1236 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1238 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1239 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1240 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1241 pdf.bookmarksopenlevel =
1242 fromqstr(pdfSupportModule->bookmarksopenlevelLE->text());
1244 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
1245 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
1246 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
1247 pdf.backref = pdfSupportModule->backrefCB->isChecked();
1248 pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
1249 if (pdfSupportModule->fullscreenCB->isChecked())
1250 pdf.pagemode = pdf.pagemode_fullscreen;
1251 pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1252 if (pdf.use_hyperref || !pdf.empty())
1253 pdf.store_options = true;
1257 /** Return the position of val in the vector if found.
1258 If not found, return 0.
1261 static size_t findPos(std::vector<A> const & vec, A const & val)
1263 typename std::vector<A>::const_iterator it =
1264 std::find(vec.begin(), vec.end(), val);
1265 if (it == vec.end())
1267 return distance(vec.begin(), it);
1271 void GuiDocumentDialog::updateParams()
1273 BufferParams const & params = controller().params();
1274 updateParams(params);
1278 void GuiDocumentDialog::updateParams(BufferParams const & params)
1280 // set the default unit
1281 // FIXME: move to controller
1282 Length::UNIT defaultUnit = Length::CM;
1283 switch (lyxrc.default_papersize) {
1284 case PAPER_DEFAULT: break;
1286 case PAPER_USLETTER:
1288 case PAPER_USEXECUTIVE:
1289 defaultUnit = Length::IN;
1298 defaultUnit = Length::CM;
1305 preambleModule->update(params, controller().id());
1308 biblioModule->citeDefaultRB->setChecked(
1309 params.getEngine() == biblio::ENGINE_BASIC);
1311 biblioModule->citeNatbibRB->setChecked(
1312 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1313 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1315 biblioModule->citeStyleCO->setCurrentIndex(
1316 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1318 biblioModule->citeJurabibRB->setChecked(
1319 params.getEngine() == biblio::ENGINE_JURABIB);
1321 biblioModule->bibtopicCB->setChecked(
1322 params.use_bibtopic);
1324 // language & quotes
1325 int const pos = int(findPos(lang_,
1326 params.language->lang()));
1327 langModule->languageCO->setCurrentIndex(pos);
1329 langModule->quoteStyleCO->setCurrentIndex(
1330 params.quotes_language);
1332 bool default_enc = true;
1333 if (params.inputenc != "auto") {
1334 default_enc = false;
1335 if (params.inputenc == "default") {
1336 langModule->encodingCO->setCurrentIndex(0);
1338 int const i = langModule->encodingCO->findText(
1339 toqstr(params.inputenc));
1341 langModule->encodingCO->setCurrentIndex(i);
1343 // unknown encoding. Set to default.
1347 langModule->defaultencodingRB->setChecked(default_enc);
1348 langModule->otherencodingRB->setChecked(!default_enc);
1351 int const min_toclevel = controller().textClass().min_toclevel();
1352 int const max_toclevel = controller().textClass().max_toclevel();
1353 if (controller().textClass().hasTocLevels()) {
1354 numberingModule->setEnabled(true);
1355 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1356 numberingModule->depthSL->setMaximum(max_toclevel);
1357 numberingModule->depthSL->setValue(params.secnumdepth);
1358 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1359 numberingModule->tocSL->setMaximum(max_toclevel);
1360 numberingModule->tocSL->setValue(params.tocdepth);
1363 numberingModule->setEnabled(false);
1364 numberingModule->tocTW->clear();
1368 bulletsModule->setBullet(0, params.user_defined_bullet(0));
1369 bulletsModule->setBullet(1, params.user_defined_bullet(1));
1370 bulletsModule->setBullet(2, params.user_defined_bullet(2));
1371 bulletsModule->setBullet(3, params.user_defined_bullet(3));
1372 bulletsModule->init();
1375 int nitem = findToken(tex_graphics, params.graphicsDriver);
1377 latexModule->psdriverCO->setCurrentIndex(nitem);
1380 mathsModule->amsCB->setChecked(
1381 params.use_amsmath == BufferParams::package_on);
1382 mathsModule->amsautoCB->setChecked(
1383 params.use_amsmath == BufferParams::package_auto);
1385 mathsModule->esintCB->setChecked(
1386 params.use_esint == BufferParams::package_on);
1387 mathsModule->esintautoCB->setChecked(
1388 params.use_esint == BufferParams::package_auto);
1390 switch (params.spacing().getSpace()) {
1391 case Spacing::Other: nitem = 3; break;
1392 case Spacing::Double: nitem = 2; break;
1393 case Spacing::Onehalf: nitem = 1; break;
1394 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1398 latexModule->classCO->setCurrentIndex(params.getBaseClass());
1400 updatePagestyle(controller().textClass().opt_pagestyle(),
1403 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1404 if (params.spacing().getSpace() == Spacing::Other) {
1405 textLayoutModule->lspacingLE->setText(
1406 toqstr(params.spacing().getValueAsString()));
1410 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1411 textLayoutModule->indentRB->setChecked(true);
1413 textLayoutModule->skipRB->setChecked(true);
1416 switch (params.getDefSkip().kind()) {
1417 case VSpace::SMALLSKIP:
1420 case VSpace::MEDSKIP:
1423 case VSpace::BIGSKIP:
1426 case VSpace::LENGTH:
1429 string const length = params.getDefSkip().asLyXCommand();
1430 lengthToWidgets(textLayoutModule->skipLE,
1431 textLayoutModule->skipLengthCO,
1432 length, defaultUnit);
1439 textLayoutModule->skipCO->setCurrentIndex(skip);
1442 textLayoutModule->twoColumnCB->setChecked(
1443 params.columns == 2);
1445 // break listings_params to multiple lines
1447 InsetListingsParams(params.listings_params).separatedParams();
1448 textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1450 if (!params.options.empty()) {
1451 latexModule->optionsLE->setText(
1452 toqstr(params.options));
1454 latexModule->optionsLE->setText(QString());
1457 floatModule->set(params.float_placement);
1460 updateFontsize(controller().textClass().opt_fontsize(),
1463 int n = findToken(tex_fonts_roman, params.fontsRoman);
1465 fontModule->fontsRomanCO->setCurrentIndex(n);
1469 n = findToken(tex_fonts_sans, params.fontsSans);
1471 fontModule->fontsSansCO->setCurrentIndex(n);
1475 n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1477 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1481 fontModule->fontScCB->setChecked(params.fontsSC);
1482 fontModule->fontOsfCB->setChecked(params.fontsOSF);
1483 fontModule->scaleSansSB->setValue(params.fontsSansScale);
1484 fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1485 n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
1487 fontModule->fontsDefaultCO->setCurrentIndex(n);
1490 int const psize = params.papersize;
1491 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1492 setCustomPapersize(psize);
1494 bool const landscape =
1495 params.orientation == ORIENTATION_LANDSCAPE;
1496 pageLayoutModule->landscapeRB->setChecked(landscape);
1497 pageLayoutModule->portraitRB->setChecked(!landscape);
1499 pageLayoutModule->facingPagesCB->setChecked(
1500 params.sides == TextClass::TwoSides);
1503 lengthToWidgets(pageLayoutModule->paperwidthLE,
1504 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1506 lengthToWidgets(pageLayoutModule->paperheightLE,
1507 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1510 Ui::MarginsUi * m = marginsModule;
1512 setMargins(!params.use_geometry);
1514 lengthToWidgets(m->topLE, m->topUnit,
1515 params.topmargin, defaultUnit);
1517 lengthToWidgets(m->bottomLE, m->bottomUnit,
1518 params.bottommargin, defaultUnit);
1520 lengthToWidgets(m->innerLE, m->innerUnit,
1521 params.leftmargin, defaultUnit);
1523 lengthToWidgets(m->outerLE, m->outerUnit,
1524 params.rightmargin, defaultUnit);
1526 lengthToWidgets(m->headheightLE, m->headheightUnit,
1527 params.headheight, defaultUnit);
1529 lengthToWidgets(m->headsepLE, m->headsepUnit,
1530 params.headsep, defaultUnit);
1532 lengthToWidgets(m->footskipLE, m->footskipUnit,
1533 params.footskip, defaultUnit);
1535 branchesModule->update(params);
1538 PDFOptions const & pdf = params.pdfoptions();
1539 pdfSupportModule->use_hyperrefCB->setChecked(pdf.use_hyperref);
1540 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1541 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1542 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1543 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1545 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1546 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1547 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1549 pdfSupportModule->bookmarksopenlevelLE->setText(
1550 toqstr(pdf.bookmarksopenlevel));
1552 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1553 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1554 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1555 pdfSupportModule->backrefCB->setChecked(pdf.backref);
1556 pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1557 pdfSupportModule->fullscreenCB->setChecked
1558 (pdf.pagemode == pdf.pagemode_fullscreen);
1560 pdfSupportModule->optionsLE->setText(
1561 toqstr(pdf.quoted_options));
1565 void GuiDocumentDialog::applyView()
1567 apply(controller().params());
1571 void GuiDocumentDialog::saveDocDefault()
1573 // we have to apply the params first
1575 controller().saveAsDefault();
1579 void GuiDocumentDialog::updateContents()
1581 //update list of available modules
1582 QStringList strlist;
1583 vector<string> const modNames = controller().getModuleNames();
1584 vector<string>::const_iterator it = modNames.begin();
1585 for (; it != modNames.end(); ++it)
1586 strlist.push_back(toqstr(*it));
1587 available_model_.setStringList(strlist);
1588 //and selected ones, too
1589 QStringList strlist2;
1590 vector<string> const & selMods = controller().getSelectedModules();
1591 it = selMods.begin();
1592 for (; it != selMods.end(); ++it)
1593 strlist2.push_back(toqstr(*it));
1594 selected_model_.setStringList(strlist2);
1596 updateParams(controller().params());
1599 void GuiDocumentDialog::useClassDefaults()
1601 BufferParams & params = controller().params();
1603 params.setJustBaseClass(latexModule->classCO->currentIndex());
1604 params.useClassDefaults();
1609 bool GuiDocumentDialog::isValid()
1611 return validate_listings_params().empty();
1615 } // namespace frontend
1618 #include "GuiDocument_moc.cpp"