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