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"
18 #include "LengthCombo.h"
19 #include "PanelStack.h"
20 #include "qt_helpers.h"
21 #include "Validator.h"
23 // For the Branches module
24 #include "GuiBranches.h"
26 #include "LaTeXHighlighter.h"
28 #include "frontend_helpers.h"
29 #include "BufferParams.h"
33 #include "LyXRC.h" // defaultUnit
34 #include "TextClassList.h"
36 #include "PDFOptions.h"
38 #include "insets/InsetListingsParams.h"
40 #include "support/lstrings.h"
42 #include <boost/bind.hpp>
44 #include <QCloseEvent>
46 #include <QTextCursor>
50 using lyx::support::token;
51 using lyx::support::bformat;
52 using lyx::support::findToken;
53 using lyx::support::getVectorFromString;
64 std::vector<typename Pair::second_type> const
65 getSecond(std::vector<Pair> const & pr)
67 std::vector<typename Pair::second_type> tmp(pr.size());
68 std::transform(pr.begin(), pr.end(), tmp.begin(),
69 boost::bind(&Pair::second, _1));
73 char const * const tex_graphics[] =
75 "default", "dvips", "dvitops", "emtex",
76 "ln", "oztex", "textures", "none", ""
80 char const * const tex_graphics_gui[] =
82 N_("Default"), "Dvips", "DVItoPS", "EmTeX",
83 "LN", "OzTeX", "Textures", N_("None"), ""
87 char const * const tex_fonts_roman[] =
89 "default", "cmr", "lmodern", "ae", "times", "palatino",
90 "charter", "newcent", "bookman", "utopia", "beraserif",
91 "ccfonts", "chancery", ""
95 char const * tex_fonts_roman_gui[] =
97 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
98 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
99 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
100 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
105 char const * const tex_fonts_sans[] =
107 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
111 char const * tex_fonts_sans_gui[] =
113 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
114 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
118 char const * const tex_fonts_monospaced[] =
120 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
124 char const * tex_fonts_monospaced_gui[] =
126 N_("Default"), N_("Computer Modern Typewriter"),
127 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
128 N_("LuxiMono"), N_("CM Typewriter Light"), ""
132 vector<pair<string, lyx::docstring> > pagestyles;
138 /////////////////////////////////////////////////////////////////////
142 /////////////////////////////////////////////////////////////////////
144 PreambleModule::PreambleModule(): current_id_(0)
146 // This is not a memory leak. The object will be destroyed
148 (void) new LaTeXHighlighter(preambleTE->document());
149 setFocusProxy(preambleTE);
150 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
154 void PreambleModule::update(BufferParams const & params, BufferId id)
156 QString preamble = toqstr(params.preamble);
157 // Nothing to do if the params and preamble are unchanged.
158 if (id == current_id_
159 && preamble == preambleTE->document()->toPlainText())
162 QTextCursor cur = preambleTE->textCursor();
163 // Save the coords before switching to the new one.
164 preamble_coords_[current_id_] =
165 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
167 // Save the params address for further use.
169 preambleTE->document()->setPlainText(preamble);
170 Coords::const_iterator it = preamble_coords_.find(current_id_);
171 if (it == preamble_coords_.end())
172 // First time we open this one.
173 preamble_coords_[current_id_] = make_pair(0,0);
175 // Restore saved coords.
176 QTextCursor cur = preambleTE->textCursor();
177 cur.setPosition(it->second.first);
178 preambleTE->setTextCursor(cur);
179 preambleTE->verticalScrollBar()->setValue(it->second.second);
184 void PreambleModule::apply(BufferParams & params)
186 params.preamble = fromqstr(preambleTE->document()->toPlainText());
190 void PreambleModule::closeEvent(QCloseEvent * e)
192 // Save the coords before closing.
193 QTextCursor cur = preambleTE->textCursor();
194 preamble_coords_[current_id_] =
195 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
200 /////////////////////////////////////////////////////////////////////
204 /////////////////////////////////////////////////////////////////////
208 GuiDocumentDialog::GuiDocumentDialog(LyXView & lv)
209 : GuiDialog(lv, "document")
212 setController(new ControlDocument(*this));
213 setViewTitle(_("Document Settings"));
215 lang_ = getSecond(getLanguageData(false));
217 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
218 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
219 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
220 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
222 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
223 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
225 // Manage the restore, ok, apply, restore and cancel/close buttons
226 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
228 bc().setApply(applyPB);
229 bc().setCancel(closePB);
230 bc().setRestore(restorePB);
232 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
234 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
235 this, SLOT(change_adaptor()));
236 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
237 this, SLOT(setLSpacing(int)));
238 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
239 this, SLOT(change_adaptor()));
240 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
241 this, SLOT(change_adaptor()));
242 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
243 this, SLOT(change_adaptor()));
244 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
245 this, SLOT(change_adaptor()));
246 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
247 this, SLOT(change_adaptor()));
248 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
249 this, SLOT(change_adaptor()));
250 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
251 this, SLOT(setSkip(int)));
252 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
253 this, SLOT(enableSkip(bool)));
254 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
255 this, SLOT(change_adaptor()));
256 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
257 this, SLOT(change_adaptor()));
258 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
259 this, SLOT(change_adaptor()));
260 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
261 this, SLOT(set_listings_msg()));
262 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
263 this, SLOT(set_listings_msg()));
264 textLayoutModule->listingsTB->setPlainText(
265 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
266 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
267 textLayoutModule->lspacingLE));
268 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
269 textLayoutModule->skipLE));
271 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
272 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
273 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
274 textLayoutModule->skipCO->addItem(qt_("Length"));
275 // remove the %-items from the unit choice
276 textLayoutModule->skipLengthCO->noPercents();
277 textLayoutModule->lspacingCO->insertItem(
278 Spacing::Single, qt_("Single"));
279 textLayoutModule->lspacingCO->insertItem(
280 Spacing::Onehalf, qt_("OneHalf"));
281 textLayoutModule->lspacingCO->insertItem(
282 Spacing::Double, qt_("Double"));
283 textLayoutModule->lspacingCO->insertItem(
284 Spacing::Other, qt_("Custom"));
286 // initialize the length validator
287 bc().addCheckedLineEdit(textLayoutModule->skipLE);
289 fontModule = new UiWidget<Ui::FontUi>;
291 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
292 this, SLOT(change_adaptor()));
293 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
294 this, SLOT(romanChanged(int)));
295 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
296 this, SLOT(change_adaptor()));
297 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
298 this, SLOT(sansChanged(int)));
299 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
300 this, SLOT(change_adaptor()));
301 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
302 this, SLOT(ttChanged(int)));
303 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
304 this, SLOT(change_adaptor()));
305 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
306 this, SLOT(change_adaptor()));
307 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
308 this, SLOT(change_adaptor()));
309 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
310 this, SLOT(change_adaptor()));
311 connect(fontModule->fontScCB, SIGNAL(clicked()),
312 this, SLOT(change_adaptor()));
313 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
314 this, SLOT(change_adaptor()));
316 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
317 QString font = qt_(tex_fonts_roman_gui[n]);
318 if (!controller().isFontAvailable(tex_fonts_roman[n]))
319 font += qt_(" (not installed)");
320 fontModule->fontsRomanCO->addItem(font);
322 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
323 QString font = qt_(tex_fonts_sans_gui[n]);
324 if (!controller().isFontAvailable(tex_fonts_sans[n]))
325 font += qt_(" (not installed)");
326 fontModule->fontsSansCO->addItem(font);
328 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
329 QString font = qt_(tex_fonts_monospaced_gui[n]);
330 if (!controller().isFontAvailable(tex_fonts_monospaced[n]))
331 font += qt_(" (not installed)");
332 fontModule->fontsTypewriterCO->addItem(font);
335 fontModule->fontsizeCO->addItem(qt_("Default"));
336 fontModule->fontsizeCO->addItem(qt_("10"));
337 fontModule->fontsizeCO->addItem(qt_("11"));
338 fontModule->fontsizeCO->addItem(qt_("12"));
340 for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
341 fontModule->fontsDefaultCO->addItem(
342 qt_(ControlDocument::fontfamilies_gui[n]));
345 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
347 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
348 this, SLOT(setCustomPapersize(int)));
349 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
350 this, SLOT(setCustomPapersize(int)));
351 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
352 this, SLOT(portraitChanged()));
353 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
354 this, SLOT(change_adaptor()));
355 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
356 this, SLOT(change_adaptor()));
357 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
358 this, SLOT(change_adaptor()));
359 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
360 this, SLOT(change_adaptor()));
361 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
362 this, SLOT(change_adaptor()));
363 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
364 this, SLOT(change_adaptor()));
365 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
366 this, SLOT(change_adaptor()));
367 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
368 this, SLOT(change_adaptor()));
369 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
370 this, SLOT(change_adaptor()));
372 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
373 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
374 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
375 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
376 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
377 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
378 pageLayoutModule->paperheightL);
379 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
380 pageLayoutModule->paperwidthL);
383 QComboBox * cb = pageLayoutModule->papersizeCO;
384 cb->addItem(qt_("Default"));
385 cb->addItem(qt_("Custom"));
386 cb->addItem(qt_("US letter"));
387 cb->addItem(qt_("US legal"));
388 cb->addItem(qt_("US executive"));
389 cb->addItem(qt_("A3"));
390 cb->addItem(qt_("A4"));
391 cb->addItem(qt_("A5"));
392 cb->addItem(qt_("B3"));
393 cb->addItem(qt_("B4"));
394 cb->addItem(qt_("B5"));
395 // remove the %-items from the unit choice
396 pageLayoutModule->paperwidthUnitCO->noPercents();
397 pageLayoutModule->paperheightUnitCO->noPercents();
398 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
399 pageLayoutModule->paperheightLE));
400 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
401 pageLayoutModule->paperwidthLE));
404 marginsModule = new UiWidget<Ui::MarginsUi>;
406 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
407 this, SLOT(setCustomMargins(bool)));
408 connect(marginsModule->marginCB, SIGNAL(clicked()),
409 this, SLOT(change_adaptor()));
410 connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
411 this, SLOT(change_adaptor()));
412 connect(marginsModule->topUnit, SIGNAL(activated(int)),
413 this, SLOT(change_adaptor()));
414 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
415 this, SLOT(change_adaptor()));
416 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
417 this, SLOT(change_adaptor()));
418 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
419 this, SLOT(change_adaptor()));
420 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
421 this, SLOT(change_adaptor()));
422 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
423 this, SLOT(change_adaptor()));
424 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
425 this, SLOT(change_adaptor()));
426 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
427 this, SLOT(change_adaptor()));
428 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
429 this, SLOT(change_adaptor()));
430 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
431 this, SLOT(change_adaptor()));
432 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
433 this, SLOT(change_adaptor()));
434 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
435 this, SLOT(change_adaptor()));
436 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
437 this, SLOT(change_adaptor()));
438 marginsModule->topLE->setValidator(unsignedLengthValidator(
439 marginsModule->topLE));
440 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
441 marginsModule->bottomLE));
442 marginsModule->innerLE->setValidator(unsignedLengthValidator(
443 marginsModule->innerLE));
444 marginsModule->outerLE->setValidator(unsignedLengthValidator(
445 marginsModule->outerLE));
446 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
447 marginsModule->headsepLE));
448 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
449 marginsModule->headheightLE));
450 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
451 marginsModule->footskipLE));
453 bc().addCheckedLineEdit(marginsModule->topLE,
454 marginsModule->topL);
455 bc().addCheckedLineEdit(marginsModule->bottomLE,
456 marginsModule->bottomL);
457 bc().addCheckedLineEdit(marginsModule->innerLE,
458 marginsModule->innerL);
459 bc().addCheckedLineEdit(marginsModule->outerLE,
460 marginsModule->outerL);
461 bc().addCheckedLineEdit(marginsModule->headsepLE,
462 marginsModule->headsepL);
463 bc().addCheckedLineEdit(marginsModule->headheightLE,
464 marginsModule->headheightL);
465 bc().addCheckedLineEdit(marginsModule->footskipLE,
466 marginsModule->footskipL);
469 langModule = new UiWidget<Ui::LanguageUi>;
471 connect(langModule->languageCO, SIGNAL(activated(int)),
472 this, SLOT(change_adaptor()));
473 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
474 this, SLOT(change_adaptor()));
475 connect(langModule->otherencodingRB, SIGNAL(clicked()),
476 this, SLOT(change_adaptor()));
477 connect(langModule->encodingCO, SIGNAL(activated(int)),
478 this, SLOT(change_adaptor()));
479 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
480 this, SLOT(change_adaptor()));
482 vector<LanguagePair> const langs = getLanguageData(false);
483 vector<LanguagePair>::const_iterator lit = langs.begin();
484 vector<LanguagePair>::const_iterator lend = langs.end();
485 for (; lit != lend; ++lit) {
486 langModule->languageCO->addItem(toqstr(lit->first));
489 // Always put the default encoding in the first position.
490 // It is special because the displayed text is translated.
491 langModule->encodingCO->addItem(qt_("LaTeX default"));
492 Encodings::const_iterator it = encodings.begin();
493 Encodings::const_iterator const end = encodings.end();
494 for (; it != end; ++it)
495 langModule->encodingCO->addItem(toqstr(it->latexName()));
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>>"));
502 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
506 numberingModule = new UiWidget<Ui::NumberingUi>;
508 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
509 this, SLOT(change_adaptor()));
510 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
511 this, SLOT(change_adaptor()));
512 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
513 this, SLOT(updateNumbering()));
514 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
515 this, SLOT(updateNumbering()));
516 numberingModule->tocTW->setColumnCount(3);
517 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
518 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
519 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
522 biblioModule = new UiWidget<Ui::BiblioUi>;
523 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
524 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
525 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
526 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
528 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
529 this, SLOT(change_adaptor()));
530 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
531 this, SLOT(change_adaptor()));
532 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
533 this, SLOT(change_adaptor()));
534 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
535 this, SLOT(change_adaptor()));
536 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
537 this, SLOT(change_adaptor()));
539 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
540 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
541 biblioModule->citeStyleCO->setCurrentIndex(0);
544 mathsModule = new UiWidget<Ui::MathsUi>;
545 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
546 mathsModule->amsCB, SLOT(setDisabled(bool)));
547 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
548 mathsModule->esintCB, SLOT(setDisabled(bool)));
550 connect(mathsModule->amsCB, SIGNAL(clicked()),
551 this, SLOT(change_adaptor()));
552 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
553 this, SLOT(change_adaptor()));
554 connect(mathsModule->esintCB, SIGNAL(clicked()),
555 this, SLOT(change_adaptor()));
556 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
557 this, SLOT(change_adaptor()));
559 latexModule = new UiWidget<Ui::LaTeXUi>;
561 connect(latexModule->classCO, SIGNAL(activated(int)),
562 this, SLOT(change_adaptor()));
563 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
564 this, SLOT(change_adaptor()));
565 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
566 this, SLOT(change_adaptor()));
567 connect(latexModule->classCO, SIGNAL(activated(int)),
568 this, SLOT(classChanged()));
571 new GuiSelectionManager(latexModule->availableLV, latexModule->selectedLV,
572 latexModule->addPB, latexModule->deletePB,
573 latexModule->upPB, latexModule->downPB,
574 availableModel(), selectedModel());
575 connect(selectionManager, SIGNAL(updateHook()),
576 this, SLOT(updateModuleInfo()));
577 connect(selectionManager, SIGNAL(updateHook()),
578 this, SLOT(change_adaptor()));
580 // postscript drivers
581 for (int n = 0; tex_graphics[n][0]; ++n) {
582 QString enc = qt_(tex_graphics_gui[n]);
583 latexModule->psdriverCO->addItem(enc);
586 //FIXME This seems too involved with the kernel. Some of this
587 //should be moved to the controller---which should perhaps just
588 //give us a list of entries or something of the sort.
589 for (TextClassList::const_iterator cit = textclasslist.begin();
590 cit != textclasslist.end(); ++cit) {
591 if (cit->isTeXClassAvailable()) {
592 latexModule->classCO->addItem(toqstr(cit->description()));
595 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
596 latexModule->classCO->addItem(toqstr(item));
601 branchesModule = new GuiBranches;
602 connect(branchesModule, SIGNAL(changed()),
603 this, SLOT(change_adaptor()));
606 preambleModule = new PreambleModule;
607 connect(preambleModule, SIGNAL(changed()),
608 this, SLOT(change_adaptor()));
611 bulletsModule = new BulletsModule;
612 connect(bulletsModule, SIGNAL(changed()),
613 this, SLOT(change_adaptor()));
616 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
618 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
619 this, SLOT(change_adaptor()));
620 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
621 this, SLOT(change_adaptor()));
622 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
623 this, SLOT(change_adaptor()));
624 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
625 this, SLOT(change_adaptor()));
626 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
627 this, SLOT(change_adaptor()));
628 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
629 this, SLOT(change_adaptor()));
630 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
631 this, SLOT(change_adaptor()));
632 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
633 this, SLOT(change_adaptor()));
634 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
635 this, SLOT(change_adaptor()));
636 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
637 this, SLOT(change_adaptor()));
638 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
639 this, SLOT(change_adaptor()));
640 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
641 this, SLOT(change_adaptor()));
642 connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
643 this, SLOT(change_adaptor()));
644 connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
645 this, SLOT(change_adaptor()));
646 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
647 this, SLOT(change_adaptor()));
648 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
649 this, SLOT(change_adaptor()));
652 floatModule = new FloatPlacement;
653 connect(floatModule, SIGNAL(changed()),
654 this, SLOT(change_adaptor()));
656 docPS->addPanel(latexModule, _("Document Class"));
657 docPS->addPanel(fontModule, _("Fonts"));
658 docPS->addPanel(textLayoutModule, _("Text Layout"));
659 docPS->addPanel(pageLayoutModule, _("Page Layout"));
660 docPS->addPanel(marginsModule, _("Page Margins"));
661 docPS->addPanel(langModule, _("Language"));
662 docPS->addPanel(numberingModule, _("Numbering & TOC"));
663 docPS->addPanel(biblioModule, _("Bibliography"));
664 docPS->addPanel(pdfSupportModule, _("PDF Properties"));
665 docPS->addPanel(mathsModule, _("Math Options"));
666 docPS->addPanel(floatModule, _("Float Placement"));
667 docPS->addPanel(bulletsModule, _("Bullets"));
668 docPS->addPanel(branchesModule, _("Branches"));
669 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
670 docPS->setCurrentPanel(_("Document Class"));
671 // FIXME: hack to work around resizing bug in Qt >= 4.2
672 // bug verified with Qt 4.2.{0-3} (JSpitzm)
673 #if QT_VERSION >= 0x040200
674 docPS->updateGeometry();
679 ControlDocument & GuiDocumentDialog::controller()
681 return static_cast<ControlDocument &>(GuiDialog::controller());
685 void GuiDocumentDialog::showPreamble()
687 docPS->setCurrentPanel(_("LaTeX Preamble"));
691 void GuiDocumentDialog::saveDefaultClicked()
697 void GuiDocumentDialog::useDefaultsClicked()
703 void GuiDocumentDialog::change_adaptor()
709 docstring GuiDocumentDialog::validate_listings_params()
711 // use a cache here to avoid repeated validation
712 // of the same parameters
713 static string param_cache = string();
714 static docstring msg_cache = docstring();
716 if (textLayoutModule->bypassCB->isChecked())
719 string params = fromqstr(textLayoutModule->listingsED->toPlainText());
720 if (params != param_cache) {
721 param_cache = params;
722 msg_cache = InsetListingsParams(params).validate();
728 void GuiDocumentDialog::set_listings_msg()
730 static bool isOK = true;
731 docstring msg = validate_listings_params();
736 // listingsTB->setTextColor("black");
737 textLayoutModule->listingsTB->setPlainText(
738 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
741 // listingsTB->setTextColor("red");
742 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
747 void GuiDocumentDialog::closeEvent(QCloseEvent * e)
754 void GuiDocumentDialog::setLSpacing(int item)
756 textLayoutModule->lspacingLE->setEnabled(item == 3);
760 void GuiDocumentDialog::setSkip(int item)
762 bool const enable = (item == 3);
763 textLayoutModule->skipLE->setEnabled(enable);
764 textLayoutModule->skipLengthCO->setEnabled(enable);
768 void GuiDocumentDialog::enableSkip(bool skip)
770 textLayoutModule->skipCO->setEnabled(skip);
771 textLayoutModule->skipLE->setEnabled(skip);
772 textLayoutModule->skipLengthCO->setEnabled(skip);
774 setSkip(textLayoutModule->skipCO->currentIndex());
777 void GuiDocumentDialog::portraitChanged()
779 setMargins(pageLayoutModule->papersizeCO->currentIndex());
782 void GuiDocumentDialog::setMargins(bool custom)
784 marginsModule->marginCB->setChecked(custom);
785 setCustomMargins(custom);
789 void GuiDocumentDialog::setCustomPapersize(int papersize)
791 bool const custom = (papersize == 1);
793 pageLayoutModule->paperwidthL->setEnabled(custom);
794 pageLayoutModule->paperwidthLE->setEnabled(custom);
795 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
796 pageLayoutModule->paperheightL->setEnabled(custom);
797 pageLayoutModule->paperheightLE->setEnabled(custom);
798 pageLayoutModule->paperheightLE->setFocus();
799 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
803 void GuiDocumentDialog::setCustomMargins(bool custom)
805 marginsModule->topL->setEnabled(!custom);
806 marginsModule->topLE->setEnabled(!custom);
807 marginsModule->topUnit->setEnabled(!custom);
809 marginsModule->bottomL->setEnabled(!custom);
810 marginsModule->bottomLE->setEnabled(!custom);
811 marginsModule->bottomUnit->setEnabled(!custom);
813 marginsModule->innerL->setEnabled(!custom);
814 marginsModule->innerLE->setEnabled(!custom);
815 marginsModule->innerUnit->setEnabled(!custom);
817 marginsModule->outerL->setEnabled(!custom);
818 marginsModule->outerLE->setEnabled(!custom);
819 marginsModule->outerUnit->setEnabled(!custom);
821 marginsModule->headheightL->setEnabled(!custom);
822 marginsModule->headheightLE->setEnabled(!custom);
823 marginsModule->headheightUnit->setEnabled(!custom);
825 marginsModule->headsepL->setEnabled(!custom);
826 marginsModule->headsepLE->setEnabled(!custom);
827 marginsModule->headsepUnit->setEnabled(!custom);
829 marginsModule->footskipL->setEnabled(!custom);
830 marginsModule->footskipLE->setEnabled(!custom);
831 marginsModule->footskipUnit->setEnabled(!custom);
835 void GuiDocumentDialog::updateFontsize(string const & items, string const & sel)
837 fontModule->fontsizeCO->clear();
838 fontModule->fontsizeCO->addItem(qt_("Default"));
840 for (int n = 0; !token(items,'|',n).empty(); ++n)
841 fontModule->fontsizeCO->
842 addItem(toqstr(token(items,'|',n)));
844 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
845 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
846 fontModule->fontsizeCO->setCurrentIndex(n);
853 void GuiDocumentDialog::romanChanged(int item)
855 string const font = tex_fonts_roman[item];
856 fontModule->fontScCB->setEnabled(controller().providesSC(font));
857 fontModule->fontOsfCB->setEnabled(controller().providesOSF(font));
861 void GuiDocumentDialog::sansChanged(int item)
863 string const font = tex_fonts_sans[item];
864 bool scaleable = controller().providesScale(font);
865 fontModule->scaleSansSB->setEnabled(scaleable);
866 fontModule->scaleSansLA->setEnabled(scaleable);
870 void GuiDocumentDialog::ttChanged(int item)
872 string const font = tex_fonts_monospaced[item];
873 bool scaleable = controller().providesScale(font);
874 fontModule->scaleTypewriterSB->setEnabled(scaleable);
875 fontModule->scaleTypewriterLA->setEnabled(scaleable);
879 void GuiDocumentDialog::updatePagestyle(string const & items, string const & sel)
882 pageLayoutModule->pagestyleCO->clear();
883 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
885 for (int n = 0; !token(items,'|',n).empty(); ++n) {
886 string style = token(items, '|', n);
887 docstring style_gui = _(style);
888 pagestyles.push_back(pair<string, docstring>(style, style_gui));
889 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
892 if (sel == "default") {
893 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
899 for (size_t i = 0; i < pagestyles.size(); ++i)
900 if (pagestyles[i].first == sel)
901 nn = pageLayoutModule->pagestyleCO->findText(
902 toqstr(pagestyles[i].second));
905 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
909 void GuiDocumentDialog::classChanged()
911 BufferParams & params = controller().params();
912 textclass_type const tc = latexModule->classCO->currentIndex();
913 params.setJustBaseClass(tc);
914 if (lyxrc.auto_reset_options)
915 params.useClassDefaults();
920 void GuiDocumentDialog::updateModuleInfo()
922 selectionManager->update();
924 QListView const * const lv = selectionManager->selectedFocused() ?
925 latexModule->selectedLV :
926 latexModule->availableLV;
927 if (lv->selectionModel()->selectedIndexes().isEmpty())
928 latexModule->infoML->document()->clear();
930 QModelIndex const idx = lv->selectionModel()->currentIndex();
931 string const modName = fromqstr(idx.data().toString());
932 string desc = controller().getModuleDescription(modName);
933 vector<string> pkgList = controller().getPackageList(modName);
935 //this mess formats the package list as "pkg1, pkg2, and pkg3"
936 int const pkgListSize = pkgList.size();
937 for (int i = 0; i < pkgListSize; ++i) {
939 if (i == pkgListSize - 1) //last element
944 if (i == pkgListSize - 1) //last element
949 pkgdesc += pkgList[i];
951 if (!pkgdesc.empty())
952 desc += " Requires " + pkgdesc + ".";
953 latexModule->infoML->document()->setPlainText(toqstr(desc));
958 void GuiDocumentDialog::updateNumbering()
960 TextClass const & tclass = controller().params().getTextClass();
962 numberingModule->tocTW->setUpdatesEnabled(false);
963 numberingModule->tocTW->clear();
965 int const depth = numberingModule->depthSL->value();
966 int const toc = numberingModule->tocSL->value();
967 QString const no = qt_("No");
968 QString const yes = qt_("Yes");
969 TextClass::const_iterator end = tclass.end();
970 TextClass::const_iterator cit = tclass.begin();
971 QTreeWidgetItem * item = 0;
972 for ( ; cit != end ; ++cit) {
973 int const toclevel = (*cit)->toclevel;
974 if (toclevel != Layout::NOT_IN_TOC
975 && (*cit)->labeltype == LABEL_COUNTER) {
976 item = new QTreeWidgetItem(numberingModule->tocTW);
977 item->setText(0, toqstr(translateIfPossible((*cit)->name())));
978 item->setText(1, (toclevel <= depth) ? yes : no);
979 item->setText(2, (toclevel <= toc) ? yes : no);
983 numberingModule->tocTW->setUpdatesEnabled(true);
984 numberingModule->tocTW->update();
988 void GuiDocumentDialog::apply(BufferParams & params)
991 preambleModule->apply(params);
994 params.setCiteEngine(biblio::ENGINE_BASIC);
996 if (biblioModule->citeNatbibRB->isChecked()) {
997 bool const use_numerical_citations =
998 biblioModule->citeStyleCO->currentIndex();
999 if (use_numerical_citations)
1000 params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1002 params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1004 } else if (biblioModule->citeJurabibRB->isChecked())
1005 params.setCiteEngine(biblio::ENGINE_JURABIB);
1007 params.use_bibtopic =
1008 biblioModule->bibtopicCB->isChecked();
1010 // language & quotes
1011 if (langModule->defaultencodingRB->isChecked()) {
1012 params.inputenc = "auto";
1014 int i = langModule->encodingCO->currentIndex();
1016 params.inputenc = "default";
1019 fromqstr(langModule->encodingCO->currentText());
1022 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1023 switch (langModule->quoteStyleCO->currentIndex()) {
1025 lga = InsetQuotes::EnglishQ;
1028 lga = InsetQuotes::SwedishQ;
1031 lga = InsetQuotes::GermanQ;
1034 lga = InsetQuotes::PolishQ;
1037 lga = InsetQuotes::FrenchQ;
1040 lga = InsetQuotes::DanishQ;
1043 params.quotes_language = lga;
1045 int const pos = langModule->languageCO->currentIndex();
1046 params.language = lyx::languages.getLanguage(lang_[pos]);
1049 if (params.getTextClass().hasTocLevels()) {
1050 params.tocdepth = numberingModule->tocSL->value();
1051 params.secnumdepth = numberingModule->depthSL->value();
1055 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1056 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1057 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1058 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1061 params.graphicsDriver =
1062 tex_graphics[latexModule->psdriverCO->currentIndex()];
1065 params.clearLayoutModules();
1066 QStringList const selMods = selectedModel()->stringList();
1067 for (int i = 0; i != selMods.size(); ++i)
1068 params.addLayoutModule(lyx::fromqstr(selMods[i]));
1071 if (mathsModule->amsautoCB->isChecked()) {
1072 params.use_amsmath = BufferParams::package_auto;
1074 if (mathsModule->amsCB->isChecked())
1075 params.use_amsmath = BufferParams::package_on;
1077 params.use_amsmath = BufferParams::package_off;
1080 if (mathsModule->esintautoCB->isChecked())
1081 params.use_esint = BufferParams::package_auto;
1083 if (mathsModule->esintCB->isChecked())
1084 params.use_esint = BufferParams::package_on;
1086 params.use_esint = BufferParams::package_off;
1090 params.setJustBaseClass(latexModule->classCO->currentIndex());
1092 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1093 params.pagestyle = "default";
1095 docstring style_gui =
1096 qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1097 for (size_t i = 0; i < pagestyles.size(); ++i)
1098 if (pagestyles[i].second == style_gui)
1099 params.pagestyle = pagestyles[i].first;
1102 switch (textLayoutModule->lspacingCO->currentIndex()) {
1104 params.spacing().set(Spacing::Single);
1107 params.spacing().set(Spacing::Onehalf);
1110 params.spacing().set(Spacing::Double);
1113 params.spacing().set(Spacing::Other,
1114 fromqstr(textLayoutModule->lspacingLE->text()));
1118 if (textLayoutModule->twoColumnCB->isChecked())
1123 // text should have passed validation
1124 params.listings_params =
1125 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1127 if (textLayoutModule->indentRB->isChecked())
1128 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1130 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1132 switch (textLayoutModule->skipCO->currentIndex()) {
1134 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1137 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1140 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1145 widgetsToLength(textLayoutModule->skipLE,
1146 textLayoutModule->skipLengthCO)
1148 params.setDefSkip(vs);
1152 // DocumentDefskipCB assures that this never happens
1153 // so Assert then !!! - jbl
1154 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1159 fromqstr(latexModule->optionsLE->text());
1161 params.float_placement = floatModule->get();
1165 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1168 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1170 params.fontsTypewriter =
1171 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1173 params.fontsSansScale = fontModule->scaleSansSB->value();
1175 params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1177 params.fontsSC = fontModule->fontScCB->isChecked();
1179 params.fontsOSF = fontModule->fontOsfCB->isChecked();
1181 params.fontsDefaultFamily = ControlDocument::fontfamilies[
1182 fontModule->fontsDefaultCO->currentIndex()];
1184 if (fontModule->fontsizeCO->currentIndex() == 0)
1185 params.fontsize = "default";
1188 fromqstr(fontModule->fontsizeCO->currentText());
1191 params.papersize = PAPER_SIZE(
1192 pageLayoutModule->papersizeCO->currentIndex());
1194 // custom, A3, B3 and B4 paper sizes need geometry
1195 int psize = pageLayoutModule->papersizeCO->currentIndex();
1196 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1198 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1199 pageLayoutModule->paperwidthUnitCO);
1201 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1202 pageLayoutModule->paperheightUnitCO);
1204 if (pageLayoutModule->facingPagesCB->isChecked())
1205 params.sides = TextClass::TwoSides;
1207 params.sides = TextClass::OneSide;
1209 if (pageLayoutModule->landscapeRB->isChecked())
1210 params.orientation = ORIENTATION_LANDSCAPE;
1212 params.orientation = ORIENTATION_PORTRAIT;
1215 params.use_geometry =
1216 (!marginsModule->marginCB->isChecked()
1219 Ui::MarginsUi const * m(marginsModule);
1221 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1222 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1223 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1224 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1225 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1226 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1227 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1229 branchesModule->apply(params);
1232 PDFOptions & pdf = params.pdfoptions();
1233 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
1234 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1235 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1236 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1237 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1239 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1240 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1241 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1242 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
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;
1252 pdf.pagemode.clear();
1253 pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1254 if (pdf.use_hyperref || !pdf.empty())
1255 pdf.store_options = true;
1259 /** Return the position of val in the vector if found.
1260 If not found, return 0.
1263 static size_t findPos(std::vector<A> const & vec, A const & val)
1265 typename std::vector<A>::const_iterator it =
1266 std::find(vec.begin(), vec.end(), val);
1267 if (it == vec.end())
1269 return distance(vec.begin(), it);
1273 void GuiDocumentDialog::updateParams()
1275 BufferParams const & params = controller().params();
1276 updateParams(params);
1280 void GuiDocumentDialog::updateParams(BufferParams const & params)
1282 // set the default unit
1283 // FIXME: move to controller
1284 Length::UNIT defaultUnit = Length::CM;
1285 switch (lyxrc.default_papersize) {
1286 case PAPER_DEFAULT: break;
1288 case PAPER_USLETTER:
1290 case PAPER_USEXECUTIVE:
1291 defaultUnit = Length::IN;
1300 defaultUnit = Length::CM;
1307 preambleModule->update(params, controller().id());
1310 biblioModule->citeDefaultRB->setChecked(
1311 params.getEngine() == biblio::ENGINE_BASIC);
1313 biblioModule->citeNatbibRB->setChecked(
1314 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1315 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1317 biblioModule->citeStyleCO->setCurrentIndex(
1318 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1320 biblioModule->citeJurabibRB->setChecked(
1321 params.getEngine() == biblio::ENGINE_JURABIB);
1323 biblioModule->bibtopicCB->setChecked(
1324 params.use_bibtopic);
1326 // language & quotes
1327 int const pos = int(findPos(lang_,
1328 params.language->lang()));
1329 langModule->languageCO->setCurrentIndex(pos);
1331 langModule->quoteStyleCO->setCurrentIndex(
1332 params.quotes_language);
1334 bool default_enc = true;
1335 if (params.inputenc != "auto") {
1336 default_enc = false;
1337 if (params.inputenc == "default") {
1338 langModule->encodingCO->setCurrentIndex(0);
1340 int const i = langModule->encodingCO->findText(
1341 toqstr(params.inputenc));
1343 langModule->encodingCO->setCurrentIndex(i);
1345 // unknown encoding. Set to default.
1349 langModule->defaultencodingRB->setChecked(default_enc);
1350 langModule->otherencodingRB->setChecked(!default_enc);
1353 int const min_toclevel = controller().textClass().min_toclevel();
1354 int const max_toclevel = controller().textClass().max_toclevel();
1355 if (controller().textClass().hasTocLevels()) {
1356 numberingModule->setEnabled(true);
1357 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1358 numberingModule->depthSL->setMaximum(max_toclevel);
1359 numberingModule->depthSL->setValue(params.secnumdepth);
1360 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1361 numberingModule->tocSL->setMaximum(max_toclevel);
1362 numberingModule->tocSL->setValue(params.tocdepth);
1365 numberingModule->setEnabled(false);
1366 numberingModule->tocTW->clear();
1370 bulletsModule->setBullet(0, params.user_defined_bullet(0));
1371 bulletsModule->setBullet(1, params.user_defined_bullet(1));
1372 bulletsModule->setBullet(2, params.user_defined_bullet(2));
1373 bulletsModule->setBullet(3, params.user_defined_bullet(3));
1374 bulletsModule->init();
1377 int nitem = findToken(tex_graphics, params.graphicsDriver);
1379 latexModule->psdriverCO->setCurrentIndex(nitem);
1382 mathsModule->amsCB->setChecked(
1383 params.use_amsmath == BufferParams::package_on);
1384 mathsModule->amsautoCB->setChecked(
1385 params.use_amsmath == BufferParams::package_auto);
1387 mathsModule->esintCB->setChecked(
1388 params.use_esint == BufferParams::package_on);
1389 mathsModule->esintautoCB->setChecked(
1390 params.use_esint == BufferParams::package_auto);
1392 switch (params.spacing().getSpace()) {
1393 case Spacing::Other: nitem = 3; break;
1394 case Spacing::Double: nitem = 2; break;
1395 case Spacing::Onehalf: nitem = 1; break;
1396 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1400 latexModule->classCO->setCurrentIndex(params.getBaseClass());
1402 updatePagestyle(controller().textClass().opt_pagestyle(),
1405 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1406 if (params.spacing().getSpace() == Spacing::Other) {
1407 textLayoutModule->lspacingLE->setText(
1408 toqstr(params.spacing().getValueAsString()));
1412 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1413 textLayoutModule->indentRB->setChecked(true);
1415 textLayoutModule->skipRB->setChecked(true);
1418 switch (params.getDefSkip().kind()) {
1419 case VSpace::SMALLSKIP:
1422 case VSpace::MEDSKIP:
1425 case VSpace::BIGSKIP:
1428 case VSpace::LENGTH:
1431 string const length = params.getDefSkip().asLyXCommand();
1432 lengthToWidgets(textLayoutModule->skipLE,
1433 textLayoutModule->skipLengthCO,
1434 length, defaultUnit);
1441 textLayoutModule->skipCO->setCurrentIndex(skip);
1444 textLayoutModule->twoColumnCB->setChecked(
1445 params.columns == 2);
1447 // break listings_params to multiple lines
1449 InsetListingsParams(params.listings_params).separatedParams();
1450 textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1452 if (!params.options.empty()) {
1453 latexModule->optionsLE->setText(
1454 toqstr(params.options));
1456 latexModule->optionsLE->setText(QString());
1459 floatModule->set(params.float_placement);
1462 updateFontsize(controller().textClass().opt_fontsize(),
1465 int n = findToken(tex_fonts_roman, params.fontsRoman);
1467 fontModule->fontsRomanCO->setCurrentIndex(n);
1471 n = findToken(tex_fonts_sans, params.fontsSans);
1473 fontModule->fontsSansCO->setCurrentIndex(n);
1477 n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1479 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1483 fontModule->fontScCB->setChecked(params.fontsSC);
1484 fontModule->fontOsfCB->setChecked(params.fontsOSF);
1485 fontModule->scaleSansSB->setValue(params.fontsSansScale);
1486 fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1487 n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
1489 fontModule->fontsDefaultCO->setCurrentIndex(n);
1492 int const psize = params.papersize;
1493 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1494 setCustomPapersize(psize);
1496 bool const landscape =
1497 params.orientation == ORIENTATION_LANDSCAPE;
1498 pageLayoutModule->landscapeRB->setChecked(landscape);
1499 pageLayoutModule->portraitRB->setChecked(!landscape);
1501 pageLayoutModule->facingPagesCB->setChecked(
1502 params.sides == TextClass::TwoSides);
1505 lengthToWidgets(pageLayoutModule->paperwidthLE,
1506 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1508 lengthToWidgets(pageLayoutModule->paperheightLE,
1509 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1512 Ui::MarginsUi * m = marginsModule;
1514 setMargins(!params.use_geometry);
1516 lengthToWidgets(m->topLE, m->topUnit,
1517 params.topmargin, defaultUnit);
1519 lengthToWidgets(m->bottomLE, m->bottomUnit,
1520 params.bottommargin, defaultUnit);
1522 lengthToWidgets(m->innerLE, m->innerUnit,
1523 params.leftmargin, defaultUnit);
1525 lengthToWidgets(m->outerLE, m->outerUnit,
1526 params.rightmargin, defaultUnit);
1528 lengthToWidgets(m->headheightLE, m->headheightUnit,
1529 params.headheight, defaultUnit);
1531 lengthToWidgets(m->headsepLE, m->headsepUnit,
1532 params.headsep, defaultUnit);
1534 lengthToWidgets(m->footskipLE, m->footskipUnit,
1535 params.footskip, defaultUnit);
1537 branchesModule->update(params);
1540 PDFOptions const & pdf = params.pdfoptions();
1541 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
1542 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1543 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1544 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1545 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1547 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1548 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1549 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1551 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
1553 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1554 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1555 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1556 pdfSupportModule->backrefCB->setChecked(pdf.backref);
1557 pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1558 pdfSupportModule->fullscreenCB->setChecked
1559 (pdf.pagemode == pdf.pagemode_fullscreen);
1561 pdfSupportModule->optionsLE->setText(
1562 toqstr(pdf.quoted_options));
1566 void GuiDocumentDialog::applyView()
1568 apply(controller().params());
1572 void GuiDocumentDialog::saveDocDefault()
1574 // we have to apply the params first
1576 controller().saveAsDefault();
1580 void GuiDocumentDialog::updateContents()
1582 //update list of available modules
1583 QStringList strlist;
1584 vector<string> const modNames = controller().getModuleNames();
1585 vector<string>::const_iterator it = modNames.begin();
1586 for (; it != modNames.end(); ++it)
1587 strlist.push_back(toqstr(*it));
1588 available_model_.setStringList(strlist);
1589 //and selected ones, too
1590 QStringList strlist2;
1591 vector<string> const & selMods = controller().getSelectedModules();
1592 it = selMods.begin();
1593 for (; it != selMods.end(); ++it)
1594 strlist2.push_back(toqstr(*it));
1595 selected_model_.setStringList(strlist2);
1597 updateParams(controller().params());
1600 void GuiDocumentDialog::useClassDefaults()
1602 BufferParams & params = controller().params();
1604 params.setJustBaseClass(latexModule->classCO->currentIndex());
1605 params.useClassDefaults();
1610 bool GuiDocumentDialog::isValid()
1612 return validate_listings_params().empty();
1616 } // namespace frontend
1619 #include "GuiDocument_moc.cpp"