4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "GuiDialog.h"
18 #include "Converter.h"
23 #include "ui_PrefsUi.h"
25 #include "ui_PrefPlaintextUi.h"
26 #include "ui_PrefDateUi.h"
27 #include "ui_PrefKeyboardUi.h"
28 #include "ui_PrefLatexUi.h"
29 #include "ui_PrefScreenFontsUi.h"
30 #include "ui_PrefColorsUi.h"
31 #include "ui_PrefDisplayUi.h"
32 #include "ui_PrefPathsUi.h"
33 #include "ui_PrefSpellcheckerUi.h"
34 #include "ui_PrefConvertersUi.h"
35 #include "ui_PrefFileformatsUi.h"
36 #include "ui_PrefLanguageUi.h"
37 #include "ui_PrefPrinterUi.h"
38 #include "ui_PrefUi.h"
39 #include "ui_PrefIdentityUi.h"
59 class PrefModule : public QWidget
63 PrefModule(docstring const & t,
64 GuiPreferences * form = 0, QWidget * parent = 0)
65 : QWidget(parent), title_(t), form_(form)
68 virtual void apply(LyXRC & rc) const = 0;
69 virtual void update(LyXRC const & rc) = 0;
71 docstring const & title() const { return title_; }
75 GuiPreferences * form_;
82 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
86 PrefPlaintext(QWidget * parent = 0);
88 virtual void apply(LyXRC & rc) const;
89 virtual void update(LyXRC const & rc);
93 class PrefDate : public PrefModule, public Ui::PrefDateUi
97 PrefDate(QWidget * parent = 0);
99 virtual void apply(LyXRC & rc) const;
100 virtual void update(LyXRC const & rc);
104 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
108 PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
110 virtual void apply(LyXRC & rc) const;
111 virtual void update(LyXRC const & rc);
114 void on_firstKeymapPB_clicked(bool);
115 void on_secondKeymapPB_clicked(bool);
116 void on_keymapCB_toggled(bool);
119 QString testKeymap(QString keymap);
123 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
127 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
129 virtual void apply(LyXRC & rc) const;
130 virtual void update(LyXRC const & rc);
134 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
138 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
140 virtual void apply(LyXRC & rc) const;
141 virtual void update(LyXRC const & rc);
144 void select_roman(const QString&);
145 void select_sans(const QString&);
146 void select_typewriter(const QString&);
150 class PrefColors : public PrefModule, public Ui::PrefColorsUi
154 PrefColors(GuiPreferences * form, QWidget * parent = 0);
156 void apply(LyXRC & rc) const;
157 void update(LyXRC const & rc);
161 void change_lyxObjects_selection();
164 std::vector<Color_color> lcolors_;
165 // FIXME the use of mutable here is required due to the
166 // fact that initialization is not done in the controller
167 // but in the constructor.
168 std::vector<QString> curcolors_;
169 std::vector<QString> newcolors_;
174 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
178 PrefDisplay(QWidget * parent = 0);
180 void apply(LyXRC & rc) const;
181 void update(LyXRC const & rc);
185 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
189 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
191 void apply(LyXRC & rc) const;
192 void update(LyXRC const & rc);
195 void select_templatedir();
196 void select_tempdir();
197 void select_backupdir();
198 void select_workingdir();
199 void select_lyxpipe();
204 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
208 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
210 void apply(LyXRC & rc) const;
211 void update(LyXRC const & rc);
218 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
222 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
224 void apply(LyXRC & rc) const;
225 void update(LyXRC const & rc);
231 void update_converter();
232 void switch_converter();
233 void converter_changed();
234 void remove_converter();
235 void on_cacheCB_stateChanged(int state);
238 void updateButtons();
242 class FormatValidator : public QValidator
245 FormatValidator(QWidget *, Formats const & f);
246 void fixup(QString & input) const;
247 QValidator::State validate(QString & input, int & pos) const;
249 virtual std::string str(Formats::const_iterator it) const = 0;
251 Formats const & formats_;
255 class FormatNameValidator : public FormatValidator
258 FormatNameValidator(QWidget *, Formats const & f);
260 std::string str(Formats::const_iterator it) const;
263 class FormatPrettynameValidator : public FormatValidator
266 FormatPrettynameValidator(QWidget *, Formats const & f);
268 std::string str(Formats::const_iterator it) const;
272 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
276 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
278 void apply(LyXRC & rc) const;
279 void update(LyXRC const & rc);
283 void formatsChanged();
286 void on_copierED_textEdited(const QString & s);
287 void on_extensionED_textEdited(const QString &);
288 void on_viewerED_textEdited(const QString &);
289 void on_editorED_textEdited(const QString &);
290 void on_shortcutED_textEdited(const QString &);
291 void on_formatED_editingFinished();
292 void on_formatED_textChanged(const QString &);
293 void on_formatsCB_currentIndexChanged(int);
294 void on_formatsCB_editTextChanged(const QString &);
295 void on_formatNewPB_clicked();
296 void on_formatRemovePB_clicked();
298 void updatePrettyname();
301 Format & currentFormat();
305 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
309 PrefLanguage(QWidget * parent = 0);
311 void apply(LyXRC & rc) const;
312 void update(LyXRC const & rc);
315 std::vector<std::string> lang_;
319 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
323 PrefPrinter(QWidget * parent = 0);
325 void apply(LyXRC & rc) const;
326 void update(LyXRC const & rc);
330 class PrefUserInterface : public PrefModule, public Ui::PrefUi
334 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
336 void apply(LyXRC & rc) const;
337 void update(LyXRC const & rc);
342 void on_loadWindowSizeCB_toggled(bool);
347 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
351 PrefIdentity(QWidget * parent = 0);
353 void apply(LyXRC & rc) const;
354 void update(LyXRC const & rc);
358 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
362 GuiPreferences(LyXView & lv);
364 void apply(LyXRC & rc) const;
365 void updateRc(LyXRC const & rc);
368 void change_adaptor();
372 void closeEvent(QCloseEvent * e);
374 void add(PrefModule * module);
377 /// update (do we need this?)
378 void updateContents();
380 std::vector<PrefModule *> modules_;
383 bool initialiseParams(std::string const &);
385 void clearParams() {}
387 void dispatchParams();
389 bool isBufferDependent() const { return false; }
391 /// various file pickers
392 docstring const browsebind(docstring const & file) const;
393 docstring const browseUI(docstring const & file) const;
394 docstring const browsekbmap(docstring const & file) const;
395 docstring const browsedict(docstring const & file) const;
398 docstring const browse(docstring const & file,
399 docstring const & title) const;
402 docstring const browsedir(docstring const & path,
403 docstring const & title) const;
406 void setColor(Color_color col, std::string const & hex);
408 /// update the screen fonts after change
409 void updateScreenFonts();
411 /// adjust the prefs paper sizes
412 PAPER_SIZE toPaperSize(int i) const;
413 /// adjust the prefs paper sizes
414 int fromPaperSize(PAPER_SIZE papersize) const;
416 LyXRC & rc() { return rc_; }
417 Converters & converters() { return converters_; }
418 Formats & formats() { return formats_; }
419 Movers & movers() { return movers_; }
424 /// temporary converters
425 Converters converters_;
426 /// temporary formats
431 /// A list of colors to be dispatched
432 std::vector<std::string> colors_;
435 bool update_screen_font_;
439 } // namespace frontend