]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QPrefsDialog.C
delete some emits that I missed, add comments about emitting signals
[lyx.git] / src / frontends / qt4 / QPrefsDialog.C
1 /**
2  * \file QPrefsDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13 #include "debug.h"
14 #include "qt_helpers.h"
15
16 #include "ColorCache.h"
17 #include "Qt2BC.h"
18 #include "qt_helpers.h"
19
20 #include "debug.h"
21 #include "session.h"
22 #include "LColor.h"
23 #include "lyxfont.h"
24
25 #include "support/lstrings.h"
26 #include "support/os.h"
27
28 #include "controllers/ControlPrefs.h"
29 #include "controllers/frnt_lang.h"
30 #include "controllers/helper_funcs.h"
31
32 #include "frontends/Alert.h"
33 #include "frontends/lyx_gui.h"
34
35 #include "QPrefsDialog.h"
36 #include "QPrefs.h"
37
38 #include "panelstack.h"
39 #include "qfontexample.h"
40
41 #include "gettext.h"
42 #include "LColor.h"
43 #include "ColorCache.h"
44
45 #include "controllers/ControlPrefs.h"
46
47 #include <QCheckBox>
48 #include <QColorDialog>
49 #include <QFontDatabase>
50 #include <QLineEdit>
51 #include <QPushButton>
52 #include <QSpinBox>
53 #include <QString>
54 #include <QValidator>
55 #include <QCloseEvent>
56
57 #include <boost/tuple/tuple.hpp>
58 #include <iomanip>
59 #include <sstream>
60
61 using lyx::support::compare_no_case;
62
63 using std::distance;
64 using std::endl;
65 using std::setfill;
66 using std::setw;
67 using std::string;
68 using std::ostringstream;
69 using std::pair;
70 using std::vector;
71
72
73 namespace lyx {
74 namespace frontend {
75
76 string const LookAndFeel = "Look and feel";
77 string const LanguageSettings = "Language settings";
78 string const Outputs = "Outputs";
79
80
81 // FIXME: move to helper_funcs.h
82 namespace {
83
84 template<class A>
85 typename std::vector<A>::size_type
86 findPos(std::vector<A> const & vec, A const & val)
87 {
88         typedef typename std::vector<A>::const_iterator Cit;
89
90         Cit it = std::find(vec.begin(), vec.end(), val);
91         if (it == vec.end())
92                 return 0;
93         return distance(vec.begin(), it);
94 }
95
96 void setComboxFont(QComboBox * cb, string const & family, string const & foundry)
97 {
98         string const name = makeFontName(family, foundry);
99         for (int i = 0; i < cb->count(); ++i) {
100                 if (fromqstr(cb->text(i)) == name) {
101                         cb->setCurrentItem(i);
102                         return;
103                 }
104         }
105
106         // Try matching without foundry name
107
108         // We count in reverse in order to prefer the Xft foundry
109         for (int i = cb->count() - 1; i >= 0; --i) {
110                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
111                 if (compare_no_case(tmp.first, family) == 0) {
112                         cb->setCurrentItem(i);
113                         return;
114                 }
115         }
116
117         // family alone can contain e.g. "Helvetica [Adobe]"
118         pair<string, string> tmpfam = parseFontName(family);
119
120         // We count in reverse in order to prefer the Xft foundry
121         for (int i = cb->count() - 1; i >= 0; --i) {
122                 pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
123                 if (compare_no_case(tmp.first, tmpfam.first) == 0) {
124                         cb->setCurrentItem(i);
125                         return;
126                 }
127         }
128
129         // Bleh, default fonts, and the names couldn't be found. Hack
130         // for bug 1063. Qt makes baby Jesus cry.
131
132         QFont font;
133
134         if (family == lyx_gui::roman_font_name()) {
135                 font.setStyleHint(QFont::Serif);
136                 font.setFamily(family.c_str());
137         } else if (family == lyx_gui::sans_font_name()) {
138                 font.setStyleHint(QFont::SansSerif);
139                 font.setFamily(family.c_str());
140         } else if (family == lyx_gui::typewriter_font_name()) {
141                 font.setStyleHint(QFont::TypeWriter);
142                 font.setFamily(family.c_str());
143         } else {
144                 lyxerr << "FAILED to find the default font: '"
145                        << foundry << "', '" << family << '\''<< endl;
146                 return;
147         }
148
149         QFontInfo info(font);
150         pair<string, string> tmp = parseFontName(fromqstr(info.family()));
151         string const & default_font_name = tmp.first;
152         lyxerr << "Apparent font is " << default_font_name << endl;
153
154         for (int i = 0; i < cb->count(); ++i) {
155                 lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
156                 if (compare_no_case(fromqstr(cb->text(i)),
157                                     default_font_name) == 0) {
158                         cb->setCurrentItem(i);
159                         return;
160                 }
161         }
162
163         lyxerr << "FAILED to find the font: '"
164                << foundry << "', '" << family << '\'' <<endl;
165 }
166
167
168 QString const external_path(string const & input)
169 {
170         return toqstr(lyx::support::os::external_path(input));
171 }
172
173
174 string const internal_path(QString const & input)
175 {
176         return lyx::support::os::internal_path(fromqstr(input));
177 }
178
179 } // end namespace anon
180
181
182 PrefAscii::PrefAscii(QWidget * parent)
183 : PrefModule(_(Outputs), _("Plain text"), 0, parent)
184 {
185         setupUi(this);
186         connect(asciiLinelengthSB, SIGNAL(valueChanged(int)),
187                 this, SIGNAL(changed()));
188         connect(asciiRoffED, SIGNAL(textChanged(const QString&)),
189                 this, SIGNAL(changed()));
190 }
191
192
193 void PrefAscii::apply(LyXRC & rc) const
194 {
195         rc.ascii_linelen = asciiLinelengthSB->value();
196         rc.ascii_roff_command = fromqstr(asciiRoffED->text());
197 }
198
199
200 void PrefAscii::update(LyXRC const & rc)
201 {
202         asciiLinelengthSB->setValue(rc.ascii_linelen);
203         asciiRoffED->setText(toqstr(rc.ascii_roff_command));
204 }
205
206
207 PrefDate::PrefDate(QWidget * parent)
208 : PrefModule(_(Outputs), _("Date format"), 0, parent)
209 {
210         setupUi(this);
211         connect(DateED, SIGNAL(textChanged(const QString&)),
212                 this, SIGNAL(changed()));
213 }
214
215
216 void PrefDate::apply(LyXRC & rc) const
217 {
218         rc.date_insert_format = fromqstr(DateED->text());
219 }
220
221
222 void PrefDate::update(LyXRC const & rc)
223 {
224         DateED->setText(toqstr(rc.date_insert_format));
225 }
226
227
228 PrefKeyboard::PrefKeyboard(QPrefs * form, QWidget * parent)
229 : PrefModule(_(LookAndFeel), _("Keyboard"), form, parent)
230 {
231         setupUi(this);
232
233         connect(keymapCB, SIGNAL( toggled(bool) ),
234                 firstKeymapLA, SLOT( setEnabled(bool) ) );
235         connect(keymapCB, SIGNAL( toggled(bool) ),
236                 secondKeymapLA, SLOT( setEnabled(bool) ) );
237         connect(keymapCB, SIGNAL( toggled(bool) ),
238                 firstKeymapED, SLOT( setEnabled(bool) ) );
239         connect(keymapCB, SIGNAL( toggled(bool) ),
240                 secondKeymapED, SLOT( setEnabled(bool) ) );
241         connect(keymapCB, SIGNAL( toggled(bool) ),
242                 firstKeymapPB, SLOT( setEnabled(bool) ) );
243         connect(keymapCB, SIGNAL( toggled(bool) ),
244                 secondKeymapPB, SLOT( setEnabled(bool) ) );
245
246         connect(keymapCB, SIGNAL(toggled(bool)),
247                 this, SIGNAL(changed()));
248         connect(firstKeymapED, SIGNAL(textChanged(const QString&)),
249                 this, SIGNAL(changed()));
250         connect(secondKeymapED, SIGNAL(textChanged(const QString&)),
251                 this, SIGNAL(changed()));
252 }
253
254
255 void PrefKeyboard::apply(LyXRC & rc) const
256 {
257         // FIXME: can derive CB from the two EDs
258         rc.use_kbmap = keymapCB->isChecked();
259         rc.primary_kbmap = internal_path(firstKeymapED->text());
260         rc.secondary_kbmap = internal_path(secondKeymapED->text());
261 }
262
263
264 void PrefKeyboard::update(LyXRC const & rc)
265 {
266         // FIXME: can derive CB from the two EDs
267         keymapCB->setChecked(rc.use_kbmap);
268         // no idea why we need these. Fscking Qt.
269         firstKeymapED->setEnabled(rc.use_kbmap);
270         firstKeymapPB->setEnabled(rc.use_kbmap);
271         firstKeymapLA->setEnabled(rc.use_kbmap);
272         secondKeymapED->setEnabled(rc.use_kbmap);
273         secondKeymapPB->setEnabled(rc.use_kbmap);
274         secondKeymapLA->setEnabled(rc.use_kbmap);
275         firstKeymapED->setText(external_path(rc.primary_kbmap));
276         secondKeymapED->setText(external_path(rc.secondary_kbmap));
277 }
278
279
280 QString PrefKeyboard::testKeymap(QString keymap)
281 {
282         return toqstr(form_->controller().browsekbmap(fromqstr(keymap)));
283 }
284
285
286 void PrefKeyboard::on_firstKeymapPB_clicked(bool)
287 {
288         QString file = testKeymap(firstKeymapED->text());
289         if (!file.isEmpty())
290                 firstKeymapED->setText(file);
291 }
292
293
294 void PrefKeyboard::on_secondKeymapPB_clicked(bool)
295 {
296         QString file = testKeymap(secondKeymapED->text());
297         if (!file.isEmpty())
298                 secondKeymapED->setText(file);
299 }
300
301
302 PrefLatex::PrefLatex(QPrefs * form, QWidget * parent)
303 : PrefModule(_(Outputs), _("LaTeX"), form, parent)
304 {
305         setupUi(this);
306         connect(latexEncodingED, SIGNAL(textChanged(const QString&)),
307                 this, SIGNAL(changed()));
308         connect(latexChecktexED, SIGNAL(textChanged(const QString&)),
309                 this, SIGNAL(changed()));
310         connect(latexBibtexED, SIGNAL(textChanged(const QString&)),
311                 this, SIGNAL(changed()));
312         connect(latexIndexED, SIGNAL(textChanged(const QString&)),
313                 this, SIGNAL(changed()));
314         connect(latexAutoresetCB, SIGNAL(toggled(bool)),
315                 this, SIGNAL(changed()));
316         connect(latexDviPaperED, SIGNAL(textChanged(const QString&)),
317                 this, SIGNAL(changed()));
318         connect(latexPaperSizeCO, SIGNAL(activated(int)),
319                 this, SIGNAL(changed()));
320 }
321
322
323 void PrefLatex::apply(LyXRC & rc) const
324 {
325         rc.fontenc = fromqstr(latexEncodingED->text());
326         rc.chktex_command = fromqstr(latexChecktexED->text());
327         rc.bibtex_command = fromqstr(latexBibtexED->text());
328         rc.index_command = fromqstr(latexIndexED->text());
329         rc.auto_reset_options = latexAutoresetCB->isChecked();
330         rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
331         rc.default_papersize =
332                 form_->controller().toPaperSize(latexPaperSizeCO->currentItem());
333 }
334
335
336 void PrefLatex::update(LyXRC const & rc)
337 {
338         latexEncodingED->setText(toqstr(rc.fontenc));
339         latexChecktexED->setText(toqstr(rc.chktex_command));
340         latexBibtexED->setText(toqstr(rc.bibtex_command));
341         latexIndexED->setText(toqstr(rc.index_command));
342         latexAutoresetCB->setChecked(rc.auto_reset_options);
343         latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
344         latexPaperSizeCO->setCurrentIndex(
345                 form_->controller().fromPaperSize(rc.default_papersize));
346 }
347
348
349 PrefScreenFonts::PrefScreenFonts(QPrefs * form, QWidget * parent)
350 : PrefModule(_(LookAndFeel), _("Screen fonts"), form, parent)
351 {
352         setupUi(this);
353
354         connect(screenRomanCO, SIGNAL(activated(const QString&)),
355                 this, SLOT(select_roman(const QString&)));
356         connect(screenSansCO, SIGNAL(activated(const QString&)),
357                 this, SLOT(select_sans(const QString&)));
358         connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
359                 this, SLOT(select_typewriter(const QString&)));
360
361         QFontDatabase fontdb;
362         QStringList families(fontdb.families());
363         for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
364                 screenRomanCO->insertItem(*it);
365                 screenSansCO->insertItem(*it);
366                 screenTypewriterCO->insertItem(*it);
367         }
368         connect(screenRomanCO, SIGNAL(activated(const QString&)),
369                 this, SIGNAL(changed()));
370         connect(screenSansCO, SIGNAL(activated(const QString&)),
371                 this, SIGNAL(changed()));
372         connect(screenTypewriterCO, SIGNAL(activated(const QString&)),
373                 this, SIGNAL(changed()));
374         connect(screenZoomSB, SIGNAL(valueChanged(int)),
375                 this, SIGNAL(changed()));
376         connect(screenDpiSB, SIGNAL(valueChanged(int)),
377                 this, SIGNAL(changed()));
378         connect(screenTinyED, SIGNAL(textChanged(const QString&)),
379                 this, SIGNAL(changed()));
380         connect(screenSmallestED, SIGNAL(textChanged(const QString&)),
381                 this, SIGNAL(changed()));
382         connect(screenSmallerED, SIGNAL(textChanged(const QString&)),
383                 this, SIGNAL(changed()));
384         connect(screenSmallED, SIGNAL(textChanged(const QString&)),
385                 this, SIGNAL(changed()));
386         connect(screenNormalED, SIGNAL(textChanged(const QString&)),
387                 this, SIGNAL(changed()));
388         connect(screenLargeED, SIGNAL(textChanged(const QString&)),
389                 this, SIGNAL(changed()));
390         connect(screenLargerED, SIGNAL(textChanged(const QString&)),
391                 this, SIGNAL(changed()));
392         connect(screenLargestED, SIGNAL(textChanged(const QString&)),
393                 this, SIGNAL(changed()));
394         connect(screenHugeED, SIGNAL(textChanged(const QString&)),
395                 this, SIGNAL(changed()));
396         connect(screenHugerED, SIGNAL(textChanged(const QString&)),
397                 this, SIGNAL(changed()));
398
399         screenTinyED->setValidator(new QDoubleValidator(
400                 screenTinyED));
401         screenSmallestED->setValidator(new QDoubleValidator(
402                 screenSmallestED));
403         screenSmallerED->setValidator(new QDoubleValidator(
404                 screenSmallerED));
405         screenSmallED->setValidator(new QDoubleValidator(
406                 screenSmallED));
407         screenNormalED->setValidator(new QDoubleValidator(
408                 screenNormalED));
409         screenLargeED->setValidator(new QDoubleValidator(
410                 screenLargeED));
411         screenLargerED->setValidator(new QDoubleValidator(
412                 screenLargerED));
413         screenLargestED->setValidator(new QDoubleValidator(
414                 screenLargestED));
415         screenHugeED->setValidator(new QDoubleValidator(
416                 screenHugeED));
417         screenHugerED->setValidator(new QDoubleValidator(
418                 screenHugerED));
419 }
420
421
422 void PrefScreenFonts::apply(LyXRC & rc) const
423 {
424         LyXRC const oldrc(rc);
425
426         boost::tie(rc.roman_font_name, rc.roman_font_foundry)
427                 = parseFontName(fromqstr(screenRomanCO->currentText()));
428         boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
429                 parseFontName(fromqstr(screenSansCO->currentText()));
430         boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
431                 parseFontName(fromqstr(screenTypewriterCO->currentText()));
432
433         rc.zoom = screenZoomSB->value();
434         rc.dpi = screenDpiSB->value();
435         rc.font_sizes[LyXFont::SIZE_TINY] = fromqstr(screenTinyED->text());
436         rc.font_sizes[LyXFont::SIZE_SCRIPT] = fromqstr(screenSmallestED->text());
437         rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = fromqstr(screenSmallerED->text());
438         rc.font_sizes[LyXFont::SIZE_SMALL] = fromqstr(screenSmallED->text());
439         rc.font_sizes[LyXFont::SIZE_NORMAL] = fromqstr(screenNormalED->text());
440         rc.font_sizes[LyXFont::SIZE_LARGE] = fromqstr(screenLargeED->text());
441         rc.font_sizes[LyXFont::SIZE_LARGER] = fromqstr(screenLargerED->text());
442         rc.font_sizes[LyXFont::SIZE_LARGEST] = fromqstr(screenLargestED->text());
443         rc.font_sizes[LyXFont::SIZE_HUGE] = fromqstr(screenHugeED->text());
444         rc.font_sizes[LyXFont::SIZE_HUGER] = fromqstr(screenHugerED->text());
445
446         if (rc.font_sizes != oldrc.font_sizes
447                 || rc.roman_font_name != oldrc.roman_font_name
448                 || rc.sans_font_name != oldrc.sans_font_name
449                 || rc.typewriter_font_name != oldrc.typewriter_font_name
450                 || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
451                 form_->controller().updateScreenFonts();
452         }
453 }
454
455
456 void PrefScreenFonts::update(LyXRC const & rc)
457 {
458         setComboxFont(screenRomanCO, rc.roman_font_name,
459                         rc.roman_font_foundry);
460         setComboxFont(screenSansCO, rc.sans_font_name,
461                         rc.sans_font_foundry);
462         setComboxFont(screenTypewriterCO, rc.typewriter_font_name,
463                         rc.typewriter_font_foundry);
464
465         select_roman(screenRomanCO->currentText());
466         select_sans(screenSansCO->currentText());
467         select_typewriter(screenTypewriterCO->currentText());
468
469         screenZoomSB->setValue(rc.zoom);
470         screenDpiSB->setValue(rc.dpi);
471         screenTinyED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_TINY]));
472         screenSmallestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SCRIPT]));
473         screenSmallerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]));
474         screenSmallED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_SMALL]));
475         screenNormalED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_NORMAL]));
476         screenLargeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGE]));
477         screenLargerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGER]));
478         screenLargestED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_LARGEST]));
479         screenHugeED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGE]));
480         screenHugerED->setText(toqstr(rc.font_sizes[LyXFont::SIZE_HUGER]));
481 }
482
483 void PrefScreenFonts::select_roman(const QString& name)
484 {
485         screenRomanFE->set(QFont(name), name);
486 }
487
488
489 void PrefScreenFonts::select_sans(const QString& name)
490 {
491         screenSansFE->set(QFont(name), name);
492 }
493
494
495 void PrefScreenFonts::select_typewriter(const QString& name)
496 {
497         screenTypewriterFE->set(QFont(name), name);
498 }
499
500
501 PrefColors::PrefColors(QPrefs * form, QWidget * parent)
502 : PrefModule(_(LookAndFeel), _("Colors"), form, parent)
503 {
504         setupUi(this);
505
506         // FIXME: put in controller
507         for (int i = 0; i < LColor::ignore; ++i) {
508                 LColor::color lc = static_cast<LColor::color>(i);
509                 if (lc == LColor::none
510                         || lc == LColor::black
511                         || lc == LColor::white
512                         || lc == LColor::red
513                         || lc == LColor::green
514                         || lc == LColor::blue
515                         || lc == LColor::cyan
516                         || lc == LColor::magenta
517                         || lc == LColor::yellow
518                         || lc == LColor::inherit
519                         || lc == LColor::ignore) continue;
520
521                 lcolors_.push_back(lc);
522                 QColor color = QColor(lcolorcache.get(lc));
523                 prefcolors_.push_back(color.name());
524                 QPixmap coloritem(32, 32);
525                 coloritem.fill(color);
526                 QListWidgetItem * newItem = new QListWidgetItem(QIcon(coloritem),
527                         toqstr(lcolor.getGUIName(lc)), lyxObjectsLW);
528         }
529         newcolors_ = prefcolors_;
530
531         connect(colorChangePB, SIGNAL(clicked()), 
532                 this, SLOT(change_color()));
533         connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)), 
534                 this, SLOT(change_color()));
535 }
536
537
538 void PrefColors::apply(LyXRC & rc) const
539 {
540         for (int i = 0; i < lcolors_.size(); ++i) {
541                 if (prefcolors_[i]!=newcolors_[i])
542                         form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
543         }
544 }
545
546
547 void PrefColors::update(LyXRC const & rc)
548 {
549 }
550
551 void PrefColors::change_color()
552 {
553         int const row = lyxObjectsLW->currentRow();
554         QString color = newcolors_[row];
555         QColor c(QColorDialog::getColor(QColor(color), 
556                 qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget()));
557
558         if (c.name()!=color) {
559                 newcolors_[row] = c.name();
560                 QPixmap coloritem(32, 32);
561                 coloritem.fill(c);
562                 lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
563                 // emit signal
564                 changed();
565         }
566 }
567
568
569 PrefCygwinPath::PrefCygwinPath(QWidget * parent)
570 : PrefModule(_(Outputs), _("Paths"), 0, parent)
571 {
572         setupUi(this);
573         connect(pathCB, SIGNAL(toggled(bool)),
574                 this, SIGNAL(changed()));
575 }
576
577
578 void PrefCygwinPath::apply(LyXRC & rc) const
579 {
580         rc.windows_style_tex_paths = pathCB->isChecked();
581 }
582
583
584 void PrefCygwinPath::update(LyXRC const & rc)
585 {
586         pathCB->setChecked(rc.windows_style_tex_paths);
587 }
588
589
590 PrefDisplay::PrefDisplay(QWidget * parent)
591 : PrefModule(_(LookAndFeel), _("Graphics"), 0, parent)
592 {
593         setupUi(this);
594         connect(instantPreviewCO, SIGNAL(activated(int)),
595                 this, SIGNAL(changed()));
596         connect(displayGraphicsCO, SIGNAL(activated(int)),
597                 this, SIGNAL(changed()));
598 }
599
600
601 void PrefDisplay::apply(LyXRC & rc) const
602 {
603         switch (instantPreviewCO->currentItem()) {
604         case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
605         case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
606         case 2: rc.preview = LyXRC::PREVIEW_ON; break;
607         }
608
609         lyx::graphics::DisplayType dtype;
610         switch (displayGraphicsCO->currentItem()) {
611         case 3: dtype = lyx::graphics::NoDisplay; break;
612         case 2: dtype = lyx::graphics::ColorDisplay; break;
613         case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
614         case 0: dtype = lyx::graphics::MonochromeDisplay; break;
615         default: dtype = lyx::graphics::GrayscaleDisplay;
616         }
617         rc.display_graphics = dtype;
618
619 #ifdef WITH_WARNINGS
620 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
621 #endif
622 #if 0
623         if (old_value != rc.display_graphics) {
624                 lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
625                 gc.changeDisplay();
626         }
627 #endif
628 }
629
630
631 void PrefDisplay::update(LyXRC const & rc)
632 {
633         switch (rc.preview) {
634         case LyXRC::PREVIEW_OFF:
635                 instantPreviewCO->setCurrentIndex(0);
636                 break;
637         case LyXRC::PREVIEW_NO_MATH :
638                 instantPreviewCO->setCurrentIndex(1);
639                 break;
640         case LyXRC::PREVIEW_ON :
641                 instantPreviewCO->setCurrentIndex(2);
642                 break;
643         }
644
645         int item = 2;
646         switch (rc.display_graphics) {
647                 case lyx::graphics::NoDisplay:          item = 3; break;
648                 case lyx::graphics::ColorDisplay:       item = 2; break;
649                 case lyx::graphics::GrayscaleDisplay:   item = 1; break;
650                 case lyx::graphics::MonochromeDisplay:  item = 0; break;
651                 default: break;
652         }
653         displayGraphicsCO->setCurrentIndex(item);
654 }
655
656
657 PrefPaths::PrefPaths(QPrefs * form, QWidget * parent)
658 : PrefModule(string(), _("Paths"), form, parent)
659 {
660         setupUi(this);
661         connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
662         connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
663         connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
664         connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
665         connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
666         connect(workingDirED, SIGNAL(textChanged(const QString&)),
667                 this, SIGNAL(changed()));
668         connect(templateDirED, SIGNAL(textChanged(const QString&)),
669                 this, SIGNAL(changed()));
670         connect(backupDirED, SIGNAL(textChanged(const QString&)),
671                 this, SIGNAL(changed()));
672         connect(tempDirED, SIGNAL(textChanged(const QString&)),
673                 this, SIGNAL(changed()));
674         connect(lyxserverDirED, SIGNAL(textChanged(const QString&)),
675                 this, SIGNAL(changed()));
676         connect(pathPrefixED, SIGNAL(textChanged(const QString&)),
677                 this, SIGNAL(changed()));
678 }
679
680
681 void PrefPaths::apply(LyXRC & rc) const
682 {
683         rc.document_path = internal_path(workingDirED->text());
684         rc.template_path = internal_path(templateDirED->text());
685         rc.backupdir_path = internal_path(backupDirED->text());
686         rc.tempdir_path = internal_path(tempDirED->text());
687         rc.path_prefix = fromqstr(pathPrefixED->text());
688         // FIXME: should be a checkbox only
689         rc.lyxpipes = internal_path(lyxserverDirED->text());
690 }
691
692
693 void PrefPaths::update(LyXRC const & rc)
694 {
695         workingDirED->setText(external_path(rc.document_path));
696         templateDirED->setText(external_path(rc.template_path));
697         backupDirED->setText(external_path(rc.backupdir_path));
698         tempDirED->setText(external_path(rc.tempdir_path));
699         pathPrefixED->setText(toqstr(rc.path_prefix));
700         // FIXME: should be a checkbox only
701         lyxserverDirED->setText(external_path(rc.lyxpipes));
702 }
703
704 // NB: the _() is OK here because it gets passed back and we toqstr() them
705
706 void PrefPaths::select_templatedir()
707 {
708         string file(form_->controller().browsedir(fromqstr(templateDirED->text()), _("Select a document templates directory")));
709         if (!file.empty())
710                 templateDirED->setText(toqstr(file));
711 }
712
713
714 void PrefPaths::select_tempdir()
715 {
716         string file(form_->controller().browsedir(fromqstr(tempDirED->text()), _("Select a temporary directory")));
717         if (!file.empty())
718                 tempDirED->setText(toqstr(file));
719 }
720
721
722 void PrefPaths::select_backupdir()
723 {
724         string file(form_->controller().browsedir(fromqstr(backupDirED->text()), _("Select a backups directory")));
725         if (!file.empty())
726                 backupDirED->setText(toqstr(file));
727 }
728
729
730 void PrefPaths::select_workingdir()
731 {
732         string file(form_->controller().browsedir(fromqstr(workingDirED->text()), _("Select a document directory")));
733         if (!file.empty())
734                 workingDirED->setText(toqstr(file));
735 }
736
737
738 void PrefPaths::select_lyxpipe()
739 {
740         string file(form_->controller().browse(fromqstr(lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
741         if (!file.empty())
742                 lyxserverDirED->setText(toqstr(file));
743 }
744
745
746 PrefSpellchecker::PrefSpellchecker(QPrefs * form, QWidget * parent)
747 : PrefModule(_(LanguageSettings), _("Spellchecker"), form, parent)
748 {
749         setupUi(this);
750
751         connect(persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
752 #if defined (USE_ISPELL)
753         connect(spellCommandCO, SIGNAL(activated(int)),
754                 this, SIGNAL(changed()));
755 #else
756         spellCommandCO->setEnabled(false);
757 #endif
758         connect(altLanguageED, SIGNAL(textChanged(const QString&)),
759                 this, SIGNAL(changed()));
760         connect(escapeCharactersED, SIGNAL(textChanged(const QString&)),
761                 this, SIGNAL(changed()));
762         connect(persDictionaryED, SIGNAL(textChanged(const QString&)),
763                 this, SIGNAL(changed()));
764         connect(compoundWordCB, SIGNAL(toggled(bool)),
765                 this, SIGNAL(changed()));
766         connect(inputEncodingCB, SIGNAL(toggled(bool)),
767                 this, SIGNAL(changed()));
768
769         spellCommandCO->insertItem(qt_("ispell"));
770         spellCommandCO->insertItem(qt_("aspell"));
771         spellCommandCO->insertItem(qt_("hspell"));
772 #ifdef USE_PSPELL
773         spellCommandCO->insertItem(qt_("pspell (library)"));
774 #else
775 #ifdef USE_ASPELL
776         spellCommandCO->insertItem(qt_("aspell (library)"));
777 #endif
778 #endif
779 }
780
781
782 void PrefSpellchecker::apply(LyXRC & rc) const
783 {
784         switch (spellCommandCO->currentItem()) {
785                 case 0:
786                 case 1:
787                 case 2:
788                         rc.use_spell_lib = false;
789                         rc.isp_command = fromqstr(spellCommandCO->currentText());
790                         break;
791                 case 3:
792                         rc.use_spell_lib = true;
793                         break;
794         }
795
796         // FIXME: remove isp_use_alt_lang
797         rc.isp_alt_lang = fromqstr(altLanguageED->text());
798         rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
799         // FIXME: remove isp_use_esc_chars
800         rc.isp_esc_chars = fromqstr(escapeCharactersED->text());
801         rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
802         // FIXME: remove isp_use_pers_dict
803         rc.isp_pers_dict = internal_path(persDictionaryED->text());
804         rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
805         rc.isp_accept_compound = compoundWordCB->isChecked();
806         rc.isp_use_input_encoding = inputEncodingCB->isChecked();
807 }
808
809
810 void PrefSpellchecker::update(LyXRC const & rc)
811 {
812         spellCommandCO->setCurrentIndex(0);
813
814         if (rc.isp_command == "ispell") {
815                 spellCommandCO->setCurrentIndex(0);
816         } else if (rc.isp_command == "aspell") {
817                 spellCommandCO->setCurrentIndex(1);
818         } else if (rc.isp_command == "hspell") {
819                 spellCommandCO->setCurrentIndex(2);
820         }
821
822         if (rc.use_spell_lib) {
823 #if defined(USE_ASPELL) || defined(USE_PSPELL)
824                 spellCommandCO->setCurrentIndex(3);
825 #endif
826         }
827
828         // FIXME: remove isp_use_alt_lang
829         altLanguageED->setText(toqstr(rc.isp_alt_lang));
830         // FIXME: remove isp_use_esc_chars
831         escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
832         // FIXME: remove isp_use_pers_dict
833         persDictionaryED->setText(external_path(rc.isp_pers_dict));
834         compoundWordCB->setChecked(rc.isp_accept_compound);
835         inputEncodingCB->setChecked(rc.isp_use_input_encoding);
836 }
837
838
839 void PrefSpellchecker::select_dict()
840 {
841         string file(form_->controller().browsedict(fromqstr(persDictionaryED->text())));
842         if (!file.empty())
843                 persDictionaryED->setText(toqstr(file));
844 }
845
846
847 PrefConverters::PrefConverters(QPrefs * form, QWidget * parent)
848 : PrefModule(string(), _("Converters"), form, parent)
849 {
850         setupUi(this);
851
852         connect(converterNewPB, SIGNAL(clicked()), 
853                 this, SLOT(new_converter()));
854         connect(converterRemovePB, SIGNAL(clicked()), 
855                 this, SLOT(remove_converter()));
856         connect(converterModifyPB, SIGNAL(clicked()), 
857                 this, SLOT(modify_converter()));
858         connect(convertersLW, SIGNAL(currentRowChanged(int)), 
859                 this, SLOT(switch_converter(int)));
860         connect(converterFromCO, SIGNAL(activated(const QString&)), 
861                 this, SLOT(converter_changed()));
862         connect(converterToCO, SIGNAL(activated(const QString&)), 
863                 this, SLOT(converter_changed()));
864         connect(converterED, SIGNAL(textChanged(const QString&)), 
865                 this, SLOT(converter_changed()));
866         connect(converterFlagED, SIGNAL(textChanged(const QString&)), 
867                 this, SLOT(converter_changed()));
868         connect(converterNewPB, SIGNAL(clicked()), 
869                 this, SIGNAL(changed()));
870         connect(converterRemovePB, SIGNAL(clicked()), 
871                 this, SIGNAL(changed()));
872         connect(converterModifyPB, SIGNAL(clicked()), 
873                 this, SIGNAL(changed()));
874 }
875
876
877 void PrefConverters::apply(LyXRC & rc) const
878 {
879 }
880
881
882 void PrefConverters::update(LyXRC const & rc)
883 {
884         updateGui();
885 }
886
887
888 void PrefConverters::updateGui()
889 {
890         // save current selection
891         QString current = converterFromCO->currentText()
892                 + " -> " + converterToCO->currentText();
893
894         converterFromCO->clear();
895         converterToCO->clear();
896
897         Formats::const_iterator cit = form_->formats().begin();
898         Formats::const_iterator end = form_->formats().end();
899         for (; cit != end; ++cit) {
900                 converterFromCO->insertItem(toqstr(cit->prettyname()));
901                 converterToCO->insertItem(toqstr(cit->prettyname()));
902         }
903
904         convertersLW->clear();
905
906         Converters::const_iterator ccit = form_->converters().begin();
907         Converters::const_iterator cend = form_->converters().end();
908         for (; ccit != cend; ++ccit) {
909                 std::string const name = ccit->From->prettyname() + " -> "
910                                                                 + ccit->To->prettyname();
911                 new QListWidgetItem(toqstr(name), convertersLW,
912                                                         form_->converters().getNumber(ccit->From->name(), ccit->To->name()));
913         }
914         convertersLW->sortItems(Qt::AscendingOrder);
915
916         // restore selection
917         if (!current.isEmpty()) {
918                 QList<QListWidgetItem *> const item = 
919                         convertersLW->findItems(current, Qt::MatchExactly);
920                 if (item.size()>0)
921                         convertersLW->setCurrentItem(item.at(0));
922         }
923         // select first element if restoring failed
924         if (convertersLW->currentRow() == -1)
925                 convertersLW->setCurrentRow(0);
926
927         updateButtons();
928 }
929
930
931 void PrefConverters::switch_converter(int nr)
932 {
933         if (nr<0)
934                 return;
935
936         int const cnr = convertersLW->currentItem()->type();
937         Converter const & c(form_->converters().get(cnr));
938         converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
939         converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
940         converterED->setText(toqstr(c.command));
941         converterFlagED->setText(toqstr(c.flags));
942
943         updateButtons();
944 }
945
946
947 void PrefConverters::converter_changed()
948 {
949         updateButtons();
950 }
951
952
953 void PrefConverters::updateButtons()
954 {
955         Format const & from(form_->formats().get(
956                 converterFromCO->currentItem()));
957         Format const & to(form_->formats().get(
958                 converterToCO->currentItem()));
959         int const sel = form_->converters().getNumber(from.name(), to.name());
960         bool const known = !(sel < 0);
961         bool const valid = !(converterED->text().isEmpty()
962                 || from.name() == to.name());
963
964         int const cnr = convertersLW->currentItem()->type();
965         Converter const & c(form_->converters().get(cnr));
966         string const old_command = c.command;
967         string const old_flag = c.flags;
968         string const new_command(fromqstr(converterED->text()));
969         string const new_flag(fromqstr(converterFlagED->text()));
970
971         bool modified = ((old_command != new_command) || (old_flag != new_flag));
972
973         converterModifyPB->setEnabled(valid && known && modified);
974         converterNewPB->setEnabled(valid && !known);
975         converterRemovePB->setEnabled(known);
976 }
977
978
979 // FIXME: user must
980 // specify unique from/to or it doesn't appear. This is really bad UI
981 void PrefConverters::new_converter()
982 {
983         Format const & from(form_->formats().get(converterFromCO->currentItem()));
984         Format const & to(form_->formats().get(converterToCO->currentItem()));
985         string const command(fromqstr(converterED->text()));
986         string const flags(fromqstr(converterFlagED->text()));
987
988         Converter const * old = form_->converters().getConverter(from.name(), to.name());
989         form_->converters().add(from.name(), to.name(), command, flags);
990         if (!old) {
991                 form_->converters().updateLast(form_->formats());
992         }
993         updateGui();
994
995         QString const name = toqstr(from.name() + " -> " + to.name());
996         QList<QListWidgetItem *> const item =
997                 convertersLW->findItems(name, Qt::MatchExactly);
998         if (item.size()>0)
999                 convertersLW->setCurrentItem(item.at(0));
1000 }
1001
1002
1003 void PrefConverters::modify_converter()
1004 {
1005         QString const current_text =
1006                 convertersLW->currentItem()->text();
1007
1008         Format const & from(form_->formats().get(converterFromCO->currentItem()));
1009         Format const & to(form_->formats().get(converterToCO->currentItem()));
1010         string flags(fromqstr(converterFlagED->text()));
1011         string name(fromqstr(converterED->text()));
1012
1013         Converter const * old = form_->converters().getConverter(from.name(), to.name());
1014         form_->converters().add(from.name(), to.name(), name, flags);
1015         if (!old) {
1016                 form_->converters().updateLast(form_->formats());
1017         }
1018         updateGui();
1019
1020         QList<QListWidgetItem *> const item =
1021                 convertersLW->findItems(current_text, Qt::MatchExactly);
1022         if (item.size()>0)
1023                 convertersLW->setCurrentItem(item.at(0));
1024 }
1025
1026
1027 void PrefConverters::remove_converter()
1028 {
1029         Format const & from(form_->formats().get(converterFromCO->currentItem()));
1030         Format const & to(form_->formats().get(converterToCO->currentItem()));
1031         form_->converters().erase(from.name(), to.name());
1032         updateGui();
1033 }
1034
1035
1036 PrefCopiers::PrefCopiers(QPrefs * form, QWidget * parent)
1037 : PrefModule(string(), _("Copiers"), form, parent)
1038 {
1039         setupUi(this);
1040
1041         connect(copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
1042         connect(copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
1043         connect(copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
1044         connect(AllCopiersLW, SIGNAL(currentRowChanged(int)), 
1045                 this, SLOT(switch_copierLB(int)));
1046         connect(copierFormatCO, SIGNAL(activated(int)), this, SLOT(switch_copierCO(int)));
1047         connect(copierNewPB, SIGNAL(clicked()),
1048                 this, SIGNAL(changed()));
1049         connect(copierRemovePB, SIGNAL(clicked()),
1050                 this, SIGNAL(changed()));
1051         connect(copierModifyPB, SIGNAL(clicked()),
1052                 this, SIGNAL(changed()));
1053         connect(copierFormatCO, SIGNAL(activated(const QString&)), this, SLOT(copiers_changed()));
1054         connect(copierED, SIGNAL(textChanged(const QString&)), this, SLOT(copiers_changed()));
1055 }
1056
1057
1058 void PrefCopiers::apply(LyXRC & rc) const
1059 {
1060 }
1061
1062
1063 void PrefCopiers::update(LyXRC const & rc)
1064 {
1065         update();
1066 }
1067
1068
1069 void PrefCopiers::update()
1070 {
1071         // The choice widget
1072         // save current selection
1073         QString current = copierFormatCO->currentText();
1074         copierFormatCO->clear();
1075
1076         for (Formats::const_iterator it = form_->formats().begin(),
1077                      end = form_->formats().end();
1078              it != end; ++it) {
1079                 copierFormatCO->insertItem(toqstr(it->prettyname()));
1080         }
1081
1082         // The browser widget
1083         AllCopiersLW->clear();
1084
1085         for (Movers::iterator it = form_->movers().begin(),
1086                      end = form_->movers().end();
1087              it != end; ++it) {
1088                 std::string const & command = it->second.command();
1089                 if (command.empty())
1090                         continue;
1091                 QString const pretty = toqstr(form_->formats().prettyName(it->first));
1092                 AllCopiersLW->addItem(pretty);
1093         }
1094         AllCopiersLW->sortItems(Qt::AscendingOrder);
1095
1096         // restore selection
1097         if (!current.isEmpty()) {
1098                 QList<QListWidgetItem *> item = 
1099                         AllCopiersLW->findItems(current, Qt::MatchExactly);
1100                 if (item.size()>0)
1101                         AllCopiersLW->setCurrentItem(item.at(0));
1102         }
1103         // select first element if restoring failed
1104         if (AllCopiersLW->currentRow() == -1)
1105                 AllCopiersLW->setCurrentRow(0);
1106 }
1107
1108
1109 namespace {
1110
1111 class SamePrettyName {
1112 public:
1113         SamePrettyName(string const & n) : pretty_name_(n) {}
1114
1115         bool operator()(::Format const & fmt) const {
1116                 return fmt.prettyname() == pretty_name_;
1117         }
1118
1119 private:
1120         string const pretty_name_;
1121 };
1122
1123
1124 Format const * getFormat(std::string const & prettyname)
1125 {
1126         Formats::const_iterator it = ::formats.begin();
1127         Formats::const_iterator const end = ::formats.end();
1128         it = std::find_if(it, end, SamePrettyName(prettyname));
1129         return it == end ? 0 : &*it;
1130 }
1131
1132 } // namespace anon
1133
1134
1135 void PrefCopiers::switch_copierLB(int row)
1136 {
1137         if (row<0)
1138                 return;
1139
1140         std::string const browser_text =
1141                 fromqstr(AllCopiersLW->currentItem()->text());
1142         Format const * fmt = getFormat(browser_text);
1143         if (fmt == 0)
1144                 return;
1145
1146         QString const gui_name = toqstr(fmt->prettyname());
1147         QString const command = toqstr(form_->movers().command(fmt->name()));
1148
1149         copierED->clear();
1150         int const combo_size = copierFormatCO->count();
1151         for (int i = 0; i < combo_size; ++i) {
1152                 QString const text = copierFormatCO->text(i);
1153                 if (text == gui_name) {
1154                         copierFormatCO->setCurrentIndex(i);
1155                         copierED->setText(command);
1156                         break;
1157                 }
1158         }
1159         updateButtons();
1160 }
1161
1162
1163 void PrefCopiers::switch_copierCO(int row)
1164 {
1165         if (row<0)
1166                 return;
1167
1168         std::string const combo_text =
1169                 fromqstr(copierFormatCO->currentText());
1170         Format const * fmt = getFormat(combo_text);
1171         if (fmt == 0)
1172                 return;
1173
1174         QString const command = toqstr(form_->movers().command(fmt->name()));
1175         copierED->setText(command);
1176
1177         QListWidgetItem * const index = AllCopiersLW->currentItem();
1178         if (index >= 0)
1179                 AllCopiersLW->setItemSelected(index, false);
1180
1181         QString const gui_name = toqstr(fmt->prettyname());
1182         int const browser_size = AllCopiersLW->count();
1183         for (int i = 0; i < browser_size; ++i) {
1184                 QString const text = AllCopiersLW->item(i)->text();
1185                 if (text == gui_name) {
1186                         QListWidgetItem * item = AllCopiersLW->item(i);
1187                         AllCopiersLW->setItemSelected(item, true);
1188                         break;
1189                 }
1190         }
1191 }
1192
1193
1194 void PrefCopiers::copiers_changed()
1195 {
1196         updateButtons();
1197 }
1198
1199
1200 void PrefCopiers::updateButtons()
1201 {
1202         QString selected = copierFormatCO->currentText();
1203
1204         bool known = false;
1205         for (unsigned int i = 0; i != AllCopiersLW->count(); i++) {
1206                 if (AllCopiersLW->item(i)->text() == selected)
1207                         known = true;
1208         }
1209
1210         bool const valid = !copierED->text().isEmpty();
1211
1212         Format const * fmt = getFormat(fromqstr(selected));
1213         string const old_command = form_->movers().command(fmt->name());
1214         string const new_command(fromqstr(copierED->text()));
1215
1216         bool modified = (old_command != new_command);
1217
1218         copierModifyPB->setEnabled(valid && known && modified);
1219         copierNewPB->setEnabled(valid && !known);
1220         copierRemovePB->setEnabled(known);
1221 }
1222
1223
1224 void PrefCopiers::new_copier()
1225 {
1226         std::string const combo_text =
1227                 fromqstr(copierFormatCO->currentText());
1228         Format const * fmt = getFormat(combo_text);
1229         if (fmt == 0)
1230                 return;
1231
1232         string const command = fromqstr(copierED->text());
1233         if (command.empty())
1234                 return;
1235
1236         form_->movers().set(fmt->name(), command);
1237
1238         update();
1239         int const last = AllCopiersLW->count() - 1;
1240         AllCopiersLW->setCurrentRow(last);
1241
1242         updateButtons();
1243 }
1244
1245
1246 void PrefCopiers::modify_copier()
1247 {
1248         std::string const combo_text =
1249                 fromqstr(copierFormatCO->currentText());
1250         Format const * fmt = getFormat(combo_text);
1251         if (fmt == 0)
1252                 return;
1253
1254         string const command = fromqstr(copierED->text());
1255         form_->movers().set(fmt->name(), command);
1256
1257         update();
1258         updateButtons();
1259 }
1260
1261
1262 void PrefCopiers::remove_copier()
1263 {
1264         std::string const combo_text =
1265                 fromqstr(copierFormatCO->currentText());
1266         Format const * fmt = getFormat(combo_text);
1267         if (fmt == 0)
1268                 return;
1269
1270         string const & fmt_name = fmt->name();
1271         form_->movers().set(fmt_name, string());
1272
1273         update();
1274         updateButtons();
1275 }
1276
1277
1278
1279 PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
1280 : PrefModule(string(), _("File formats"), form, parent)
1281 {
1282         setupUi(this);
1283
1284         connect(formatNewPB, SIGNAL(clicked()), this, SLOT(new_format()));
1285         connect(formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format()));
1286         connect(formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format()));
1287         connect(formatsLW, SIGNAL(currentRowChanged(int)), 
1288                 this, SLOT(switch_format(int)));
1289         connect(formatED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1290         connect(guiNameED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1291         connect(shortcutED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1292         connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1293         connect(viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1294         connect(editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
1295         connect(documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
1296         connect(formatNewPB, SIGNAL(clicked()),
1297                 this, SIGNAL(changed()));
1298         connect(formatRemovePB, SIGNAL(clicked()),
1299                 this, SIGNAL(changed()));
1300         connect(formatModifyPB, SIGNAL(clicked()),
1301                 this, SIGNAL(changed()));
1302 }
1303
1304
1305 void PrefFileformats::apply(LyXRC & rc) const
1306 {
1307 }
1308
1309
1310 void PrefFileformats::update(LyXRC const & rc)
1311 {
1312         update();
1313 }
1314
1315
1316 void PrefFileformats::update()
1317 {
1318         // save current selection
1319         QString current = guiNameED->text();
1320
1321         formatsLW->clear();
1322
1323         Formats::const_iterator cit = form_->formats().begin();
1324         Formats::const_iterator end = form_->formats().end();
1325         for (; cit != end; ++cit) {
1326                 new QListWidgetItem(toqstr(cit->prettyname()),
1327                                                         formatsLW,
1328                                                         form_->formats().getNumber(cit->name()) );
1329         }
1330         formatsLW->sortItems(Qt::AscendingOrder);
1331
1332         // restore selection
1333         if (!current.isEmpty()) {
1334                 QList<QListWidgetItem *>  item = formatsLW->findItems(current, Qt::MatchExactly);
1335                 if (item.size()>0)
1336                         formatsLW->setCurrentItem(item.at(0));
1337         }
1338         // select first element if restoring failed
1339         if (formatsLW->currentRow() == -1)
1340                 formatsLW->setCurrentRow(0);
1341 }
1342
1343
1344 void PrefFileformats::switch_format(int nr)
1345 {
1346         if (nr<0)
1347                 return;
1348
1349         int const ftype = formatsLW->item(nr)->type();
1350         Format const f(form_->formats().get(ftype));
1351
1352         formatED->setText(toqstr(f.name()));
1353         guiNameED->setText(toqstr(f.prettyname()));
1354         extensionED->setText(toqstr(f.extension()));
1355         shortcutED->setText(toqstr(f.shortcut()));
1356         viewerED->setText(toqstr(f.viewer()));
1357         editorED->setText(toqstr(f.editor()));
1358         documentCB->setChecked((f.documentFormat()));
1359         formatRemovePB->setEnabled(
1360                 !form_->converters().formatIsUsed(f.name()));
1361
1362         updateButtons();
1363 }
1364
1365
1366 void PrefFileformats::fileformat_changed()
1367 {
1368         updateButtons();
1369 }
1370
1371
1372 void PrefFileformats::updateButtons()
1373 {
1374         QString const format = formatED->text();
1375         QString const gui_name = guiNameED->text();
1376         int const sel = form_->formats().getNumber(fromqstr(format));
1377         bool gui_name_known = false;
1378         int where = sel;
1379         for (unsigned int i = 0; i != formatsLW->count(); i++) {
1380                 if (formatsLW->item(i)->text() == gui_name) {
1381                         gui_name_known = true;
1382                         where = formatsLW->item(i)->type();
1383                 }
1384         }
1385
1386         // assure that a gui name cannot be chosen twice
1387         bool const known_otherwise = gui_name_known && (where != sel);
1388
1389         bool const known = !(sel < 0);
1390         bool const valid = (!formatED->text().isEmpty()
1391                 && !guiNameED->text().isEmpty());
1392
1393         int const ftype = formatsLW->currentItem()->type();
1394         Format const & f(form_->formats().get(ftype));
1395         string const old_pretty(f.prettyname());
1396         string const old_shortcut(f.shortcut());
1397         string const old_extension(f.extension());
1398         string const old_viewer(f.viewer());
1399         string const old_editor(f.editor());
1400         bool const old_document(f.documentFormat());
1401
1402         string const new_pretty(fromqstr(gui_name));
1403         string const new_shortcut(fromqstr(shortcutED->text()));
1404         string const new_extension(fromqstr(extensionED->text()));
1405         string const new_viewer(fromqstr(viewerED->text()));
1406         string const new_editor(fromqstr(editorED->text()));
1407         bool const new_document(documentCB->isChecked());
1408
1409         bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
1410                 || (old_extension != new_extension) || (old_viewer != new_viewer)
1411                 || (old_editor != new_editor) || old_document != new_document);
1412
1413         formatModifyPB->setEnabled(
1414                 valid && known && modified && !known_otherwise);
1415         formatNewPB->setEnabled(valid && !known && !gui_name_known);
1416         formatRemovePB->setEnabled(known);
1417 }
1418
1419 void PrefFileformats::setConverters(PrefConverters * converters)
1420 {
1421         converters_ = converters;
1422 }
1423
1424 void PrefFileformats::new_format()
1425 {
1426         string const name = fromqstr(formatED->text());
1427         string const prettyname = fromqstr(guiNameED->text());
1428         string const extension = fromqstr(extensionED->text());
1429         string const shortcut = fromqstr(shortcutED->text());
1430         string const viewer = fromqstr(viewerED->text());
1431         string const editor = fromqstr(editorED->text());
1432         bool const document = documentCB->isChecked();
1433
1434         form_->formats().add(name, extension, prettyname, shortcut, viewer,
1435                              editor, document);
1436         form_->formats().sort();
1437         update();
1438
1439         QList<QListWidgetItem *>  const item =
1440                 formatsLW->findItems(toqstr(prettyname), Qt::MatchExactly);
1441         if (item.size()>0)
1442                 formatsLW->setCurrentItem(item.at(0));
1443
1444         form_->converters().update(form_->formats());
1445
1446         converters_->updateGui();
1447         updateButtons();
1448 }
1449
1450
1451 void PrefFileformats::modify_format()
1452 {
1453         int const current_item = formatsLW->currentItem()->type();
1454         QString const current_text =
1455                 formatsLW->currentItem()->text();
1456
1457         Format const & oldformat(form_->formats().get(current_item));
1458         string const oldpretty(oldformat.prettyname());
1459         string const name(fromqstr(formatED->text()));
1460         form_->formats().erase(oldformat.name());
1461
1462         string const prettyname = fromqstr(guiNameED->text());
1463         string const extension = fromqstr(extensionED->text());
1464         string const shortcut = fromqstr(shortcutED->text());
1465         string const viewer = fromqstr(viewerED->text());
1466         string const editor = fromqstr(editorED->text());
1467         bool const document = documentCB->isChecked();
1468
1469         form_->formats().add(name, extension, prettyname, shortcut, viewer,
1470                              editor, document);
1471         form_->formats().sort();
1472
1473         formatsLW->setUpdatesEnabled(false);
1474         update();
1475         formatsLW->setUpdatesEnabled(true);
1476         formatsLW->update();
1477
1478         converters_->updateGui();
1479         updateButtons();
1480
1481         QList<QListWidgetItem *>  const item =
1482                 formatsLW->findItems(current_text, Qt::MatchExactly);
1483         if (item.size()>0)
1484                 formatsLW->setCurrentItem(item.at(0));
1485 }
1486
1487
1488 void PrefFileformats::remove_format()
1489 {
1490         int const nr = formatsLW->currentItem()->type();
1491         if (nr < 0)
1492                 return;
1493         string const current_text = form_->formats().get(nr).name();
1494         if (form_->converters().formatIsUsed(current_text)) {
1495                 Alert::error(_("Format in use"),
1496                                 _("Cannot remove a Format used by a Converter. "
1497                                       "Remove the converter first."));
1498                 return;
1499         }
1500
1501         form_->formats().erase(current_text);
1502         update();
1503         form_->converters().update(form_->formats());
1504
1505         converters_->updateGui();
1506         updateButtons();
1507 }
1508
1509
1510
1511 PrefLanguage::PrefLanguage(QWidget * parent)
1512 : PrefModule(string(), _("Language"), 0, parent)
1513 {
1514         setupUi(this);
1515
1516         connect(rtlCB, SIGNAL(toggled(bool)),
1517                 this, SIGNAL(changed()));
1518         connect(markForeignCB, SIGNAL(toggled(bool)),
1519                 this, SIGNAL(changed()));
1520         connect(autoBeginCB, SIGNAL(toggled(bool)),
1521                 this, SIGNAL(changed()));
1522         connect(autoEndCB, SIGNAL(toggled(bool)),
1523                 this, SIGNAL(changed()));
1524         connect(useBabelCB, SIGNAL(toggled(bool)),
1525                 this, SIGNAL(changed()));
1526         connect(globalCB, SIGNAL(toggled(bool)),
1527                 this, SIGNAL(changed()));
1528         connect(languagePackageED, SIGNAL(textChanged(const QString&)),
1529                 this, SIGNAL(changed()));
1530         connect(startCommandED, SIGNAL(textChanged(const QString&)),
1531                 this, SIGNAL(changed()));
1532         connect(endCommandED, SIGNAL(textChanged(const QString&)),
1533                 this, SIGNAL(changed()));
1534         connect(defaultLanguageCO, SIGNAL(activated(int)),
1535                 this, SIGNAL(changed()));
1536
1537         defaultLanguageCO->clear();
1538
1539         // store the lang identifiers for later
1540         using lyx::frontend::LanguagePair;
1541         std::vector<LanguagePair> const langs =
1542                 lyx::frontend::getLanguageData(false);
1543         lang_ = getSecond(langs);
1544
1545         std::vector<LanguagePair>::const_iterator lit  = langs.begin();
1546         std::vector<LanguagePair>::const_iterator lend = langs.end();
1547         for (; lit != lend; ++lit) {
1548                 defaultLanguageCO->insertItem(toqstr(lit->first));
1549         }
1550 }
1551
1552
1553 void PrefLanguage::apply(LyXRC & rc) const
1554 {
1555         // FIXME: remove rtl_support bool
1556         rc.rtl_support = rtlCB->isChecked();
1557         rc.mark_foreign_language = markForeignCB->isChecked();
1558         rc.language_auto_begin = autoBeginCB->isChecked();
1559         rc.language_auto_end = autoEndCB->isChecked();
1560         rc.language_use_babel = useBabelCB->isChecked();
1561         rc.language_global_options = globalCB->isChecked();
1562         rc.language_package = fromqstr(languagePackageED->text());
1563         rc.language_command_begin = fromqstr(startCommandED->text());
1564         rc.language_command_end = fromqstr(endCommandED->text());
1565         rc.default_language = lang_[defaultLanguageCO->currentItem()];
1566 }
1567
1568
1569 void PrefLanguage::update(LyXRC const & rc)
1570 {
1571         // FIXME: remove rtl_support bool
1572         rtlCB->setChecked(rc.rtl_support);
1573         markForeignCB->setChecked(rc.mark_foreign_language);
1574         autoBeginCB->setChecked(rc.language_auto_begin);
1575         autoEndCB->setChecked(rc.language_auto_end);
1576         useBabelCB->setChecked(rc.language_use_babel);
1577         globalCB->setChecked(rc.language_global_options);
1578         languagePackageED->setText(toqstr(rc.language_package));
1579         startCommandED->setText(toqstr(rc.language_command_begin));
1580         endCommandED->setText(toqstr(rc.language_command_end));
1581
1582         int const pos = int(findPos(lang_, rc.default_language));
1583         defaultLanguageCO->setCurrentIndex(pos);
1584 }
1585
1586
1587 PrefPrinter::PrefPrinter(QWidget * parent)
1588 : PrefModule(_(Outputs), _("Printer"), 0, parent)
1589 {
1590         setupUi(this);
1591
1592         connect(printerAdaptCB, SIGNAL(toggled(bool)),
1593                 this, SIGNAL(changed()));
1594         connect(printerCommandED, SIGNAL(textChanged(const QString&)),
1595                 this, SIGNAL(changed()));
1596         connect(printerNameED, SIGNAL(textChanged(const QString&)),
1597                 this, SIGNAL(changed()));
1598         connect(printerPageRangeED, SIGNAL(textChanged(const QString&)),
1599                 this, SIGNAL(changed()));
1600         connect(printerCopiesED, SIGNAL(textChanged(const QString&)),
1601                 this, SIGNAL(changed()));
1602         connect(printerReverseED, SIGNAL(textChanged(const QString&)),
1603                 this, SIGNAL(changed()));
1604         connect(printerToPrinterED, SIGNAL(textChanged(const QString&)),
1605                 this, SIGNAL(changed()));
1606         connect(printerExtensionED, SIGNAL(textChanged(const QString&)),
1607                 this, SIGNAL(changed()));
1608         connect(printerSpoolCommandED, SIGNAL(textChanged(const QString&)),
1609                 this, SIGNAL(changed()));
1610         connect(printerPaperTypeED, SIGNAL(textChanged(const QString&)),
1611                 this, SIGNAL(changed()));
1612         connect(printerEvenED, SIGNAL(textChanged(const QString&)),
1613                 this, SIGNAL(changed()));
1614         connect(printerOddED, SIGNAL(textChanged(const QString&)),
1615                 this, SIGNAL(changed()));
1616         connect(printerCollatedED, SIGNAL(textChanged(const QString&)),
1617                 this, SIGNAL(changed()));
1618         connect(printerLandscapeED, SIGNAL(textChanged(const QString&)),
1619                 this, SIGNAL(changed()));
1620         connect(printerToFileED, SIGNAL(textChanged(const QString&)),
1621                 this, SIGNAL(changed()));
1622         connect(printerExtraED, SIGNAL(textChanged(const QString&)),
1623                 this, SIGNAL(changed()));
1624         connect(printerSpoolPrefixED, SIGNAL(textChanged(const QString&)),
1625                 this, SIGNAL(changed()));
1626         connect(printerPaperSizeED, SIGNAL(textChanged(const QString&)),
1627                 this, SIGNAL(changed()));
1628 }
1629
1630
1631 void PrefPrinter::apply(LyXRC & rc) const
1632 {
1633         rc.print_adapt_output = printerAdaptCB->isChecked();
1634         rc.print_command = fromqstr(printerCommandED->text());
1635         rc.printer = fromqstr(printerNameED->text());
1636
1637         rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
1638         rc.print_copies_flag = fromqstr(printerCopiesED->text());
1639         rc.print_reverse_flag = fromqstr(printerReverseED->text());
1640         rc.print_to_printer = fromqstr(printerToPrinterED->text());
1641         rc.print_file_extension = fromqstr(printerExtensionED->text());
1642         rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
1643         rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
1644         rc.print_evenpage_flag = fromqstr(printerEvenED->text());
1645         rc.print_oddpage_flag = fromqstr(printerOddED->text());
1646         rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
1647         rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
1648         rc.print_to_file = internal_path(printerToFileED->text());
1649         rc.print_extra_options = fromqstr(printerExtraED->text());
1650         rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
1651         rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
1652 }
1653
1654
1655 void PrefPrinter::update(LyXRC const & rc)
1656 {
1657         printerAdaptCB->setChecked(rc.print_adapt_output);
1658         printerCommandED->setText(toqstr(rc.print_command));
1659         printerNameED->setText(toqstr(rc.printer));
1660
1661         printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
1662         printerCopiesED->setText(toqstr(rc.print_copies_flag));
1663         printerReverseED->setText(toqstr(rc.print_reverse_flag));
1664         printerToPrinterED->setText(toqstr(rc.print_to_printer));
1665         printerExtensionED->setText(toqstr(rc.print_file_extension));
1666         printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
1667         printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
1668         printerEvenED->setText(toqstr(rc.print_evenpage_flag));
1669         printerOddED->setText(toqstr(rc.print_oddpage_flag));
1670         printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
1671         printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
1672         printerToFileED->setText(external_path(rc.print_to_file));
1673         printerExtraED->setText(toqstr(rc.print_extra_options));
1674         printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
1675         printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
1676 }
1677
1678
1679 PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
1680 : PrefModule(_(LookAndFeel), _("User interface"), form, parent)
1681 {
1682         setupUi(this);
1683
1684         connect(autoSaveCB, SIGNAL( toggled(bool) ), autoSaveLA, SLOT( setEnabled(bool) ) );
1685         connect(autoSaveCB, SIGNAL( toggled(bool) ), autoSaveSB, SLOT( setEnabled(bool) ) );
1686         connect(autoSaveCB, SIGNAL( toggled(bool) ), TextLabel1, SLOT( setEnabled(bool) ) );
1687         connect(uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui()));
1688         connect(bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind()));
1689         connect(uiFileED, SIGNAL(textChanged(const QString&)),
1690                 this, SIGNAL(changed()));
1691         connect(bindFileED, SIGNAL(textChanged(const QString&)),
1692                 this, SIGNAL(changed()));
1693         connect(restoreCursorCB, SIGNAL(toggled(bool)),
1694                 this, SIGNAL(changed()));
1695         connect(loadSessionCB, SIGNAL(toggled(bool)),
1696                 this, SIGNAL(changed()));
1697         connect(cursorFollowsCB, SIGNAL(toggled(bool)),
1698                 this, SIGNAL(changed()));
1699         connect(autoSaveSB, SIGNAL(valueChanged(int)),
1700                 this, SIGNAL(changed()));
1701         connect(autoSaveCB, SIGNAL(toggled(bool)),
1702                 this, SIGNAL(changed()));
1703         connect(lastfilesSB, SIGNAL(valueChanged(int)),
1704                 this, SIGNAL(changed()));
1705         lastfilesSB->setMaxValue(maxlastfiles);
1706 }
1707
1708
1709 void PrefUserInterface::apply(LyXRC & rc) const
1710 {
1711         rc.ui_file = internal_path(uiFileED->text());
1712         rc.bind_file = internal_path(bindFileED->text());
1713         rc.use_lastfilepos = restoreCursorCB->isChecked();
1714         rc.load_session = loadSessionCB->isChecked();
1715         rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
1716         rc.autosave = autoSaveSB->value() * 60;
1717         rc.make_backup = autoSaveCB->isChecked();
1718         rc.num_lastfiles = lastfilesSB->value();
1719 }
1720
1721
1722 void PrefUserInterface::update(LyXRC const & rc)
1723 {
1724         uiFileED->setText(external_path(rc.ui_file));
1725         bindFileED->setText(external_path(rc.bind_file));
1726         restoreCursorCB->setChecked(rc.use_lastfilepos);
1727         loadSessionCB->setChecked(rc.load_session);
1728         cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
1729         // convert to minutes
1730         int mins(rc.autosave / 60);
1731         if (rc.autosave && !mins)
1732                 mins = 1;
1733         autoSaveSB->setValue(mins);
1734         autoSaveCB->setChecked(rc.make_backup);
1735         lastfilesSB->setValue(rc.num_lastfiles);
1736 }
1737
1738
1739
1740 void PrefUserInterface::select_ui()
1741 {
1742         string file(form_->controller().browseUI(fromqstr(uiFileED->text())));
1743         if (!file.empty())
1744                 uiFileED->setText(toqstr(file));
1745 }
1746
1747
1748 void PrefUserInterface::select_bind()
1749 {
1750         string file(form_->controller().browsebind(fromqstr(bindFileED->text())));
1751         if (!file.empty())
1752                 bindFileED->setText(toqstr(file));
1753 }
1754
1755
1756 PrefIdentity::PrefIdentity(QWidget * parent)
1757 : PrefModule(string(), _("Identity"), 0, parent)
1758 {
1759         setupUi(this);
1760
1761         connect(nameED, SIGNAL(textChanged(const QString&)),
1762                 this, SIGNAL(changed()));
1763         connect(emailED, SIGNAL(textChanged(const QString&)),
1764                 this, SIGNAL(changed()));
1765 }
1766
1767
1768 void PrefIdentity::apply(LyXRC & rc) const
1769 {
1770         rc.user_name = fromqstr(nameED->text());
1771         rc.user_email = fromqstr(emailED->text());
1772 }
1773
1774
1775 void PrefIdentity::update(LyXRC const & rc)
1776 {
1777         nameED->setText(toqstr(rc.user_name));
1778         emailED->setText(toqstr(rc.user_email));
1779 }
1780
1781
1782
1783 QPrefsDialog::QPrefsDialog(QPrefs * form)
1784         : form_(form)
1785 {
1786         setupUi(this);
1787         QDialog::setModal(true);
1788
1789         connect(savePB, SIGNAL(clicked()),
1790                 form, SLOT(slotOK()));
1791         connect(applyPB, SIGNAL(clicked()),
1792                 form, SLOT(slotApply()));
1793         connect(closePB, SIGNAL(clicked()),
1794                 form, SLOT(slotClose()));
1795         connect(restorePB, SIGNAL(clicked()),
1796                 form, SLOT(slotRestore()));
1797
1798         add(new PrefAscii);
1799         add(new PrefDate);
1800         add(new PrefKeyboard(form_));
1801         add(new PrefLatex(form_));
1802         add(new PrefScreenFonts(form_));
1803         add(new PrefColors(form_));
1804
1805 #if defined(__CYGWIN__) || defined(_WIN32)
1806         add(new PrefCygwinPath);
1807 #endif
1808
1809         add(new PrefDisplay);
1810         add(new PrefPaths(form_));
1811         add(new PrefSpellchecker(form_));
1812
1813         PrefConverters * converters = new PrefConverters(form_);
1814         PrefFileformats * formats = new PrefFileformats(form_);
1815         formats->setConverters(converters);
1816         add(converters);
1817         add(formats);
1818
1819         add(new PrefCopiers(form_));
1820         
1821         add(new PrefLanguage);
1822         add(new PrefPrinter);
1823         add(new PrefUserInterface(form_));
1824         add(new PrefIdentity);
1825
1826         prefsPS->setCurrentPanel(_("User interface"));
1827
1828         form_->bcview().setOK(savePB);
1829         form_->bcview().setApply(applyPB);
1830         form_->bcview().setCancel(closePB);
1831         form_->bcview().setRestore(restorePB);
1832 }
1833
1834
1835 QPrefsDialog::~QPrefsDialog()
1836 {
1837 }
1838
1839
1840 void QPrefsDialog::add(PrefModule * module)
1841 {
1842         BOOST_ASSERT(module);
1843
1844 //      if (module->category().empty())
1845 //              prefsPS->addPanel(module, module->title());
1846 //      else
1847                 prefsPS->addPanel(module, module->title(), module->category());
1848
1849         connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
1850
1851         modules_.push_back(module);
1852 }
1853
1854 void QPrefsDialog::closeEvent(QCloseEvent * e)
1855 {
1856         form_->slotWMHide();
1857         e->accept();
1858 }
1859
1860
1861 void QPrefsDialog::change_adaptor()
1862 {
1863         form_->changed();
1864 }
1865
1866
1867 void QPrefsDialog::apply(LyXRC & rc) const
1868 {
1869         size_t end = modules_.size();
1870         for (size_t i = 0; i != end; ++i)
1871                 modules_[i]->apply(rc);
1872 }
1873
1874
1875 void QPrefsDialog::update(LyXRC const & rc)
1876 {
1877         size_t end = modules_.size();
1878         for (size_t i = 0; i != end; ++i)
1879                 modules_[i]->update(rc);
1880 }
1881
1882
1883 } // namespace frontend
1884 } // namespace lyx
1885
1886 #include "QPrefsDialog_moc.cpp"