4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
11 * Full author contact details are available in file CREDITS.
17 #include "GuiDialog.h"
19 #include "ColorCode.h"
20 #include "Converter.h"
27 #include "ui_PrefsUi.h"
29 #include "ui_PrefPlaintextUi.h"
30 #include "ui_PrefDateUi.h"
31 #include "ui_PrefInputUi.h"
32 #include "ui_PrefLatexUi.h"
33 #include "ui_PrefScreenFontsUi.h"
34 #include "ui_PrefCompletionUi.h"
35 #include "ui_PrefColorsUi.h"
36 #include "ui_PrefDisplayUi.h"
37 #include "ui_PrefEditUi.h"
38 #include "ui_PrefPathsUi.h"
39 #include "ui_PrefShortcutsUi.h"
40 #include "ui_PrefSpellcheckerUi.h"
41 #include "ui_PrefConvertersUi.h"
42 #include "ui_PrefFileformatsUi.h"
43 #include "ui_PrefLanguageUi.h"
44 #include "ui_PrefPrinterUi.h"
45 #include "ui_PrefUi.h"
46 #include "ui_PrefIdentityUi.h"
47 #include "ui_ShortcutUi.h"
66 class PrefModule : public QWidget
70 PrefModule(QString const & cat, QString const & t,
71 GuiPreferences * form = 0, QWidget * parent = 0)
72 : QWidget(parent), category_(cat), title_(t), form_(form)
75 virtual void apply(LyXRC & rc) const = 0;
76 virtual void update(LyXRC const & rc) = 0;
78 QString const & category() const { return category_; }
79 QString const & title() const { return title_; }
84 GuiPreferences * form_;
91 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
95 PrefPlaintext(QWidget * parent = 0);
97 virtual void apply(LyXRC & rc) const;
98 virtual void update(LyXRC const & rc);
102 class PrefDate : public PrefModule, public Ui::PrefDateUi
106 PrefDate(QWidget * parent = 0);
108 virtual void apply(LyXRC & rc) const;
109 virtual void update(LyXRC const & rc);
113 class PrefInput : public PrefModule, public Ui::PrefInputUi
117 PrefInput(GuiPreferences * form, QWidget * parent = 0);
119 virtual void apply(LyXRC & rc) const;
120 virtual void update(LyXRC const & rc);
123 void on_firstKeymapPB_clicked(bool);
124 void on_secondKeymapPB_clicked(bool);
125 void on_keymapCB_toggled(bool);
128 QString testKeymap(QString keymap);
132 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
136 PrefCompletion(GuiPreferences * form, QWidget * parent = 0);
138 virtual void apply(LyXRC & rc) const;
139 virtual void update(LyXRC const & rc);
143 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
147 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
149 virtual void apply(LyXRC & rc) const;
150 virtual void update(LyXRC const & rc);
154 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
158 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
160 virtual void apply(LyXRC & rc) const;
161 virtual void update(LyXRC const & rc);
164 void select_roman(const QString&);
165 void select_sans(const QString&);
166 void select_typewriter(const QString&);
170 class PrefColors : public PrefModule, public Ui::PrefColorsUi
174 PrefColors(GuiPreferences * form, QWidget * parent = 0);
176 void apply(LyXRC & rc) const;
177 void update(LyXRC const & rc);
181 void change_lyxObjects_selection();
184 std::vector<ColorCode> lcolors_;
185 // FIXME the use of mutable here is required due to the
186 // fact that initialization is not done in the controller
187 // but in the constructor.
188 std::vector<QString> curcolors_;
189 std::vector<QString> newcolors_;
194 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
198 PrefDisplay(QWidget * parent = 0);
200 void apply(LyXRC & rc) const;
201 void update(LyXRC const & rc);
205 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
209 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
211 void apply(LyXRC & rc) const;
212 void update(LyXRC const & rc);
215 void select_exampledir();
216 void select_templatedir();
217 void select_tempdir();
218 void select_backupdir();
219 void select_workingdir();
220 void select_lyxpipe();
225 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
229 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
231 void apply(LyXRC & rc) const;
232 void update(LyXRC const & rc);
239 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
243 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
245 void apply(LyXRC & rc) const;
246 void update(LyXRC const & rc);
252 void update_converter();
253 void switch_converter();
254 void converter_changed();
255 void remove_converter();
256 void on_cacheCB_stateChanged(int state);
259 void updateButtons();
263 class FormatValidator : public QValidator
266 FormatValidator(QWidget *, Formats const & f);
267 void fixup(QString & input) const;
268 QValidator::State validate(QString & input, int & pos) const;
270 virtual std::string str(Formats::const_iterator it) const = 0;
272 Formats const & formats_;
276 class FormatNameValidator : public FormatValidator
279 FormatNameValidator(QWidget *, Formats const & f);
281 std::string str(Formats::const_iterator it) const;
284 class FormatPrettynameValidator : public FormatValidator
287 FormatPrettynameValidator(QWidget *, Formats const & f);
289 std::string str(Formats::const_iterator it) const;
293 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
297 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
299 void apply(LyXRC & rc) const;
300 void update(LyXRC const & rc);
304 void formatsChanged();
307 void on_copierED_textEdited(const QString & s);
308 void on_extensionED_textEdited(const QString &);
309 void on_viewerED_textEdited(const QString &);
310 void on_editorED_textEdited(const QString &);
311 void on_shortcutED_textEdited(const QString &);
312 void on_formatED_editingFinished();
313 void on_formatED_textChanged(const QString &);
314 void on_formatsCB_currentIndexChanged(int);
315 void on_formatsCB_editTextChanged(const QString &);
316 void on_formatNewPB_clicked();
317 void on_formatRemovePB_clicked();
319 void updatePrettyname();
322 Format & currentFormat();
326 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
330 PrefLanguage(QWidget * parent = 0);
332 void apply(LyXRC & rc) const;
333 void update(LyXRC const & rc);
337 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
341 PrefPrinter(QWidget * parent = 0);
343 void apply(LyXRC & rc) const;
344 void update(LyXRC const & rc);
348 class PrefUserInterface : public PrefModule, public Ui::PrefUi
352 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
354 void apply(LyXRC & rc) const;
355 void update(LyXRC const & rc);
362 class PrefEdit : public PrefModule, public Ui::PrefEditUi
366 PrefEdit(GuiPreferences * form, QWidget * parent = 0);
368 void apply(LyXRC & rc) const;
369 void update(LyXRC const & rc);
374 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
377 GuiShortcutDialog(QWidget * parent);
381 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
386 System, //< loaded from a bind file
387 UserBind, //< \bind loaded from user.bind
388 UserUnbind, //< \unbind loaded from user.bind, with corresponding
389 //< entry in system bind file
390 UserExtraUnbind //< \unbind loaded from user.bind, without
391 //< corresponding entry in system bind file.
394 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
396 void apply(LyXRC & rc) const;
397 void update(LyXRC const & rc);
398 void updateShortcutsTW();
399 void modifyShortcut();
401 void setItemType(QTreeWidgetItem * item, item_type tag);
402 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
403 KeySequence const & shortcut, item_type tag);
407 void on_modifyPB_pressed();
408 void on_newPB_pressed();
409 void on_removePB_pressed();
410 void on_searchLE_textEdited();
412 void on_shortcutsTW_itemSelectionChanged();
413 void shortcut_okPB_pressed();
414 void shortcut_clearPB_pressed();
415 void on_shortcutsTW_itemDoubleClicked();
419 GuiShortcutDialog * shortcut_;
421 ButtonController shortcut_bc_;
423 QTreeWidgetItem * editItem_;
424 QTreeWidgetItem * mathItem_;
425 QTreeWidgetItem * bufferItem_;
426 QTreeWidgetItem * layoutItem_;
427 QTreeWidgetItem * systemItem_;
428 // system_bind_ holds bindings from rc.bind_file
429 // user_bind_ holds \bind bindings from user.bind
430 // user_unbind_ holds \unbind bindings from user.bind
431 // When an item is inserted, it is added to user_bind_
432 // When an item from system_bind_ is deleted, it is added to user_unbind_
433 // When an item in user_bind_ or user_unbind_ is deleted, it is
441 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
445 PrefIdentity(QWidget * parent = 0);
447 void apply(LyXRC & rc) const;
448 void update(LyXRC const & rc);
452 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
456 GuiPreferences(GuiView & lv);
458 void apply(LyXRC & rc) const;
459 void updateRc(LyXRC const & rc);
462 void change_adaptor();
466 void add(PrefModule * module);
469 /// update (do we need this?)
470 void updateContents();
472 std::vector<PrefModule *> modules_;
475 bool initialiseParams(std::string const &);
477 void clearParams() {}
479 void dispatchParams();
481 bool isBufferDependent() const { return false; }
483 /// various file pickers
484 QString browsebind(QString const & file) const;
485 QString browseUI(QString const & file) const;
486 QString browsekbmap(QString const & file) const;
487 QString browsedict(QString const & file) const;
490 QString browse(QString const & file, QString const & title) const;
493 void setColor(ColorCode col, std::string const & hex);
495 /// update the screen fonts after change
496 void updateScreenFonts();
498 /// adjust the prefs paper sizes
499 PAPER_SIZE toPaperSize(int i) const;
500 /// adjust the prefs paper sizes
501 int fromPaperSize(PAPER_SIZE papersize) const;
503 LyXRC & rc() { return rc_; }
504 Converters & converters() { return converters_; }
505 Formats & formats() { return formats_; }
506 Movers & movers() { return movers_; }
511 /// temporary converters
512 Converters converters_;
513 /// temporary formats
518 /// A list of colors to be dispatched
519 std::vector<std::string> colors_;
522 bool update_screen_font_;
526 } // namespace frontend