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_PrefShortcutsUi.h"
34 #include "ui_PrefSpellcheckerUi.h"
35 #include "ui_PrefConvertersUi.h"
36 #include "ui_PrefFileformatsUi.h"
37 #include "ui_PrefLanguageUi.h"
38 #include "ui_PrefPrinterUi.h"
39 #include "ui_PrefUi.h"
40 #include "ui_PrefIdentityUi.h"
60 class PrefModule : public QWidget
64 PrefModule(docstring const & t,
65 GuiPreferences * form = 0, QWidget * parent = 0)
66 : QWidget(parent), title_(t), form_(form)
69 virtual void apply(LyXRC & rc) const = 0;
70 virtual void update(LyXRC const & rc) = 0;
72 docstring const & title() const { return title_; }
76 GuiPreferences * form_;
83 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
87 PrefPlaintext(QWidget * parent = 0);
89 virtual void apply(LyXRC & rc) const;
90 virtual void update(LyXRC const & rc);
94 class PrefDate : public PrefModule, public Ui::PrefDateUi
98 PrefDate(QWidget * parent = 0);
100 virtual void apply(LyXRC & rc) const;
101 virtual void update(LyXRC const & rc);
105 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
109 PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
111 virtual void apply(LyXRC & rc) const;
112 virtual void update(LyXRC const & rc);
115 void on_firstKeymapPB_clicked(bool);
116 void on_secondKeymapPB_clicked(bool);
117 void on_keymapCB_toggled(bool);
120 QString testKeymap(QString keymap);
124 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
128 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
130 virtual void apply(LyXRC & rc) const;
131 virtual void update(LyXRC const & rc);
135 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
139 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
141 virtual void apply(LyXRC & rc) const;
142 virtual void update(LyXRC const & rc);
145 void select_roman(const QString&);
146 void select_sans(const QString&);
147 void select_typewriter(const QString&);
151 class PrefColors : public PrefModule, public Ui::PrefColorsUi
155 PrefColors(GuiPreferences * form, QWidget * parent = 0);
157 void apply(LyXRC & rc) const;
158 void update(LyXRC const & rc);
162 void change_lyxObjects_selection();
165 std::vector<Color_color> lcolors_;
166 // FIXME the use of mutable here is required due to the
167 // fact that initialization is not done in the controller
168 // but in the constructor.
169 std::vector<QString> curcolors_;
170 std::vector<QString> newcolors_;
175 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
179 PrefDisplay(QWidget * parent = 0);
181 void apply(LyXRC & rc) const;
182 void update(LyXRC const & rc);
186 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
190 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
192 void apply(LyXRC & rc) const;
193 void update(LyXRC const & rc);
196 void select_templatedir();
197 void select_tempdir();
198 void select_backupdir();
199 void select_workingdir();
200 void select_lyxpipe();
205 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
209 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
211 void apply(LyXRC & rc) const;
212 void update(LyXRC const & rc);
219 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
223 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
225 void apply(LyXRC & rc) const;
226 void update(LyXRC const & rc);
232 void update_converter();
233 void switch_converter();
234 void converter_changed();
235 void remove_converter();
236 void on_cacheCB_stateChanged(int state);
239 void updateButtons();
243 class FormatValidator : public QValidator
246 FormatValidator(QWidget *, Formats const & f);
247 void fixup(QString & input) const;
248 QValidator::State validate(QString & input, int & pos) const;
250 virtual std::string str(Formats::const_iterator it) const = 0;
252 Formats const & formats_;
256 class FormatNameValidator : public FormatValidator
259 FormatNameValidator(QWidget *, Formats const & f);
261 std::string str(Formats::const_iterator it) const;
264 class FormatPrettynameValidator : public FormatValidator
267 FormatPrettynameValidator(QWidget *, Formats const & f);
269 std::string str(Formats::const_iterator it) const;
273 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
277 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
279 void apply(LyXRC & rc) const;
280 void update(LyXRC const & rc);
284 void formatsChanged();
287 void on_copierED_textEdited(const QString & s);
288 void on_extensionED_textEdited(const QString &);
289 void on_viewerED_textEdited(const QString &);
290 void on_editorED_textEdited(const QString &);
291 void on_shortcutED_textEdited(const QString &);
292 void on_formatED_editingFinished();
293 void on_formatED_textChanged(const QString &);
294 void on_formatsCB_currentIndexChanged(int);
295 void on_formatsCB_editTextChanged(const QString &);
296 void on_formatNewPB_clicked();
297 void on_formatRemovePB_clicked();
299 void updatePrettyname();
302 Format & currentFormat();
306 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
310 PrefLanguage(QWidget * parent = 0);
312 void apply(LyXRC & rc) const;
313 void update(LyXRC const & rc);
316 std::vector<std::string> lang_;
320 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
324 PrefPrinter(QWidget * parent = 0);
326 void apply(LyXRC & rc) const;
327 void update(LyXRC const & rc);
331 class PrefUserInterface : public PrefModule, public Ui::PrefUi
335 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
337 void apply(LyXRC & rc) const;
338 void update(LyXRC const & rc);
342 void on_loadWindowSizeCB_toggled(bool);
347 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
351 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
353 void apply(LyXRC & rc) const;
354 void update(LyXRC const & rc);
362 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
366 PrefIdentity(QWidget * parent = 0);
368 void apply(LyXRC & rc) const;
369 void update(LyXRC const & rc);
373 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
377 GuiPreferences(LyXView & lv);
379 void apply(LyXRC & rc) const;
380 void updateRc(LyXRC const & rc);
383 void change_adaptor();
387 void closeEvent(QCloseEvent * e);
389 void add(PrefModule * module);
392 /// update (do we need this?)
393 void updateContents();
395 std::vector<PrefModule *> modules_;
398 bool initialiseParams(std::string const &);
400 void clearParams() {}
402 void dispatchParams();
404 bool isBufferDependent() const { return false; }
406 /// various file pickers
407 docstring const browsebind(docstring const & file) const;
408 docstring const browseUI(docstring const & file) const;
409 docstring const browsekbmap(docstring const & file) const;
410 docstring const browsedict(docstring const & file) const;
413 docstring const browse(docstring const & file,
414 docstring const & title) const;
417 docstring const browsedir(docstring const & path,
418 docstring const & title) const;
421 void setColor(Color_color col, std::string const & hex);
423 /// update the screen fonts after change
424 void updateScreenFonts();
426 /// adjust the prefs paper sizes
427 PAPER_SIZE toPaperSize(int i) const;
428 /// adjust the prefs paper sizes
429 int fromPaperSize(PAPER_SIZE papersize) const;
431 LyXRC & rc() { return rc_; }
432 Converters & converters() { return converters_; }
433 Formats & formats() { return formats_; }
434 Movers & movers() { return movers_; }
439 /// temporary converters
440 Converters converters_;
441 /// temporary formats
446 /// A list of colors to be dispatched
447 std::vector<std::string> colors_;
450 bool update_screen_font_;
454 } // namespace frontend