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"
63 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
67 GuiPreferences(GuiView & lv);
69 void apply(LyXRC & rc) const;
70 void updateRc(LyXRC const & rc);
73 void change_adaptor();
78 /// update (do we need this?)
79 void updateContents();
81 std::vector<PrefModule *> modules_;
84 bool initialiseParams(std::string const &);
88 void dispatchParams();
90 bool isBufferDependent() const { return false; }
92 /// various file pickers
93 QString browsebind(QString const & file) const;
94 QString browseUI(QString const & file) const;
95 QString browsekbmap(QString const & file) const;
96 QString browsedict(QString const & file) const;
99 QString browse(QString const & file, QString const & title) const;
102 void setColor(ColorCode col, QString const & hex);
104 /// update the screen fonts after change
105 void updateScreenFonts();
107 /// adjust the prefs paper sizes
108 PAPER_SIZE toPaperSize(int i) const;
109 /// adjust the prefs paper sizes
110 int fromPaperSize(PAPER_SIZE papersize) const;
112 LyXRC & rc() { return rc_; }
113 Converters & converters() { return converters_; }
114 Formats & formats() { return formats_; }
115 Movers & movers() { return movers_; }
119 void addModule(PrefModule * module);
123 /// temporary converters
124 Converters converters_;
125 /// temporary formats
130 /// A list of colors to be dispatched
131 std::vector<std::string> colors_;
134 bool update_screen_font_;
138 class PrefModule : public QWidget
142 PrefModule(QString const & cat, QString const & t,
143 GuiPreferences * form)
144 : QWidget(form), category_(cat), title_(t), form_(form)
147 virtual void apply(LyXRC & rc) const = 0;
148 virtual void update(LyXRC const & rc) = 0;
150 QString const & category() const { return category_; }
151 QString const & title() const { return title_; }
156 GuiPreferences * form_;
163 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
167 PrefPlaintext(GuiPreferences * form);
169 virtual void apply(LyXRC & rc) const;
170 virtual void update(LyXRC const & rc);
174 class PrefDate : public PrefModule, public Ui::PrefDateUi
178 PrefDate(GuiPreferences * form);
180 virtual void apply(LyXRC & rc) const;
181 virtual void update(LyXRC const & rc);
185 class PrefInput : public PrefModule, public Ui::PrefInputUi
189 PrefInput(GuiPreferences * form);
191 virtual void apply(LyXRC & rc) const;
192 virtual void update(LyXRC const & rc);
195 void on_firstKeymapPB_clicked(bool);
196 void on_secondKeymapPB_clicked(bool);
197 void on_keymapCB_toggled(bool);
200 QString testKeymap(QString const & keymap);
204 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
208 PrefCompletion(GuiPreferences * form);
210 virtual void apply(LyXRC & rc) const;
211 virtual void update(LyXRC const & rc);
215 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
219 PrefLatex(GuiPreferences * form);
221 virtual void apply(LyXRC & rc) const;
222 virtual void update(LyXRC const & rc);
226 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
230 PrefScreenFonts(GuiPreferences * form);
232 virtual void apply(LyXRC & rc) const;
233 virtual void update(LyXRC const & rc);
236 void select_roman(const QString&);
237 void select_sans(const QString&);
238 void select_typewriter(const QString&);
242 class PrefColors : public PrefModule, public Ui::PrefColorsUi
246 PrefColors(GuiPreferences * form);
248 void apply(LyXRC & rc) const;
249 void update(LyXRC const & rc);
253 void change_lyxObjects_selection();
256 std::vector<ColorCode> lcolors_;
257 std::vector<QString> curcolors_;
258 std::vector<QString> newcolors_;
262 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
266 PrefDisplay(GuiPreferences * form);
268 void apply(LyXRC & rc) const;
269 void update(LyXRC const & rc);
273 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
277 PrefPaths(GuiPreferences * form);
279 void apply(LyXRC & rc) const;
280 void update(LyXRC const & rc);
283 void select_exampledir();
284 void select_templatedir();
285 void select_tempdir();
286 void select_backupdir();
287 void select_workingdir();
288 void select_lyxpipe();
293 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
297 PrefSpellchecker(GuiPreferences * form);
299 void apply(LyXRC & rc) const;
300 void update(LyXRC const & rc);
307 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
311 PrefConverters(GuiPreferences * form);
313 void apply(LyXRC & rc) const;
314 void update(LyXRC const & rc);
320 void update_converter();
321 void switch_converter();
322 void converter_changed();
323 void remove_converter();
324 void on_cacheCB_stateChanged(int state);
327 void updateButtons();
331 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
335 PrefFileformats(GuiPreferences * form);
337 void apply(LyXRC & rc) const;
338 void update(LyXRC const & rc);
342 void formatsChanged();
345 void on_copierED_textEdited(const QString & s);
346 void on_extensionED_textEdited(const QString &);
347 void on_viewerED_textEdited(const QString &);
348 void on_editorED_textEdited(const QString &);
349 void on_shortcutED_textEdited(const QString &);
350 void on_formatED_editingFinished();
351 void on_formatED_textChanged(const QString &);
352 void on_formatsCB_currentIndexChanged(int);
353 void on_formatsCB_editTextChanged(const QString &);
354 void on_formatNewPB_clicked();
355 void on_formatRemovePB_clicked();
357 void updatePrettyname();
360 Format & currentFormat();
364 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
368 PrefLanguage(GuiPreferences * form);
370 void apply(LyXRC & rc) const;
371 void update(LyXRC const & rc);
375 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
379 PrefPrinter(GuiPreferences * form);
381 void apply(LyXRC & rc) const;
382 void update(LyXRC const & rc);
386 class PrefUserInterface : public PrefModule, public Ui::PrefUi
390 PrefUserInterface(GuiPreferences * form);
392 void apply(LyXRC & rc) const;
393 void update(LyXRC const & rc);
400 class PrefEdit : public PrefModule, public Ui::PrefEditUi
404 PrefEdit(GuiPreferences * form);
406 void apply(LyXRC & rc) const;
407 void update(LyXRC const & rc);
412 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
415 GuiShortcutDialog(QWidget * parent);
419 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
424 System, //< loaded from a bind file
425 UserBind, //< \bind loaded from user.bind
426 UserUnbind, //< \unbind loaded from user.bind, with corresponding
427 //< entry in system bind file
428 UserExtraUnbind //< \unbind loaded from user.bind, without
429 //< corresponding entry in system bind file.
432 PrefShortcuts(GuiPreferences * form);
434 void apply(LyXRC & rc) const;
435 void update(LyXRC const & rc);
436 void updateShortcutsTW();
437 void modifyShortcut();
439 void setItemType(QTreeWidgetItem * item, ItemType tag);
440 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
441 KeySequence const & shortcut, ItemType tag);
445 void on_modifyPB_pressed();
446 void on_newPB_pressed();
447 void on_removePB_pressed();
448 void on_searchLE_textEdited();
450 void on_shortcutsTW_itemSelectionChanged();
451 void shortcut_okPB_pressed();
452 void shortcut_clearPB_pressed();
453 void on_shortcutsTW_itemDoubleClicked();
457 GuiShortcutDialog * shortcut_;
459 ButtonController shortcut_bc_;
461 QTreeWidgetItem * editItem_;
462 QTreeWidgetItem * mathItem_;
463 QTreeWidgetItem * bufferItem_;
464 QTreeWidgetItem * layoutItem_;
465 QTreeWidgetItem * systemItem_;
466 // system_bind_ holds bindings from rc.bind_file
467 // user_bind_ holds \bind bindings from user.bind
468 // user_unbind_ holds \unbind bindings from user.bind
469 // When an item is inserted, it is added to user_bind_
470 // When an item from system_bind_ is deleted, it is added to user_unbind_
471 // When an item in user_bind_ or user_unbind_ is deleted, it is
479 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
483 PrefIdentity(GuiPreferences * form);
485 void apply(LyXRC & rc) const;
486 void update(LyXRC const & rc);
490 } // namespace frontend