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"
20 #include "Converter.h"
27 #include "ui_PrefsUi.h"
29 #include "ui_PrefPlaintextUi.h"
30 #include "ui_PrefDateUi.h"
31 #include "ui_PrefKeyboardUi.h"
32 #include "ui_PrefLatexUi.h"
33 #include "ui_PrefScreenFontsUi.h"
34 #include "ui_PrefColorsUi.h"
35 #include "ui_PrefDisplayUi.h"
36 #include "ui_PrefPathsUi.h"
37 #include "ui_PrefShortcutsUi.h"
38 #include "ui_PrefSpellcheckerUi.h"
39 #include "ui_PrefConvertersUi.h"
40 #include "ui_PrefFileformatsUi.h"
41 #include "ui_PrefLanguageUi.h"
42 #include "ui_PrefPrinterUi.h"
43 #include "ui_PrefUi.h"
44 #include "ui_PrefIdentityUi.h"
45 #include "ui_ShortcutUi.h"
65 class PrefModule : public QWidget
69 PrefModule(docstring const & t,
70 GuiPreferences * form = 0, QWidget * parent = 0)
71 : QWidget(parent), title_(t), form_(form)
74 virtual void apply(LyXRC & rc) const = 0;
75 virtual void update(LyXRC const & rc) = 0;
77 docstring const & title() const { return title_; }
81 GuiPreferences * form_;
88 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
92 PrefPlaintext(QWidget * parent = 0);
94 virtual void apply(LyXRC & rc) const;
95 virtual void update(LyXRC const & rc);
99 class PrefDate : public PrefModule, public Ui::PrefDateUi
103 PrefDate(QWidget * parent = 0);
105 virtual void apply(LyXRC & rc) const;
106 virtual void update(LyXRC const & rc);
110 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
114 PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
116 virtual void apply(LyXRC & rc) const;
117 virtual void update(LyXRC const & rc);
120 void on_firstKeymapPB_clicked(bool);
121 void on_secondKeymapPB_clicked(bool);
122 void on_keymapCB_toggled(bool);
125 QString testKeymap(QString keymap);
129 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
133 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
135 virtual void apply(LyXRC & rc) const;
136 virtual void update(LyXRC const & rc);
140 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
144 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
146 virtual void apply(LyXRC & rc) const;
147 virtual void update(LyXRC const & rc);
150 void select_roman(const QString&);
151 void select_sans(const QString&);
152 void select_typewriter(const QString&);
156 class PrefColors : public PrefModule, public Ui::PrefColorsUi
160 PrefColors(GuiPreferences * form, QWidget * parent = 0);
162 void apply(LyXRC & rc) const;
163 void update(LyXRC const & rc);
167 void change_lyxObjects_selection();
170 std::vector<Color_color> lcolors_;
171 // FIXME the use of mutable here is required due to the
172 // fact that initialization is not done in the controller
173 // but in the constructor.
174 std::vector<QString> curcolors_;
175 std::vector<QString> newcolors_;
180 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
184 PrefDisplay(QWidget * parent = 0);
186 void apply(LyXRC & rc) const;
187 void update(LyXRC const & rc);
191 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
195 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
197 void apply(LyXRC & rc) const;
198 void update(LyXRC const & rc);
201 void select_templatedir();
202 void select_tempdir();
203 void select_backupdir();
204 void select_workingdir();
205 void select_lyxpipe();
210 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
214 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
216 void apply(LyXRC & rc) const;
217 void update(LyXRC const & rc);
224 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
228 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
230 void apply(LyXRC & rc) const;
231 void update(LyXRC const & rc);
237 void update_converter();
238 void switch_converter();
239 void converter_changed();
240 void remove_converter();
241 void on_cacheCB_stateChanged(int state);
244 void updateButtons();
248 class FormatValidator : public QValidator
251 FormatValidator(QWidget *, Formats const & f);
252 void fixup(QString & input) const;
253 QValidator::State validate(QString & input, int & pos) const;
255 virtual std::string str(Formats::const_iterator it) const = 0;
257 Formats const & formats_;
261 class FormatNameValidator : public FormatValidator
264 FormatNameValidator(QWidget *, Formats const & f);
266 std::string str(Formats::const_iterator it) const;
269 class FormatPrettynameValidator : public FormatValidator
272 FormatPrettynameValidator(QWidget *, Formats const & f);
274 std::string str(Formats::const_iterator it) const;
278 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
282 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
284 void apply(LyXRC & rc) const;
285 void update(LyXRC const & rc);
289 void formatsChanged();
292 void on_copierED_textEdited(const QString & s);
293 void on_extensionED_textEdited(const QString &);
294 void on_viewerED_textEdited(const QString &);
295 void on_editorED_textEdited(const QString &);
296 void on_shortcutED_textEdited(const QString &);
297 void on_formatED_editingFinished();
298 void on_formatED_textChanged(const QString &);
299 void on_formatsCB_currentIndexChanged(int);
300 void on_formatsCB_editTextChanged(const QString &);
301 void on_formatNewPB_clicked();
302 void on_formatRemovePB_clicked();
304 void updatePrettyname();
307 Format & currentFormat();
311 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
315 PrefLanguage(QWidget * parent = 0);
317 void apply(LyXRC & rc) const;
318 void update(LyXRC const & rc);
321 std::vector<std::string> lang_;
325 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
329 PrefPrinter(QWidget * parent = 0);
331 void apply(LyXRC & rc) const;
332 void update(LyXRC const & rc);
336 class PrefUserInterface : public PrefModule, public Ui::PrefUi
340 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
342 void apply(LyXRC & rc) const;
343 void update(LyXRC const & rc);
347 void on_loadWindowSizeCB_toggled(bool);
352 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
355 GuiShortcutDialog(QWidget * parent);
359 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
364 System, //< loaded from a bind file
365 UserBind, //< \bind loaded from user.bind
366 UserUnbind, //< \unbind loaded from user.bind, with corresponding
367 //< entry in system bind file
368 UserExtraUnbind //< \unbind loaded from user.bind, without
369 //< corresponding entry in system bind file.
372 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
374 void apply(LyXRC & rc) const;
375 void update(LyXRC const & rc);
376 void updateShortcutsTW();
378 void setItemType(QTreeWidgetItem * item, item_type tag);
379 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
380 KeySequence const & shortcut, item_type tag);
384 void on_newPB_pressed();
385 void on_removePB_pressed();
386 void on_searchLE_textChanged();
388 void on_shortcutsTW_itemSelectionChanged();
389 void shortcut_okPB_pressed();
390 void shortcut_clearPB_pressed();
391 void on_shortcutsTW_itemDoubleClicked();
395 GuiShortcutDialog * shortcut_;
397 ButtonController shortcut_bc_;
399 QTreeWidgetItem * editItem_;
400 QTreeWidgetItem * mathItem_;
401 QTreeWidgetItem * bufferItem_;
402 QTreeWidgetItem * layoutItem_;
403 QTreeWidgetItem * systemItem_;
404 // system_bind_ holds bindings from rc.bind_file
405 // user_bind_ holds \bind bindings from user.bind
406 // user_unbind_ holds \unbind bindings from user.bind
407 // When an item is inserted, it is added to user_bind_
408 // When an item from system_bind_ is deleted, it is added to user_unbind_
409 // When an item in user_bind_ or user_unbind_ is deleted, it is
417 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
421 PrefIdentity(QWidget * parent = 0);
423 void apply(LyXRC & rc) const;
424 void update(LyXRC const & rc);
428 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
432 GuiPreferences(LyXView & lv);
434 void apply(LyXRC & rc) const;
435 void updateRc(LyXRC const & rc);
438 void change_adaptor();
442 void closeEvent(QCloseEvent * e);
444 void add(PrefModule * module);
447 /// update (do we need this?)
448 void updateContents();
450 std::vector<PrefModule *> modules_;
453 bool initialiseParams(std::string const &);
455 void clearParams() {}
457 void dispatchParams();
459 bool isBufferDependent() const { return false; }
461 /// various file pickers
462 docstring const browsebind(docstring const & file) const;
463 docstring const browseUI(docstring const & file) const;
464 docstring const browsekbmap(docstring const & file) const;
465 docstring const browsedict(docstring const & file) const;
468 docstring const browse(docstring const & file,
469 docstring const & title) const;
472 docstring const browsedir(docstring const & path,
473 docstring const & title) const;
476 void setColor(Color_color col, std::string const & hex);
478 /// update the screen fonts after change
479 void updateScreenFonts();
481 /// adjust the prefs paper sizes
482 PAPER_SIZE toPaperSize(int i) const;
483 /// adjust the prefs paper sizes
484 int fromPaperSize(PAPER_SIZE papersize) const;
486 LyXRC & rc() { return rc_; }
487 Converters & converters() { return converters_; }
488 Formats & formats() { return formats_; }
489 Movers & movers() { return movers_; }
494 /// temporary converters
495 Converters converters_;
496 /// temporary formats
501 /// A list of colors to be dispatched
502 std::vector<std::string> colors_;
505 bool update_screen_font_;
509 } // namespace frontend