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