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