]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QPrefsDialog.C
* src/frontends/qt4/QPrefsDialog.C
[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->autoSaveSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
398         connect(uiModule->autoSaveCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
399         connect(uiModule->lastfilesSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
400         uiModule->lastfilesSB->setMaxValue(maxlastfiles);
401
402
403
404
405         identityModule = new UiWidget<Ui::QPrefIdentityUi>(this);
406         connect(identityModule->nameED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
407         connect(identityModule->emailED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
408
409
410
411
412         string const laf = _("Look and feel");
413         prefsPS->addCategory(laf);
414         prefsPS->addPanel(uiModule, _("User interface"), laf);
415         prefsPS->addPanel(screenfontsModule, _("Screen fonts"), laf);
416         prefsPS->addPanel(colorsModule, _("Colors"), laf);
417         prefsPS->addPanel(displayModule, _("Graphics"), laf);
418         prefsPS->addPanel(keyboardModule, _("Keyboard"), laf);
419
420         string const ls = _("Language settings");
421         prefsPS->addCategory(ls);
422         prefsPS->addPanel(languageModule, _("Language"), ls);
423         prefsPS->addPanel(spellcheckerModule, _("Spellchecker"), ls);
424
425         string const op = _("Outputs");
426         prefsPS->addCategory(op);
427         prefsPS->addPanel(asciiModule, _("Plain text"), op);
428         prefsPS->addPanel(dateModule, _("Date format"), op);
429         prefsPS->addPanel(latexModule, _("LaTeX"), op);
430 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
431         prefsPS->addPanel(cygwinpathModule, _("Paths"), op);
432 #endif
433         prefsPS->addPanel(printerModule, _("Printer"), op);
434
435         prefsPS->addPanel(identityModule, _("Identity"));
436         prefsPS->addPanel(pathsModule, _("Paths"));
437         prefsPS->addPanel(fileformatsModule, _("File formats"));
438         prefsPS->addPanel(convertersModule, _("Converters"));
439         prefsPS->addPanel(copiersModule, _("Copiers"));
440
441         prefsPS->setCurrentPanel(_("User interface"));
442
443
444         form_->bcview().setOK(savePB);
445         form_->bcview().setApply(applyPB);
446         form_->bcview().setCancel(closePB);
447         form_->bcview().setRestore(restorePB);
448 }
449
450
451
452
453 QPrefsDialog::~QPrefsDialog()
454 {
455 }
456
457
458 void QPrefsDialog::closeEvent(QCloseEvent * e)
459 {
460         form_->slotWMHide();
461         e->accept();
462 }
463
464
465 void QPrefsDialog::change_adaptor()
466 {
467         form_->changed();
468 }
469
470
471 void QPrefsDialog::updateConverters()
472 {
473         Ui::QPrefConvertersUi* convertmod(convertersModule);
474
475         // save current selection
476         QString current = convertmod->converterFromCO->currentText()
477                 + " -> " + convertmod->converterToCO->currentText();
478
479         convertmod->converterFromCO->clear();
480         convertmod->converterToCO->clear();
481
482         Formats::const_iterator cit = form_->formats().begin();
483         Formats::const_iterator end = form_->formats().end();
484         for (; cit != end; ++cit) {
485                 convertmod->converterFromCO->insertItem(toqstr(cit->prettyname()));
486                 convertmod->converterToCO->insertItem(toqstr(cit->prettyname()));
487         }
488
489         convertmod->convertersLB->clear();
490
491         Converters::const_iterator ccit = form_->converters().begin();
492         Converters::const_iterator cend = form_->converters().end();
493         for (; ccit != cend; ++ccit) {
494                 std::string const name = ccit->From->prettyname() + " -> "
495                         + ccit->To->prettyname();
496                 convertmod->convertersLB->insertItem(toqstr(name));
497         }
498
499         // restore selection
500         if (!current.isEmpty()) {
501                 Q3ListBoxItem * item = convertmod->convertersLB->findItem(current);
502                 convertmod->convertersLB->setCurrentItem(item);
503         }
504         // select first element if restoring failed
505         if (convertmod->convertersLB->currentItem() == -1)
506                 convertmod->convertersLB->setCurrentItem(0);
507
508         updateConverterButtons();
509 }
510
511
512 void QPrefsDialog::switch_converter(int nr)
513 {
514         Converter const & c(form_->converters().get(nr));
515         convertersModule->converterFromCO->setCurrentItem(form_->formats().getNumber(c.from));
516         convertersModule->converterToCO->setCurrentItem(form_->formats().getNumber(c.to));
517         convertersModule->converterED->setText(toqstr(c.command));
518         convertersModule->converterFlagED->setText(toqstr(c.flags));
519
520         updateConverterButtons();
521 }
522
523
524 void QPrefsDialog::converter_changed()
525 {
526         updateConverterButtons();
527 }
528
529
530 void QPrefsDialog::updateConverterButtons()
531 {
532         Format const & from(form_->formats().get(
533                 convertersModule->converterFromCO->currentItem()));
534         Format const & to(form_->formats().get(
535                 convertersModule->converterToCO->currentItem()));
536         int const sel = form_->converters().getNumber(from.name(), to.name());
537         bool const known = !(sel < 0);
538         bool const valid = !(convertersModule->converterED->text().isEmpty()
539                 || from.name() == to.name());
540
541         Converter const & c(form_->converters().get(
542                 convertersModule->convertersLB->currentItem()));
543         string const old_command = c.command;
544         string const old_flag = c.flags;
545         string const new_command(fromqstr(convertersModule->converterED->text()));
546         string const new_flag(fromqstr(convertersModule->converterFlagED->text()));
547
548         bool modified = ((old_command != new_command) || (old_flag != new_flag));
549
550         convertersModule->converterModifyPB->setEnabled(valid && known && modified);
551         convertersModule->converterNewPB->setEnabled(valid && !known);
552         convertersModule->converterRemovePB->setEnabled(known);
553 }
554
555
556 // FIXME: user must
557 // specify unique from/to or it doesn't appear. This is really bad UI
558 void QPrefsDialog::new_converter()
559 {
560         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
561         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
562         string const command(fromqstr(convertersModule->converterED->text()));
563         string const flags(fromqstr(convertersModule->converterFlagED->text()));
564
565         Converter const * old = form_->converters().getConverter(from.name(), to.name());
566         form_->converters().add(from.name(), to.name(), command, flags);
567         if (!old) {
568                 form_->converters().updateLast(form_->formats());
569         }
570         updateConverters();
571         convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1);
572 }
573
574
575 void QPrefsDialog::modify_converter()
576 {
577         int const top_item = convertersModule->convertersLB->topItem();
578         QString const current_text =
579                 convertersModule->convertersLB->currentText();
580
581         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
582         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
583         string flags(fromqstr(convertersModule->converterFlagED->text()));
584         string name(fromqstr(convertersModule->converterED->text()));
585
586         Converter const * old = form_->converters().getConverter(from.name(), to.name());
587         form_->converters().add(from.name(), to.name(), name, flags);
588         if (!old) {
589                 form_->converters().updateLast(form_->formats());
590         }
591         updateConverters();
592
593         Q3ListBoxItem * const item =
594                 convertersModule->convertersLB->findItem(current_text);
595         convertersModule->convertersLB->setCurrentItem(item);
596         convertersModule->convertersLB->setTopItem(top_item);
597 }
598
599
600 void QPrefsDialog::remove_converter()
601 {
602         Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
603         Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
604         form_->converters().erase(from.name(), to.name());
605         updateConverters();
606 }
607
608
609 void QPrefsDialog::updateCopiers()
610 {
611         // The choice widget
612         // save current selection
613         QString current = copiersModule->copierFormatCO->currentText();
614         copiersModule->copierFormatCO->clear();
615
616         for (Formats::const_iterator it = form_->formats().begin(),
617                      end = form_->formats().end();
618              it != end; ++it) {
619                 copiersModule->copierFormatCO->insertItem(toqstr(it->prettyname()));
620         }
621
622         // The browser widget
623         copiersModule->AllCopiersLB->clear();
624
625         for (Movers::iterator it = form_->movers().begin(),
626                      end = form_->movers().end();
627              it != end; ++it) {
628                 std::string const & command = it->second.command();
629                 if (command.empty())
630                         continue;
631                 std::string const & fmt = it->first;
632                 std::string const & pretty = form_->formats().prettyName(fmt);
633
634                 copiersModule->AllCopiersLB->insertItem(toqstr(pretty));
635         }
636
637         // restore selection
638         if (!current.isEmpty()) {
639                 Q3ListBoxItem * item = copiersModule->AllCopiersLB->findItem(current);
640                 copiersModule->AllCopiersLB->setCurrentItem(item);
641         }
642         // select first element if restoring failed
643         if (copiersModule->AllCopiersLB->currentItem() == -1)
644                 copiersModule->AllCopiersLB->setCurrentItem(0);
645 }
646
647
648 namespace {
649
650 class SamePrettyName {
651 public:
652         SamePrettyName(string const & n) : pretty_name_(n) {}
653
654         bool operator()(::Format const & fmt) const {
655                 return fmt.prettyname() == pretty_name_;
656         }
657
658 private:
659         string const pretty_name_;
660 };
661
662
663 Format const * getFormat(std::string const & prettyname)
664 {
665         Formats::const_iterator it = ::formats.begin();
666         Formats::const_iterator const end = ::formats.end();
667         it = std::find_if(it, end, SamePrettyName(prettyname));
668         return it == end ? 0 : &*it;
669 }
670
671 } // namespace anon
672
673
674 void QPrefsDialog::switch_copierLB(int)
675 {
676         std::string const browser_text =
677                 fromqstr(copiersModule->AllCopiersLB->currentText());
678         Format const * fmt = getFormat(browser_text);
679         if (fmt == 0)
680                 return;
681
682         string const & fmt_name = fmt->name();
683         string const & gui_name = fmt->prettyname();
684         string const & command = form_->movers().command(fmt_name);
685
686         copiersModule->copierED->clear();
687         int const combo_size = copiersModule->copierFormatCO->count();
688         for (int i = 0; i < combo_size; ++i) {
689                 QString const qtext = copiersModule->copierFormatCO->text(i);
690                 std::string const text = fromqstr(qtext);
691                 if (text == gui_name) {
692                         copiersModule->copierFormatCO->setCurrentItem(i);
693                         copiersModule->copierED->setText(toqstr(command));
694                         break;
695                 }
696         }
697         updateCopierButtons();
698 }
699
700
701 void QPrefsDialog::switch_copierCO(int)
702 {
703         std::string const combo_text =
704                 fromqstr(copiersModule->copierFormatCO->currentText());
705         Format const * fmt = getFormat(combo_text);
706         if (fmt == 0)
707                 return;
708
709         string const & fmt_name = fmt->name();
710         string const & gui_name = fmt->prettyname();
711         string const & command = form_->movers().command(fmt_name);
712
713         copiersModule->copierED->setText(toqstr(command));
714
715         int const index = copiersModule->AllCopiersLB->currentItem();
716         if (index >= 0)
717                 copiersModule->AllCopiersLB->setSelected(index, false);
718
719         int const browser_size = copiersModule->AllCopiersLB->count();
720         for (int i = 0; i < browser_size; ++i) {
721                 QString const qtext = copiersModule->AllCopiersLB->text(i);
722                 std::string const text = fromqstr(qtext);
723                 if (text == gui_name) {
724                         copiersModule->AllCopiersLB->setSelected(i, true);
725                         int top = std::max(i - 5, 0);
726                         copiersModule->AllCopiersLB->setTopItem(top);
727                         break;
728                 }
729         }
730 }
731
732
733 void QPrefsDialog::copiers_changed()
734 {
735         updateCopierButtons();
736 }
737
738
739 void QPrefsDialog::updateCopierButtons()
740 {
741         QString selected = copiersModule->copierFormatCO->currentText();
742
743         bool known = false;
744         for (unsigned int i = 0; i != copiersModule->AllCopiersLB->count(); i++) {
745                 if (copiersModule->AllCopiersLB->text(i) == selected)
746                         known = true;
747         }
748
749         bool const valid = !copiersModule->copierED->text().isEmpty();
750
751         Format const * fmt = getFormat(fromqstr(selected));
752         string const old_command = form_->movers().command(fmt->name());
753         string const new_command(fromqstr(copiersModule->copierED->text()));
754
755         bool modified = (old_command != new_command);
756
757         copiersModule->copierModifyPB->setEnabled(valid && known && modified);
758         copiersModule->copierNewPB->setEnabled(valid && !known);
759         copiersModule->copierRemovePB->setEnabled(known);
760 }
761
762
763 void QPrefsDialog::new_copier()
764 {
765         std::string const combo_text =
766                 fromqstr(copiersModule->copierFormatCO->currentText());
767         Format const * fmt = getFormat(combo_text);
768         if (fmt == 0)
769                 return;
770
771         string const command = fromqstr(copiersModule->copierED->text());
772         if (command.empty())
773                 return;
774
775         form_->movers().set(fmt->name(), command);
776
777         updateCopiers();
778         int const last = copiersModule->AllCopiersLB->count() - 1;
779         copiersModule->AllCopiersLB->setCurrentItem(last);
780
781         updateCopierButtons();
782 }
783
784
785 void QPrefsDialog::modify_copier()
786 {
787         std::string const combo_text =
788                 fromqstr(copiersModule->copierFormatCO->currentText());
789         Format const * fmt = getFormat(combo_text);
790         if (fmt == 0)
791                 return;
792
793         string const command = fromqstr(copiersModule->copierED->text());
794         form_->movers().set(fmt->name(), command);
795
796         updateCopiers();
797         updateCopierButtons();
798 }
799
800
801 void QPrefsDialog::remove_copier()
802 {
803         std::string const combo_text =
804                 fromqstr(copiersModule->copierFormatCO->currentText());
805         Format const * fmt = getFormat(combo_text);
806         if (fmt == 0)
807                 return;
808
809         string const & fmt_name = fmt->name();
810         form_->movers().set(fmt_name, string());
811
812         updateCopiers();
813         updateCopierButtons();
814 }
815
816
817 void QPrefsDialog::updateFormats()
818 {
819         Ui::QPrefFileformatsUi * formatmod(fileformatsModule);
820
821         // save current selection
822         QString current = formatmod->guiNameED->text();
823
824         formatmod->formatsLB->clear();
825
826         Formats::const_iterator cit = form_->formats().begin();
827         Formats::const_iterator end = form_->formats().end();
828         for (; cit != end; ++cit) {
829                 formatmod->formatsLB->insertItem(toqstr(cit->prettyname()));
830         }
831
832         // restore selection
833         if (!current.isEmpty()) {
834                 Q3ListBoxItem * item = formatmod->formatsLB->findItem(current);
835                 formatmod->formatsLB->setCurrentItem(item);
836         }
837         // select first element if restoring failed
838         if (formatmod->formatsLB->currentItem() == -1)
839                 formatmod->formatsLB->setCurrentItem(0);
840 }
841
842
843 void QPrefsDialog::switch_format(int nr)
844 {
845         Format const & f(form_->formats().get(nr));
846         fileformatsModule->formatED->setText(toqstr(f.name()));
847         fileformatsModule->guiNameED->setText(toqstr(f.prettyname()));
848         fileformatsModule->extensionED->setText(toqstr(f.extension()));
849         fileformatsModule->shortcutED->setText(toqstr(f.shortcut()));
850         fileformatsModule->viewerED->setText(toqstr(f.viewer()));
851         fileformatsModule->editorED->setText(toqstr(f.editor()));
852         fileformatsModule->formatRemovePB->setEnabled(
853                 !form_->converters().formatIsUsed(f.name()));
854
855         updateFormatsButtons();
856 }
857
858
859 void QPrefsDialog::fileformat_changed()
860 {
861         updateFormatsButtons();
862 }
863
864
865 void QPrefsDialog::updateFormatsButtons()
866 {
867         QString const format = fileformatsModule->formatED->text();
868         QString const gui_name = fileformatsModule->guiNameED->text();
869         int const sel = form_->formats().getNumber(fromqstr(format));
870         bool gui_name_known = false;
871         int where = sel;
872         for (unsigned int i = 0; i != fileformatsModule->formatsLB->count(); i++) {
873                 if (fileformatsModule->formatsLB->text(i) == gui_name) {
874                         gui_name_known = true;
875                         where = i;
876                 }
877         }
878
879         // assure that a gui name cannot be chosen twice
880         bool const known_otherwise = gui_name_known && (where != sel);
881
882         bool const known = !(sel < 0);
883         bool const valid = (!fileformatsModule->formatED->text().isEmpty()
884                 && !fileformatsModule->guiNameED->text().isEmpty());
885
886         Format const & f(form_->formats().get(
887                 fileformatsModule->formatsLB->currentItem()));
888         string const old_pretty(f.prettyname());
889         string const old_shortcut(f.shortcut());
890         string const old_extension(f.extension());
891         string const old_viewer(f.viewer());
892         string const old_editor(f.editor());
893
894         string const new_pretty(fromqstr(gui_name));
895         string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text()));
896         string const new_extension(fromqstr(fileformatsModule->extensionED->text()));
897         string const new_viewer(fromqstr(fileformatsModule->viewerED->text()));
898         string const new_editor(fromqstr(fileformatsModule->editorED->text()));
899
900         bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
901                 || (old_extension != new_extension) || (old_viewer != new_viewer)
902                 || (old_editor != new_editor));
903
904         fileformatsModule->formatModifyPB->setEnabled(
905                 valid && known && modified && !known_otherwise);
906         fileformatsModule->formatNewPB->setEnabled(valid && !known && !gui_name_known);
907         fileformatsModule->formatRemovePB->setEnabled(known);
908 }
909
910
911 void QPrefsDialog::new_format()
912 {
913         string const name = fromqstr(fileformatsModule->formatED->text());
914         string const prettyname = fromqstr(fileformatsModule->guiNameED->text());
915         string const extension = fromqstr(fileformatsModule->extensionED->text());
916         string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
917         string const viewer = fromqstr(fileformatsModule->viewerED->text());
918         string const editor = fromqstr(fileformatsModule->editorED->text());
919
920         form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
921         form_->formats().sort();
922         updateFormats();
923         fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name));
924         form_->converters().update(form_->formats());
925
926         updateConverters();
927         updateFormatsButtons();
928 }
929
930
931 void QPrefsDialog::modify_format()
932 {
933         int const top_item = fileformatsModule->formatsLB->topItem();
934         int const current_item = fileformatsModule->formatsLB->currentItem();
935         QString const current_text =
936                 fileformatsModule->formatsLB->currentText();
937
938         Format const & oldformat(form_->formats().get(current_item));
939         string const oldpretty(oldformat.prettyname());
940         string const name(fromqstr(fileformatsModule->formatED->text()));
941         form_->formats().erase(oldformat.name());
942
943         string const prettyname = fromqstr(fileformatsModule->guiNameED->text());
944         string const extension = fromqstr(fileformatsModule->extensionED->text());
945         string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
946         string const viewer = fromqstr(fileformatsModule->viewerED->text());
947         string const editor = fromqstr(fileformatsModule->editorED->text());
948
949         form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
950         form_->formats().sort();
951
952         fileformatsModule->formatsLB->setUpdatesEnabled(false);
953         updateFormats();
954         fileformatsModule->formatsLB->setUpdatesEnabled(true);
955         fileformatsModule->formatsLB->update();
956
957         updateConverters();
958         updateFormatsButtons();
959
960         Q3ListBoxItem * const item =
961                 fileformatsModule->formatsLB->findItem(current_text);
962         fileformatsModule->formatsLB->setCurrentItem(item);
963         fileformatsModule->formatsLB->setTopItem(top_item);
964 }
965
966
967 void QPrefsDialog::remove_format()
968 {
969         int const nr(fileformatsModule->formatsLB->currentItem());
970         if (nr < 0)
971                 return;
972         form_->formats().erase(form_->formats().get(nr).name());
973         updateFormats();
974         form_->converters().update(form_->formats());
975
976         updateConverters();
977         updateFormatsButtons();
978 }
979
980
981 void QPrefsDialog::change_color()
982 {
983         Q3ListBox * lb(colorsModule->lyxObjectsLB);
984         if (lb->currentItem() < 0)
985                 return;
986         Q3ListBoxItem * ib(lb->item(lb->currentItem()));
987         QColorItem * ci(static_cast<QColorItem*>(ib));
988         QColor c(QColorDialog::getColor(ci->color(), qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget()));
989         if (c.isValid()) {
990                 ci->color(c);
991                 lb->triggerUpdate(false);
992                 change_adaptor();
993         }
994 }
995
996
997 void QPrefsDialog::select_ui()
998 {
999         string file(form_->controller().browseUI(fromqstr(uiModule->uiFileED->text())));
1000         if (!file.empty())
1001                 uiModule->uiFileED->setText(toqstr(file));
1002 }
1003
1004
1005 void QPrefsDialog::select_bind()
1006 {
1007         string file(form_->controller().browsebind(fromqstr(uiModule->bindFileED->text())));
1008         if (!file.empty())
1009                 uiModule->bindFileED->setText(toqstr(file));
1010 }
1011
1012
1013 void QPrefsDialog::select_keymap1()
1014 {
1015         string file(form_->controller().browsekbmap(fromqstr(keyboardModule->firstKeymapED->text())));
1016         if (!file.empty())
1017                 keyboardModule->firstKeymapED->setText(toqstr(file));
1018 }
1019
1020
1021 void QPrefsDialog::select_keymap2()
1022 {
1023         string file(form_->controller().browsekbmap(fromqstr(keyboardModule->secondKeymapED->text())));
1024         if (!file.empty())
1025                 keyboardModule->secondKeymapED->setText(toqstr(file));
1026 }
1027
1028
1029 void QPrefsDialog::select_dict()
1030 {
1031         string file(form_->controller().browsedict(fromqstr(spellcheckerModule->persDictionaryED->text())));
1032         if (!file.empty())
1033                 spellcheckerModule->persDictionaryED->setText(toqstr(file));
1034 }
1035
1036
1037 // NB: the _() is OK here because it gets passed back and we toqstr() them
1038
1039 void QPrefsDialog::select_templatedir()
1040 {
1041         string file(form_->controller().browsedir(fromqstr(pathsModule->templateDirED->text()), _("Select a document templates directory")));
1042         if (!file.empty())
1043                 pathsModule->templateDirED->setText(toqstr(file));
1044 }
1045
1046
1047 void QPrefsDialog::select_tempdir()
1048 {
1049         string file(form_->controller().browsedir(fromqstr(pathsModule->tempDirED->text()), _("Select a temporary directory")));
1050         if (!file.empty())
1051                 pathsModule->tempDirED->setText(toqstr(file));
1052 }
1053
1054
1055 void QPrefsDialog::select_backupdir()
1056 {
1057         string file(form_->controller().browsedir(fromqstr(pathsModule->backupDirED->text()), _("Select a backups directory")));
1058         if (!file.empty())
1059                 pathsModule->backupDirED->setText(toqstr(file));
1060 }
1061
1062
1063 void QPrefsDialog::select_workingdir()
1064 {
1065         string file(form_->controller().browsedir(fromqstr(pathsModule->workingDirED->text()), _("Select a document directory")));
1066         if (!file.empty())
1067                 pathsModule->workingDirED->setText(toqstr(file));
1068 }
1069
1070
1071 void QPrefsDialog::select_lyxpipe()
1072 {
1073         string file(form_->controller().browse(fromqstr(pathsModule->lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
1074         if (!file.empty())
1075                 pathsModule->lyxserverDirED->setText(toqstr(file));
1076 }
1077
1078
1079 void QPrefsDialog::select_roman(const QString& name)
1080 {
1081         screenfontsModule->screenRomanFE->set(QFont(name), name);
1082 }
1083
1084
1085 void QPrefsDialog::select_sans(const QString& name)
1086 {
1087         screenfontsModule->screenSansFE->set(QFont(name), name);
1088 }
1089
1090
1091 void QPrefsDialog::select_typewriter(const QString& name)
1092 {
1093         screenfontsModule->screenTypewriterFE->set(QFont(name), name);
1094 }
1095
1096 namespace {
1097
1098 string const internal_path(QString const & input)
1099 {
1100         return lyx::support::os::internal_path(fromqstr(input));
1101 }
1102
1103 }
1104
1105 void QPrefsDialog::apply(LyXRC & rc) const
1106 {
1107         // FIXME: remove rtl_support bool
1108         rc.rtl_support = languageModule->rtlCB->isChecked();
1109         rc.mark_foreign_language = languageModule->markForeignCB->isChecked();
1110         rc.language_auto_begin = languageModule->autoBeginCB->isChecked();
1111         rc.language_auto_end = languageModule->autoEndCB->isChecked();
1112         rc.language_use_babel = languageModule->useBabelCB->isChecked();
1113         rc.language_global_options = languageModule->globalCB->isChecked();
1114         rc.language_package = fromqstr(languageModule->languagePackageED->text());
1115         rc.language_command_begin = fromqstr(languageModule->startCommandED->text());
1116         rc.language_command_end = fromqstr(languageModule->endCommandED->text());
1117         rc.default_language = lang_[languageModule->defaultLanguageCO->currentItem()];
1118
1119
1120         rc.ui_file = internal_path(uiModule->uiFileED->text());
1121         rc.bind_file = internal_path(uiModule->bindFileED->text());
1122         rc.cursor_follows_scrollbar = uiModule->cursorFollowsCB->isChecked();
1123         rc.autosave = uiModule->autoSaveSB->value() * 60;
1124         rc.make_backup = uiModule->autoSaveCB->isChecked();
1125         rc.num_lastfiles = uiModule->lastfilesSB->value();
1126
1127
1128         // FIXME: can derive CB from the two EDs
1129         rc.use_kbmap = keyboardModule->keymapCB->isChecked();
1130         rc.primary_kbmap = internal_path(keyboardModule->firstKeymapED->text());
1131         rc.secondary_kbmap = internal_path(keyboardModule->secondKeymapED->text());
1132
1133
1134         rc.ascii_linelen = asciiModule->asciiLinelengthSB->value();
1135         rc.ascii_roff_command = fromqstr(asciiModule->asciiRoffED->text());
1136
1137
1138         rc.date_insert_format = fromqstr(dateModule->DateED->text());
1139
1140
1141 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
1142         rc.cygwin_path_fix = cygwinpathModule->pathCB->isChecked();
1143 #endif
1144
1145
1146         rc.fontenc = fromqstr(latexModule->latexEncodingED->text());
1147         rc.chktex_command = fromqstr(latexModule->latexChecktexED->text());
1148         rc.bibtex_command = fromqstr(latexModule->latexBibtexED->text());
1149         rc.index_command = fromqstr(latexModule->latexIndexED->text());
1150         rc.auto_reset_options = latexModule->latexAutoresetCB->isChecked();
1151         rc.view_dvi_paper_option = fromqstr(latexModule->latexDviPaperED->text());
1152         rc.default_papersize =
1153                 form_->controller().toPaperSize(latexModule->latexPaperSizeCO->currentItem());
1154
1155
1156         switch (displayModule->instantPreviewCO->currentItem()) {
1157         case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
1158         case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
1159         case 2: rc.preview = LyXRC::PREVIEW_ON; break;
1160         }
1161
1162         lyx::graphics::DisplayType dtype;
1163         switch (displayModule->displayGraphicsCO->currentItem()) {
1164         case 3: dtype = lyx::graphics::NoDisplay; break;
1165         case 2: dtype = lyx::graphics::ColorDisplay; break;
1166         case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
1167         case 0: dtype = lyx::graphics::MonochromeDisplay; break;
1168         default: dtype = lyx::graphics::GrayscaleDisplay;
1169         }
1170         rc.display_graphics = dtype;
1171
1172 #ifdef WITH_WARNINGS
1173 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1174 #endif
1175 #if 0
1176         if (old_value != rc.display_graphics) {
1177                 lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
1178                 gc.changeDisplay();
1179         }
1180 #endif
1181
1182
1183         rc.document_path = internal_path(pathsModule->workingDirED->text());
1184         rc.template_path = internal_path(pathsModule->templateDirED->text());
1185         rc.backupdir_path = internal_path(pathsModule->backupDirED->text());
1186         rc.tempdir_path = internal_path(pathsModule->tempDirED->text());
1187         rc.path_prefix = fromqstr(pathsModule->pathPrefixED->text());
1188         // FIXME: should be a checkbox only
1189         rc.lyxpipes = internal_path(pathsModule->lyxserverDirED->text());
1190
1191
1192         switch (spellcheckerModule->spellCommandCO->currentItem()) {
1193                 case 0:
1194                 case 1:
1195                 case 2:
1196                         rc.use_spell_lib = false;
1197                         rc.isp_command = fromqstr(spellcheckerModule->spellCommandCO->currentText());
1198                         break;
1199                 case 3:
1200                         rc.use_spell_lib = true;
1201                         break;
1202         }
1203
1204         // FIXME: remove isp_use_alt_lang
1205         rc.isp_alt_lang = fromqstr(spellcheckerModule->altLanguageED->text());
1206         rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
1207         // FIXME: remove isp_use_esc_chars
1208         rc.isp_esc_chars = fromqstr(spellcheckerModule->escapeCharactersED->text());
1209         rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
1210         // FIXME: remove isp_use_pers_dict
1211         rc.isp_pers_dict = internal_path(spellcheckerModule->persDictionaryED->text());
1212         rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
1213         rc.isp_accept_compound = spellcheckerModule->compoundWordCB->isChecked();
1214         rc.isp_use_input_encoding = spellcheckerModule->inputEncodingCB->isChecked();
1215
1216
1217
1218         rc.print_adapt_output = printerModule->printerAdaptCB->isChecked();
1219         rc.print_command = fromqstr(printerModule->printerCommandED->text());
1220         rc.printer = fromqstr(printerModule->printerNameED->text());
1221
1222         rc.print_pagerange_flag = fromqstr(printerModule->printerPageRangeED->text());
1223         rc.print_copies_flag = fromqstr(printerModule->printerCopiesED->text());
1224         rc.print_reverse_flag = fromqstr(printerModule->printerReverseED->text());
1225         rc.print_to_printer = fromqstr(printerModule->printerToPrinterED->text());
1226         rc.print_file_extension = fromqstr(printerModule->printerExtensionED->text());
1227         rc.print_spool_command = fromqstr(printerModule->printerSpoolCommandED->text());
1228         rc.print_paper_flag = fromqstr(printerModule->printerPaperTypeED->text());
1229         rc.print_evenpage_flag = fromqstr(printerModule->printerEvenED->text());
1230         rc.print_oddpage_flag = fromqstr(printerModule->printerOddED->text());
1231         rc.print_collcopies_flag = fromqstr(printerModule->printerCollatedED->text());
1232         rc.print_landscape_flag = fromqstr(printerModule->printerLandscapeED->text());
1233         rc.print_to_file = internal_path(printerModule->printerToFileED->text());
1234         rc.print_extra_options = fromqstr(printerModule->printerExtraED->text());
1235         rc.print_spool_printerprefix = fromqstr(printerModule->printerSpoolPrefixED->text());
1236         rc.print_paper_dimension_flag = fromqstr(printerModule->printerPaperSizeED->text());
1237
1238
1239
1240         rc.user_name = fromqstr(identityModule->nameED->text());
1241         rc.user_email = fromqstr(identityModule->emailED->text());
1242
1243
1244
1245         LyXRC const oldrc(rc);
1246
1247         boost::tie(rc.roman_font_name, rc.roman_font_foundry)
1248                 = parseFontName(fromqstr(screenfontsModule->screenRomanCO->currentText()));
1249         boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
1250                 parseFontName(fromqstr(screenfontsModule->screenSansCO->currentText()));
1251         boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
1252                 parseFontName(fromqstr(screenfontsModule->screenTypewriterCO->currentText()));
1253
1254         rc.zoom = screenfontsModule->screenZoomSB->value();
1255         rc.dpi = screenfontsModule->screenDpiSB->value();
1256         rc.font_sizes[LyXFont::SIZE_TINY] = fromqstr(screenfontsModule->screenTinyED->text());
1257         rc.font_sizes[LyXFont::SIZE_SCRIPT] = fromqstr(screenfontsModule->screenSmallestED->text());
1258         rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = fromqstr(screenfontsModule->screenSmallerED->text());
1259         rc.font_sizes[LyXFont::SIZE_SMALL] = fromqstr(screenfontsModule->screenSmallED->text());
1260         rc.font_sizes[LyXFont::SIZE_NORMAL] = fromqstr(screenfontsModule->screenNormalED->text());
1261         rc.font_sizes[LyXFont::SIZE_LARGE] = fromqstr(screenfontsModule->screenLargeED->text());
1262         rc.font_sizes[LyXFont::SIZE_LARGER] = fromqstr(screenfontsModule->screenLargerED->text());
1263         rc.font_sizes[LyXFont::SIZE_LARGEST] = fromqstr(screenfontsModule->screenLargestED->text());
1264         rc.font_sizes[LyXFont::SIZE_HUGE] = fromqstr(screenfontsModule->screenHugeED->text());
1265         rc.font_sizes[LyXFont::SIZE_HUGER] = fromqstr(screenfontsModule->screenHugerED->text());
1266
1267         if (rc.font_sizes != oldrc.font_sizes
1268                 || rc.roman_font_name != oldrc.roman_font_name
1269                 || rc.sans_font_name != oldrc.sans_font_name
1270                 || rc.typewriter_font_name != oldrc.typewriter_font_name
1271                 || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
1272                 form_->controller().updateScreenFonts();
1273         }
1274
1275         
1276         
1277         
1278         unsigned int i;
1279         for (i = 0; i < colorsModule->lyxObjectsLB->count(); ++i) {
1280                 Q3ListBoxItem * ib(colorsModule->lyxObjectsLB->item(i));
1281                 QColorItem * ci(static_cast<QColorItem*>(ib));
1282
1283                 LColor::color const col(colors_[i]);
1284                 QColor const & qcol(lcolorcache.get(col));
1285
1286                 // FIXME: dubious, but it's what xforms does
1287                 if (qcol != ci->color()) {
1288                         ostringstream ostr;
1289
1290                         ostr << '#' << std::setbase(16) << setfill('0')
1291                              << setw(2) << ci->color().red()
1292                              << setw(2) << ci->color().green()
1293                              << setw(2) << ci->color().blue();
1294
1295                         string newhex(ostr.str());
1296                         form_->controller().setColor(col, newhex);
1297                 }
1298         }
1299 }
1300
1301 // FIXME: move to helper_funcs.h
1302 namespace {
1303
1304 template<class A>
1305 typename std::vector<A>::size_type
1306 findPos(std::vector<A> const & vec, A const & val)
1307 {
1308         typedef typename std::vector<A>::const_iterator Cit;
1309
1310         Cit it = std::find(vec.begin(), vec.end(), val);
1311         if (it == vec.end())
1312                 return 0;
1313         return distance(vec.begin(), it);
1314 }
1315
1316 void setComboxFont(QComboBox * cb, string const & family, string const & foundry)
1317 {
1318         string const name = makeFontName(family, foundry);
1319         for (int i = 0; i < cb->count(); ++i) {
1320                 if (fromqstr(cb->text(i)) == name) {
1321                         cb->setCurrentItem(i);
1322                         return;
1323                 }
1324         }
1325
1326         // Try matching without foundry name
1327
1328         // We count in reverse in order to prefer the Xft foundry
1329         for (int i = cb->count() - 1; i >= 0; --i) {
1330                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
1331                 if (compare_no_case(tmp.first, family) == 0) {
1332                         cb->setCurrentItem(i);
1333                         return;
1334                 }
1335         }
1336
1337         // family alone can contain e.g. "Helvetica [Adobe]"
1338         pair<string, string> tmpfam = parseFontName(family);
1339
1340         // We count in reverse in order to prefer the Xft foundry
1341         for (int i = cb->count() - 1; i >= 0; --i) {
1342                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
1343                 if (compare_no_case(tmp.first, tmpfam.first) == 0) {
1344                         cb->setCurrentItem(i);
1345                         return;
1346                 }
1347         }
1348
1349         // Bleh, default fonts, and the names couldn't be found. Hack
1350         // for bug 1063. Qt makes baby Jesus cry.
1351
1352         QFont font;
1353
1354         if (family == lyx_gui::roman_font_name()) {
1355                 font.setStyleHint(QFont::Serif);
1356                 font.setFamily(family.c_str());
1357         } else if (family == lyx_gui::sans_font_name()) {
1358                 font.setStyleHint(QFont::SansSerif);
1359                 font.setFamily(family.c_str());
1360         } else if (family == lyx_gui::typewriter_font_name()) {
1361                 font.setStyleHint(QFont::TypeWriter);
1362                 font.setFamily(family.c_str());
1363         } else {
1364                 lyxerr << "FAILED to find the default font: '"
1365                        << foundry << "', '" << family << '\''<< endl;
1366                 return;
1367         }
1368
1369         QFontInfo info(font);
1370         pair<string, string> tmp = parseFontName(fromqstr(info.family()));
1371         string const & default_font_name = tmp.first;
1372         lyxerr << "Apparent font is " << default_font_name << endl;
1373
1374         for (int i = 0; i < cb->count(); ++i) {
1375                 lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
1376                 if (compare_no_case(fromqstr(cb->text(i)),
1377                                     default_font_name) == 0) {
1378                         cb->setCurrentItem(i);
1379                         return;
1380                 }
1381         }
1382
1383         lyxerr << "FAILED to find the font: '"
1384                << foundry << "', '" << family << '\'' <<endl;
1385 }
1386
1387 } // end namespace anon
1388
1389 namespace {
1390
1391 QString const external_path(string const & input)
1392 {
1393         return toqstr(lyx::support::os::external_path(input));
1394 }
1395
1396 }
1397
1398 void QPrefsDialog::update(LyXRC const & rc)
1399 {
1400         // FIXME: remove rtl_support bool
1401         languageModule->rtlCB->setChecked(rc.rtl_support);
1402         languageModule->markForeignCB->setChecked(rc.mark_foreign_language);
1403         languageModule->autoBeginCB->setChecked(rc.language_auto_begin);
1404         languageModule->autoEndCB->setChecked(rc.language_auto_end);
1405         languageModule->useBabelCB->setChecked(rc.language_use_babel);
1406         languageModule->globalCB->setChecked(rc.language_global_options);
1407         languageModule->languagePackageED->setText(toqstr(rc.language_package));
1408         languageModule->startCommandED->setText(toqstr(rc.language_command_begin));
1409         languageModule->endCommandED->setText(toqstr(rc.language_command_end));
1410
1411         int const pos = int(findPos(lang_, rc.default_language));
1412         languageModule->defaultLanguageCO->setCurrentItem(pos);
1413
1414         uiModule->uiFileED->setText(external_path(rc.ui_file));
1415         uiModule->bindFileED->setText(external_path(rc.bind_file));
1416         uiModule->cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
1417         // convert to minutes
1418         int mins(rc.autosave / 60);
1419         if (rc.autosave && !mins)
1420                 mins = 1;
1421         uiModule->autoSaveSB->setValue(mins);
1422         uiModule->autoSaveCB->setChecked(rc.make_backup);
1423         uiModule->lastfilesSB->setValue(rc.num_lastfiles);
1424
1425
1426         identityModule->nameED->setText(toqstr(rc.user_name));
1427         identityModule->emailED->setText(toqstr(rc.user_email));
1428
1429
1430         // FIXME: can derive CB from the two EDs
1431         keyboardModule->keymapCB->setChecked(rc.use_kbmap);
1432         // no idea why we need these. Fscking Qt.
1433         keyboardModule->firstKeymapED->setEnabled(rc.use_kbmap);
1434         keyboardModule->firstKeymapPB->setEnabled(rc.use_kbmap);
1435         keyboardModule->firstKeymapLA->setEnabled(rc.use_kbmap);
1436         keyboardModule->secondKeymapED->setEnabled(rc.use_kbmap);
1437         keyboardModule->secondKeymapPB->setEnabled(rc.use_kbmap);
1438         keyboardModule->secondKeymapLA->setEnabled(rc.use_kbmap);
1439         keyboardModule->firstKeymapED->setText(external_path(rc.primary_kbmap));
1440         keyboardModule->secondKeymapED->setText(external_path(rc.secondary_kbmap));
1441
1442
1443
1444         asciiModule->asciiLinelengthSB->setValue(rc.ascii_linelen);
1445         asciiModule->asciiRoffED->setText(toqstr(rc.ascii_roff_command));
1446
1447
1448
1449         dateModule->DateED->setText(toqstr(rc.date_insert_format));
1450
1451
1452
1453 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
1454         cygwinpathModule->pathCB->setChecked(rc.cygwin_path_fix);
1455 #endif
1456
1457
1458
1459         latexModule->latexEncodingED->setText(toqstr(rc.fontenc));
1460         latexModule->latexChecktexED->setText(toqstr(rc.chktex_command));
1461         latexModule->latexBibtexED->setText(toqstr(rc.bibtex_command));
1462         latexModule->latexIndexED->setText(toqstr(rc.index_command));
1463         latexModule->latexAutoresetCB->setChecked(rc.auto_reset_options);
1464         latexModule->latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
1465         latexModule->latexPaperSizeCO->setCurrentItem(
1466                 form_->controller().fromPaperSize(rc.default_papersize));
1467
1468
1469
1470         switch (rc.preview) {
1471         case LyXRC::PREVIEW_OFF:
1472                 displayModule->instantPreviewCO->setCurrentItem(0);
1473                 break;
1474         case LyXRC::PREVIEW_NO_MATH :
1475                 displayModule->instantPreviewCO->setCurrentItem(1);
1476                 break;
1477         case LyXRC::PREVIEW_ON :
1478                 displayModule->instantPreviewCO->setCurrentItem(2);
1479                 break;
1480         }
1481
1482         int item = 2;
1483         switch (rc.display_graphics) {
1484                 case lyx::graphics::NoDisplay:          item = 3; break;
1485                 case lyx::graphics::ColorDisplay:       item = 2; break;
1486                 case lyx::graphics::GrayscaleDisplay:   item = 1; break;
1487                 case lyx::graphics::MonochromeDisplay:  item = 0; break;
1488                 default: break;
1489         }
1490         displayModule->displayGraphicsCO->setCurrentItem(item);
1491
1492
1493
1494         pathsModule->workingDirED->setText(external_path(rc.document_path));
1495         pathsModule->templateDirED->setText(external_path(rc.template_path));
1496         pathsModule->backupDirED->setText(external_path(rc.backupdir_path));
1497         pathsModule->tempDirED->setText(external_path(rc.tempdir_path));
1498         pathsModule->pathPrefixED->setText(toqstr(rc.path_prefix));
1499         // FIXME: should be a checkbox only
1500         pathsModule->lyxserverDirED->setText(external_path(rc.lyxpipes));
1501
1502
1503
1504         spellcheckerModule->spellCommandCO->setCurrentItem(0);
1505
1506         if (rc.isp_command == "ispell") {
1507                 spellcheckerModule->spellCommandCO->setCurrentItem(0);
1508         } else if (rc.isp_command == "aspell") {
1509                 spellcheckerModule->spellCommandCO->setCurrentItem(1);
1510         } else if (rc.isp_command == "hspell") {
1511                 spellcheckerModule->spellCommandCO->setCurrentItem(2);
1512         }
1513
1514         if (rc.use_spell_lib) {
1515 #if defined(USE_ASPELL) || defined(USE_PSPELL)
1516                 spellcheckerModule->spellCommandCO->setCurrentItem(3);
1517 #endif
1518         }
1519
1520         // FIXME: remove isp_use_alt_lang
1521         spellcheckerModule->altLanguageED->setText(toqstr(rc.isp_alt_lang));
1522         // FIXME: remove isp_use_esc_chars
1523         spellcheckerModule->escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
1524         // FIXME: remove isp_use_pers_dict
1525         spellcheckerModule->persDictionaryED->setText(external_path(rc.isp_pers_dict));
1526         spellcheckerModule->compoundWordCB->setChecked(rc.isp_accept_compound);
1527         spellcheckerModule->inputEncodingCB->setChecked(rc.isp_use_input_encoding);
1528
1529
1530
1531
1532         printerModule->printerAdaptCB->setChecked(rc.print_adapt_output);
1533         printerModule->printerCommandED->setText(toqstr(rc.print_command));
1534         printerModule->printerNameED->setText(toqstr(rc.printer));
1535
1536         printerModule->printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
1537         printerModule->printerCopiesED->setText(toqstr(rc.print_copies_flag));
1538         printerModule->printerReverseED->setText(toqstr(rc.print_reverse_flag));
1539         printerModule->printerToPrinterED->setText(toqstr(rc.print_to_printer));
1540         printerModule->printerExtensionED->setText(toqstr(rc.print_file_extension));
1541         printerModule->printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
1542         printerModule->printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
1543         printerModule->printerEvenED->setText(toqstr(rc.print_evenpage_flag));
1544         printerModule->printerOddED->setText(toqstr(rc.print_oddpage_flag));
1545         printerModule->printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
1546         printerModule->printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
1547         printerModule->printerToFileED->setText(external_path(rc.print_to_file));
1548         printerModule->printerExtraED->setText(toqstr(rc.print_extra_options));
1549         printerModule->printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
1550         printerModule->printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
1551
1552
1553
1554
1555         setComboxFont(screenfontsModule->screenRomanCO, rc.roman_font_name,
1556                         rc.roman_font_foundry);
1557         setComboxFont(screenfontsModule->screenSansCO, rc.sans_font_name,
1558                         rc.sans_font_foundry);
1559         setComboxFont(screenfontsModule->screenTypewriterCO, rc.typewriter_font_name,
1560                         rc.typewriter_font_foundry);
1561
1562         select_roman(screenfontsModule->screenRomanCO->currentText());
1563         select_sans(screenfontsModule->screenSansCO->currentText());
1564         select_typewriter(screenfontsModule->screenTypewriterCO->currentText());
1565
1566         screenfontsModule->screenZoomSB->setValue(rc.zoom);
1567         screenfontsModule->screenDpiSB->setValue(rc.dpi);
1568         screenfontsModule->screenTinyED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_TINY]));
1569         screenfontsModule->screenSmallestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SCRIPT]));
1570         screenfontsModule->screenSmallerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]));
1571         screenfontsModule->screenSmallED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SMALL]));
1572         screenfontsModule->screenNormalED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_NORMAL]));
1573         screenfontsModule->screenLargeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGE]));
1574         screenfontsModule->screenLargerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGER]));
1575         screenfontsModule->screenLargestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGEST]));
1576         screenfontsModule->screenHugeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGE]));
1577         screenfontsModule->screenHugerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGER]));
1578
1579         updateFormats();
1580         updateConverters();
1581         updateCopiers();
1582
1583 }
1584
1585
1586 } // namespace frontend
1587 } // namespace lyx