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"
25 #include "ui_PrefsUi.h"
27 #include "ui_PrefPlaintextUi.h"
28 #include "ui_PrefDateUi.h"
29 #include "ui_PrefKeyboardUi.h"
30 #include "ui_PrefLatexUi.h"
31 #include "ui_PrefScreenFontsUi.h"
32 #include "ui_PrefColorsUi.h"
33 #include "ui_PrefDisplayUi.h"
34 #include "ui_PrefPathsUi.h"
35 #include "ui_PrefShortcutsUi.h"
36 #include "ui_PrefSpellcheckerUi.h"
37 #include "ui_PrefConvertersUi.h"
38 #include "ui_PrefFileformatsUi.h"
39 #include "ui_PrefLanguageUi.h"
40 #include "ui_PrefPrinterUi.h"
41 #include "ui_PrefUi.h"
42 #include "ui_PrefIdentityUi.h"
43 #include "ui_ShortcutUi.h"
63 class PrefModule : public QWidget
67 PrefModule(docstring const & t,
68 GuiPreferences * form = 0, QWidget * parent = 0)
69 : QWidget(parent), title_(t), form_(form)
72 virtual void apply(LyXRC & rc) const = 0;
73 virtual void update(LyXRC const & rc) = 0;
75 docstring const & title() const { return title_; }
79 GuiPreferences * form_;
86 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
90 PrefPlaintext(QWidget * parent = 0);
92 virtual void apply(LyXRC & rc) const;
93 virtual void update(LyXRC const & rc);
97 class PrefDate : public PrefModule, public Ui::PrefDateUi
101 PrefDate(QWidget * parent = 0);
103 virtual void apply(LyXRC & rc) const;
104 virtual void update(LyXRC const & rc);
108 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
112 PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
114 virtual void apply(LyXRC & rc) const;
115 virtual void update(LyXRC const & rc);
118 void on_firstKeymapPB_clicked(bool);
119 void on_secondKeymapPB_clicked(bool);
120 void on_keymapCB_toggled(bool);
123 QString testKeymap(QString keymap);
127 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
131 PrefLatex(GuiPreferences * form, QWidget * parent = 0);
133 virtual void apply(LyXRC & rc) const;
134 virtual void update(LyXRC const & rc);
138 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
142 PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
144 virtual void apply(LyXRC & rc) const;
145 virtual void update(LyXRC const & rc);
148 void select_roman(const QString&);
149 void select_sans(const QString&);
150 void select_typewriter(const QString&);
154 class PrefColors : public PrefModule, public Ui::PrefColorsUi
158 PrefColors(GuiPreferences * form, QWidget * parent = 0);
160 void apply(LyXRC & rc) const;
161 void update(LyXRC const & rc);
165 void change_lyxObjects_selection();
168 std::vector<Color_color> lcolors_;
169 // FIXME the use of mutable here is required due to the
170 // fact that initialization is not done in the controller
171 // but in the constructor.
172 std::vector<QString> curcolors_;
173 std::vector<QString> newcolors_;
178 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
182 PrefDisplay(QWidget * parent = 0);
184 void apply(LyXRC & rc) const;
185 void update(LyXRC const & rc);
189 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
193 PrefPaths(GuiPreferences * form, QWidget * parent = 0);
195 void apply(LyXRC & rc) const;
196 void update(LyXRC const & rc);
199 void select_templatedir();
200 void select_tempdir();
201 void select_backupdir();
202 void select_workingdir();
203 void select_lyxpipe();
208 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
212 PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
214 void apply(LyXRC & rc) const;
215 void update(LyXRC const & rc);
222 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
226 PrefConverters(GuiPreferences * form, QWidget * parent = 0);
228 void apply(LyXRC & rc) const;
229 void update(LyXRC const & rc);
235 void update_converter();
236 void switch_converter();
237 void converter_changed();
238 void remove_converter();
239 void on_cacheCB_stateChanged(int state);
242 void updateButtons();
246 class FormatValidator : public QValidator
249 FormatValidator(QWidget *, Formats const & f);
250 void fixup(QString & input) const;
251 QValidator::State validate(QString & input, int & pos) const;
253 virtual std::string str(Formats::const_iterator it) const = 0;
255 Formats const & formats_;
259 class FormatNameValidator : public FormatValidator
262 FormatNameValidator(QWidget *, Formats const & f);
264 std::string str(Formats::const_iterator it) const;
267 class FormatPrettynameValidator : public FormatValidator
270 FormatPrettynameValidator(QWidget *, Formats const & f);
272 std::string str(Formats::const_iterator it) const;
276 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
280 PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
282 void apply(LyXRC & rc) const;
283 void update(LyXRC const & rc);
287 void formatsChanged();
290 void on_copierED_textEdited(const QString & s);
291 void on_extensionED_textEdited(const QString &);
292 void on_viewerED_textEdited(const QString &);
293 void on_editorED_textEdited(const QString &);
294 void on_shortcutED_textEdited(const QString &);
295 void on_formatED_editingFinished();
296 void on_formatED_textChanged(const QString &);
297 void on_formatsCB_currentIndexChanged(int);
298 void on_formatsCB_editTextChanged(const QString &);
299 void on_formatNewPB_clicked();
300 void on_formatRemovePB_clicked();
302 void updatePrettyname();
305 Format & currentFormat();
309 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
313 PrefLanguage(QWidget * parent = 0);
315 void apply(LyXRC & rc) const;
316 void update(LyXRC const & rc);
319 std::vector<std::string> lang_;
323 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
327 PrefPrinter(QWidget * parent = 0);
329 void apply(LyXRC & rc) const;
330 void update(LyXRC const & rc);
334 class PrefUserInterface : public PrefModule, public Ui::PrefUi
338 PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
340 void apply(LyXRC & rc) const;
341 void update(LyXRC const & rc);
345 void on_loadWindowSizeCB_toggled(bool);
350 class GuiShortcutDialog : public QDialog, public Ui::ShortcutUi
353 GuiShortcutDialog(QWidget * parent) : QDialog(parent)
355 Ui::ShortcutUi::setupUi(this);
356 QDialog::setModal(true);
361 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
366 System, //< loaded from a bind file
367 UserBind, //< \bind loaded from user.bind
368 UserUnbind //< \unbind loaded from user.bind
371 PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
373 void apply(LyXRC & rc) const;
374 void update(LyXRC const & rc);
375 void updateShortcutsTW();
377 void setItemType(QTreeWidgetItem * item, item_type tag);
378 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
379 KeySequence const & shortcut, item_type tag);
383 void on_newPB_pressed();
384 void on_removePB_pressed();
385 void on_searchPB_pressed();
386 void on_searchLE_textChanged();
388 void on_shortcutsTW_itemSelectionChanged();
389 void shortcut_okPB_pressed();
390 void on_shortcutsTW_itemDoubleClicked();
394 GuiShortcutDialog * shortcut_;
396 ButtonController shortcut_bc_;
398 QTreeWidgetItem * editItem_;
399 QTreeWidgetItem * mathItem_;
400 QTreeWidgetItem * bufferItem_;
401 QTreeWidgetItem * layoutItem_;
402 QTreeWidgetItem * systemItem_;
403 // system_bind_ holds bindings from rc.bind_file
404 // user_bind_ holds \bind bindings from user.bind
405 // user_unbind_ holds \unbind bindings from user.bind
406 // When an item is inserted, it is added to user_bind_
407 // When an item from system_bind_ is deleted, it is added to user_unbind_
408 // When an item in user_bind_ or user_unbind_ is deleted, it is
416 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
420 PrefIdentity(QWidget * parent = 0);
422 void apply(LyXRC & rc) const;
423 void update(LyXRC const & rc);
427 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
431 GuiPreferences(LyXView & lv);
433 void apply(LyXRC & rc) const;
434 void updateRc(LyXRC const & rc);
437 void change_adaptor();
441 void closeEvent(QCloseEvent * e);
443 void add(PrefModule * module);
446 /// update (do we need this?)
447 void updateContents();
449 std::vector<PrefModule *> modules_;
452 bool initialiseParams(std::string const &);
454 void clearParams() {}
456 void dispatchParams();
458 bool isBufferDependent() const { return false; }
460 /// various file pickers
461 docstring const browsebind(docstring const & file) const;
462 docstring const browseUI(docstring const & file) const;
463 docstring const browsekbmap(docstring const & file) const;
464 docstring const browsedict(docstring const & file) const;
467 docstring const browse(docstring const & file,
468 docstring const & title) const;
471 docstring const browsedir(docstring const & path,
472 docstring const & title) const;
475 void setColor(Color_color col, std::string const & hex);
477 /// update the screen fonts after change
478 void updateScreenFonts();
480 /// adjust the prefs paper sizes
481 PAPER_SIZE toPaperSize(int i) const;
482 /// adjust the prefs paper sizes
483 int fromPaperSize(PAPER_SIZE papersize) const;
485 LyXRC & rc() { return rc_; }
486 Converters & converters() { return converters_; }
487 Formats & formats() { return formats_; }
488 Movers & movers() { return movers_; }
493 /// temporary converters
494 Converters converters_;
495 /// temporary formats
500 /// A list of colors to be dispatched
501 std::vector<std::string> colors_;
504 bool update_screen_font_;
508 } // namespace frontend