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_PrefOutputUi.h"
30 #include "ui_PrefInputUi.h"
31 #include "ui_PrefLatexUi.h"
32 #include "ui_PrefScreenFontsUi.h"
33 #include "ui_PrefCompletionUi.h"
34 #include "ui_PrefColorsUi.h"
35 #include "ui_PrefDisplayUi.h"
36 #include "ui_PrefEditUi.h"
37 #include "ui_PrefPathsUi.h"
38 #include "ui_PrefShortcutsUi.h"
39 #include "ui_PrefSpellcheckerUi.h"
40 #include "ui_PrefConvertersUi.h"
41 #include "ui_PrefFileformatsUi.h"
42 #include "ui_PrefLanguageUi.h"
43 #include "ui_PrefPrinterUi.h"
44 #include "ui_PrefUi.h"
45 #include "ui_PrefIdentityUi.h"
46 #include "ui_ShortcutUi.h"
62 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
66 GuiPreferences(GuiView & lv);
68 void apply(LyXRC & rc) const;
69 void updateRc(LyXRC const & rc);
72 void change_adaptor();
75 void prefsApplied(LyXRC const & rc);
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;
98 QString browse(QString const & file, QString const & title) const;
101 void setColor(ColorCode col, QString const & hex);
103 /// update the screen fonts after change
104 void updateScreenFonts();
106 LyXRC & rc() { return rc_; }
107 Converters & converters() { return converters_; }
108 Formats & formats() { return formats_; }
109 Movers & movers() { return movers_; }
113 void addModule(PrefModule * module);
117 /// temporary converters
118 Converters converters_;
119 /// temporary formats
124 /// A list of colors to be dispatched
125 std::vector<std::string> colors_;
128 bool update_screen_font_;
132 class PrefModule : public QWidget
136 PrefModule(QString const & cat, QString const & t,
137 GuiPreferences * form)
138 : QWidget(form), category_(cat), title_(t), form_(form)
141 virtual void apply(LyXRC & rc) const = 0;
142 virtual void update(LyXRC const & rc) = 0;
144 QString const & category() const { return category_; }
145 QString const & title() const { return title_; }
150 GuiPreferences * form_;
157 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
161 PrefOutput(GuiPreferences * form);
163 virtual void apply(LyXRC & rc) const;
164 virtual void update(LyXRC const & rc);
167 void on_DateED_textChanged(const QString &);
171 class PrefInput : public PrefModule, public Ui::PrefInputUi
175 PrefInput(GuiPreferences * form);
177 virtual void apply(LyXRC & rc) const;
178 virtual void update(LyXRC const & rc);
181 void on_firstKeymapPB_clicked(bool);
182 void on_secondKeymapPB_clicked(bool);
183 void on_keymapCB_toggled(bool);
184 void on_scrollzoomEnableCB_toggled(bool);
187 QString testKeymap(QString const & keymap);
191 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
195 PrefCompletion(GuiPreferences * form);
197 virtual void apply(LyXRC & rc) const;
198 virtual void update(LyXRC const & rc);
199 virtual void enableCB();
201 void on_popupTextCB_clicked();
202 void on_inlineTextCB_clicked();
206 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
210 PrefLatex(GuiPreferences * form);
212 virtual void apply(LyXRC & rc) const;
213 virtual void update(LyXRC const & rc);
216 void on_latexEncodingCB_stateChanged(int state);
217 void on_latexBibtexCO_activated(int n);
218 void on_latexIndexCO_activated(int n);
222 std::set<std::string> bibtex_alternatives;
224 std::set<std::string> index_alternatives;
228 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
232 PrefScreenFonts(GuiPreferences * form);
234 virtual void apply(LyXRC & rc) const;
235 virtual void update(LyXRC const & rc);
238 void selectRoman(const QString&);
239 void selectSans(const QString&);
240 void selectTypewriter(const QString&);
243 void updateScreenFontSizes(LyXRC const & rc);
247 class PrefColors : public PrefModule, public Ui::PrefColorsUi
251 PrefColors(GuiPreferences * form);
253 void apply(LyXRC & rc) const;
254 void update(LyXRC const & rc);
258 void changeSysColor();
259 void changeLyxObjectsSelection();
262 std::vector<ColorCode> lcolors_;
263 std::vector<QString> curcolors_;
264 std::vector<QString> newcolors_;
268 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
272 PrefDisplay(GuiPreferences * form);
274 void apply(LyXRC & rc) const;
275 void update(LyXRC const & rc);
278 void on_instantPreviewCO_currentIndexChanged(int);
279 void on_displayGraphicsCB_toggled(bool);
283 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
287 PrefPaths(GuiPreferences * form);
289 void apply(LyXRC & rc) const;
290 void update(LyXRC const & rc);
293 void selectExampledir();
294 void selectTemplatedir();
295 void selectTempdir();
296 void selectBackupdir();
297 void selectWorkingdir();
298 void selectThesaurusdir();
299 void selectHunspelldir();
300 void selectLyxPipe();
305 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
309 PrefSpellchecker(GuiPreferences * form);
311 void apply(LyXRC & rc) const;
312 void update(LyXRC const & rc);
315 void on_spellcheckerCB_currentIndexChanged(int);
319 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
323 PrefConverters(GuiPreferences * form);
325 void apply(LyXRC & rc) const;
326 void update(LyXRC const & rc);
332 void updateConverter();
333 void switchConverter();
334 void removeConverter();
335 void changeConverter();
336 void on_cacheCB_stateChanged(int state);
339 void updateButtons();
343 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
347 PrefFileformats(GuiPreferences * form);
349 void apply(LyXRC & rc) const;
350 void update(LyXRC const & rc);
354 void formatsChanged();
357 void on_copierED_textEdited(const QString & s);
358 void on_extensionsED_textEdited(const QString &);
359 void on_viewerED_textEdited(const QString &);
360 void on_editorED_textEdited(const QString &);
361 void on_mimeED_textEdited(const QString &);
362 void on_shortcutED_textEdited(const QString &);
363 void on_formatED_editingFinished();
364 void on_formatED_textChanged(const QString &);
365 void on_formatsCB_currentIndexChanged(int);
366 void on_formatsCB_editTextChanged(const QString &);
367 void on_formatNewPB_clicked();
368 void on_formatRemovePB_clicked();
369 void on_viewerCO_currentIndexChanged(int i);
370 void on_editorCO_currentIndexChanged(int i);
372 void updatePrettyname();
375 Format & currentFormat();
377 void updateViewers();
379 void updateEditors();
381 LyXRC::Alternatives viewer_alternatives;
383 LyXRC::Alternatives editor_alternatives;
387 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
391 PrefLanguage(GuiPreferences * form);
393 void apply(LyXRC & rc) const;
394 void update(LyXRC const & rc);
397 void on_uiLanguageCO_currentIndexChanged(int);
398 void on_languagePackageCO_currentIndexChanged(int);
402 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
406 PrefPrinter(GuiPreferences * form);
408 void apply(LyXRC & rc) const;
409 void update(LyXRC const & rc);
413 class PrefUserInterface : public PrefModule, public Ui::PrefUi
417 PrefUserInterface(GuiPreferences * form);
419 void apply(LyXRC & rc) const;
420 void update(LyXRC const & rc);
424 void on_clearSessionPB_clicked();
428 class PrefEdit : public PrefModule, public Ui::PrefEditUi
432 PrefEdit(GuiPreferences * form);
434 void apply(LyXRC & rc) const;
435 void update(LyXRC const & rc);
440 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
443 GuiShortcutDialog(QWidget * parent);
447 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
451 PrefShortcuts(GuiPreferences * form);
453 void apply(LyXRC & rc) const;
454 void update(LyXRC const & rc);
455 void updateShortcutsTW();
456 void modifyShortcut();
457 void removeShortcut();
459 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
460 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
461 KeySequence const & shortcut, KeyMap::ItemType tag);
465 void on_modifyPB_pressed();
466 void on_newPB_pressed();
467 void on_removePB_pressed();
468 void on_searchLE_textEdited();
470 void on_shortcutsTW_itemSelectionChanged();
471 void on_shortcutsTW_itemDoubleClicked();
473 void shortcutOkPressed();
474 void shortcutCancelPressed();
475 void shortcutClearPressed();
476 void shortcutRemovePressed();
480 GuiShortcutDialog * shortcut_;
482 ButtonController shortcut_bc_;
484 QTreeWidgetItem * editItem_;
485 QTreeWidgetItem * mathItem_;
486 QTreeWidgetItem * bufferItem_;
487 QTreeWidgetItem * layoutItem_;
488 QTreeWidgetItem * systemItem_;
489 // system_bind_ holds bindings from rc.bind_file
490 // user_bind_ holds \bind bindings from user.bind
491 // user_unbind_ holds \unbind bindings from user.bind
492 // When an item is inserted, it is added to user_bind_
493 // When an item from system_bind_ is deleted, it is added to user_unbind_
494 // When an item in user_bind_ or user_unbind_ is deleted, it is
504 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
508 PrefIdentity(GuiPreferences * form);
510 void apply(LyXRC & rc) const;
511 void update(LyXRC const & rc);
515 } // namespace frontend