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();
79 std::vector<PrefModule *> modules_;
82 bool initialiseParams(std::string const &);
86 void dispatchParams();
88 bool isBufferDependent() const { return false; }
90 /// various file pickers
91 QString browsebind(QString const & file) const;
92 QString browseUI(QString const & file) const;
93 QString browsekbmap(QString const & file) const;
94 QString browsedict(QString const & file) const;
97 QString browse(QString const & file, QString const & title) const;
100 void setColor(ColorCode col, QString const & hex);
102 /// update the screen fonts after change
103 void updateScreenFonts();
105 /// adjust the prefs paper sizes
106 PAPER_SIZE toPaperSize(int i) const;
107 /// adjust the prefs paper sizes
108 int fromPaperSize(PAPER_SIZE papersize) const;
110 LyXRC & rc() { return rc_; }
111 Converters & converters() { return converters_; }
112 Formats & formats() { return formats_; }
113 Movers & movers() { return movers_; }
117 void addModule(PrefModule * module);
121 /// temporary converters
122 Converters converters_;
123 /// temporary formats
128 /// A list of colors to be dispatched
129 std::vector<std::string> colors_;
132 bool update_screen_font_;
136 class PrefModule : public QWidget
140 PrefModule(QString const & cat, QString const & t,
141 GuiPreferences * form)
142 : QWidget(form), category_(cat), title_(t), form_(form)
145 virtual void apply(LyXRC & rc) const = 0;
146 virtual void update(LyXRC const & rc) = 0;
148 QString const & category() const { return category_; }
149 QString const & title() const { return title_; }
154 GuiPreferences * form_;
161 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
165 PrefPlaintext(GuiPreferences * form);
167 virtual void apply(LyXRC & rc) const;
168 virtual void update(LyXRC const & rc);
172 class PrefDate : public PrefModule, public Ui::PrefDateUi
176 PrefDate(GuiPreferences * form);
178 virtual void apply(LyXRC & rc) const;
179 virtual void update(LyXRC const & rc);
182 void on_DateED_textChanged(const QString &);
186 class PrefInput : public PrefModule, public Ui::PrefInputUi
190 PrefInput(GuiPreferences * form);
192 virtual void apply(LyXRC & rc) const;
193 virtual void update(LyXRC const & rc);
196 void on_firstKeymapPB_clicked(bool);
197 void on_secondKeymapPB_clicked(bool);
198 void on_keymapCB_toggled(bool);
201 QString testKeymap(QString const & keymap);
205 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
209 PrefCompletion(GuiPreferences * form);
211 virtual void apply(LyXRC & rc) const;
212 virtual void update(LyXRC const & rc);
216 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
220 PrefLatex(GuiPreferences * form);
222 virtual void apply(LyXRC & rc) const;
223 virtual void update(LyXRC const & rc);
227 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
231 PrefScreenFonts(GuiPreferences * form);
233 virtual void apply(LyXRC & rc) const;
234 virtual void update(LyXRC const & rc);
237 void select_roman(const QString&);
238 void select_sans(const QString&);
239 void select_typewriter(const QString&);
243 class PrefColors : public PrefModule, public Ui::PrefColorsUi
247 PrefColors(GuiPreferences * form);
249 void apply(LyXRC & rc) const;
250 void update(LyXRC const & rc);
254 void change_lyxObjects_selection();
257 std::vector<ColorCode> lcolors_;
258 std::vector<QString> curcolors_;
259 std::vector<QString> newcolors_;
263 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
267 PrefDisplay(GuiPreferences * form);
269 void apply(LyXRC & rc) const;
270 void update(LyXRC const & rc);
274 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
278 PrefPaths(GuiPreferences * form);
280 void apply(LyXRC & rc) const;
281 void update(LyXRC const & rc);
284 void select_exampledir();
285 void select_templatedir();
286 void select_tempdir();
287 void select_backupdir();
288 void select_workingdir();
289 void select_thesaurusdir();
290 void select_lyxpipe();
295 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
299 PrefSpellchecker(GuiPreferences * form);
301 void apply(LyXRC & rc) const;
302 void update(LyXRC const & rc);
309 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
313 PrefConverters(GuiPreferences * form);
315 void apply(LyXRC & rc) const;
316 void update(LyXRC const & rc);
322 void update_converter();
323 void switch_converter();
324 void converter_changed();
325 void remove_converter();
326 void on_cacheCB_stateChanged(int state);
329 void updateButtons();
333 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
337 PrefFileformats(GuiPreferences * form);
339 void apply(LyXRC & rc) const;
340 void update(LyXRC const & rc);
344 void formatsChanged();
347 void on_copierED_textEdited(const QString & s);
348 void on_extensionED_textEdited(const QString &);
349 void on_viewerED_textEdited(const QString &);
350 void on_editorED_textEdited(const QString &);
351 void on_shortcutED_textEdited(const QString &);
352 void on_formatED_editingFinished();
353 void on_formatED_textChanged(const QString &);
354 void on_formatsCB_currentIndexChanged(int);
355 void on_formatsCB_editTextChanged(const QString &);
356 void on_formatNewPB_clicked();
357 void on_formatRemovePB_clicked();
359 void updatePrettyname();
362 Format & currentFormat();
366 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
370 PrefLanguage(GuiPreferences * form);
372 void apply(LyXRC & rc) const;
373 void update(LyXRC const & rc);
376 void on_uiLanguageCO_currentIndexChanged(int);
380 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
384 PrefPrinter(GuiPreferences * form);
386 void apply(LyXRC & rc) const;
387 void update(LyXRC const & rc);
391 class PrefUserInterface : public PrefModule, public Ui::PrefUi
395 PrefUserInterface(GuiPreferences * form);
397 void apply(LyXRC & rc) const;
398 void update(LyXRC const & rc);
402 void on_clearSessionPB_clicked();
406 class PrefEdit : public PrefModule, public Ui::PrefEditUi
410 PrefEdit(GuiPreferences * form);
412 void apply(LyXRC & rc) const;
413 void update(LyXRC const & rc);
418 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
421 GuiShortcutDialog(QWidget * parent);
425 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
429 PrefShortcuts(GuiPreferences * form);
431 void apply(LyXRC & rc) const;
432 void update(LyXRC const & rc);
433 void updateShortcutsTW();
434 void modifyShortcut();
435 void removeShortcut();
437 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
438 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
439 KeySequence const & shortcut, KeyMap::ItemType tag);
443 void on_modifyPB_pressed();
444 void on_newPB_pressed();
445 void on_removePB_pressed();
446 void on_searchLE_textEdited();
448 void on_shortcutsTW_itemSelectionChanged();
449 void shortcut_okPB_pressed();
450 void shortcut_cancelPB_pressed();
451 void shortcut_clearPB_pressed();
452 void shortcut_removePB_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
481 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
485 PrefIdentity(GuiPreferences * form);
487 void apply(LyXRC & rc) const;
488 void update(LyXRC const & rc);
492 } // namespace frontend