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