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);
340 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
344 PrefPrinter(QWidget * parent = 0);
346 void apply(LyXRC & rc) const;
347 void update(LyXRC const & rc);
351 class PrefUserInterface : public PrefModule, public Ui::PrefUi
355 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
357 void apply(LyXRC & rc) const;
358 void update(LyXRC const & rc);
365 class PrefEdit : public PrefModule, public Ui::PrefEditUi
369 PrefEdit(GuiPreferences * form, QWidget * parent = 0);
371 void apply(LyXRC & rc) const;
372 void update(LyXRC const & rc);
377 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
380 GuiShortcutDialog(QWidget * parent);
384 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
389 System, //< loaded from a bind file
390 UserBind, //< \bind loaded from user.bind
391 UserUnbind, //< \unbind loaded from user.bind, with corresponding
392 //< entry in system bind file
393 UserExtraUnbind //< \unbind loaded from user.bind, without
394 //< corresponding entry in system bind file.
397 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
399 void apply(LyXRC & rc) const;
400 void update(LyXRC const & rc);
401 void updateShortcutsTW();
403 void setItemType(QTreeWidgetItem * item, item_type tag);
404 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
405 KeySequence const & shortcut, item_type tag);
409 void on_newPB_pressed();
410 void on_removePB_pressed();
411 void on_searchLE_textEdited();
413 void on_shortcutsTW_itemSelectionChanged();
414 void shortcut_okPB_pressed();
415 void shortcut_clearPB_pressed();
416 void on_shortcutsTW_itemDoubleClicked();
420 GuiShortcutDialog * shortcut_;
422 ButtonController shortcut_bc_;
424 QTreeWidgetItem * editItem_;
425 QTreeWidgetItem * mathItem_;
426 QTreeWidgetItem * bufferItem_;
427 QTreeWidgetItem * layoutItem_;
428 QTreeWidgetItem * systemItem_;
429 // system_bind_ holds bindings from rc.bind_file
430 // user_bind_ holds \bind bindings from user.bind
431 // user_unbind_ holds \unbind bindings from user.bind
432 // When an item is inserted, it is added to user_bind_
433 // When an item from system_bind_ is deleted, it is added to user_unbind_
434 // When an item in user_bind_ or user_unbind_ is deleted, it is
442 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
446 PrefIdentity(QWidget * parent = 0);
448 void apply(LyXRC & rc) const;
449 void update(LyXRC const & rc);
453 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
457 GuiPreferences(GuiView & lv);
459 void apply(LyXRC & rc) const;
460 void updateRc(LyXRC const & rc);
463 void change_adaptor();
467 void add(PrefModule * module);
470 /// update (do we need this?)
471 void updateContents();
473 std::vector<PrefModule *> modules_;
476 bool initialiseParams(std::string const &);
478 void clearParams() {}
480 void dispatchParams();
482 bool isBufferDependent() const { return false; }
484 /// various file pickers
485 QString browsebind(QString const & file) const;
486 QString browseUI(QString const & file) const;
487 QString browsekbmap(QString const & file) const;
488 QString browsedict(QString const & file) const;
491 QString browse(QString const & file, QString const & title) const;
494 void setColor(ColorCode col, std::string const & hex);
496 /// update the screen fonts after change
497 void updateScreenFonts();
499 /// adjust the prefs paper sizes
500 PAPER_SIZE toPaperSize(int i) const;
501 /// adjust the prefs paper sizes
502 int fromPaperSize(PAPER_SIZE papersize) const;
504 LyXRC & rc() { return rc_; }
505 Converters & converters() { return converters_; }
506 Formats & formats() { return formats_; }
507 Movers & movers() { return movers_; }
512 /// temporary converters
513 Converters converters_;
514 /// temporary formats
519 /// A list of colors to be dispatched
520 std::vector<std::string> colors_;
523 bool update_screen_font_;
527 } // namespace frontend