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