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