]> git.lyx.org Git - lyx.git/blob - src/frontends/qt3/QPrefs.C
Add lyxrc.use_lastfilepos and load_session to the preference dialog. Bo Peng (ben...
[lyx.git] / src / frontends / qt3 / QPrefs.C
1 /**
2  * \file QPrefs.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QPrefs.h"
14 #include "QPrefsDialog.h"
15
16 #include "lcolorcache.h"
17 #include "Qt2BC.h"
18 #include "qt_helpers.h"
19
20 #include "ui/QPrefAsciiModule.h"
21 #include "ui/QPrefDateModule.h"
22 #include "ui/QPrefKeyboardModule.h"
23 #include "ui/QPrefLatexModule.h"
24 #include "ui/QPrefScreenFontsModule.h"
25 #include "ui/QPrefColorsModule.h"
26 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
27 #include "ui/QPrefCygwinPathModule.h"
28 #endif
29 #include "ui/QPrefDisplayModule.h"
30 #include "ui/QPrefPathsModule.h"
31 #include "ui/QPrefSpellcheckerModule.h"
32 #include "ui/QPrefLanguageModule.h"
33 #include "ui/QPrefPrinterModule.h"
34 #include "ui/QPrefUIModule.h"
35 #include "ui/QPrefIdentityModule.h"
36
37 #include "debug.h"
38 #include "session.h"
39 #include "LColor.h"
40 #include "lyxfont.h"
41
42 #include "support/lstrings.h"
43 #include "support/os.h"
44
45 #include "controllers/ControlPrefs.h"
46 #include "controllers/frnt_lang.h"
47 #include "controllers/helper_funcs.h"
48
49 #include "frontends/lyx_gui.h"
50
51 #include <qcheckbox.h>
52 #include "qcoloritem.h"
53 #include <qcombobox.h>
54 #include <qlabel.h>
55 #include <qlineedit.h>
56 #include <qpushbutton.h>
57 #include <qspinbox.h>
58
59 #include <boost/tuple/tuple.hpp>
60
61 #include <iomanip>
62 #include <sstream>
63
64 using lyx::support::compare_no_case;
65
66 using std::distance;
67 using std::endl;
68 using std::setfill;
69 using std::setw;
70 using std::string;
71 using std::ostringstream;
72 using std::pair;
73 using std::vector;
74
75 namespace lyx {
76 namespace frontend {
77
78 typedef QController<ControlPrefs, QView<QPrefsDialog> > base_class;
79
80 QPrefs::QPrefs(Dialog & parent)
81         : base_class(parent, _("Preferences"))
82 {
83 }
84
85
86 Converters & QPrefs::converters()
87 {
88         return controller().converters();
89 }
90
91
92 Formats & QPrefs::formats()
93 {
94         return controller().formats();
95 }
96
97
98 Movers & QPrefs::movers()
99 {
100         return controller().movers();
101 }
102
103
104 void QPrefs::build_dialog()
105 {
106         dialog_.reset(new QPrefsDialog(this));
107
108         bcview().setOK(dialog_->savePB);
109         bcview().setApply(dialog_->applyPB);
110         bcview().setCancel(dialog_->closePB);
111         bcview().setRestore(dialog_->restorePB);
112
113         dialog_->uiModule->lastfilesSB->setMaxValue(maxlastfiles);
114
115         QPrefLanguageModule * langmod(dialog_->languageModule);
116
117         langmod->defaultLanguageCO->clear();
118         // store the lang identifiers for later
119         using lyx::frontend::LanguagePair;
120         vector<LanguagePair> const langs =
121                 lyx::frontend::getLanguageData(false);
122         lang_ = getSecond(langs);
123
124         vector<LanguagePair>::const_iterator lit  = langs.begin();
125         vector<LanguagePair>::const_iterator lend = langs.end();
126         for (; lit != lend; ++lit) {
127                 langmod->defaultLanguageCO->insertItem(toqstr(lit->first));
128         }
129
130         QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
131         spellmod->spellCommandCO->insertItem(qt_("ispell"));
132         spellmod->spellCommandCO->insertItem(qt_("aspell"));
133         spellmod->spellCommandCO->insertItem(qt_("hspell"));
134 #ifdef USE_PSPELL
135         spellmod->spellCommandCO->insertItem(qt_("pspell (library)"));
136 #else
137 #ifdef USE_ASPELL
138         spellmod->spellCommandCO->insertItem(qt_("aspell (library)"));
139 #endif
140 #endif
141 }
142
143
144 namespace {
145
146 string const internal_path(QString const & input)
147 {
148         return lyx::support::os::internal_path(fromqstr(input));
149 }
150
151 string const internal_path_list(QString const & input)
152 {
153         return lyx::support::os::internal_path_list(fromqstr(input));
154 }
155
156 }
157
158
159 void QPrefs::apply()
160 {
161         LyXRC & rc(controller().rc());
162
163         QPrefLanguageModule * langmod(dialog_->languageModule);
164
165         // FIXME: remove rtl_support bool
166         rc.rtl_support = langmod->rtlCB->isChecked();
167         rc.mark_foreign_language = langmod->markForeignCB->isChecked();
168         rc.language_auto_begin = langmod->autoBeginCB->isChecked();
169         rc.language_auto_end = langmod->autoEndCB->isChecked();
170         rc.language_use_babel = langmod->useBabelCB->isChecked();
171         rc.language_global_options = langmod->globalCB->isChecked();
172         rc.language_package = fromqstr(langmod->languagePackageED->text());
173         rc.language_command_begin = fromqstr(langmod->startCommandED->text());
174         rc.language_command_end = fromqstr(langmod->endCommandED->text());
175         rc.default_language = lang_[langmod->defaultLanguageCO->currentItem()];
176
177         QPrefUIModule * uimod(dialog_->uiModule);
178
179         rc.ui_file = internal_path(uimod->uiFileED->text());
180         rc.bind_file = internal_path(uimod->bindFileED->text());
181         rc.use_lastfilepos = uimod->restoreCursorCB->isChecked();
182         rc.load_session = uimod->loadSessionCB->isChecked();
183         rc.cursor_follows_scrollbar = uimod->cursorFollowsCB->isChecked();
184         rc.autosave = uimod->autoSaveSB->value() * 60;
185         rc.make_backup = uimod->autoSaveCB->isChecked();
186         rc.num_lastfiles = uimod->lastfilesSB->value();
187
188
189         QPrefKeyboardModule * keymod(dialog_->keyboardModule);
190
191         // FIXME: can derive CB from the two EDs
192         rc.use_kbmap = keymod->keymapCB->isChecked();
193         rc.primary_kbmap = internal_path(keymod->firstKeymapED->text());
194         rc.secondary_kbmap = internal_path(keymod->secondKeymapED->text());
195
196
197         QPrefAsciiModule * ascmod(dialog_->asciiModule);
198
199         rc.ascii_linelen = ascmod->asciiLinelengthSB->value();
200         rc.ascii_roff_command = fromqstr(ascmod->asciiRoffED->text());
201
202
203         QPrefDateModule * datemod(dialog_->dateModule);
204
205         rc.date_insert_format = fromqstr(datemod->DateED->text());
206
207 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
208         QPrefCygwinPathModule * cygwinmod(dialog_->cygwinpathModule);
209         rc.cygwin_path_fix = !cygwinmod->pathCB->isChecked();
210 #endif
211
212         QPrefLatexModule * latexmod(dialog_->latexModule);
213
214         rc.fontenc = fromqstr(latexmod->latexEncodingED->text());
215         rc.chktex_command = fromqstr(latexmod->latexChecktexED->text());
216         rc.bibtex_command = fromqstr(latexmod->latexBibtexED->text());
217         rc.index_command = fromqstr(latexmod->latexIndexED->text());
218         rc.auto_reset_options = latexmod->latexAutoresetCB->isChecked();
219         rc.view_dvi_paper_option = fromqstr(latexmod->latexDviPaperED->text());
220         rc.default_papersize =
221                 controller().toPaperSize(latexmod->latexPaperSizeCO->currentItem());
222
223         QPrefDisplayModule * displaymod(dialog_->displayModule);
224
225         switch (displaymod->instantPreviewCO->currentItem()) {
226         case 0:
227                 rc.preview = LyXRC::PREVIEW_OFF;
228                 break;
229         case 1:
230                 rc.preview = LyXRC::PREVIEW_NO_MATH;
231                 break;
232         case 2:
233                 rc.preview = LyXRC::PREVIEW_ON;
234                 break;
235         }
236
237         lyx::graphics::DisplayType dtype(lyx::graphics::ColorDisplay);
238
239         switch (displaymod->displayGraphicsCO->currentItem()) {
240         case 3: dtype = lyx::graphics::NoDisplay; break;
241         case 2: dtype = lyx::graphics::ColorDisplay; break;
242         case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
243         case 0: dtype = lyx::graphics::MonochromeDisplay; break;
244         }
245         rc.display_graphics = dtype;
246
247 #ifdef WITH_WARNINGS
248 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
249 #endif
250 #if 0
251         if (old_value != rc.display_graphics) {
252                 lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
253                 gc.changeDisplay();
254         }
255 #endif
256
257         QPrefPathsModule * pathsmod(dialog_->pathsModule);
258
259         rc.document_path = internal_path(pathsmod->workingDirED->text());
260         rc.template_path = internal_path(pathsmod->templateDirED->text());
261         rc.backupdir_path = internal_path(pathsmod->backupDirED->text());
262         rc.tempdir_path = internal_path(pathsmod->tempDirED->text());
263         rc.path_prefix = internal_path_list(pathsmod->pathPrefixED->text());
264         // FIXME: should be a checkbox only
265         rc.lyxpipes = internal_path(pathsmod->lyxserverDirED->text());
266
267
268         QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
269
270         switch (spellmod->spellCommandCO->currentItem()) {
271                 case 0:
272                 case 1:
273                 case 2:
274                         rc.use_spell_lib = false;
275                         rc.isp_command = fromqstr(spellmod->spellCommandCO->currentText());
276                         break;
277                 case 3:
278                         rc.use_spell_lib = true;
279                         break;
280         }
281
282         // FIXME: remove isp_use_alt_lang
283         rc.isp_alt_lang = fromqstr(spellmod->altLanguageED->text());
284         rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
285         // FIXME: remove isp_use_esc_chars
286         rc.isp_esc_chars = fromqstr(spellmod->escapeCharactersED->text());
287         rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
288         // FIXME: remove isp_use_pers_dict
289         rc.isp_pers_dict = internal_path(spellmod->persDictionaryED->text());
290         rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
291         rc.isp_accept_compound = spellmod->compoundWordCB->isChecked();
292         rc.isp_use_input_encoding = spellmod->inputEncodingCB->isChecked();
293
294
295         QPrefPrinterModule * printmod(dialog_->printerModule);
296
297         rc.print_adapt_output = printmod->printerAdaptCB->isChecked();
298         rc.print_command = fromqstr(printmod->printerCommandED->text());
299         rc.printer = fromqstr(printmod->printerNameED->text());
300
301         rc.print_pagerange_flag = fromqstr(printmod->printerPageRangeED->text());
302         rc.print_copies_flag = fromqstr(printmod->printerCopiesED->text());
303         rc.print_reverse_flag = fromqstr(printmod->printerReverseED->text());
304         rc.print_to_printer = fromqstr(printmod->printerToPrinterED->text());
305         rc.print_file_extension = fromqstr(printmod->printerExtensionED->text());
306         rc.print_spool_command = fromqstr(printmod->printerSpoolCommandED->text());
307         rc.print_paper_flag = fromqstr(printmod->printerPaperTypeED->text());
308         rc.print_evenpage_flag = fromqstr(printmod->printerEvenED->text());
309         rc.print_oddpage_flag = fromqstr(printmod->printerOddED->text());
310         rc.print_collcopies_flag = fromqstr(printmod->printerCollatedED->text());
311         rc.print_landscape_flag = fromqstr(printmod->printerLandscapeED->text());
312         rc.print_to_file = internal_path(printmod->printerToFileED->text());
313         rc.print_extra_options = fromqstr(printmod->printerExtraED->text());
314         rc.print_spool_printerprefix = fromqstr(printmod->printerSpoolPrefixED->text());
315         rc.print_paper_dimension_flag = fromqstr(printmod->printerPaperSizeED->text());
316
317
318         QPrefIdentityModule * idmod(dialog_->identityModule);
319         rc.user_name = fromqstr(idmod->nameED->text());
320         rc.user_email = fromqstr(idmod->emailED->text());
321
322         QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
323
324         LyXRC const oldrc(rc);
325
326         boost::tie(rc.roman_font_name, rc.roman_font_foundry)
327                 = parseFontName(fromqstr(fontmod->screenRomanCO->currentText()));
328         boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
329                 parseFontName(fromqstr(fontmod->screenSansCO->currentText()));
330         boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
331                 parseFontName(fromqstr(fontmod->screenTypewriterCO->currentText()));
332
333         rc.zoom = fontmod->screenZoomSB->value();
334         rc.dpi = fontmod->screenDpiSB->value();
335         rc.font_sizes[LyXFont::SIZE_TINY] = fromqstr(fontmod->screenTinyED->text());
336         rc.font_sizes[LyXFont::SIZE_SCRIPT] = fromqstr(fontmod->screenSmallestED->text());
337         rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = fromqstr(fontmod->screenSmallerED->text());
338         rc.font_sizes[LyXFont::SIZE_SMALL] = fromqstr(fontmod->screenSmallED->text());
339         rc.font_sizes[LyXFont::SIZE_NORMAL] = fromqstr(fontmod->screenNormalED->text());
340         rc.font_sizes[LyXFont::SIZE_LARGE] = fromqstr(fontmod->screenLargeED->text());
341         rc.font_sizes[LyXFont::SIZE_LARGER] = fromqstr(fontmod->screenLargerED->text());
342         rc.font_sizes[LyXFont::SIZE_LARGEST] = fromqstr(fontmod->screenLargestED->text());
343         rc.font_sizes[LyXFont::SIZE_HUGE] = fromqstr(fontmod->screenHugeED->text());
344         rc.font_sizes[LyXFont::SIZE_HUGER] = fromqstr(fontmod->screenHugerED->text());
345
346         if (rc.font_sizes != oldrc.font_sizes
347                 || rc.roman_font_name != oldrc.roman_font_name
348                 || rc.sans_font_name != oldrc.sans_font_name
349                 || rc.typewriter_font_name != oldrc.typewriter_font_name
350                 || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
351                 controller().updateScreenFonts();
352         }
353
354         QPrefColorsModule * colmod(dialog_->colorsModule);
355
356         unsigned int i;
357
358         for (i = 0; i < colmod->lyxObjectsLB->count(); ++i) {
359                 QListBoxItem * ib(colmod->lyxObjectsLB->item(i));
360                 QColorItem * ci(static_cast<QColorItem*>(ib));
361
362                 LColor::color const col(dialog_->colors_[i]);
363                 QColor const & qcol(lcolorcache.get(col));
364
365                 // FIXME: dubious, but it's what xforms does
366                 if (qcol != ci->color()) {
367                         ostringstream ostr;
368
369                         ostr << '#' << std::setbase(16) << setfill('0')
370                              << setw(2) << ci->color().red()
371                              << setw(2) << ci->color().green()
372                              << setw(2) << ci->color().blue();
373
374                         string newhex(ostr.str());
375                         controller().setColor(col, newhex);
376                 }
377         }
378 }
379
380
381 // FIXME: move to helper_funcs.h
382 namespace {
383
384 template<class A>
385 typename std::vector<A>::size_type
386 findPos(std::vector<A> const & vec, A const & val)
387 {
388         typedef typename std::vector<A>::const_iterator Cit;
389
390         Cit it = std::find(vec.begin(), vec.end(), val);
391         if (it == vec.end())
392                 return 0;
393         return distance(vec.begin(), it);
394 }
395
396 void setComboxFont(QComboBox * cb, string const & family, string const & foundry)
397 {
398         string const name = makeFontName(family, foundry);
399         for (int i = 0; i < cb->count(); ++i) {
400                 if (fromqstr(cb->text(i)) == name) {
401                         cb->setCurrentItem(i);
402                         return;
403                 }
404         }
405
406         // Try matching without foundry name
407
408         // We count in reverse in order to prefer the Xft foundry
409         for (int i = cb->count() - 1; i >= 0; --i) {
410                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
411                 if (compare_no_case(tmp.first, family) == 0) {
412                         cb->setCurrentItem(i);
413                         return;
414                 }
415         }
416
417         // family alone can contain e.g. "Helvetica [Adobe]"
418         pair<string, string> tmpfam = parseFontName(family);
419
420         // We count in reverse in order to prefer the Xft foundry
421         for (int i = cb->count() - 1; i >= 0; --i) {
422                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
423                 if (compare_no_case(tmp.first, tmpfam.first) == 0) {
424                         cb->setCurrentItem(i);
425                         return;
426                 }
427         }
428
429         // Bleh, default fonts, and the names couldn't be found. Hack
430         // for bug 1063. Qt makes baby Jesus cry.
431
432         QFont font;
433
434         if (family == lyx_gui::roman_font_name()) {
435                 font.setStyleHint(QFont::Serif);
436                 font.setFamily(family.c_str());
437         } else if (family == lyx_gui::sans_font_name()) {
438                 font.setStyleHint(QFont::SansSerif);
439                 font.setFamily(family.c_str());
440         } else if (family == lyx_gui::typewriter_font_name()) {
441                 font.setStyleHint(QFont::TypeWriter);
442                 font.setFamily(family.c_str());
443         } else {
444                 lyxerr << "FAILED to find the default font: '"
445                        << foundry << "', '" << family << '\''<< endl;
446                 return;
447         }
448
449         QFontInfo info(font);
450         pair<string, string> tmp = parseFontName(fromqstr(info.family()));
451         string const & default_font_name = tmp.first;
452         lyxerr << "Apparent font is " << default_font_name << endl;
453
454         for (int i = 0; i < cb->count(); ++i) {
455                 lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
456                 if (compare_no_case(fromqstr(cb->text(i)),
457                                     default_font_name) == 0) {
458                         cb->setCurrentItem(i);
459                         return;
460                 }
461         }
462
463         lyxerr << "FAILED to find the font: '"
464                << foundry << "', '" << family << '\'' <<endl;
465 }
466
467 } // end namespace anon
468
469
470 namespace {
471
472 QString const external_path(string const & input)
473 {
474         return toqstr(lyx::support::os::external_path(input));
475 }
476
477 QString const external_path_list(string const & input)
478 {
479         return toqstr(lyx::support::os::external_path_list(input));
480 }
481
482 }
483
484
485 void QPrefs::update_contents()
486 {
487         LyXRC const & rc(controller().rc());
488
489         QPrefLanguageModule * langmod(dialog_->languageModule);
490
491         // FIXME: remove rtl_support bool
492         langmod->rtlCB->setChecked(rc.rtl_support);
493         langmod->markForeignCB->setChecked(rc.mark_foreign_language);
494         langmod->autoBeginCB->setChecked(rc.language_auto_begin);
495         langmod->autoEndCB->setChecked(rc.language_auto_end);
496         langmod->useBabelCB->setChecked(rc.language_use_babel);
497         langmod->globalCB->setChecked(rc.language_global_options);
498         langmod->languagePackageED->setText(toqstr(rc.language_package));
499         langmod->startCommandED->setText(toqstr(rc.language_command_begin));
500         langmod->endCommandED->setText(toqstr(rc.language_command_end));
501
502         int const pos = int(findPos(lang_, rc.default_language));
503         langmod->defaultLanguageCO->setCurrentItem(pos);
504
505         QPrefUIModule * uimod(dialog_->uiModule);
506
507         uimod->uiFileED->setText(external_path(rc.ui_file));
508         uimod->bindFileED->setText(external_path(rc.bind_file));
509         uimod->restoreCursorCB->setChecked(rc.use_lastfilepos);
510         uimod->loadSessionCB->setChecked(rc.load_session);
511         uimod->cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
512         // convert to minutes
513         int mins(rc.autosave / 60);
514         if (rc.autosave && !mins)
515                 mins = 1;
516         uimod->autoSaveSB->setValue(mins);
517         uimod->autoSaveCB->setChecked(rc.make_backup);
518         uimod->lastfilesSB->setValue(rc.num_lastfiles);
519
520
521         QPrefIdentityModule * idmod(dialog_->identityModule);
522         idmod->nameED->setText(toqstr(rc.user_name));
523         idmod->emailED->setText(toqstr(rc.user_email));
524
525
526         QPrefKeyboardModule * keymod(dialog_->keyboardModule);
527
528         // FIXME: can derive CB from the two EDs
529         keymod->keymapCB->setChecked(rc.use_kbmap);
530         // no idea why we need these. Fscking Qt.
531         keymod->firstKeymapED->setEnabled(rc.use_kbmap);
532         keymod->firstKeymapPB->setEnabled(rc.use_kbmap);
533         keymod->firstKeymapLA->setEnabled(rc.use_kbmap);
534         keymod->secondKeymapED->setEnabled(rc.use_kbmap);
535         keymod->secondKeymapPB->setEnabled(rc.use_kbmap);
536         keymod->secondKeymapLA->setEnabled(rc.use_kbmap);
537         keymod->firstKeymapED->setText(external_path(rc.primary_kbmap));
538         keymod->secondKeymapED->setText(external_path(rc.secondary_kbmap));
539
540
541         QPrefAsciiModule * ascmod(dialog_->asciiModule);
542
543         ascmod->asciiLinelengthSB->setValue(rc.ascii_linelen);
544         ascmod->asciiRoffED->setText(toqstr(rc.ascii_roff_command));
545
546
547         QPrefDateModule * datemod(dialog_->dateModule);
548
549         datemod->DateED->setText(toqstr(rc.date_insert_format));
550
551 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
552         QPrefCygwinPathModule * cygwinmod(dialog_->cygwinpathModule);
553         cygwinmod->pathCB->setChecked(!rc.cygwin_path_fix);
554 #endif
555
556         QPrefLatexModule * latexmod(dialog_->latexModule);
557
558         latexmod->latexEncodingED->setText(toqstr(rc.fontenc));
559         latexmod->latexChecktexED->setText(toqstr(rc.chktex_command));
560         latexmod->latexBibtexED->setText(toqstr(rc.bibtex_command));
561         latexmod->latexIndexED->setText(toqstr(rc.index_command));
562         latexmod->latexAutoresetCB->setChecked(rc.auto_reset_options);
563         latexmod->latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
564         latexmod->latexPaperSizeCO->setCurrentItem(
565                 controller().fromPaperSize(rc.default_papersize));
566
567
568         QPrefDisplayModule * displaymod(dialog_->displayModule);
569
570         switch (rc.preview) {
571         case LyXRC::PREVIEW_OFF:
572                 displaymod->instantPreviewCO->setCurrentItem(0);
573                 break;
574         case LyXRC::PREVIEW_NO_MATH :
575                 displaymod->instantPreviewCO->setCurrentItem(1);
576                 break;
577         case LyXRC::PREVIEW_ON :
578                 displaymod->instantPreviewCO->setCurrentItem(2);
579                 break;
580         }
581
582         int item = 2;
583
584         switch (rc.display_graphics) {
585                 case lyx::graphics::NoDisplay:          item = 3; break;
586                 case lyx::graphics::ColorDisplay:       item = 2; break;
587                 case lyx::graphics::GrayscaleDisplay:   item = 1; break;
588                 case lyx::graphics::MonochromeDisplay:  item = 0; break;
589                 default: break;
590         }
591         displaymod->displayGraphicsCO->setCurrentItem(item);
592
593
594         QPrefPathsModule * pathsmod(dialog_->pathsModule);
595
596         pathsmod->workingDirED->setText(external_path(rc.document_path));
597         pathsmod->templateDirED->setText(external_path(rc.template_path));
598         pathsmod->backupDirED->setText(external_path(rc.backupdir_path));
599         pathsmod->tempDirED->setText(external_path(rc.tempdir_path));
600         pathsmod->pathPrefixED->setText(external_path_list(rc.path_prefix));
601         // FIXME: should be a checkbox only
602         pathsmod->lyxserverDirED->setText(external_path(rc.lyxpipes));
603
604         QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
605
606         spellmod->spellCommandCO->setCurrentItem(0);
607
608         if (rc.isp_command == "ispell") {
609                 spellmod->spellCommandCO->setCurrentItem(0);
610         } else if (rc.isp_command == "aspell") {
611                 spellmod->spellCommandCO->setCurrentItem(1);
612         } else if (rc.isp_command == "hspell") {
613                 spellmod->spellCommandCO->setCurrentItem(2);
614         }
615
616         if (rc.use_spell_lib) {
617 #if defined(USE_ASPELL) || defined(USE_PSPELL)
618                 spellmod->spellCommandCO->setCurrentItem(3);
619 #endif
620         }
621
622         // FIXME: remove isp_use_alt_lang
623         spellmod->altLanguageED->setText(toqstr(rc.isp_alt_lang));
624         // FIXME: remove isp_use_esc_chars
625         spellmod->escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
626         // FIXME: remove isp_use_pers_dict
627         spellmod->persDictionaryED->setText(external_path(rc.isp_pers_dict));
628         spellmod->compoundWordCB->setChecked(rc.isp_accept_compound);
629         spellmod->inputEncodingCB->setChecked(rc.isp_use_input_encoding);
630
631
632         QPrefPrinterModule * printmod(dialog_->printerModule);
633
634         printmod->printerAdaptCB->setChecked(rc.print_adapt_output);
635         printmod->printerCommandED->setText(toqstr(rc.print_command));
636         printmod->printerNameED->setText(toqstr(rc.printer));
637
638         printmod->printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
639         printmod->printerCopiesED->setText(toqstr(rc.print_copies_flag));
640         printmod->printerReverseED->setText(toqstr(rc.print_reverse_flag));
641         printmod->printerToPrinterED->setText(toqstr(rc.print_to_printer));
642         printmod->printerExtensionED->setText(toqstr(rc.print_file_extension));
643         printmod->printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
644         printmod->printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
645         printmod->printerEvenED->setText(toqstr(rc.print_evenpage_flag));
646         printmod->printerOddED->setText(toqstr(rc.print_oddpage_flag));
647         printmod->printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
648         printmod->printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
649         printmod->printerToFileED->setText(external_path(rc.print_to_file));
650         printmod->printerExtraED->setText(toqstr(rc.print_extra_options));
651         printmod->printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
652         printmod->printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
653
654
655         QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
656
657         setComboxFont(fontmod->screenRomanCO, rc.roman_font_name,
658                         rc.roman_font_foundry);
659         setComboxFont(fontmod->screenSansCO, rc.sans_font_name,
660                         rc.sans_font_foundry);
661         setComboxFont(fontmod->screenTypewriterCO, rc.typewriter_font_name,
662                         rc.typewriter_font_foundry);
663
664         dialog_->select_roman(fontmod->screenRomanCO->currentText());
665         dialog_->select_sans(fontmod->screenSansCO->currentText());
666         dialog_->select_typewriter(fontmod->screenTypewriterCO->currentText());
667
668         fontmod->screenZoomSB->setValue(rc.zoom);
669         fontmod->screenDpiSB->setValue(rc.dpi);
670         fontmod->screenTinyED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_TINY]));
671         fontmod->screenSmallestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SCRIPT]));
672         fontmod->screenSmallerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]));
673         fontmod->screenSmallED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SMALL]));
674         fontmod->screenNormalED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_NORMAL]));
675         fontmod->screenLargeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGE]));
676         fontmod->screenLargerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGER]));
677         fontmod->screenLargestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGEST]));
678         fontmod->screenHugeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGE]));
679         fontmod->screenHugerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGER]));
680
681         dialog_->updateFormats();
682         dialog_->updateConverters();
683         dialog_->updateCopiers();
684 }
685
686 } // namespace frontend
687 } // namespace lyx