]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QDocumentDialog.C
* qt_helpers.h:
[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 "QDocument.h"
15 #include "QDocumentDialog.h"
16
17 #include <QCloseEvent>
18
19 #include "FloatPlacement.h"
20 #include "lengthcombo.h"
21 #include "validators.h"
22 #include "panelstack.h"
23 #include "Qt2BC.h"
24 #include "checkedwidgets.h"
25 #include "qt_helpers.h"
26
27 #include "bufferparams.h"
28 #include "gettext.h"
29 #include "helper_funcs.h" // getSecond()
30 #include "language.h"
31 #include "lyxrc.h" // defaultUnit
32 #include "lyxtextclasslist.h"
33 #include "tex-strings.h" // tex_graphics
34 #include "Spacing.h"
35
36 #include "controllers/ControlDocument.h"
37 #include "controllers/frnt_lang.h"
38
39 #include "support/lstrings.h"
40
41 #include "controllers/ControlDocument.h"
42 #include "controllers/frnt_lang.h"
43
44
45 using lyx::support::token;
46 using lyx::support::bformat;
47 using lyx::support::findToken;
48 using lyx::support::getVectorFromString;
49
50 using std::distance;
51 using std::vector;
52 using std::string;
53
54
55 namespace lyx {
56 namespace frontend {
57
58
59 namespace {
60
61 // FIXME: This list is incomplete. It should not be hardcoded but come from
62 // the available encodings in src/encodings.C
63 char const * encodings[] = { "LaTeX default", "latin1", "latin2",
64         "latin3", "latin4", "latin5", "latin9",
65         "koi8-r", "koi8-u", "cp866", "cp1251",
66         "iso88595", "pt154", "utf8", 0
67 };
68
69 }
70
71 QDocumentDialog::QDocumentDialog(QDocument * form)
72         : form_(form),
73         lang_(getSecond(getLanguageData(false)))
74 {
75         setupUi(this);
76
77         connect(okPB, SIGNAL(clicked()),
78                 form, SLOT(slotOK()));
79         connect(applyPB, SIGNAL(clicked()),
80                 form, SLOT(slotApply()));
81         connect(closePB, SIGNAL(clicked()),
82                 form, SLOT(slotClose()));
83         connect(restorePB, SIGNAL(clicked()),
84                 form, SLOT(slotRestore()));
85
86
87         connect(savePB, SIGNAL( clicked() ), 
88                 this, SLOT( saveDefaultClicked() ) );
89         connect(defaultPB, SIGNAL( clicked() ), 
90                 this, SLOT( useDefaultsClicked() ) );
91
92         // Manage the restore, ok, apply, restore and cancel/close buttons
93         form_->bcview().setOK(okPB);
94         form_->bcview().setApply(applyPB);
95         form_->bcview().setCancel(closePB);
96         form_->bcview().setRestore(restorePB);
97
98
99         textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
100         // text layout
101         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
102         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int)));
103         connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
104         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
105         connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
106         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
107         connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
108         connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
109         connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int)));
110         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool)));
111         connect(textLayoutModule->twoColumnCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
112         textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
113                 textLayoutModule->lspacingLE));
114         textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
115                 textLayoutModule->skipLE));
116
117         textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
118         textLayoutModule->skipCO->addItem(qt_("MedSkip"));
119         textLayoutModule->skipCO->addItem(qt_("BigSkip"));
120         textLayoutModule->skipCO->addItem(qt_("Length"));
121         // remove the %-items from the unit choice
122         textLayoutModule->skipLengthCO->noPercents();
123         textLayoutModule->lspacingCO->insertItem(
124                 Spacing::Single, qt_("Single"));
125         textLayoutModule->lspacingCO->insertItem(
126                 Spacing::Onehalf, qt_("OneHalf"));
127         textLayoutModule->lspacingCO->insertItem(
128                 Spacing::Double, qt_("Double"));
129         textLayoutModule->lspacingCO->insertItem(
130                 Spacing::Other, qt_("Custom"));
131
132         // initialize the length validator
133         addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
134
135
136
137
138         fontModule = new UiWidget<Ui::FontUi>;
139         // fonts
140         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
141         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(romanChanged(int)));
142         connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
143         connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(sansChanged(int)));
144         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
145         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(ttChanged(int)));
146         connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
147         connect(fontModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
148         connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
149         connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
150         connect(fontModule->fontScCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
151         connect(fontModule->fontOsfCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
152
153         for (int n = 0; tex_fonts_roman[n][0]; ++n) {
154                 QString font = toqstr(tex_fonts_roman_gui[n]);
155                 if (!form_->controller().isFontAvailable(tex_fonts_roman[n]))
156                         font += qt_(" (not installed)");
157                 fontModule->fontsRomanCO->addItem(font);
158         }
159         for (int n = 0; tex_fonts_sans[n][0]; ++n) {
160                 QString font = toqstr(tex_fonts_sans_gui[n]);
161                 if (!form_->controller().isFontAvailable(tex_fonts_sans[n]))
162                         font += qt_(" (not installed)");
163                 fontModule->fontsSansCO->addItem(font);
164         }
165         for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
166                 QString font = toqstr(tex_fonts_monospaced_gui[n]);
167                 if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n]))
168                         font += qt_(" (not installed)");
169                 fontModule->fontsTypewriterCO->addItem(font);
170         }
171
172         fontModule->fontsizeCO->addItem(qt_("default"));
173         fontModule->fontsizeCO->addItem(qt_("10"));
174         fontModule->fontsizeCO->addItem(qt_("11"));
175         fontModule->fontsizeCO->addItem(qt_("12"));
176
177         for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n)
178                 fontModule->fontsDefaultCO->addItem(
179                         qt_(ControlDocument::fontfamilies_gui[n]));
180
181
182
183
184         pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
185         // page layout
186         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
187         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
188         connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(portraitChanged()));
189         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
190         connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
191         connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
192         connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
193         connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
194         connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
195         connect(pageLayoutModule->landscapeRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
196         connect(pageLayoutModule->facingPagesCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
197         connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
198         pageLayoutModule->pagestyleCO->addItem(qt_("default"));
199         pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
200         pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
201         pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
202         pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
203         addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE,
204                 pageLayoutModule->paperheightL);
205         addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
206                 pageLayoutModule->paperwidthL);
207
208         // paper
209         QComboBox * cb = pageLayoutModule->papersizeCO;
210         cb->addItem(qt_("Default"));
211         cb->addItem(qt_("Custom"));
212         cb->addItem(qt_("US letter"));
213         cb->addItem(qt_("US legal"));
214         cb->addItem(qt_("US executive"));
215         cb->addItem(qt_("A3"));
216         cb->addItem(qt_("A4"));
217         cb->addItem(qt_("A5"));
218         cb->addItem(qt_("B3"));
219         cb->addItem(qt_("B4"));
220         cb->addItem(qt_("B5"));
221         // remove the %-items from the unit choice
222         pageLayoutModule->paperwidthUnitCO->noPercents();
223         pageLayoutModule->paperheightUnitCO->noPercents();
224         pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
225                 pageLayoutModule->paperheightLE));
226         pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
227                 pageLayoutModule->paperwidthLE));
228
229
230
231
232         marginsModule = new UiWidget<Ui::MarginsUi>;
233         // margins
234         connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(setCustomMargins(bool)));
235         connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
236         connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
237         connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
238         connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
239         connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
240         connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
241         connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
242         connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
243         connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
244         connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
245         connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
246         connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
247         connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
248         connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
249         connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
250         marginsModule->topLE->setValidator(unsignedLengthValidator(
251                 marginsModule->topLE));
252         marginsModule->bottomLE->setValidator(unsignedLengthValidator(
253                 marginsModule->bottomLE));
254         marginsModule->innerLE->setValidator(unsignedLengthValidator(
255                 marginsModule->innerLE));
256         marginsModule->outerLE->setValidator(unsignedLengthValidator(
257                 marginsModule->outerLE));
258         marginsModule->headsepLE->setValidator(unsignedLengthValidator(
259                 marginsModule->headsepLE));
260         marginsModule->headheightLE->setValidator(unsignedLengthValidator(
261                 marginsModule->headheightLE));
262         marginsModule->footskipLE->setValidator(unsignedLengthValidator(
263                 marginsModule->footskipLE));
264
265         addCheckedLineEdit(form_->bcview(), marginsModule->topLE,
266                 marginsModule->topL);
267         addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE,
268                 marginsModule->bottomL);
269         addCheckedLineEdit(form_->bcview(), marginsModule->innerLE,
270                 marginsModule->innerL);
271         addCheckedLineEdit(form_->bcview(), marginsModule->outerLE,
272                 marginsModule->outerL);
273         addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE,
274                 marginsModule->headsepL);
275         addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE,
276                 marginsModule->headheightL);
277         addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE,
278                 marginsModule->footskipL);
279
280
281
282
283
284         langModule = new UiWidget<Ui::LanguageUi>;
285         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingL, SLOT(setDisabled(bool)));
286         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingCO, SLOT(setDisabled(bool)));
287         // language & quote
288         connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
289         connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
290         connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
291         connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
292         // language & quotes
293         vector<LanguagePair> const langs = getLanguageData(false);
294         vector<LanguagePair>::const_iterator lit  = langs.begin();
295         vector<LanguagePair>::const_iterator lend = langs.end();
296         for (; lit != lend; ++lit) {
297                 langModule->languageCO->addItem(
298                         toqstr(lit->first));
299         }
300
301         int k = 0;
302         while (encodings[k]) {
303                 langModule->encodingCO->addItem(qt_(encodings[k++]));
304         }
305
306         langModule->quoteStyleCO->addItem(qt_("``text''"));
307         langModule->quoteStyleCO->addItem(qt_("''text''"));
308         langModule->quoteStyleCO->addItem(qt_(",,text``"));
309         langModule->quoteStyleCO->addItem(qt_(",,text''"));
310         langModule->quoteStyleCO->addItem(qt_("<<text>>"));
311         langModule->quoteStyleCO->addItem(qt_(">>text<<"));
312
313
314
315         numberingModule = new UiWidget<Ui::NumberingUi>;
316         // numbering
317         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
318         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
319         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
320         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
321         numberingModule->tocTW->setColumnCount(3);
322         numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
323         numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
324         numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
325
326
327         biblioModule = new UiWidget<Ui::BiblioUi>;
328         connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) );
329         connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) );
330         // biblio
331         connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
332         connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
333         connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
334         connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
335         connect(biblioModule->bibtopicCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
336         // biblio
337         biblioModule->citeStyleCO->addItem(qt_("Author-year"));
338         biblioModule->citeStyleCO->addItem(qt_("Numerical"));
339         biblioModule->citeStyleCO->setCurrentIndex(0);
340
341
342
343         mathsModule = new UiWidget<Ui::MathsUi>;
344         connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), mathsModule->amsCB, SLOT(setDisabled(bool)));
345         connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)), mathsModule->esintCB, SLOT(setDisabled(bool)));
346         // maths
347         connect(mathsModule->amsCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
348         connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
349         connect(mathsModule->esintCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
350         connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
351
352         latexModule = new UiWidget<Ui::LaTeXUi>;
353         // latex class
354         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
355         connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
356         connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
357         connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged()));
358         // packages
359         for (int n = 0; tex_graphics[n][0]; ++n) {
360                 QString enc = tex_graphics[n];
361                 latexModule->psdriverCO->addItem(enc);
362         }
363         // latex
364         for (LyXTextClassList::const_iterator cit = textclasslist.begin();
365              cit != textclasslist.end(); ++cit) {
366                 if (cit->isTeXClassAvailable()) {
367                         latexModule->classCO->addItem(toqstr(cit->description()));
368                 } else {
369                         docstring item =
370                                 bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description()));
371                         latexModule->classCO->addItem(toqstr(item));
372                 }
373         }
374
375         // branches
376         branchesModule = new QBranches;
377         connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
378
379         // preamble
380         preambleModule = new UiWidget<Ui::PreambleUi>;
381         connect(preambleModule->preambleTE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
382
383
384         // bullets
385         bulletsModule = new BulletsModule;
386         connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
387
388
389         // float
390         floatModule = new FloatPlacement;
391         connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
392
393         docPS->addPanel(latexModule, _("Document Class"));
394         docPS->addPanel(fontModule, _("Fonts"));
395         docPS->addPanel(textLayoutModule, _("Text Layout"));
396         docPS->addPanel(pageLayoutModule, _("Page Layout"));
397         docPS->addPanel(marginsModule, _("Page Margins"));
398         docPS->addPanel(langModule, _("Language"));
399         docPS->addPanel(numberingModule, _("Numbering & TOC"));
400         docPS->addPanel(biblioModule, _("Bibliography"));
401         docPS->addPanel(mathsModule, _("Math Options"));
402         docPS->addPanel(floatModule, _("Float Placement"));
403         docPS->addPanel(bulletsModule, _("Bullets"));
404         docPS->addPanel(branchesModule, _("Branches"));
405         docPS->addPanel(preambleModule, _("LaTeX Preamble"));
406         docPS->setCurrentPanel(_("Document Class"));
407 // FIXME: hack to work around resizing bug in Qt >= 4.2
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.cite_engine = 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.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
658                 else
659                         params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
660
661         } else if (biblioModule->citeJurabibRB->isChecked())
662                 params.cite_engine = 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 = encodings[i];
676                 }
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::update(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.cite_engine == biblio::ENGINE_BASIC);
930
931         biblioModule->citeNatbibRB->setChecked(
932                 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
933                 params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
934
935         biblioModule->citeStyleCO->setCurrentIndex(
936                 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
937
938         biblioModule->citeJurabibRB->setChecked(
939                 params.cite_engine == 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 i = 0;
960                         while (encodings[i]) {
961                                 if (encodings[i] == params.inputenc) {
962                                         langModule->encodingCO->setCurrentIndex(i);
963                                         break;
964                                 }
965                                 ++i;
966                         }
967                         // FIXME: possible data loss because of encodings is
968                         // incomplete
969                 }
970         }
971
972         // numbering
973         int const min_toclevel = form_->controller().textClass().min_toclevel();
974         int const max_toclevel = form_->controller().textClass().max_toclevel();
975         if (form_->controller().textClass().hasTocLevels()) {
976                 numberingModule->setEnabled(true);
977                 numberingModule->depthSL->setMinimum(min_toclevel - 1);
978                 numberingModule->depthSL->setMaximum(max_toclevel);
979                 numberingModule->depthSL->setValue(params.secnumdepth);
980                 numberingModule->tocSL->setMaximum(min_toclevel - 1);
981                 numberingModule->tocSL->setMaximum(max_toclevel);
982                 numberingModule->tocSL->setValue(params.tocdepth);
983                 updateNumbering();
984         } else {
985                 numberingModule->setEnabled(false);
986                 numberingModule->tocTW->clear();
987         }
988
989         // bullets
990         bulletsModule->setBullet(0, params.user_defined_bullet(0));
991         bulletsModule->setBullet(1, params.user_defined_bullet(1));
992         bulletsModule->setBullet(2, params.user_defined_bullet(2));
993         bulletsModule->setBullet(3, params.user_defined_bullet(3));
994         bulletsModule->init();
995
996         // packages
997         QString text = toqstr(params.graphicsDriver);
998         int nitem = latexModule->psdriverCO->count();
999         for (int n = 0; n < nitem ; ++n) {
1000                 QString enc = tex_graphics[n];
1001                 if (enc == text) {
1002                         latexModule->psdriverCO->setCurrentIndex(n);
1003                 }
1004         }
1005
1006
1007         mathsModule->amsCB->setChecked(
1008                 params.use_amsmath == BufferParams::package_on);
1009         mathsModule->amsautoCB->setChecked(
1010                 params.use_amsmath == BufferParams::package_auto);
1011
1012         mathsModule->esintCB->setChecked(
1013                 params.use_esint == BufferParams::package_on);
1014         mathsModule->esintautoCB->setChecked(
1015                 params.use_esint == BufferParams::package_auto);
1016
1017         switch (params.spacing().getSpace()) {
1018                 case Spacing::Other: nitem = 3; break;
1019                 case Spacing::Double: nitem = 2; break;
1020                 case Spacing::Onehalf: nitem = 1; break;
1021                 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1022         }
1023
1024         // text layout
1025         latexModule->classCO->setCurrentIndex(params.textclass);
1026
1027         updatePagestyle(form_->controller().textClass().opt_pagestyle(),
1028                                  params.pagestyle);
1029
1030         textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1031         if (params.spacing().getSpace() == Spacing::Other) {
1032                 textLayoutModule->lspacingLE->setText(
1033                         toqstr(params.spacing().getValueAsString()));
1034         }
1035         setLSpacing(nitem);
1036
1037         if (params.paragraph_separation
1038             == BufferParams::PARSEP_INDENT) {
1039                 textLayoutModule->indentRB->setChecked(true);
1040         } else {
1041                 textLayoutModule->skipRB->setChecked(true);
1042         }
1043
1044         int skip = 0;
1045         switch (params.getDefSkip().kind()) {
1046         case VSpace::SMALLSKIP:
1047                 skip = 0;
1048                 break;
1049         case VSpace::MEDSKIP:
1050                 skip = 1;
1051                 break;
1052         case VSpace::BIGSKIP:
1053                 skip = 2;
1054                 break;
1055         case VSpace::LENGTH:
1056         {
1057                 skip = 3;
1058                 string const length = params.getDefSkip().asLyXCommand();
1059                 lengthToWidgets(textLayoutModule->skipLE,
1060                         textLayoutModule->skipLengthCO,
1061                         length, defaultUnit);
1062                 break;
1063         }
1064         default:
1065                 skip = 0;
1066                 break;
1067         }
1068         textLayoutModule->skipCO->setCurrentIndex(skip);
1069         setSkip(skip);
1070
1071         textLayoutModule->twoColumnCB->setChecked(
1072                 params.columns == 2);
1073
1074         if (!params.options.empty()) {
1075                 latexModule->optionsLE->setText(
1076                         toqstr(params.options));
1077         } else {
1078                 latexModule->optionsLE->setText("");
1079         }
1080
1081         floatModule->set(params.float_placement);
1082
1083         //fonts
1084         updateFontsize(form_->controller().textClass().opt_fontsize(),
1085                         params.fontsize);
1086
1087         int n = findToken(tex_fonts_roman, params.fontsRoman);
1088         if (n >= 0) {
1089                 fontModule->fontsRomanCO->setCurrentIndex(n);
1090                 romanChanged(n);
1091         }
1092
1093         n = findToken(tex_fonts_sans, params.fontsSans);
1094         if (n >= 0)     {
1095                 fontModule->fontsSansCO->setCurrentIndex(n);
1096                 sansChanged(n);
1097         }
1098
1099         n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1100         if (n >= 0) {
1101                 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1102                 ttChanged(n);
1103         }
1104
1105         fontModule->fontScCB->setChecked(params.fontsSC);
1106         fontModule->fontOsfCB->setChecked(params.fontsOSF);
1107         fontModule->scaleSansSB->setValue(params.fontsSansScale);
1108         fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1109         n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily);
1110         if (n >= 0)
1111                 fontModule->fontsDefaultCO->setCurrentIndex(n);
1112
1113         // paper
1114         int const psize = params.papersize;
1115         pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1116         setCustomPapersize(psize);
1117
1118         bool const landscape =
1119                 params.orientation == ORIENTATION_LANDSCAPE;
1120         pageLayoutModule->landscapeRB->setChecked(landscape);
1121         pageLayoutModule->portraitRB->setChecked(!landscape);
1122
1123         pageLayoutModule->facingPagesCB->setChecked(
1124                 params.sides == LyXTextClass::TwoSides);
1125
1126
1127         lengthToWidgets(pageLayoutModule->paperwidthLE,
1128                 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1129
1130         lengthToWidgets(pageLayoutModule->paperheightLE,
1131                 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1132
1133         // margins
1134         Ui::MarginsUi * m = marginsModule;
1135
1136         setMargins(!params.use_geometry);
1137
1138         lengthToWidgets(m->topLE, m->topUnit,
1139                 params.topmargin, defaultUnit);
1140
1141         lengthToWidgets(m->bottomLE, m->bottomUnit,
1142                 params.bottommargin, defaultUnit);
1143
1144         lengthToWidgets(m->innerLE, m->innerUnit,
1145                 params.leftmargin, defaultUnit);
1146
1147         lengthToWidgets(m->outerLE, m->outerUnit,
1148                 params.rightmargin, defaultUnit);
1149
1150         lengthToWidgets(m->headheightLE, m->headheightUnit,
1151                 params.headheight, defaultUnit);
1152
1153         lengthToWidgets(m->headsepLE, m->headsepUnit,
1154                 params.headsep, defaultUnit);
1155
1156         lengthToWidgets(m->footskipLE, m->footskipUnit,
1157                 params.footskip, defaultUnit);
1158
1159         branchesModule->update(params);
1160 }
1161
1162
1163
1164
1165 } // namespace frontend
1166 } // namespace lyx
1167
1168 #include "QDocumentDialog_moc.cpp"