]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QPrefsDialog.C
Changelog:
[lyx.git] / src / frontends / qt4 / QPrefsDialog.C
1 /**
2  * \file QPrefsDialog.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 #include "debug.h"
14 #include "qt_helpers.h"
15
16 #include "lcolorcache.h"
17 #include "Qt2BC.h"
18 #include "qt_helpers.h"
19
20 #include "debug.h"
21 #include "lastfiles.h"
22 #include "LColor.h"
23 #include "lyxfont.h"
24
25 #include "support/lstrings.h"
26 #include "support/os.h"
27
28 #include "controllers/ControlPrefs.h"
29 #include "controllers/frnt_lang.h"
30 #include "controllers/helper_funcs.h"
31
32 #include "frontends/lyx_gui.h"
33
34 #include "QPrefsDialog.h"
35 #include "QPrefs.h"
36
37 #include "panelstack.h"
38 #include "qcoloritem.h"
39 #include "qfontexample.h"
40
41 #include "ui/QPrefAsciiUi.h"
42 #include "ui/QPrefDateUi.h"
43 #include "ui/QPrefKeyboardUi.h"
44 #include "ui/QPrefLatexUi.h"
45 #include "ui/QPrefScreenFontsUi.h"
46 #include "ui/QPrefColorsUi.h"
47 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
48 #include "ui/QPrefCygwinPathUi.h"
49 #endif
50 #include "ui/QPrefDisplayUi.h"
51 #include "ui/QPrefPathsUi.h"
52 #include "ui/QPrefSpellcheckerUi.h"
53 #include "ui/QPrefConvertersUi.h"
54 #include "ui/QPrefCopiersUi.h"
55 #include "ui/QPrefFileformatsUi.h"
56 #include "ui/QPrefLanguageUi.h"
57 #include "ui/QPrefPrinterUi.h"
58 #include "ui/QPrefUi.h"
59 #include "ui/QPrefIdentityUi.h"
60
61 #include "gettext.h"
62 #include "LColor.h"
63 #include "lcolorcache.h"
64
65 #include "controllers/ControlPrefs.h"
66
67 #include <QCheckBox>
68 #include <QColorDialog>
69 #include <QFontDatabase>
70 #include <QLineEdit>
71 #include <QPushButton>
72 #include <QSpinBox>
73 #include <QString>
74 #include <QValidator>
75 #include <QCloseEvent>
76
77 #include <boost/tuple/tuple.hpp>
78 #include <iomanip>
79 #include <sstream>
80
81 using lyx::support::compare_no_case;
82
83 using std::distance;
84 using std::endl;
85 using std::setfill;
86 using std::setw;
87 using std::string;
88 using std::ostringstream;
89 using std::pair;
90 using std::vector;
91
92 namespace lyx {
93 namespace frontend {
94
95 QPrefsDialog::QPrefsDialog(QPrefs * form)
96         : form_(form)
97 {
98         setupUi(this);
99
100         connect(savePB, SIGNAL(clicked()),
101                 form, SLOT(slotOK()));
102         connect(applyPB, SIGNAL(clicked()),
103                 form, SLOT(slotApply()));
104         connect(closePB, SIGNAL(clicked()),
105                 form, SLOT(slotClose()));
106         connect(restorePB, SIGNAL(clicked()),
107                 form, SLOT(slotRestore()));
108
109
110
111         asciiModule = new UiWidget<Ui::QPrefAsciiUi>(this);
112         connect(asciiModule->asciiLinelengthSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
113         connect(asciiModule->asciiRoffED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
114
115         
116         dateModule = new UiWidget<Ui::QPrefDateUi>(this);
117         connect(dateModule->DateED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
118
119         
120
121         keyboardModule = new UiWidget<Ui::QPrefKeyboardUi>(this);
122         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
123                  keyboardModule->firstKeymapLA, SLOT( setEnabled(bool) ) );
124         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
125                 keyboardModule->secondKeymapLA, SLOT( setEnabled(bool) ) );
126         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
127                 keyboardModule->firstKeymapED, SLOT( setEnabled(bool) ) );
128         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
129                 keyboardModule->secondKeymapED, SLOT( setEnabled(bool) ) );
130         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
131                 keyboardModule->firstKeymapPB, SLOT( setEnabled(bool) ) );
132         connect( keyboardModule->keymapCB, SIGNAL( toggled(bool) ),
133                 keyboardModule->secondKeymapPB, SLOT( setEnabled(bool) ) );
134         connect(keyboardModule->firstKeymapPB, SIGNAL(clicked()), this, SLOT(select_keymap1()));
135         connect(keyboardModule->secondKeymapPB, SIGNAL(clicked()), this, SLOT(select_keymap2()));
136         connect(keyboardModule->keymapCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
137         connect(keyboardModule->firstKeymapED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
138         connect(keyboardModule->secondKeymapED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
139
140
141
142         latexModule = new UiWidget<Ui::QPrefLatexUi>(this);
143         connect(latexModule->latexEncodingED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
144         connect(latexModule->latexChecktexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
145         connect(latexModule->latexBibtexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
146         connect(latexModule->latexIndexED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
147         connect(latexModule->latexAutoresetCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
148         connect(latexModule->latexDviPaperED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
149         connect(latexModule->latexPaperSizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
150         
151
152
153
154         screenfontsModule = new UiWidget<Ui::QPrefScreenFontsUi>(this);
155         connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(select_roman(const QString&)));
156         connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(select_sans(const QString&)));
157         connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(select_typewriter(const QString&)));
158
159         QFontDatabase fontdb;
160         QStringList families(fontdb.families());
161         for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
162                 screenfontsModule->screenRomanCO->insertItem(*it);
163                 screenfontsModule->screenSansCO->insertItem(*it);
164                 screenfontsModule->screenTypewriterCO->insertItem(*it);
165         }
166         connect(screenfontsModule->screenRomanCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
167         connect(screenfontsModule->screenSansCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
168         connect(screenfontsModule->screenTypewriterCO, SIGNAL(activated(const QString&)), this, SLOT(change_adaptor()));
169         connect(screenfontsModule->screenZoomSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
170         connect(screenfontsModule->screenDpiSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
171         connect(screenfontsModule->screenTinyED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
172         connect(screenfontsModule->screenSmallestED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
173         connect(screenfontsModule->screenSmallerED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
174         connect(screenfontsModule->screenSmallED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
175         connect(screenfontsModule->screenNormalED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
176         connect(screenfontsModule->screenLargeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
177         connect(screenfontsModule->screenLargerED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
178         connect(screenfontsModule->screenLargestED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
179         connect(screenfontsModule->screenHugeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
180         connect(screenfontsModule->screenHugerED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
181
182         screenfontsModule->screenTinyED->setValidator(new QDoubleValidator(
183                 screenfontsModule->screenTinyED));
184         screenfontsModule->screenSmallestED->setValidator(new QDoubleValidator(
185                 screenfontsModule->screenSmallestED));
186         screenfontsModule->screenSmallerED->setValidator(new QDoubleValidator(
187                 screenfontsModule->screenSmallerED));
188         screenfontsModule->screenSmallED->setValidator(new QDoubleValidator(
189                 screenfontsModule->screenSmallED));
190         screenfontsModule->screenNormalED->setValidator(new QDoubleValidator(
191                 screenfontsModule->screenNormalED));
192         screenfontsModule->screenLargeED->setValidator(new QDoubleValidator(
193                 screenfontsModule->screenLargeED));
194         screenfontsModule->screenLargerED->setValidator(new QDoubleValidator(
195                 screenfontsModule->screenLargerED));
196         screenfontsModule->screenLargestED->setValidator(new QDoubleValidator(
197                 screenfontsModule->screenLargestED));
198         screenfontsModule->screenHugeED->setValidator(new QDoubleValidator(
199                 screenfontsModule->screenHugeED));
200         screenfontsModule->screenHugerED->setValidator(new QDoubleValidator(
201                 screenfontsModule->screenHugerED));
202
203
204         
205
206         colorsModule = new UiWidget<Ui::QPrefColorsUi>(this);
207         // FIXME: put in controller
208         for (int i = 0; i < LColor::ignore; ++i) {
209                 LColor::color lc = static_cast<LColor::color>(i);
210                 if (lc == LColor::none
211                         || lc == LColor::black
212                         || lc == LColor::white
213                         || lc == LColor::red
214                         || lc == LColor::green
215                         || lc == LColor::blue
216                         || lc == LColor::cyan
217                         || lc == LColor::magenta
218                         || lc == LColor::yellow
219                         || lc == LColor::inherit
220                         || lc == LColor::ignore) continue;
221
222                 colors_.push_back(lc);
223                 string const guiname(lcolor.getGUIName(lc));
224                 QColorItem * ci(new QColorItem(lcolorcache.get(lc),
225                                 toqstr(guiname)));
226                 colorsModule->lyxObjectsLB->insertItem(ci);
227         }
228         connect(colorsModule->colorChangePB, SIGNAL(clicked()), this, SLOT(change_color()));
229         connect(colorsModule->lyxObjectsLB, SIGNAL(selected(int)), this, SLOT(change_color()));
230
231
232
233
234 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
235         cygwinpathModule = new UiWidget<Ui::QPrefCygwinPathUi>(this);
236         connect(cygwinpathModule->pathCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
237 #endif
238
239
240
241         displayModule = new UiWidget<Ui::QPrefDisplayUi>(this);
242         connect(displayModule->instantPreviewCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
243         connect(displayModule->displayGraphicsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
244         
245
246
247         pathsModule = new UiWidget<Ui::QPrefPathsUi>(this);
248         connect(pathsModule->templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
249         connect(pathsModule->tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
250         connect(pathsModule->backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
251         connect(pathsModule->workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
252         connect(pathsModule->lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
253         connect(pathsModule->workingDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
254         connect(pathsModule->templateDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
255         connect(pathsModule->backupDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
256         connect(pathsModule->tempDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
257         connect(pathsModule->lyxserverDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
258         connect(pathsModule->pathPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
259         
260
261
262         spellcheckerModule = new UiWidget<Ui::QPrefSpellcheckerUi>(this);
263         connect(spellcheckerModule->persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
264 #if defined (USE_ISPELL)
265         connect(spellcheckerModule->spellCommandCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
266 #else
267         spellcheckerModule->spellCommandCO->setEnabled(false);
268 #endif
269         connect(spellcheckerModule->altLanguageED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
270         connect(spellcheckerModule->escapeCharactersED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
271         connect(spellcheckerModule->persDictionaryED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
272         connect(spellcheckerModule->compoundWordCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
273         connect(spellcheckerModule->inputEncodingCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
274         spellcheckerModule->spellCommandCO->insertItem(qt_("ispell"));
275         spellcheckerModule->spellCommandCO->insertItem(qt_("aspell"));
276         spellcheckerModule->spellCommandCO->insertItem(qt_("hspell"));
277 #ifdef USE_PSPELL
278         spellcheckerModule->spellCommandCO->insertItem(qt_("pspell (library)"));
279 #else
280 #ifdef USE_ASPELL
281         spellcheckerModule->spellCommandCO->insertItem(qt_("aspell (library)"));
282 #endif
283 #endif
284
285         
286
287         convertersModule = new UiWidget<Ui::QPrefConvertersUi>(this);
288         connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter()));
289         connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
290         connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(modify_converter()));
291         connect(convertersModule->convertersLB, SIGNAL(highlighted(int)), this, SLOT(switch_converter(int)));
292         connect(convertersModule->converterFromCO, SIGNAL(activated(const QString&)), this, SLOT(converter_changed()));
293         connect(convertersModule->converterToCO, SIGNAL(activated(const QString&)), this, SLOT(converter_changed()));
294         connect(convertersModule->converterED, SIGNAL(textChanged(const QString&)), this, SLOT(converter_changed()));
295         connect(convertersModule->converterFlagED, SIGNAL(textChanged(const QString&)), this, SLOT(converter_changed()));
296         connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
297         connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
298         connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
299
300         
301
302         copiersModule = new UiWidget<Ui::QPrefCopiersUi>(this);
303         connect(copiersModule->copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
304         connect(copiersModule->copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
305         connect(copiersModule->copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
306         connect(copiersModule->AllCopiersLB, SIGNAL(highlighted(int)), this, SLOT(switch_copierLB(int)));
307         connect(copiersModule->copierFormatCO, SIGNAL(activated(int)), this, SLOT(switch_copierCO(int)));
308         connect(copiersModule->copierNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
309         connect(copiersModule->copierRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
310         connect(copiersModule->copierModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
311         connect(copiersModule->copierFormatCO, SIGNAL(activated(const QString&)), this, SLOT(copiers_changed()));
312         connect(copiersModule->copierED, SIGNAL(textChanged(const QString&)), this, SLOT(copiers_changed()));
313         
314
315
316
317         fileformatsModule = new UiWidget<Ui::QPrefFileformatsUi>(this);
318         connect(fileformatsModule->formatNewPB, SIGNAL(clicked()), this, SLOT(new_format()));
319         connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format()));
320         connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format()));
321         connect(fileformatsModule->formatsLB, SIGNAL(highlighted(int)), this, SLOT(switch_format(int)));
322         connect(fileformatsModule->formatED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
323         connect(fileformatsModule->guiNameED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
324         connect(fileformatsModule->shortcutED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
325         connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
326         connect(fileformatsModule->viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
327         connect(fileformatsModule->editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
328         connect(fileformatsModule->formatNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
329         connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
330         connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
331         
332
333
334
335         languageModule = new UiWidget<Ui::QPrefLanguageUi>(this);
336         connect(languageModule->rtlCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
337         connect(languageModule->markForeignCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
338         connect(languageModule->autoBeginCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
339         connect(languageModule->autoEndCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
340         connect(languageModule->useBabelCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
341         connect(languageModule->globalCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
342         connect(languageModule->languagePackageED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
343         connect(languageModule->startCommandED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
344         connect(languageModule->endCommandED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
345         connect(languageModule->defaultLanguageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
346
347         languageModule->defaultLanguageCO->clear();
348
349         // store the lang identifiers for later
350         using lyx::frontend::LanguagePair;
351         std::vector<LanguagePair> const langs =
352                 lyx::frontend::getLanguageData(false);
353         lang_ = getSecond(langs);
354
355         std::vector<LanguagePair>::const_iterator lit  = langs.begin();
356         std::vector<LanguagePair>::const_iterator lend = langs.end();
357         for (; lit != lend; ++lit) {
358                 languageModule->defaultLanguageCO->insertItem(toqstr(lit->first));
359         }
360
361
362
363         
364         
365         printerModule = new UiWidget<Ui::QPrefPrinterUi>(this);
366         connect(printerModule->printerAdaptCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
367         connect(printerModule->printerCommandED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
368         connect(printerModule->printerNameED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
369         connect(printerModule->printerPageRangeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
370         connect(printerModule->printerCopiesED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
371         connect(printerModule->printerReverseED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
372         connect(printerModule->printerToPrinterED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
373         connect(printerModule->printerExtensionED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
374         connect(printerModule->printerSpoolCommandED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
375         connect(printerModule->printerPaperTypeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
376         connect(printerModule->printerEvenED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
377         connect(printerModule->printerOddED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
378         connect(printerModule->printerCollatedED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
379         connect(printerModule->printerLandscapeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
380         connect(printerModule->printerToFileED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
381         connect(printerModule->printerExtraED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
382         connect(printerModule->printerSpoolPrefixED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
383         connect(printerModule->printerPaperSizeED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
384         
385
386
387
388         uiModule = new UiWidget<Ui::QPrefUi>(this);
389     connect( uiModule->autoSaveCB, SIGNAL( toggled(bool) ), uiModule->autoSaveLA, SLOT( setEnabled(bool) ) );
390     connect( uiModule->autoSaveCB, SIGNAL( toggled(bool) ), uiModule->autoSaveSB, SLOT( setEnabled(bool) ) );
391     connect( uiModule->autoSaveCB, SIGNAL( toggled(bool) ), uiModule->TextLabel1, SLOT( setEnabled(bool) ) );
392         connect(uiModule->uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui()));
393         connect(uiModule->bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind()));
394         connect(uiModule->uiFileED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
395         connect(uiModule->bindFileED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
396         connect(uiModule->cursorFollowsCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
397         connect(uiModule->wheelMouseSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
398         connect(uiModule->autoSaveSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
399         connect(uiModule->autoSaveCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
400         connect(uiModule->lastfilesSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
401         uiModule->lastfilesSB->setMaxValue(maxlastfiles);
402
403
404
405
406         identityModule = new UiWidget<Ui::QPrefIdentityUi>(this);
407         connect(identityModule->nameED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
408         connect(identityModule->emailED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
409
410
411
412
413         string const laf = _("Look and feel");
414         prefsPS->addCategory(laf);
415         prefsPS->addPanel(uiModule, _("User interface"), laf);
416         prefsPS->addPanel(screenfontsModule, _("Screen fonts"), laf);
417         prefsPS->addPanel(colorsModule, _("Colors"), laf);
418         prefsPS->addPanel(displayModule, _("Graphics"), laf);
419         prefsPS->addPanel(keyboardModule, _("Keyboard"), laf);
420
421         string const ls = _("Language settings");
422         prefsPS->addCategory(ls);
423         prefsPS->addPanel(languageModule, _("Language"), ls);
424         prefsPS->addPanel(spellcheckerModule, _("Spellchecker"), ls);
425
426         string const op = _("Outputs");
427         prefsPS->addCategory(op);
428         prefsPS->addPanel(asciiModule, _("Plain text"), op);
429         prefsPS->addPanel(dateModule, _("Date format"), op);
430         prefsPS->addPanel(latexModule, _("LaTeX"), op);
431 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
432         prefsPS->addPanel(cygwinpathModule, _("Paths"), op);
433 #endif
434         prefsPS->addPanel(printerModule, _("Printer"), op);
435
436         prefsPS->addPanel(identityModule, _("Identity"));
437         prefsPS->addPanel(pathsModule, _("Paths"));
438         prefsPS->addPanel(fileformatsModule, _("File formats"));
439         prefsPS->addPanel(convertersModule, _("Converters"));
440         prefsPS->addPanel(copiersModule, _("Copiers"));
441
442         prefsPS->setCurrentPanel(_("User interface"));
443
444
445         form_->bcview().setOK(savePB);
446         form_->bcview().setApply(applyPB);
447         form_->bcview().setCancel(closePB);
448         form_->bcview().setRestore(restorePB);
449 }
450
451
452
453
454 QPrefsDialog::~QPrefsDialog()
455 {
456 }
457
458
459 void QPrefsDialog::closeEvent(QCloseEvent * e)
460 {
461         form_->slotWMHide();
462         e->accept();
463 }
464
465
466 void QPrefsDialog::change_adaptor()
467 {
468         form_->changed();
469 }
470
471
472 void QPrefsDialog::updateConverters()
473 {
474         Ui::QPrefConvertersUi* convertmod(convertersModule);
475
476         // save current selection
477         QString current = convertmod->converterFromCO->currentText()
478                 + " -> " + convertmod->converterToCO->currentText();
479
480         convertmod->converterFromCO->clear();
481         convertmod->converterToCO->clear();
482
483         Formats::const_iterator cit = form_->formats().begin();
484         Formats::const_iterator end = form_->formats().end();
485         for (; cit != end; ++cit) {
486                 convertmod->converterFromCO->insertItem(toqstr(cit->prettyname()));
487                 convertmod->converterToCO->insertItem(toqstr(cit->prettyname()));
488         }
489
490         convertmod->convertersLB->clear();
491
492         Converters::const_iterator ccit = form_->converters().begin();
493         Converters::const_iterator cend = form_->converters().end();
494         for (; ccit != cend; ++ccit) {
495                 std::string const name = ccit->From->prettyname() + " -> "
496                         + ccit->To->prettyname();
497                 convertmod->convertersLB->insertItem(toqstr(name));
498         }
499
500         // restore selection
501         if (!current.isEmpty()) {
502                 Q3ListBoxItem * item = convertmod->convertersLB->findItem(current);
503                 convertmod->convertersLB->setCurrentItem(item);
504         }
505         // select first element if restoring failed
506         if (convertmod->convertersLB->currentItem() == -1)
507                 convertmod->convertersLB->setCurrentItem(0);
508
509         updateConverterButtons();
510 }
511
512
513 void QPrefsDialog::switch_converter(int nr)
514 {
515         Converter const & c(form_->converters().get(nr));
516         convertersModule->converterFromCO->setCurrentItem(form_->formats().getNumber(c.from));
517         convertersModule->converterToCO->setCurrentItem(form_->formats().getNumber(c.to));
518         convertersModule->converterED->setText(toqstr(c.command));
519         convertersModule->converterFlagED->setText(toqstr(c.flags));
520
521         updateConverterButtons();
522 }
523
524
525 void QPrefsDialog::converter_changed()
526 {
527         updateConverterButtons();
528 }
529
530
531 void QPrefsDialog::updateConverterButtons()
532 {
533         Format const & from(form_->formats().get(
534                 convertersModule->converterFromCO->currentItem()));
535         Format const & to(form_->formats().get(
536                 convertersModule->converterToCO->currentItem()));
537         int const sel = form_->converters().getNumber(from.name(), to.name());
538         bool const known = !(sel < 0);
539         bool const valid = !(convertersModule->converterED->text().isEmpty()
540                 || from.name() == to.name());
541
542         Converter const & c(form_->converters().get(
543                 convertersModule->convertersLB->currentItem()));
544         string const old_command = c.command;
545         string const old_flag = c.flags;
546         string const new_command(fromqstr(convertersModule->converterED->text()));
547         string const new_flag(fromqstr(convertersModule->converterFlagED->text()));
548
549         bool modified = ((old_command != new_command) || (old_flag != new_flag));
550
551         convertersModule->converterModifyPB->setEnabled(valid && known && modified);
552         convertersModule->converterNewPB->setEnabled(valid && !known);
553         convertersModule->converterRemovePB->setEnabled(known);
554 }
555
556
557 // FIXME: user must
558 // specify unique from/to or it doesn't appear. This is really bad UI
559 void QPrefsDialog::new_converter()
560 {
561         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
562         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
563         string const command(fromqstr(convertersModule->converterED->text()));
564         string const flags(fromqstr(convertersModule->converterFlagED->text()));
565
566         Converter const * old = form_->converters().getConverter(from.name(), to.name());
567         form_->converters().add(from.name(), to.name(), command, flags);
568         if (!old) {
569                 form_->converters().updateLast(form_->formats());
570         }
571         updateConverters();
572         convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1);
573 }
574
575
576 void QPrefsDialog::modify_converter()
577 {
578         int const top_item = convertersModule->convertersLB->topItem();
579         QString const current_text =
580                 convertersModule->convertersLB->currentText();
581
582         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
583         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
584         string flags(fromqstr(convertersModule->converterFlagED->text()));
585         string name(fromqstr(convertersModule->converterED->text()));
586
587         Converter const * old = form_->converters().getConverter(from.name(), to.name());
588         form_->converters().add(from.name(), to.name(), name, flags);
589         if (!old) {
590                 form_->converters().updateLast(form_->formats());
591         }
592         updateConverters();
593
594         Q3ListBoxItem * const item =
595                 convertersModule->convertersLB->findItem(current_text);
596         convertersModule->convertersLB->setCurrentItem(item);
597         convertersModule->convertersLB->setTopItem(top_item);
598 }
599
600
601 void QPrefsDialog::remove_converter()
602 {
603         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
604         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
605         form_->converters().erase(from.name(), to.name());
606         updateConverters();
607 }
608
609
610 void QPrefsDialog::updateCopiers()
611 {
612         // The choice widget
613         // save current selection
614         QString current = copiersModule->copierFormatCO->currentText();
615         copiersModule->copierFormatCO->clear();
616
617         for (Formats::const_iterator it = form_->formats().begin(),
618                      end = form_->formats().end();
619              it != end; ++it) {
620                 copiersModule->copierFormatCO->insertItem(toqstr(it->prettyname()));
621         }
622
623         // The browser widget
624         copiersModule->AllCopiersLB->clear();
625
626         for (Movers::iterator it = form_->movers().begin(),
627                      end = form_->movers().end();
628              it != end; ++it) {
629                 std::string const & command = it->second.command();
630                 if (command.empty())
631                         continue;
632                 std::string const & fmt = it->first;
633                 std::string const & pretty = form_->formats().prettyName(fmt);
634
635                 copiersModule->AllCopiersLB->insertItem(toqstr(pretty));
636         }
637
638         // restore selection
639         if (!current.isEmpty()) {
640                 Q3ListBoxItem * item = copiersModule->AllCopiersLB->findItem(current);
641                 copiersModule->AllCopiersLB->setCurrentItem(item);
642         }
643         // select first element if restoring failed
644         if (copiersModule->AllCopiersLB->currentItem() == -1)
645                 copiersModule->AllCopiersLB->setCurrentItem(0);
646 }
647
648
649 namespace {
650
651 class SamePrettyName {
652 public:
653         SamePrettyName(string const & n) : pretty_name_(n) {}
654
655         bool operator()(::Format const & fmt) const {
656                 return fmt.prettyname() == pretty_name_;
657         }
658
659 private:
660         string const pretty_name_;
661 };
662
663
664 Format const * getFormat(std::string const & prettyname)
665 {
666         Formats::const_iterator it = ::formats.begin();
667         Formats::const_iterator const end = ::formats.end();
668         it = std::find_if(it, end, SamePrettyName(prettyname));
669         return it == end ? 0 : &*it;
670 }
671
672 } // namespace anon
673
674
675 void QPrefsDialog::switch_copierLB(int)
676 {
677         std::string const browser_text =
678                 fromqstr(copiersModule->AllCopiersLB->currentText());
679         Format const * fmt = getFormat(browser_text);
680         if (fmt == 0)
681                 return;
682
683         string const & fmt_name = fmt->name();
684         string const & gui_name = fmt->prettyname();
685         string const & command = form_->movers().command(fmt_name);
686
687         copiersModule->copierED->clear();
688         int const combo_size = copiersModule->copierFormatCO->count();
689         for (int i = 0; i < combo_size; ++i) {
690                 QString const qtext = copiersModule->copierFormatCO->text(i);
691                 std::string const text = fromqstr(qtext);
692                 if (text == gui_name) {
693                         copiersModule->copierFormatCO->setCurrentItem(i);
694                         copiersModule->copierED->setText(toqstr(command));
695                         break;
696                 }
697         }
698         updateCopierButtons();
699 }
700
701
702 void QPrefsDialog::switch_copierCO(int)
703 {
704         std::string const combo_text =
705                 fromqstr(copiersModule->copierFormatCO->currentText());
706         Format const * fmt = getFormat(combo_text);
707         if (fmt == 0)
708                 return;
709
710         string const & fmt_name = fmt->name();
711         string const & gui_name = fmt->prettyname();
712         string const & command = form_->movers().command(fmt_name);
713
714         copiersModule->copierED->setText(toqstr(command));
715
716         int const index = copiersModule->AllCopiersLB->currentItem();
717         if (index >= 0)
718                 copiersModule->AllCopiersLB->setSelected(index, false);
719
720         int const browser_size = copiersModule->AllCopiersLB->count();
721         for (int i = 0; i < browser_size; ++i) {
722                 QString const qtext = copiersModule->AllCopiersLB->text(i);
723                 std::string const text = fromqstr(qtext);
724                 if (text == gui_name) {
725                         copiersModule->AllCopiersLB->setSelected(i, true);
726                         int top = std::max(i - 5, 0);
727                         copiersModule->AllCopiersLB->setTopItem(top);
728                         break;
729                 }
730         }
731 }
732
733
734 void QPrefsDialog::copiers_changed()
735 {
736         updateCopierButtons();
737 }
738
739
740 void QPrefsDialog::updateCopierButtons()
741 {
742         QString selected = copiersModule->copierFormatCO->currentText();
743
744         bool known = false;
745         for (unsigned int i = 0; i != copiersModule->AllCopiersLB->count(); i++) {
746                 if (copiersModule->AllCopiersLB->text(i) == selected)
747                         known = true;
748         }
749
750         bool const valid = !copiersModule->copierED->text().isEmpty();
751
752         Format const * fmt = getFormat(fromqstr(selected));
753         string const old_command = form_->movers().command(fmt->name());
754         string const new_command(fromqstr(copiersModule->copierED->text()));
755
756         bool modified = (old_command != new_command);
757
758         copiersModule->copierModifyPB->setEnabled(valid && known && modified);
759         copiersModule->copierNewPB->setEnabled(valid && !known);
760         copiersModule->copierRemovePB->setEnabled(known);
761 }
762
763
764 void QPrefsDialog::new_copier()
765 {
766         std::string const combo_text =
767                 fromqstr(copiersModule->copierFormatCO->currentText());
768         Format const * fmt = getFormat(combo_text);
769         if (fmt == 0)
770                 return;
771
772         string const command = fromqstr(copiersModule->copierED->text());
773         if (command.empty())
774                 return;
775
776         form_->movers().set(fmt->name(), command);
777
778         updateCopiers();
779         int const last = copiersModule->AllCopiersLB->count() - 1;
780         copiersModule->AllCopiersLB->setCurrentItem(last);
781
782         updateCopierButtons();
783 }
784
785
786 void QPrefsDialog::modify_copier()
787 {
788         std::string const combo_text =
789                 fromqstr(copiersModule->copierFormatCO->currentText());
790         Format const * fmt = getFormat(combo_text);
791         if (fmt == 0)
792                 return;
793
794         string const command = fromqstr(copiersModule->copierED->text());
795         form_->movers().set(fmt->name(), command);
796
797         updateCopiers();
798         updateCopierButtons();
799 }
800
801
802 void QPrefsDialog::remove_copier()
803 {
804         std::string const combo_text =
805                 fromqstr(copiersModule->copierFormatCO->currentText());
806         Format const * fmt = getFormat(combo_text);
807         if (fmt == 0)
808                 return;
809
810         string const & fmt_name = fmt->name();
811         form_->movers().set(fmt_name, string());
812
813         updateCopiers();
814         updateCopierButtons();
815 }
816
817
818 void QPrefsDialog::updateFormats()
819 {
820         Ui::QPrefFileformatsUi * formatmod(fileformatsModule);
821
822         // save current selection
823         QString current = formatmod->guiNameED->text();
824
825         formatmod->formatsLB->clear();
826
827         Formats::const_iterator cit = form_->formats().begin();
828         Formats::const_iterator end = form_->formats().end();
829         for (; cit != end; ++cit) {
830                 formatmod->formatsLB->insertItem(toqstr(cit->prettyname()));
831         }
832
833         // restore selection
834         if (!current.isEmpty()) {
835                 Q3ListBoxItem * item = formatmod->formatsLB->findItem(current);
836                 formatmod->formatsLB->setCurrentItem(item);
837         }
838         // select first element if restoring failed
839         if (formatmod->formatsLB->currentItem() == -1)
840                 formatmod->formatsLB->setCurrentItem(0);
841 }
842
843
844 void QPrefsDialog::switch_format(int nr)
845 {
846         Format const & f(form_->formats().get(nr));
847         fileformatsModule->formatED->setText(toqstr(f.name()));
848         fileformatsModule->guiNameED->setText(toqstr(f.prettyname()));
849         fileformatsModule->extensionED->setText(toqstr(f.extension()));
850         fileformatsModule->shortcutED->setText(toqstr(f.shortcut()));
851         fileformatsModule->viewerED->setText(toqstr(f.viewer()));
852         fileformatsModule->editorED->setText(toqstr(f.editor()));
853         fileformatsModule->formatRemovePB->setEnabled(
854                 !form_->converters().formatIsUsed(f.name()));
855
856         updateFormatsButtons();
857 }
858
859
860 void QPrefsDialog::fileformat_changed()
861 {
862         updateFormatsButtons();
863 }
864
865
866 void QPrefsDialog::updateFormatsButtons()
867 {
868         QString const format = fileformatsModule->formatED->text();
869         QString const gui_name = fileformatsModule->guiNameED->text();
870         int const sel = form_->formats().getNumber(fromqstr(format));
871         bool gui_name_known = false;
872         int where = sel;
873         for (unsigned int i = 0; i != fileformatsModule->formatsLB->count(); i++) {
874                 if (fileformatsModule->formatsLB->text(i) == gui_name) {
875                         gui_name_known = true;
876                         where = i;
877                 }
878         }
879
880         // assure that a gui name cannot be chosen twice
881         bool const known_otherwise = gui_name_known && (where != sel);
882
883         bool const known = !(sel < 0);
884         bool const valid = (!fileformatsModule->formatED->text().isEmpty()
885                 && !fileformatsModule->guiNameED->text().isEmpty());
886
887         Format const & f(form_->formats().get(
888                 fileformatsModule->formatsLB->currentItem()));
889         string const old_pretty(f.prettyname());
890         string const old_shortcut(f.shortcut());
891         string const old_extension(f.extension());
892         string const old_viewer(f.viewer());
893         string const old_editor(f.editor());
894
895         string const new_pretty(fromqstr(gui_name));
896         string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text()));
897         string const new_extension(fromqstr(fileformatsModule->extensionED->text()));
898         string const new_viewer(fromqstr(fileformatsModule->viewerED->text()));
899         string const new_editor(fromqstr(fileformatsModule->editorED->text()));
900
901         bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
902                 || (old_extension != new_extension) || (old_viewer != new_viewer)
903                 || (old_editor != new_editor));
904
905         fileformatsModule->formatModifyPB->setEnabled(
906                 valid && known && modified && !known_otherwise);
907         fileformatsModule->formatNewPB->setEnabled(valid && !known && !gui_name_known);
908         fileformatsModule->formatRemovePB->setEnabled(known);
909 }
910
911
912 void QPrefsDialog::new_format()
913 {
914         string const name = fromqstr(fileformatsModule->formatED->text());
915         string const prettyname = fromqstr(fileformatsModule->guiNameED->text());
916         string const extension = fromqstr(fileformatsModule->extensionED->text());
917         string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
918         string const viewer = fromqstr(fileformatsModule->viewerED->text());
919         string const editor = fromqstr(fileformatsModule->editorED->text());
920
921         form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
922         form_->formats().sort();
923         updateFormats();
924         fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name));
925         form_->converters().update(form_->formats());
926
927         updateConverters();
928         updateFormatsButtons();
929 }
930
931
932 void QPrefsDialog::modify_format()
933 {
934         int const top_item = fileformatsModule->formatsLB->topItem();
935         int const current_item = fileformatsModule->formatsLB->currentItem();
936         QString const current_text =
937                 fileformatsModule->formatsLB->currentText();
938
939         Format const & oldformat(form_->formats().get(current_item));
940         string const oldpretty(oldformat.prettyname());
941         string const name(fromqstr(fileformatsModule->formatED->text()));
942         form_->formats().erase(oldformat.name());
943
944         string const prettyname = fromqstr(fileformatsModule->guiNameED->text());
945         string const extension = fromqstr(fileformatsModule->extensionED->text());
946         string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
947         string const viewer = fromqstr(fileformatsModule->viewerED->text());
948         string const editor = fromqstr(fileformatsModule->editorED->text());
949
950         form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
951         form_->formats().sort();
952
953         fileformatsModule->formatsLB->setUpdatesEnabled(false);
954         updateFormats();
955         fileformatsModule->formatsLB->setUpdatesEnabled(true);
956         fileformatsModule->formatsLB->update();
957
958         updateConverters();
959         updateFormatsButtons();
960
961         Q3ListBoxItem * const item =
962                 fileformatsModule->formatsLB->findItem(current_text);
963         fileformatsModule->formatsLB->setCurrentItem(item);
964         fileformatsModule->formatsLB->setTopItem(top_item);
965 }
966
967
968 void QPrefsDialog::remove_format()
969 {
970         int const nr(fileformatsModule->formatsLB->currentItem());
971         if (nr < 0)
972                 return;
973         form_->formats().erase(form_->formats().get(nr).name());
974         updateFormats();
975         form_->converters().update(form_->formats());
976
977         updateConverters();
978         updateFormatsButtons();
979 }
980
981
982 void QPrefsDialog::change_color()
983 {
984         Q3ListBox * lb(colorsModule->lyxObjectsLB);
985         if (lb->currentItem() < 0)
986                 return;
987         Q3ListBoxItem * ib(lb->item(lb->currentItem()));
988         QColorItem * ci(static_cast<QColorItem*>(ib));
989         QColor c(QColorDialog::getColor(ci->color(), qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget()));
990         if (c.isValid()) {
991                 ci->color(c);
992                 lb->triggerUpdate(false);
993                 change_adaptor();
994         }
995 }
996
997
998 void QPrefsDialog::select_ui()
999 {
1000         string file(form_->controller().browseUI(fromqstr(uiModule->uiFileED->text())));
1001         if (!file.empty())
1002                 uiModule->uiFileED->setText(toqstr(file));
1003 }
1004
1005
1006 void QPrefsDialog::select_bind()
1007 {
1008         string file(form_->controller().browsebind(fromqstr(uiModule->bindFileED->text())));
1009         if (!file.empty())
1010                 uiModule->bindFileED->setText(toqstr(file));
1011 }
1012
1013
1014 void QPrefsDialog::select_keymap1()
1015 {
1016         string file(form_->controller().browsekbmap(fromqstr(keyboardModule->firstKeymapED->text())));
1017         if (!file.empty())
1018                 keyboardModule->firstKeymapED->setText(toqstr(file));
1019 }
1020
1021
1022 void QPrefsDialog::select_keymap2()
1023 {
1024         string file(form_->controller().browsekbmap(fromqstr(keyboardModule->secondKeymapED->text())));
1025         if (!file.empty())
1026                 keyboardModule->secondKeymapED->setText(toqstr(file));
1027 }
1028
1029
1030 void QPrefsDialog::select_dict()
1031 {
1032         string file(form_->controller().browsedict(fromqstr(spellcheckerModule->persDictionaryED->text())));
1033         if (!file.empty())
1034                 spellcheckerModule->persDictionaryED->setText(toqstr(file));
1035 }
1036
1037
1038 // NB: the _() is OK here because it gets passed back and we toqstr() them
1039
1040 void QPrefsDialog::select_templatedir()
1041 {
1042         string file(form_->controller().browsedir(fromqstr(pathsModule->templateDirED->text()), _("Select a document templates directory")));
1043         if (!file.empty())
1044                 pathsModule->templateDirED->setText(toqstr(file));
1045 }
1046
1047
1048 void QPrefsDialog::select_tempdir()
1049 {
1050         string file(form_->controller().browsedir(fromqstr(pathsModule->tempDirED->text()), _("Select a temporary directory")));
1051         if (!file.empty())
1052                 pathsModule->tempDirED->setText(toqstr(file));
1053 }
1054
1055
1056 void QPrefsDialog::select_backupdir()
1057 {
1058         string file(form_->controller().browsedir(fromqstr(pathsModule->backupDirED->text()), _("Select a backups directory")));
1059         if (!file.empty())
1060                 pathsModule->backupDirED->setText(toqstr(file));
1061 }
1062
1063
1064 void QPrefsDialog::select_workingdir()
1065 {
1066         string file(form_->controller().browsedir(fromqstr(pathsModule->workingDirED->text()), _("Select a document directory")));
1067         if (!file.empty())
1068                 pathsModule->workingDirED->setText(toqstr(file));
1069 }
1070
1071
1072 void QPrefsDialog::select_lyxpipe()
1073 {
1074         string file(form_->controller().browse(fromqstr(pathsModule->lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
1075         if (!file.empty())
1076                 pathsModule->lyxserverDirED->setText(toqstr(file));
1077 }
1078
1079
1080 void QPrefsDialog::select_roman(const QString& name)
1081 {
1082         screenfontsModule->screenRomanFE->set(QFont(name), name);
1083 }
1084
1085
1086 void QPrefsDialog::select_sans(const QString& name)
1087 {
1088         screenfontsModule->screenSansFE->set(QFont(name), name);
1089 }
1090
1091
1092 void QPrefsDialog::select_typewriter(const QString& name)
1093 {
1094         screenfontsModule->screenTypewriterFE->set(QFont(name), name);
1095 }
1096
1097 namespace {
1098
1099 string const internal_path(QString const & input)
1100 {
1101         return lyx::support::os::internal_path(fromqstr(input));
1102 }
1103
1104 }
1105
1106 void QPrefsDialog::apply(LyXRC & rc) const
1107 {
1108         // FIXME: remove rtl_support bool
1109         rc.rtl_support = languageModule->rtlCB->isChecked();
1110         rc.mark_foreign_language = languageModule->markForeignCB->isChecked();
1111         rc.language_auto_begin = languageModule->autoBeginCB->isChecked();
1112         rc.language_auto_end = languageModule->autoEndCB->isChecked();
1113         rc.language_use_babel = languageModule->useBabelCB->isChecked();
1114         rc.language_global_options = languageModule->globalCB->isChecked();
1115         rc.language_package = fromqstr(languageModule->languagePackageED->text());
1116         rc.language_command_begin = fromqstr(languageModule->startCommandED->text());
1117         rc.language_command_end = fromqstr(languageModule->endCommandED->text());
1118         rc.default_language = lang_[languageModule->defaultLanguageCO->currentItem()];
1119
1120
1121         rc.ui_file = internal_path(uiModule->uiFileED->text());
1122         rc.bind_file = internal_path(uiModule->bindFileED->text());
1123         rc.cursor_follows_scrollbar = uiModule->cursorFollowsCB->isChecked();
1124         rc.wheel_jump = uiModule->wheelMouseSB->value();
1125         rc.autosave = uiModule->autoSaveSB->value() * 60;
1126         rc.make_backup = uiModule->autoSaveCB->isChecked();
1127         rc.num_lastfiles = uiModule->lastfilesSB->value();
1128
1129
1130         // FIXME: can derive CB from the two EDs
1131         rc.use_kbmap = keyboardModule->keymapCB->isChecked();
1132         rc.primary_kbmap = internal_path(keyboardModule->firstKeymapED->text());
1133         rc.secondary_kbmap = internal_path(keyboardModule->secondKeymapED->text());
1134
1135
1136         rc.ascii_linelen = asciiModule->asciiLinelengthSB->value();
1137         rc.ascii_roff_command = fromqstr(asciiModule->asciiRoffED->text());
1138
1139
1140         rc.date_insert_format = fromqstr(dateModule->DateED->text());
1141
1142
1143 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
1144         rc.cygwin_path_fix = cygwinpathModule->pathCB->isChecked();
1145 #endif
1146
1147
1148         rc.fontenc = fromqstr(latexModule->latexEncodingED->text());
1149         rc.chktex_command = fromqstr(latexModule->latexChecktexED->text());
1150         rc.bibtex_command = fromqstr(latexModule->latexBibtexED->text());
1151         rc.index_command = fromqstr(latexModule->latexIndexED->text());
1152         rc.auto_reset_options = latexModule->latexAutoresetCB->isChecked();
1153         rc.view_dvi_paper_option = fromqstr(latexModule->latexDviPaperED->text());
1154         rc.default_papersize =
1155                 form_->controller().toPaperSize(latexModule->latexPaperSizeCO->currentItem());
1156
1157
1158         switch (displayModule->instantPreviewCO->currentItem()) {
1159         case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
1160         case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
1161         case 2: rc.preview = LyXRC::PREVIEW_ON; break;
1162         }
1163
1164         lyx::graphics::DisplayType dtype;
1165         switch (displayModule->displayGraphicsCO->currentItem()) {
1166         case 3: dtype = lyx::graphics::NoDisplay; break;
1167         case 2: dtype = lyx::graphics::ColorDisplay; break;
1168         case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
1169         case 0: dtype = lyx::graphics::MonochromeDisplay; break;
1170         default: dtype = lyx::graphics::GrayscaleDisplay;
1171         }
1172         rc.display_graphics = dtype;
1173
1174 #ifdef WITH_WARNINGS
1175 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1176 #endif
1177 #if 0
1178         if (old_value != rc.display_graphics) {
1179                 lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
1180                 gc.changeDisplay();
1181         }
1182 #endif
1183
1184
1185         rc.document_path = internal_path(pathsModule->workingDirED->text());
1186         rc.template_path = internal_path(pathsModule->templateDirED->text());
1187         rc.backupdir_path = internal_path(pathsModule->backupDirED->text());
1188         rc.tempdir_path = internal_path(pathsModule->tempDirED->text());
1189         rc.path_prefix = fromqstr(pathsModule->pathPrefixED->text());
1190         // FIXME: should be a checkbox only
1191         rc.lyxpipes = internal_path(pathsModule->lyxserverDirED->text());
1192
1193
1194         switch (spellcheckerModule->spellCommandCO->currentItem()) {
1195                 case 0:
1196                 case 1:
1197                 case 2:
1198                         rc.use_spell_lib = false;
1199                         rc.isp_command = fromqstr(spellcheckerModule->spellCommandCO->currentText());
1200                         break;
1201                 case 3:
1202                         rc.use_spell_lib = true;
1203                         break;
1204         }
1205
1206         // FIXME: remove isp_use_alt_lang
1207         rc.isp_alt_lang = fromqstr(spellcheckerModule->altLanguageED->text());
1208         rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
1209         // FIXME: remove isp_use_esc_chars
1210         rc.isp_esc_chars = fromqstr(spellcheckerModule->escapeCharactersED->text());
1211         rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
1212         // FIXME: remove isp_use_pers_dict
1213         rc.isp_pers_dict = internal_path(spellcheckerModule->persDictionaryED->text());
1214         rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
1215         rc.isp_accept_compound = spellcheckerModule->compoundWordCB->isChecked();
1216         rc.isp_use_input_encoding = spellcheckerModule->inputEncodingCB->isChecked();
1217
1218
1219
1220         rc.print_adapt_output = printerModule->printerAdaptCB->isChecked();
1221         rc.print_command = fromqstr(printerModule->printerCommandED->text());
1222         rc.printer = fromqstr(printerModule->printerNameED->text());
1223
1224         rc.print_pagerange_flag = fromqstr(printerModule->printerPageRangeED->text());
1225         rc.print_copies_flag = fromqstr(printerModule->printerCopiesED->text());
1226         rc.print_reverse_flag = fromqstr(printerModule->printerReverseED->text());
1227         rc.print_to_printer = fromqstr(printerModule->printerToPrinterED->text());
1228         rc.print_file_extension = fromqstr(printerModule->printerExtensionED->text());
1229         rc.print_spool_command = fromqstr(printerModule->printerSpoolCommandED->text());
1230         rc.print_paper_flag = fromqstr(printerModule->printerPaperTypeED->text());
1231         rc.print_evenpage_flag = fromqstr(printerModule->printerEvenED->text());
1232         rc.print_oddpage_flag = fromqstr(printerModule->printerOddED->text());
1233         rc.print_collcopies_flag = fromqstr(printerModule->printerCollatedED->text());
1234         rc.print_landscape_flag = fromqstr(printerModule->printerLandscapeED->text());
1235         rc.print_to_file = internal_path(printerModule->printerToFileED->text());
1236         rc.print_extra_options = fromqstr(printerModule->printerExtraED->text());
1237         rc.print_spool_printerprefix = fromqstr(printerModule->printerSpoolPrefixED->text());
1238         rc.print_paper_dimension_flag = fromqstr(printerModule->printerPaperSizeED->text());
1239
1240
1241
1242         rc.user_name = fromqstr(identityModule->nameED->text());
1243         rc.user_email = fromqstr(identityModule->emailED->text());
1244
1245
1246
1247         LyXRC const oldrc(rc);
1248
1249         boost::tie(rc.roman_font_name, rc.roman_font_foundry)
1250                 = parseFontName(fromqstr(screenfontsModule->screenRomanCO->currentText()));
1251         boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
1252                 parseFontName(fromqstr(screenfontsModule->screenSansCO->currentText()));
1253         boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
1254                 parseFontName(fromqstr(screenfontsModule->screenTypewriterCO->currentText()));
1255
1256         rc.zoom = screenfontsModule->screenZoomSB->value();
1257         rc.dpi = screenfontsModule->screenDpiSB->value();
1258         rc.font_sizes[LyXFont::SIZE_TINY] = fromqstr(screenfontsModule->screenTinyED->text());
1259         rc.font_sizes[LyXFont::SIZE_SCRIPT] = fromqstr(screenfontsModule->screenSmallestED->text());
1260         rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = fromqstr(screenfontsModule->screenSmallerED->text());
1261         rc.font_sizes[LyXFont::SIZE_SMALL] = fromqstr(screenfontsModule->screenSmallED->text());
1262         rc.font_sizes[LyXFont::SIZE_NORMAL] = fromqstr(screenfontsModule->screenNormalED->text());
1263         rc.font_sizes[LyXFont::SIZE_LARGE] = fromqstr(screenfontsModule->screenLargeED->text());
1264         rc.font_sizes[LyXFont::SIZE_LARGER] = fromqstr(screenfontsModule->screenLargerED->text());
1265         rc.font_sizes[LyXFont::SIZE_LARGEST] = fromqstr(screenfontsModule->screenLargestED->text());
1266         rc.font_sizes[LyXFont::SIZE_HUGE] = fromqstr(screenfontsModule->screenHugeED->text());
1267         rc.font_sizes[LyXFont::SIZE_HUGER] = fromqstr(screenfontsModule->screenHugerED->text());
1268
1269         if (rc.font_sizes != oldrc.font_sizes
1270                 || rc.roman_font_name != oldrc.roman_font_name
1271                 || rc.sans_font_name != oldrc.sans_font_name
1272                 || rc.typewriter_font_name != oldrc.typewriter_font_name
1273                 || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
1274                 form_->controller().updateScreenFonts();
1275         }
1276
1277         
1278         
1279         
1280         unsigned int i;
1281         for (i = 0; i < colorsModule->lyxObjectsLB->count(); ++i) {
1282                 Q3ListBoxItem * ib(colorsModule->lyxObjectsLB->item(i));
1283                 QColorItem * ci(static_cast<QColorItem*>(ib));
1284
1285                 LColor::color const col(colors_[i]);
1286                 QColor const & qcol(lcolorcache.get(col));
1287
1288                 // FIXME: dubious, but it's what xforms does
1289                 if (qcol != ci->color()) {
1290                         ostringstream ostr;
1291
1292                         ostr << '#' << std::setbase(16) << setfill('0')
1293                              << setw(2) << ci->color().red()
1294                              << setw(2) << ci->color().green()
1295                              << setw(2) << ci->color().blue();
1296
1297                         string newhex(ostr.str());
1298                         form_->controller().setColor(col, newhex);
1299                 }
1300         }
1301 }
1302
1303 // FIXME: move to helper_funcs.h
1304 namespace {
1305
1306 template<class A>
1307 typename std::vector<A>::size_type
1308 findPos(std::vector<A> const & vec, A const & val)
1309 {
1310         typedef typename std::vector<A>::const_iterator Cit;
1311
1312         Cit it = std::find(vec.begin(), vec.end(), val);
1313         if (it == vec.end())
1314                 return 0;
1315         return distance(vec.begin(), it);
1316 }
1317
1318 void setComboxFont(QComboBox * cb, string const & family, string const & foundry)
1319 {
1320         string const name = makeFontName(family, foundry);
1321         for (int i = 0; i < cb->count(); ++i) {
1322                 if (fromqstr(cb->text(i)) == name) {
1323                         cb->setCurrentItem(i);
1324                         return;
1325                 }
1326         }
1327
1328         // Try matching without foundry name
1329
1330         // We count in reverse in order to prefer the Xft foundry
1331         for (int i = cb->count() - 1; i >= 0; --i) {
1332                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
1333                 if (compare_no_case(tmp.first, family) == 0) {
1334                         cb->setCurrentItem(i);
1335                         return;
1336                 }
1337         }
1338
1339         // family alone can contain e.g. "Helvetica [Adobe]"
1340         pair<string, string> tmpfam = parseFontName(family);
1341
1342         // We count in reverse in order to prefer the Xft foundry
1343         for (int i = cb->count() - 1; i >= 0; --i) {
1344                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
1345                 if (compare_no_case(tmp.first, tmpfam.first) == 0) {
1346                         cb->setCurrentItem(i);
1347                         return;
1348                 }
1349         }
1350
1351         // Bleh, default fonts, and the names couldn't be found. Hack
1352         // for bug 1063. Qt makes baby Jesus cry.
1353
1354         QFont font;
1355
1356         if (family == lyx_gui::roman_font_name()) {
1357                 font.setStyleHint(QFont::Serif);
1358                 font.setFamily(family.c_str());
1359         } else if (family == lyx_gui::sans_font_name()) {
1360                 font.setStyleHint(QFont::SansSerif);
1361                 font.setFamily(family.c_str());
1362         } else if (family == lyx_gui::typewriter_font_name()) {
1363                 font.setStyleHint(QFont::TypeWriter);
1364                 font.setFamily(family.c_str());
1365         } else {
1366                 lyxerr << "FAILED to find the default font: '"
1367                        << foundry << "', '" << family << '\''<< endl;
1368                 return;
1369         }
1370
1371         QFontInfo info(font);
1372         pair<string, string> tmp = parseFontName(fromqstr(info.family()));
1373         string const & default_font_name = tmp.first;
1374         lyxerr << "Apparent font is " << default_font_name << endl;
1375
1376         for (int i = 0; i < cb->count(); ++i) {
1377                 lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
1378                 if (compare_no_case(fromqstr(cb->text(i)),
1379                                     default_font_name) == 0) {
1380                         cb->setCurrentItem(i);
1381                         return;
1382                 }
1383         }
1384
1385         lyxerr << "FAILED to find the font: '"
1386                << foundry << "', '" << family << '\'' <<endl;
1387 }
1388
1389 } // end namespace anon
1390
1391 namespace {
1392
1393 QString const external_path(string const & input)
1394 {
1395         return toqstr(lyx::support::os::external_path(input));
1396 }
1397
1398 }
1399
1400 void QPrefsDialog::update(LyXRC const & rc)
1401 {
1402         // FIXME: remove rtl_support bool
1403         languageModule->rtlCB->setChecked(rc.rtl_support);
1404         languageModule->markForeignCB->setChecked(rc.mark_foreign_language);
1405         languageModule->autoBeginCB->setChecked(rc.language_auto_begin);
1406         languageModule->autoEndCB->setChecked(rc.language_auto_end);
1407         languageModule->useBabelCB->setChecked(rc.language_use_babel);
1408         languageModule->globalCB->setChecked(rc.language_global_options);
1409         languageModule->languagePackageED->setText(toqstr(rc.language_package));
1410         languageModule->startCommandED->setText(toqstr(rc.language_command_begin));
1411         languageModule->endCommandED->setText(toqstr(rc.language_command_end));
1412
1413         int const pos = int(findPos(lang_, rc.default_language));
1414         languageModule->defaultLanguageCO->setCurrentItem(pos);
1415
1416         uiModule->uiFileED->setText(external_path(rc.ui_file));
1417         uiModule->bindFileED->setText(external_path(rc.bind_file));
1418         uiModule->cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
1419         uiModule->wheelMouseSB->setValue(rc.wheel_jump);
1420         // convert to minutes
1421         int mins(rc.autosave / 60);
1422         if (rc.autosave && !mins)
1423                 mins = 1;
1424         uiModule->autoSaveSB->setValue(mins);
1425         uiModule->autoSaveCB->setChecked(rc.make_backup);
1426         uiModule->lastfilesSB->setValue(rc.num_lastfiles);
1427
1428
1429         identityModule->nameED->setText(toqstr(rc.user_name));
1430         identityModule->emailED->setText(toqstr(rc.user_email));
1431
1432
1433         // FIXME: can derive CB from the two EDs
1434         keyboardModule->keymapCB->setChecked(rc.use_kbmap);
1435         // no idea why we need these. Fscking Qt.
1436         keyboardModule->firstKeymapED->setEnabled(rc.use_kbmap);
1437         keyboardModule->firstKeymapPB->setEnabled(rc.use_kbmap);
1438         keyboardModule->firstKeymapLA->setEnabled(rc.use_kbmap);
1439         keyboardModule->secondKeymapED->setEnabled(rc.use_kbmap);
1440         keyboardModule->secondKeymapPB->setEnabled(rc.use_kbmap);
1441         keyboardModule->secondKeymapLA->setEnabled(rc.use_kbmap);
1442         keyboardModule->firstKeymapED->setText(external_path(rc.primary_kbmap));
1443         keyboardModule->secondKeymapED->setText(external_path(rc.secondary_kbmap));
1444
1445
1446
1447         asciiModule->asciiLinelengthSB->setValue(rc.ascii_linelen);
1448         asciiModule->asciiRoffED->setText(toqstr(rc.ascii_roff_command));
1449
1450
1451
1452         dateModule->DateED->setText(toqstr(rc.date_insert_format));
1453
1454
1455
1456 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
1457         cygwinpathModule->pathCB->setChecked(rc.cygwin_path_fix);
1458 #endif
1459
1460
1461
1462         latexModule->latexEncodingED->setText(toqstr(rc.fontenc));
1463         latexModule->latexChecktexED->setText(toqstr(rc.chktex_command));
1464         latexModule->latexBibtexED->setText(toqstr(rc.bibtex_command));
1465         latexModule->latexIndexED->setText(toqstr(rc.index_command));
1466         latexModule->latexAutoresetCB->setChecked(rc.auto_reset_options);
1467         latexModule->latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
1468         latexModule->latexPaperSizeCO->setCurrentItem(
1469                 form_->controller().fromPaperSize(rc.default_papersize));
1470
1471
1472
1473         switch (rc.preview) {
1474         case LyXRC::PREVIEW_OFF:
1475                 displayModule->instantPreviewCO->setCurrentItem(0);
1476                 break;
1477         case LyXRC::PREVIEW_NO_MATH :
1478                 displayModule->instantPreviewCO->setCurrentItem(1);
1479                 break;
1480         case LyXRC::PREVIEW_ON :
1481                 displayModule->instantPreviewCO->setCurrentItem(2);
1482                 break;
1483         }
1484
1485         int item = 2;
1486         switch (rc.display_graphics) {
1487                 case lyx::graphics::NoDisplay:          item = 3; break;
1488                 case lyx::graphics::ColorDisplay:       item = 2; break;
1489                 case lyx::graphics::GrayscaleDisplay:   item = 1; break;
1490                 case lyx::graphics::MonochromeDisplay:  item = 0; break;
1491                 default: break;
1492         }
1493         displayModule->displayGraphicsCO->setCurrentItem(item);
1494
1495
1496
1497         pathsModule->workingDirED->setText(external_path(rc.document_path));
1498         pathsModule->templateDirED->setText(external_path(rc.template_path));
1499         pathsModule->backupDirED->setText(external_path(rc.backupdir_path));
1500         pathsModule->tempDirED->setText(external_path(rc.tempdir_path));
1501         pathsModule->pathPrefixED->setText(toqstr(rc.path_prefix));
1502         // FIXME: should be a checkbox only
1503         pathsModule->lyxserverDirED->setText(external_path(rc.lyxpipes));
1504
1505
1506
1507         spellcheckerModule->spellCommandCO->setCurrentItem(0);
1508
1509         if (rc.isp_command == "ispell") {
1510                 spellcheckerModule->spellCommandCO->setCurrentItem(0);
1511         } else if (rc.isp_command == "aspell") {
1512                 spellcheckerModule->spellCommandCO->setCurrentItem(1);
1513         } else if (rc.isp_command == "hspell") {
1514                 spellcheckerModule->spellCommandCO->setCurrentItem(2);
1515         }
1516
1517         if (rc.use_spell_lib) {
1518 #if defined(USE_ASPELL) || defined(USE_PSPELL)
1519                 spellcheckerModule->spellCommandCO->setCurrentItem(3);
1520 #endif
1521         }
1522
1523         // FIXME: remove isp_use_alt_lang
1524         spellcheckerModule->altLanguageED->setText(toqstr(rc.isp_alt_lang));
1525         // FIXME: remove isp_use_esc_chars
1526         spellcheckerModule->escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
1527         // FIXME: remove isp_use_pers_dict
1528         spellcheckerModule->persDictionaryED->setText(external_path(rc.isp_pers_dict));
1529         spellcheckerModule->compoundWordCB->setChecked(rc.isp_accept_compound);
1530         spellcheckerModule->inputEncodingCB->setChecked(rc.isp_use_input_encoding);
1531
1532
1533
1534
1535         printerModule->printerAdaptCB->setChecked(rc.print_adapt_output);
1536         printerModule->printerCommandED->setText(toqstr(rc.print_command));
1537         printerModule->printerNameED->setText(toqstr(rc.printer));
1538
1539         printerModule->printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
1540         printerModule->printerCopiesED->setText(toqstr(rc.print_copies_flag));
1541         printerModule->printerReverseED->setText(toqstr(rc.print_reverse_flag));
1542         printerModule->printerToPrinterED->setText(toqstr(rc.print_to_printer));
1543         printerModule->printerExtensionED->setText(toqstr(rc.print_file_extension));
1544         printerModule->printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
1545         printerModule->printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
1546         printerModule->printerEvenED->setText(toqstr(rc.print_evenpage_flag));
1547         printerModule->printerOddED->setText(toqstr(rc.print_oddpage_flag));
1548         printerModule->printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
1549         printerModule->printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
1550         printerModule->printerToFileED->setText(external_path(rc.print_to_file));
1551         printerModule->printerExtraED->setText(toqstr(rc.print_extra_options));
1552         printerModule->printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
1553         printerModule->printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
1554
1555
1556
1557
1558         setComboxFont(screenfontsModule->screenRomanCO, rc.roman_font_name,
1559                         rc.roman_font_foundry);
1560         setComboxFont(screenfontsModule->screenSansCO, rc.sans_font_name,
1561                         rc.sans_font_foundry);
1562         setComboxFont(screenfontsModule->screenTypewriterCO, rc.typewriter_font_name,
1563                         rc.typewriter_font_foundry);
1564
1565         select_roman(screenfontsModule->screenRomanCO->currentText());
1566         select_sans(screenfontsModule->screenSansCO->currentText());
1567         select_typewriter(screenfontsModule->screenTypewriterCO->currentText());
1568
1569         screenfontsModule->screenZoomSB->setValue(rc.zoom);
1570         screenfontsModule->screenDpiSB->setValue(rc.dpi);
1571         screenfontsModule->screenTinyED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_TINY]));
1572         screenfontsModule->screenSmallestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SCRIPT]));
1573         screenfontsModule->screenSmallerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]));
1574         screenfontsModule->screenSmallED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SMALL]));
1575         screenfontsModule->screenNormalED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_NORMAL]));
1576         screenfontsModule->screenLargeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGE]));
1577         screenfontsModule->screenLargerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGER]));
1578         screenfontsModule->screenLargestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGEST]));
1579         screenfontsModule->screenHugeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGE]));
1580         screenfontsModule->screenHugerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGER]));
1581
1582         updateFormats();
1583         updateConverters();
1584         updateCopiers();
1585
1586 }
1587
1588
1589 } // namespace frontend
1590 } // namespace lyx