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"
41 #include "ui_ShortcutUi.h"
61 class PrefModule : public QWidget
65 PrefModule(docstring const & t,
66 GuiPreferences * form = 0, QWidget * parent = 0)
67 : QWidget(parent), title_(t), form_(form)
70 virtual void apply(LyXRC & rc) const = 0;
71 virtual void update(LyXRC const & rc) = 0;
73 docstring const & title() const { return title_; }
77 GuiPreferences * form_;
84 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
88 PrefPlaintext(QWidget * parent = 0);
90 virtual void apply(LyXRC & rc) const;
91 virtual void update(LyXRC const & rc);
95 class PrefDate : public PrefModule, public Ui::PrefDateUi
99 PrefDate(QWidget * parent = 0);
101 virtual void apply(LyXRC & rc) const;
102 virtual void update(LyXRC const & rc);
106 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
110 PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
112 virtual void apply(LyXRC & rc) const;
113 virtual void update(LyXRC const & rc);
116 void on_firstKeymapPB_clicked(bool);
117 void on_secondKeymapPB_clicked(bool);
118 void on_keymapCB_toggled(bool);
121 QString testKeymap(QString keymap);
125 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
129 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
131 virtual void apply(LyXRC & rc) const;
132 virtual void update(LyXRC const & rc);
136 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
140 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
142 virtual void apply(LyXRC & rc) const;
143 virtual void update(LyXRC const & rc);
146 void select_roman(const QString&);
147 void select_sans(const QString&);
148 void select_typewriter(const QString&);
152 class PrefColors : public PrefModule, public Ui::PrefColorsUi
156 PrefColors(GuiPreferences * form, QWidget * parent = 0);
158 void apply(LyXRC & rc) const;
159 void update(LyXRC const & rc);
163 void change_lyxObjects_selection();
166 std::vector<Color_color> lcolors_;
167 // FIXME the use of mutable here is required due to the
168 // fact that initialization is not done in the controller
169 // but in the constructor.
170 std::vector<QString> curcolors_;
171 std::vector<QString> newcolors_;
176 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
180 PrefDisplay(QWidget * parent = 0);
182 void apply(LyXRC & rc) const;
183 void update(LyXRC const & rc);
187 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
191 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
193 void apply(LyXRC & rc) const;
194 void update(LyXRC const & rc);
197 void select_templatedir();
198 void select_tempdir();
199 void select_backupdir();
200 void select_workingdir();
201 void select_lyxpipe();
206 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
210 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
212 void apply(LyXRC & rc) const;
213 void update(LyXRC const & rc);
220 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
224 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
226 void apply(LyXRC & rc) const;
227 void update(LyXRC const & rc);
233 void update_converter();
234 void switch_converter();
235 void converter_changed();
236 void remove_converter();
237 void on_cacheCB_stateChanged(int state);
240 void updateButtons();
244 class FormatValidator : public QValidator
247 FormatValidator(QWidget *, Formats const & f);
248 void fixup(QString & input) const;
249 QValidator::State validate(QString & input, int & pos) const;
251 virtual std::string str(Formats::const_iterator it) const = 0;
253 Formats const & formats_;
257 class FormatNameValidator : public FormatValidator
260 FormatNameValidator(QWidget *, Formats const & f);
262 std::string str(Formats::const_iterator it) const;
265 class FormatPrettynameValidator : public FormatValidator
268 FormatPrettynameValidator(QWidget *, Formats const & f);
270 std::string str(Formats::const_iterator it) const;
274 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
278 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
280 void apply(LyXRC & rc) const;
281 void update(LyXRC const & rc);
285 void formatsChanged();
288 void on_copierED_textEdited(const QString & s);
289 void on_extensionED_textEdited(const QString &);
290 void on_viewerED_textEdited(const QString &);
291 void on_editorED_textEdited(const QString &);
292 void on_shortcutED_textEdited(const QString &);
293 void on_formatED_editingFinished();
294 void on_formatED_textChanged(const QString &);
295 void on_formatsCB_currentIndexChanged(int);
296 void on_formatsCB_editTextChanged(const QString &);
297 void on_formatNewPB_clicked();
298 void on_formatRemovePB_clicked();
300 void updatePrettyname();
303 Format & currentFormat();
307 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
311 PrefLanguage(QWidget * parent = 0);
313 void apply(LyXRC & rc) const;
314 void update(LyXRC const & rc);
317 std::vector<std::string> lang_;
321 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
325 PrefPrinter(QWidget * parent = 0);
327 void apply(LyXRC & rc) const;
328 void update(LyXRC const & rc);
332 class PrefUserInterface : public PrefModule, public Ui::PrefUi
336 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
338 void apply(LyXRC & rc) const;
339 void update(LyXRC const & rc);
343 void on_loadWindowSizeCB_toggled(bool);
348 class GuiShortcutDialog : public QDialog, public Ui::ShortcutUi
351 GuiShortcutDialog(QWidget * parent) : QDialog(parent)
353 Ui::ShortcutUi::setupUi(this);
354 QDialog::setModal(true);
359 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
363 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
365 void apply(LyXRC & rc) const;
366 void update(LyXRC const & rc);
370 void on_newPB_pressed();
371 void on_modifyPB_pressed();
372 void on_removePB_pressed();
373 void on_searchPB_pressed();
374 void on_searchLE_textChanged();
376 void on_shortcutsTW_itemSelectionChanged();
378 void on_shortcutsTW_itemDoubleClicked();
381 GuiShortcutDialog * shortcut_;
383 ButtonController shortcut_bc_;
387 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
391 PrefIdentity(QWidget * parent = 0);
393 void apply(LyXRC & rc) const;
394 void update(LyXRC const & rc);
398 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
402 GuiPreferences(LyXView & lv);
404 void apply(LyXRC & rc) const;
405 void updateRc(LyXRC const & rc);
408 void change_adaptor();
412 void closeEvent(QCloseEvent * e);
414 void add(PrefModule * module);
417 /// update (do we need this?)
418 void updateContents();
420 std::vector<PrefModule *> modules_;
423 bool initialiseParams(std::string const &);
425 void clearParams() {}
427 void dispatchParams();
429 bool isBufferDependent() const { return false; }
431 /// various file pickers
432 docstring const browsebind(docstring const & file) const;
433 docstring const browseUI(docstring const & file) const;
434 docstring const browsekbmap(docstring const & file) const;
435 docstring const browsedict(docstring const & file) const;
438 docstring const browse(docstring const & file,
439 docstring const & title) const;
442 docstring const browsedir(docstring const & path,
443 docstring const & title) const;
446 void setColor(Color_color col, std::string const & hex);
448 /// update the screen fonts after change
449 void updateScreenFonts();
451 /// adjust the prefs paper sizes
452 PAPER_SIZE toPaperSize(int i) const;
453 /// adjust the prefs paper sizes
454 int fromPaperSize(PAPER_SIZE papersize) const;
456 LyXRC & rc() { return rc_; }
457 Converters & converters() { return converters_; }
458 Formats & formats() { return formats_; }
459 Movers & movers() { return movers_; }
464 /// temporary converters
465 Converters converters_;
466 /// temporary formats
471 /// A list of colors to be dispatched
472 std::vector<std::string> colors_;
475 bool update_screen_font_;
479 } // namespace frontend