]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QDocumentDialog.C
Fix unreported bug related to 3246 by Richard Heck:
[lyx.git] / src / frontends / qt4 / QDocumentDialog.C
1 /**
2  * \file QDocumentDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QBranches.h"
15 #include "QDocument.h"
16 #include "QDocumentDialog.h"
17
18 #include <QCloseEvent>
19
20 #include "FloatPlacement.h"
21 #include "lengthcombo.h"
22 #include "validators.h"
23 #include "panelstack.h"
24 #include "Qt2BC.h"
25 #include "checkedwidgets.h"
26 #include "qt_helpers.h"
27 // For latexHighlighter use in the preamble.
28 #include "QViewSource.h"
29
30 #include "bufferparams.h"
31 #include "encoding.h"
32 #include "gettext.h"
33 #include "helper_funcs.h" // getSecond()
34 #include "language.h"
35 #include "lyxrc.h" // defaultUnit
36 #include "lyxtextclasslist.h"
37 #include "tex-strings.h" // tex_graphics
38 #include "Spacing.h"
39
40 #include "frontends/controllers/biblio.h"
41 #include "controllers/ControlDocument.h"
42 #include "controllers/frnt_lang.h"
43
44 #include "support/lstrings.h"
45
46 #include "controllers/ControlDocument.h"
47 #include "controllers/frnt_lang.h"
48
49
50 using lyx::support::token;
51 using lyx::support::bformat;
52 using lyx::support::findToken;
53 using lyx::support::getVectorFromString;
54
55 using std::distance;
56 using std::vector;
57 using std::string;
58
59
60 namespace lyx {
61 namespace frontend {
62
63
64 QDocumentDialog::QDocumentDialog(QDocument * form)
65         : form_(form),
66         lang_(getSecond(getLanguageData(false)))
67 {
68         setupUi(this);
69
70         connect(okPB, SIGNAL(clicked()),
71                 form, SLOT(slotOK()));
72         connect(applyPB, SIGNAL(clicked()),
73                 form, SLOT(slotApply()));
74         connect(closePB, SIGNAL(clicked()),
75                 form, SLOT(slotClose()));
76         connect(restorePB, SIGNAL(clicked()),
77                 form, SLOT(slotRestore()));
78
79
80         connect(savePB, SIGNAL( clicked() ), 
81                 this, SLOT( saveDefaultClicked() ) );
82         connect(defaultPB, SIGNAL( clicked() ), 
83                 this, SLOT( useDefaultsClicked() ) );
84
85         // Manage the restore, ok, apply, restore and cancel/close buttons
86         form_->bcview().setOK(okPB);
87         form_->bcview().setApply(applyPB);
88         form_->bcview().setCancel(closePB);
89         form_->bcview().setRestore(restorePB);
90
91
92         textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
93         // text layout
94         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
95         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int)));
96         connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
97         connect(textLayoutModule->skipRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
98         connect(textLayoutModule->indentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
99         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
100         connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
101         connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
102         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int)));
103         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool)));
104         connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
105         textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
106                 textLayoutModule->lspacingLE));
107         textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
108                 textLayoutModule->skipLE));
109
110         textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
111         textLayoutModule->skipCO->addItem(qt_("MedSkip"));
112         textLayoutModule->skipCO->addItem(qt_("BigSkip"));
113         textLayoutModule->skipCO->addItem(qt_("Length"));
114         // remove the %-items from the unit choice
115         textLayoutModule->skipLengthCO->noPercents();
116         textLayoutModule->lspacingCO->insertItem(
117                 Spacing::Single, qt_("Single"));
118         textLayoutModule->lspacingCO->insertItem(
119                 Spacing::Onehalf, qt_("OneHalf"));
120         textLayoutModule->lspacingCO->insertItem(
121                 Spacing::Double, qt_("Double"));
122         textLayoutModule->lspacingCO->insertItem(
123                 Spacing::Other, qt_("Custom"));
124
125         // initialize the length validator
126         addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
127
128
129
130
131         fontModule = new UiWidget<Ui::FontUi>;
132         // fonts
133         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
134         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(romanChanged(int)));
135         connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
136         connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(sansChanged(int)));
137         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
138         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(ttChanged(int)));
139         connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
140         connect(fontModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
141         connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
142         connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
143         connect(fontModule->fontScCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
144         connect(fontModule->fontOsfCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
145
146         for (int n = 0; tex_fonts_roman[n][0]; ++n) {
147                 QString font = toqstr(tex_fonts_roman_gui[n]);
148                 if (!form_->controller().isFontAvailable(tex_fonts_roman[n]))
149                         font += qt_(" (not installed)");
150                 fontModule->fontsRomanCO->addItem(font);
151         }
152         for (int n = 0; tex_fonts_sans[n][0]; ++n) {
153                 QString font = toqstr(tex_fonts_sans_gui[n]);
154                 if (!form_->controller().isFontAvailable(tex_fonts_sans[n]))
155                         font += qt_(" (not installed)");
156                 fontModule->fontsSansCO->addItem(font);
157         }
158         for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
159                 QString font = toqstr(tex_fonts_monospaced_gui[n]);
160                 if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n]))
161                         font += qt_(" (not installed)");
162                 fontModule->fontsTypewriterCO->addItem(font);
163         }
164
165         fontModule->fontsizeCO->addItem(qt_("default"));
166         fontModule->fontsizeCO->addItem(qt_("10"));
167         fontModule->fontsizeCO->addItem(qt_("11"));
168         fontModule->fontsizeCO->addItem(qt_("12"));
169
170         for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
171                 fontModule->fontsDefaultCO->addItem(
172                         qt_(ControlDocument::fontfamilies_gui[n]));
173
174
175
176
177         pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
178         // page layout
179         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
180         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
181         connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(portraitChanged()));
182         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
183         connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
184         connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
185         connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
186         connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
187         connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
188         connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
189         connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
190         connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
191         pageLayoutModule->pagestyleCO->addItem(qt_("default"));
192         pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
193         pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
194         pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
195         pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
196         addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE,
197                 pageLayoutModule->paperheightL);
198         addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
199                 pageLayoutModule->paperwidthL);
200
201         // paper
202         QComboBox * cb = pageLayoutModule->papersizeCO;
203         cb->addItem(qt_("Default"));
204         cb->addItem(qt_("Custom"));
205         cb->addItem(qt_("US letter"));
206         cb->addItem(qt_("US legal"));
207         cb->addItem(qt_("US executive"));
208         cb->addItem(qt_("A3"));
209         cb->addItem(qt_("A4"));
210         cb->addItem(qt_("A5"));
211         cb->addItem(qt_("B3"));
212         cb->addItem(qt_("B4"));
213         cb->addItem(qt_("B5"));
214         // remove the %-items from the unit choice
215         pageLayoutModule->paperwidthUnitCO->noPercents();
216         pageLayoutModule->paperheightUnitCO->noPercents();
217         pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
218                 pageLayoutModule->paperheightLE));
219         pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
220                 pageLayoutModule->paperwidthLE));
221
222
223
224
225         marginsModule = new UiWidget<Ui::MarginsUi>;
226         // margins
227         connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(setCustomMargins(bool)));
228         connect(marginsModule->marginCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
229         connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
230         connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
231         connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
232         connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
233         connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
234         connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
235         connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
236         connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
237         connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
238         connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
239         connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
240         connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
241         connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
242         connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
243         marginsModule->topLE->setValidator(unsignedLengthValidator(
244                 marginsModule->topLE));
245         marginsModule->bottomLE->setValidator(unsignedLengthValidator(
246                 marginsModule->bottomLE));
247         marginsModule->innerLE->setValidator(unsignedLengthValidator(
248                 marginsModule->innerLE));
249         marginsModule->outerLE->setValidator(unsignedLengthValidator(
250                 marginsModule->outerLE));
251         marginsModule->headsepLE->setValidator(unsignedLengthValidator(
252                 marginsModule->headsepLE));
253         marginsModule->headheightLE->setValidator(unsignedLengthValidator(
254                 marginsModule->headheightLE));
255         marginsModule->footskipLE->setValidator(unsignedLengthValidator(
256                 marginsModule->footskipLE));
257
258         addCheckedLineEdit(form_->bcview(), marginsModule->topLE,
259                 marginsModule->topL);
260         addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE,
261                 marginsModule->bottomL);
262         addCheckedLineEdit(form_->bcview(), marginsModule->innerLE,
263                 marginsModule->innerL);
264         addCheckedLineEdit(form_->bcview(), marginsModule->outerLE,
265                 marginsModule->outerL);
266         addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE,
267                 marginsModule->headsepL);
268         addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE,
269                 marginsModule->headheightL);
270         addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE,
271                 marginsModule->footskipL);
272
273
274
275
276
277         langModule = new UiWidget<Ui::LanguageUi>;
278         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingL, SLOT(setDisabled(bool)));
279         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingCO, SLOT(setDisabled(bool)));
280         // language & quote
281         connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
282         connect(langModule->defaultencodingCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
283         connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
284         connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
285         // language & quotes
286         vector<LanguagePair> const langs = getLanguageData(false);
287         vector<LanguagePair>::const_iterator lit  = langs.begin();
288         vector<LanguagePair>::const_iterator lend = langs.end();
289         for (; lit != lend; ++lit) {
290                 langModule->languageCO->addItem(
291                         toqstr(lit->first));
292         }
293
294         // Always put the default encoding in the first position.
295         // It is special because the displayed text is translated.
296         langModule->encodingCO->addItem(qt_("LaTeX default"));
297         Encodings::const_iterator it = encodings.begin();
298         Encodings::const_iterator const end = encodings.end();
299         for (; it != end; ++it)
300                 langModule->encodingCO->addItem(toqstr(it->latexName()));
301
302         langModule->quoteStyleCO->addItem(qt_("``text''"));
303         langModule->quoteStyleCO->addItem(qt_("''text''"));
304         langModule->quoteStyleCO->addItem(qt_(",,text``"));
305         langModule->quoteStyleCO->addItem(qt_(",,text''"));
306         langModule->quoteStyleCO->addItem(qt_("<<text>>"));
307         langModule->quoteStyleCO->addItem(qt_(">>text<<"));
308
309
310
311         numberingModule = new UiWidget<Ui::NumberingUi>;
312         // numbering
313         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
314         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
315         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
316         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
317         numberingModule->tocTW->setColumnCount(3);
318         numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
319         numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
320         numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
321
322
323         biblioModule = new UiWidget<Ui::BiblioUi>;
324         connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) );
325         connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) );
326         // biblio
327         connect(biblioModule->citeDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
328         connect(biblioModule->citeNatbibRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
329         connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
330         connect(biblioModule->citeJurabibRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
331         connect(biblioModule->bibtopicCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
332         // biblio
333         biblioModule->citeStyleCO->addItem(qt_("Author-year"));
334         biblioModule->citeStyleCO->addItem(qt_("Numerical"));
335         biblioModule->citeStyleCO->setCurrentIndex(0);
336
337
338
339         mathsModule = new UiWidget<Ui::MathsUi>;
340         connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), mathsModule->amsCB, SLOT(setDisabled(bool)));
341         connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)), mathsModule->esintCB, SLOT(setDisabled(bool)));
342         // maths
343         connect(mathsModule->amsCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
344         connect(mathsModule->amsautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
345         connect(mathsModule->esintCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
346         connect(mathsModule->esintautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
347
348         latexModule = new UiWidget<Ui::LaTeXUi>;
349         // latex class
350         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
351         connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
352         connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
353         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged()));
354         // packages
355         for (int n = 0; tex_graphics[n][0]; ++n) {
356                 QString enc = tex_graphics[n];
357                 latexModule->psdriverCO->addItem(enc);
358         }
359         // latex
360         for (LyXTextClassList::const_iterator cit = textclasslist.begin();
361              cit != textclasslist.end(); ++cit) {
362                 if (cit->isTeXClassAvailable()) {
363                         latexModule->classCO->addItem(toqstr(cit->description()));
364                 } else {
365                         docstring item =
366                                 bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description()));
367                         latexModule->classCO->addItem(toqstr(item));
368                 }
369         }
370
371         // branches
372         branchesModule = new QBranches;
373         connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
374
375         // preamble
376         preambleModule = new UiWidget<Ui::PreambleUi>;
377         connect(preambleModule->preambleTE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
378         // This is not a memory leak. The object will be destroyed
379         // with preambleModule.
380         new latexHighlighter(preambleModule->preambleTE->document());
381
382
383         // bullets
384         bulletsModule = new BulletsModule;
385         connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
386
387
388         // float
389         floatModule = new FloatPlacement;
390         connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
391
392         docPS->addPanel(latexModule, _("Document Class"));
393         docPS->addPanel(fontModule, _("Fonts"));
394         docPS->addPanel(textLayoutModule, _("Text Layout"));
395         docPS->addPanel(pageLayoutModule, _("Page Layout"));
396         docPS->addPanel(marginsModule, _("Page Margins"));
397         docPS->addPanel(langModule, _("Language"));
398         docPS->addPanel(numberingModule, _("Numbering & TOC"));
399         docPS->addPanel(biblioModule, _("Bibliography"));
400         docPS->addPanel(mathsModule, _("Math Options"));
401         docPS->addPanel(floatModule, _("Float Placement"));
402         docPS->addPanel(bulletsModule, _("Bullets"));
403         docPS->addPanel(branchesModule, _("Branches"));
404         docPS->addPanel(preambleModule, _("LaTeX Preamble"));
405         docPS->setCurrentPanel(_("Document Class"));
406 // FIXME: hack to work around resizing bug in Qt >= 4.2
407 // bug verified with Qt 4.2.{0-3} (JSpitzm)
408 #if QT_VERSION >= 0x040200
409         docPS->updateGeometry();
410 #endif
411 }
412
413
414 QDocumentDialog::~QDocumentDialog()
415 {
416 }
417
418
419 void QDocumentDialog::showPreamble()
420 {
421         docPS->setCurrentPanel(_("LaTeX Preamble"));
422 }
423
424
425 void QDocumentDialog::saveDefaultClicked()
426 {
427         form_->saveDocDefault();
428 }
429
430
431 void QDocumentDialog::useDefaultsClicked()
432 {
433         form_->useClassDefaults();
434 }
435
436
437 void QDocumentDialog::change_adaptor()
438 {
439         form_->changed();
440 }
441
442
443 void QDocumentDialog::closeEvent(QCloseEvent * e)
444 {
445         form_->slotWMHide();
446         e->accept();
447 }
448
449
450 void QDocumentDialog::setLSpacing(int item)
451 {
452         textLayoutModule->lspacingLE->setEnabled(item == 3);
453 }
454
455
456 void QDocumentDialog::setSkip(int item)
457 {
458         bool const enable = (item == 3);
459         textLayoutModule->skipLE->setEnabled(enable);
460         textLayoutModule->skipLengthCO->setEnabled(enable);
461 }
462
463
464 void QDocumentDialog::enableSkip(bool skip)
465 {
466         textLayoutModule->skipCO->setEnabled(skip);
467         textLayoutModule->skipLE->setEnabled(skip);
468         textLayoutModule->skipLengthCO->setEnabled(skip);
469         if (skip)
470                 setSkip(textLayoutModule->skipCO->currentIndex());
471 }
472
473 void QDocumentDialog::portraitChanged()
474 {
475         setMargins(pageLayoutModule->papersizeCO->currentIndex());
476 }
477
478 void QDocumentDialog::setMargins(bool custom)
479 {
480         marginsModule->marginCB->setChecked(custom);
481         setCustomMargins(custom);
482 }
483
484
485 void QDocumentDialog::setCustomPapersize(int papersize)
486 {
487         bool const custom = (papersize == 1);
488
489         pageLayoutModule->paperwidthL->setEnabled(custom);
490         pageLayoutModule->paperwidthLE->setEnabled(custom);
491         pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
492         pageLayoutModule->paperheightL->setEnabled(custom);
493         pageLayoutModule->paperheightLE->setEnabled(custom);
494         pageLayoutModule->paperheightLE->setFocus();
495         pageLayoutModule->paperheightUnitCO->setEnabled(custom);
496 }
497
498
499 void QDocumentDialog::setCustomMargins(bool custom)
500 {
501         marginsModule->topL->setEnabled(!custom);
502         marginsModule->topLE->setEnabled(!custom);
503         marginsModule->topUnit->setEnabled(!custom);
504
505         marginsModule->bottomL->setEnabled(!custom);
506         marginsModule->bottomLE->setEnabled(!custom);
507         marginsModule->bottomUnit->setEnabled(!custom);
508
509         marginsModule->innerL->setEnabled(!custom);
510         marginsModule->innerLE->setEnabled(!custom);
511         marginsModule->innerUnit->setEnabled(!custom);
512
513         marginsModule->outerL->setEnabled(!custom);
514         marginsModule->outerLE->setEnabled(!custom);
515         marginsModule->outerUnit->setEnabled(!custom);
516
517         marginsModule->headheightL->setEnabled(!custom);
518         marginsModule->headheightLE->setEnabled(!custom);
519         marginsModule->headheightUnit->setEnabled(!custom);
520
521         marginsModule->headsepL->setEnabled(!custom);
522         marginsModule->headsepLE->setEnabled(!custom);
523         marginsModule->headsepUnit->setEnabled(!custom);
524
525         marginsModule->footskipL->setEnabled(!custom);
526         marginsModule->footskipLE->setEnabled(!custom);
527         marginsModule->footskipUnit->setEnabled(!custom);
528 }
529
530
531 void QDocumentDialog::updateFontsize(string const & items, string const & sel)
532 {
533         fontModule->fontsizeCO->clear();
534         fontModule->fontsizeCO->addItem(qt_("default"));
535
536         for (int n = 0; !token(items,'|',n).empty(); ++n)
537                 fontModule->fontsizeCO->
538                         addItem(toqstr(token(items,'|',n)));
539
540         for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
541                 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
542                         fontModule->fontsizeCO->setCurrentIndex(n);
543                         break;
544                 }
545         }
546 }
547
548
549 void QDocumentDialog::romanChanged(int item)
550 {
551         string const font = tex_fonts_roman[item];
552         
553         fontModule->fontScCB->setEnabled(
554                 form_->controller().providesSC(font));
555         fontModule->fontOsfCB->setEnabled(
556                 form_->controller().providesOSF(font));
557 }
558
559
560 void QDocumentDialog::sansChanged(int item)
561 {
562         string const font = tex_fonts_sans[item];
563         bool scaleable = form_->controller().providesScale(font);
564         fontModule->scaleSansSB->setEnabled(scaleable);
565         fontModule->scaleSansLA->setEnabled(scaleable);
566 }
567
568
569 void QDocumentDialog::ttChanged(int item)
570 {
571         string const font = tex_fonts_monospaced[item];
572         bool scaleable = form_->controller().providesScale(font);
573         fontModule->scaleTypewriterSB->setEnabled(scaleable);
574         fontModule->scaleTypewriterLA->setEnabled(scaleable);
575 }
576
577
578 void QDocumentDialog::updatePagestyle(string const & items, string const & sel)
579 {
580         pageLayoutModule->pagestyleCO->clear();
581         pageLayoutModule->pagestyleCO->addItem("default");
582
583         for (int n=0; !token(items,'|',n).empty(); ++n)
584                 pageLayoutModule->pagestyleCO->
585                         addItem(toqstr(token(items,'|',n)));
586
587         for (int n = 0; n<pageLayoutModule->pagestyleCO->count(); ++n) {
588                 if (fromqstr(pageLayoutModule->pagestyleCO->itemText(n))==sel) {
589                         pageLayoutModule->pagestyleCO->setCurrentIndex(n);
590                         break;
591                 }
592         }
593 }
594
595
596 void QDocumentDialog::classChanged()
597 {
598         ControlDocument & cntrl = form_->controller();
599         BufferParams & params = cntrl.params();
600
601         lyx::textclass_type const tc = latexModule->classCO->currentIndex();
602
603         if (form_->controller().loadTextclass(tc)) {
604                 params.textclass = tc;
605                 if (lyxrc.auto_reset_options)
606                         params.useClassDefaults();
607                 form_->update_contents();
608         } else {
609                 latexModule->classCO->setCurrentIndex(params.textclass);
610         }
611 }
612
613
614 void QDocumentDialog::updateNumbering()
615 {
616         LyXTextClass const & tclass =
617                 form_->controller().params().getLyXTextClass();
618
619         numberingModule->tocTW->setUpdatesEnabled(false);
620         numberingModule->tocTW->clear();
621
622         int const depth = numberingModule->depthSL->value();
623         int const toc = numberingModule->tocSL->value();
624         QString const no = qt_("No");
625         QString const yes = qt_("Yes");
626         LyXTextClass::const_iterator end = tclass.end();
627         LyXTextClass::const_iterator cit = tclass.begin();
628         QTreeWidgetItem * item = 0;
629         for ( ; cit != end ; ++cit) {
630                 int const toclevel = (*cit)->toclevel;
631                 if (toclevel != LyXLayout::NOT_IN_TOC 
632                     && (*cit)->labeltype == LABEL_COUNTER) {
633                         item = new QTreeWidgetItem(numberingModule->tocTW);
634                         item->setText(0, qt_((*cit)->name()));
635                         item->setText(1, (toclevel <= depth) ? yes : no);
636                         item->setText(2, (toclevel <= toc) ? yes : no);
637                 }
638         }
639
640         numberingModule->tocTW->setUpdatesEnabled(true);
641         numberingModule->tocTW->update();
642 }
643
644 void QDocumentDialog::apply(BufferParams & params)
645 {
646         // preamble
647         params.preamble =
648                 fromqstr(preambleModule->preambleTE->document()->toPlainText());
649
650         // biblio
651         params.setCiteEngine(biblio::ENGINE_BASIC);
652
653         if (biblioModule->citeNatbibRB->isChecked()) {
654                 bool const use_numerical_citations =
655                         biblioModule->citeStyleCO->currentIndex();
656                 if (use_numerical_citations)
657                         params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
658                 else
659                         params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
660
661         } else if (biblioModule->citeJurabibRB->isChecked())
662                 params.setCiteEngine(biblio::ENGINE_JURABIB);
663
664         params.use_bibtopic =
665                 biblioModule->bibtopicCB->isChecked();
666
667         // language & quotes
668         if (langModule->defaultencodingCB->isChecked()) {
669                 params.inputenc = "auto";
670         } else {
671                 int i = langModule->encodingCO->currentIndex();
672                 if (i == 0)
673                         params.inputenc = "default";
674                 else
675                         params.inputenc =
676                                 fromqstr(langModule->encodingCO->currentText());
677         }
678
679         InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
680         switch (langModule->quoteStyleCO->currentIndex()) {
681         case 0:
682                 lga = InsetQuotes::EnglishQ;
683                 break;
684         case 1:
685                 lga = InsetQuotes::SwedishQ;
686                 break;
687         case 2:
688                 lga = InsetQuotes::GermanQ;
689                 break;
690         case 3:
691                 lga = InsetQuotes::PolishQ;
692                 break;
693         case 4:
694                 lga = InsetQuotes::FrenchQ;
695                 break;
696         case 5:
697                 lga = InsetQuotes::DanishQ;
698                 break;
699         }
700         params.quotes_language = lga;
701
702         int const pos = langModule->languageCO->currentIndex();
703         params.language = languages.getLanguage(lang_[pos]);
704
705         // numbering
706         if (params.getLyXTextClass().hasTocLevels()) {
707                 params.tocdepth = numberingModule->tocSL->value();
708                 params.secnumdepth = numberingModule->depthSL->value();
709         }
710
711         // bullets
712         params.user_defined_bullet(0) = bulletsModule->getBullet(0);
713         params.user_defined_bullet(1) = bulletsModule->getBullet(1);
714         params.user_defined_bullet(2) = bulletsModule->getBullet(2);
715         params.user_defined_bullet(3) = bulletsModule->getBullet(3);
716
717         // packages
718         params.graphicsDriver =
719                 fromqstr(latexModule->psdriverCO->currentText());
720
721         if (mathsModule->amsautoCB->isChecked()) {
722                 params.use_amsmath = BufferParams::package_auto;
723         } else {
724                 if (mathsModule->amsCB->isChecked())
725                         params.use_amsmath = BufferParams::package_on;
726                 else
727                         params.use_amsmath = BufferParams::package_off;
728         }
729
730         if (mathsModule->esintautoCB->isChecked())
731                 params.use_esint = BufferParams::package_auto;
732         else {
733                 if (mathsModule->esintCB->isChecked())
734                         params.use_esint = BufferParams::package_on;
735                 else
736                         params.use_esint = BufferParams::package_off;
737         }
738
739         // text layout
740         params.textclass =
741                 latexModule->classCO->currentIndex();
742
743         params.pagestyle =
744                 fromqstr(pageLayoutModule->pagestyleCO->currentText());
745
746         switch (textLayoutModule->lspacingCO->currentIndex()) {
747         case 0:
748                 params.spacing().set(Spacing::Single);
749                 break;
750         case 1:
751                 params.spacing().set(Spacing::Onehalf);
752                 break;
753         case 2:
754                 params.spacing().set(Spacing::Double);
755                 break;
756         case 3:
757                 params.spacing().set(Spacing::Other,
758                         fromqstr(textLayoutModule->lspacingLE->text()));
759                 break;
760         }
761
762         if (textLayoutModule->twoColumnCB->isChecked())
763                 params.columns = 2;
764         else
765                 params.columns = 1;
766
767         if (textLayoutModule->indentRB->isChecked())
768                 params.paragraph_separation = BufferParams::PARSEP_INDENT;
769         else
770                 params.paragraph_separation = BufferParams::PARSEP_SKIP;
771
772         switch (textLayoutModule->skipCO->currentIndex()) {
773         case 0:
774                 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
775                 break;
776         case 1:
777                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
778                 break;
779         case 2:
780                 params.setDefSkip(VSpace(VSpace::BIGSKIP));
781                 break;
782         case 3:
783         {
784                 VSpace vs = VSpace(
785                         widgetsToLength(textLayoutModule->skipLE,
786                                 textLayoutModule->skipLengthCO)
787                         );
788                 params.setDefSkip(vs);
789                 break;
790         }
791         default:
792                 // DocumentDefskipCB assures that this never happens
793                 // so Assert then !!!  - jbl
794                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
795                 break;
796         }
797
798         params.options =
799                 fromqstr(latexModule->optionsLE->text());
800
801         params.float_placement = floatModule->get();
802
803         // fonts
804         params.fontsRoman =
805                 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
806
807         params.fontsSans =
808                 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
809
810         params.fontsTypewriter =
811                 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
812
813         params.fontsSansScale = fontModule->scaleSansSB->value();
814
815         params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
816
817         params.fontsSC = fontModule->fontScCB->isChecked();
818
819         params.fontsOSF = fontModule->fontOsfCB->isChecked();
820
821         params.fontsDefaultFamily = ControlDocument::fontfamilies[
822                 fontModule->fontsDefaultCO->currentIndex()];
823
824         if (fontModule->fontsizeCO->currentIndex() == 0)
825                 params.fontsize = "default";
826         else
827                 params.fontsize =
828                         fromqstr(fontModule->fontsizeCO->currentText());
829
830         // paper
831         params.papersize = PAPER_SIZE(
832                 pageLayoutModule->papersizeCO->currentIndex());
833
834         // custom, A3, B3 and B4 paper sizes need geometry
835         int psize = pageLayoutModule->papersizeCO->currentIndex();
836         bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
837
838         params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
839                 pageLayoutModule->paperwidthUnitCO);
840
841         params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
842                 pageLayoutModule->paperheightUnitCO);
843
844         if (pageLayoutModule->facingPagesCB->isChecked())
845                 params.sides = LyXTextClass::TwoSides;
846         else
847                 params.sides = LyXTextClass::OneSide;
848
849         if (pageLayoutModule->landscapeRB->isChecked())
850                 params.orientation = ORIENTATION_LANDSCAPE;
851         else
852                 params.orientation = ORIENTATION_PORTRAIT;
853
854         // margins
855         params.use_geometry =
856                 (!marginsModule->marginCB->isChecked()
857                 || geom_papersize);
858
859         Ui::MarginsUi const * m(marginsModule);
860
861         params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
862
863         params.topmargin = widgetsToLength(m->topLE, m->topUnit);
864
865         params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
866
867         params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
868
869         params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
870
871         params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
872
873         params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
874
875         branchesModule->apply(params);
876 }
877
878 namespace {
879
880 /** Return the position of val in the vector if found.
881     If not found, return 0.
882  */
883 template<class A>
884 typename std::vector<A>::size_type
885 findPos(std::vector<A> const & vec, A const & val)
886 {
887         typename std::vector<A>::const_iterator it =
888                 std::find(vec.begin(), vec.end(), val);
889         if (it == vec.end())
890                 return 0;
891         return distance(vec.begin(), it);
892 }
893
894 } // namespace anom
895
896
897 void QDocumentDialog::updateParams(BufferParams const & params)
898 {
899         // set the default unit
900         // FIXME: move to controller
901         LyXLength::UNIT defaultUnit = LyXLength::CM;
902         switch (lyxrc.default_papersize) {
903                 case PAPER_DEFAULT: break;
904
905                 case PAPER_USLETTER:
906                 case PAPER_USLEGAL:
907                 case PAPER_USEXECUTIVE:
908                         defaultUnit = LyXLength::IN;
909                         break;
910
911                 case PAPER_A3:
912                 case PAPER_A4:
913                 case PAPER_A5:
914                 case PAPER_B3:
915                 case PAPER_B4:
916                 case PAPER_B5:
917                         defaultUnit = LyXLength::CM;
918                         break;
919                 case PAPER_CUSTOM:
920                         break;
921         }
922
923         // preamble
924         QString preamble = toqstr(params.preamble);
925         preambleModule->preambleTE->document()->setPlainText(preamble);
926
927         // biblio
928         biblioModule->citeDefaultRB->setChecked(
929                 params.getEngine() == biblio::ENGINE_BASIC);
930
931         biblioModule->citeNatbibRB->setChecked(
932                 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
933                 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
934
935         biblioModule->citeStyleCO->setCurrentIndex(
936                 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
937
938         biblioModule->citeJurabibRB->setChecked(
939                 params.getEngine() == biblio::ENGINE_JURABIB);
940
941         biblioModule->bibtopicCB->setChecked(
942                 params.use_bibtopic);
943
944         // language & quotes
945         int const pos = int(findPos(lang_,
946                                     params.language->lang()));
947         langModule->languageCO->setCurrentIndex(pos);
948
949         langModule->quoteStyleCO->setCurrentIndex(
950                 params.quotes_language);
951
952         langModule->defaultencodingCB->setChecked(true);
953
954         if (params.inputenc != "auto") {
955                 langModule->defaultencodingCB->setChecked(false);
956                 if (params.inputenc == "default") {
957                         langModule->encodingCO->setCurrentIndex(0);
958                 } else {
959                         int const i = langModule->encodingCO->findText(
960                                         toqstr(params.inputenc));
961                         if (i >= 0)
962                                 langModule->encodingCO->setCurrentIndex(i);
963                         else
964                                 // unknown encoding. Set to default.
965                                 langModule->defaultencodingCB->setChecked(true);
966                 }
967         }
968
969         // numbering
970         int const min_toclevel = form_->controller().textClass().min_toclevel();
971         int const max_toclevel = form_->controller().textClass().max_toclevel();
972         if (form_->controller().textClass().hasTocLevels()) {
973                 numberingModule->setEnabled(true);
974                 numberingModule->depthSL->setMinimum(min_toclevel - 1);
975                 numberingModule->depthSL->setMaximum(max_toclevel);
976                 numberingModule->depthSL->setValue(params.secnumdepth);
977                 numberingModule->tocSL->setMaximum(min_toclevel - 1);
978                 numberingModule->tocSL->setMaximum(max_toclevel);
979                 numberingModule->tocSL->setValue(params.tocdepth);
980                 updateNumbering();
981         } else {
982                 numberingModule->setEnabled(false);
983                 numberingModule->tocTW->clear();
984         }
985
986         // bullets
987         bulletsModule->setBullet(0, params.user_defined_bullet(0));
988         bulletsModule->setBullet(1, params.user_defined_bullet(1));
989         bulletsModule->setBullet(2, params.user_defined_bullet(2));
990         bulletsModule->setBullet(3, params.user_defined_bullet(3));
991         bulletsModule->init();
992
993         // packages
994         QString text = toqstr(params.graphicsDriver);
995         int nitem = latexModule->psdriverCO->count();
996         for (int n = 0; n < nitem ; ++n) {
997                 QString enc = tex_graphics[n];
998                 if (enc == text) {
999                         latexModule->psdriverCO->setCurrentIndex(n);
1000                 }
1001         }
1002
1003
1004         mathsModule->amsCB->setChecked(
1005                 params.use_amsmath == BufferParams::package_on);
1006         mathsModule->amsautoCB->setChecked(
1007                 params.use_amsmath == BufferParams::package_auto);
1008
1009         mathsModule->esintCB->setChecked(
1010                 params.use_esint == BufferParams::package_on);
1011         mathsModule->esintautoCB->setChecked(
1012                 params.use_esint == BufferParams::package_auto);
1013
1014         switch (params.spacing().getSpace()) {
1015                 case Spacing::Other: nitem = 3; break;
1016                 case Spacing::Double: nitem = 2; break;
1017                 case Spacing::Onehalf: nitem = 1; break;
1018                 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1019         }
1020
1021         // text layout
1022         latexModule->classCO->setCurrentIndex(params.textclass);
1023
1024         updatePagestyle(form_->controller().textClass().opt_pagestyle(),
1025                                  params.pagestyle);
1026
1027         textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1028         if (params.spacing().getSpace() == Spacing::Other) {
1029                 textLayoutModule->lspacingLE->setText(
1030                         toqstr(params.spacing().getValueAsString()));
1031         }
1032         setLSpacing(nitem);
1033
1034         if (params.paragraph_separation
1035             == BufferParams::PARSEP_INDENT) {
1036                 textLayoutModule->indentRB->setChecked(true);
1037         } else {
1038                 textLayoutModule->skipRB->setChecked(true);
1039         }
1040
1041         int skip = 0;
1042         switch (params.getDefSkip().kind()) {
1043         case VSpace::SMALLSKIP:
1044                 skip = 0;
1045                 break;
1046         case VSpace::MEDSKIP:
1047                 skip = 1;
1048                 break;
1049         case VSpace::BIGSKIP:
1050                 skip = 2;
1051                 break;
1052         case VSpace::LENGTH:
1053         {
1054                 skip = 3;
1055                 string const length = params.getDefSkip().asLyXCommand();
1056                 lengthToWidgets(textLayoutModule->skipLE,
1057                         textLayoutModule->skipLengthCO,
1058                         length, defaultUnit);
1059                 break;
1060         }
1061         default:
1062                 skip = 0;
1063                 break;
1064         }
1065         textLayoutModule->skipCO->setCurrentIndex(skip);
1066         setSkip(skip);
1067
1068         textLayoutModule->twoColumnCB->setChecked(
1069                 params.columns == 2);
1070
1071         if (!params.options.empty()) {
1072                 latexModule->optionsLE->setText(
1073                         toqstr(params.options));
1074         } else {
1075                 latexModule->optionsLE->setText("");
1076         }
1077
1078         floatModule->set(params.float_placement);
1079
1080         //fonts
1081         updateFontsize(form_->controller().textClass().opt_fontsize(),
1082                         params.fontsize);
1083
1084         int n = findToken(tex_fonts_roman, params.fontsRoman);
1085         if (n >= 0) {
1086                 fontModule->fontsRomanCO->setCurrentIndex(n);
1087                 romanChanged(n);
1088         }
1089
1090         n = findToken(tex_fonts_sans, params.fontsSans);
1091         if (n >= 0)     {
1092                 fontModule->fontsSansCO->setCurrentIndex(n);
1093                 sansChanged(n);
1094         }
1095
1096         n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1097         if (n >= 0) {
1098                 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1099                 ttChanged(n);
1100         }
1101
1102         fontModule->fontScCB->setChecked(params.fontsSC);
1103         fontModule->fontOsfCB->setChecked(params.fontsOSF);
1104         fontModule->scaleSansSB->setValue(params.fontsSansScale);
1105         fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1106         n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
1107         if (n >= 0)
1108                 fontModule->fontsDefaultCO->setCurrentIndex(n);
1109
1110         // paper
1111         int const psize = params.papersize;
1112         pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1113         setCustomPapersize(psize);
1114
1115         bool const landscape =
1116                 params.orientation == ORIENTATION_LANDSCAPE;
1117         pageLayoutModule->landscapeRB->setChecked(landscape);
1118         pageLayoutModule->portraitRB->setChecked(!landscape);
1119
1120         pageLayoutModule->facingPagesCB->setChecked(
1121                 params.sides == LyXTextClass::TwoSides);
1122
1123
1124         lengthToWidgets(pageLayoutModule->paperwidthLE,
1125                 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1126
1127         lengthToWidgets(pageLayoutModule->paperheightLE,
1128                 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1129
1130         // margins
1131         Ui::MarginsUi * m = marginsModule;
1132
1133         setMargins(!params.use_geometry);
1134
1135         lengthToWidgets(m->topLE, m->topUnit,
1136                 params.topmargin, defaultUnit);
1137
1138         lengthToWidgets(m->bottomLE, m->bottomUnit,
1139                 params.bottommargin, defaultUnit);
1140
1141         lengthToWidgets(m->innerLE, m->innerUnit,
1142                 params.leftmargin, defaultUnit);
1143
1144         lengthToWidgets(m->outerLE, m->outerUnit,
1145                 params.rightmargin, defaultUnit);
1146
1147         lengthToWidgets(m->headheightLE, m->headheightUnit,
1148                 params.headheight, defaultUnit);
1149
1150         lengthToWidgets(m->headsepLE, m->headsepUnit,
1151                 params.headsep, defaultUnit);
1152
1153         lengthToWidgets(m->footskipLE, m->footskipUnit,
1154                 params.footskip, defaultUnit);
1155
1156         branchesModule->update(params);
1157 }
1158
1159
1160
1161
1162 } // namespace frontend
1163 } // namespace lyx
1164
1165 #include "QDocumentDialog_moc.cpp"