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