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"
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();
76 void prefsApplied(LyXRC const & rc);
82 std::vector<PrefModule *> modules_;
85 bool initialiseParams(std::string const &);
89 void dispatchParams();
91 bool isBufferDependent() const { return false; }
93 /// various file pickers
94 QString browsebind(QString const & file) const;
95 QString browseUI(QString const & file) const;
96 QString browsekbmap(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 PrefOutput : public PrefModule, public Ui::PrefOutputUi
167 PrefOutput(GuiPreferences * form);
169 virtual void apply(LyXRC & rc) const;
170 virtual void update(LyXRC const & rc);
173 void on_DateED_textChanged(const QString &);
177 class PrefInput : public PrefModule, public Ui::PrefInputUi
181 PrefInput(GuiPreferences * form);
183 virtual void apply(LyXRC & rc) const;
184 virtual void update(LyXRC const & rc);
187 void on_firstKeymapPB_clicked(bool);
188 void on_secondKeymapPB_clicked(bool);
189 void on_keymapCB_toggled(bool);
190 void on_scrollzoomEnableCB_toggled(bool);
193 QString testKeymap(QString const & keymap);
197 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
201 PrefCompletion(GuiPreferences * form);
203 virtual void apply(LyXRC & rc) const;
204 virtual void update(LyXRC const & rc);
205 virtual void enableCB();
207 void on_popupTextCB_clicked();
208 void on_inlineTextCB_clicked();
212 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
216 PrefLatex(GuiPreferences * form);
218 virtual void apply(LyXRC & rc) const;
219 virtual void update(LyXRC const & rc);
222 void on_latexEncodingCB_stateChanged(int state);
223 void on_latexBibtexCO_activated(int n);
224 void on_latexIndexCO_activated(int n);
228 std::set<std::string> bibtex_alternatives;
230 std::set<std::string> index_alternatives;
234 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
238 PrefScreenFonts(GuiPreferences * form);
240 virtual void apply(LyXRC & rc) const;
241 virtual void update(LyXRC const & rc);
244 void selectRoman(const QString&);
245 void selectSans(const QString&);
246 void selectTypewriter(const QString&);
249 void updateScreenFontSizes(LyXRC const & rc);
253 class PrefColors : public PrefModule, public Ui::PrefColorsUi
257 PrefColors(GuiPreferences * form);
259 void apply(LyXRC & rc) const;
260 void update(LyXRC const & rc);
264 void changeSysColor();
265 void changeLyxObjectsSelection();
268 std::vector<ColorCode> lcolors_;
269 std::vector<QString> curcolors_;
270 std::vector<QString> newcolors_;
274 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
278 PrefDisplay(GuiPreferences * form);
280 void apply(LyXRC & rc) const;
281 void update(LyXRC const & rc);
284 void on_instantPreviewCO_currentIndexChanged(int);
285 void on_displayGraphicsCB_toggled(bool);
289 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
293 PrefPaths(GuiPreferences * form);
295 void apply(LyXRC & rc) const;
296 void update(LyXRC const & rc);
299 void selectExampledir();
300 void selectTemplatedir();
301 void selectTempdir();
302 void selectBackupdir();
303 void selectWorkingdir();
304 void selectThesaurusdir();
305 void selectHunspelldir();
306 void selectLyxPipe();
311 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
315 PrefSpellchecker(GuiPreferences * form);
317 void apply(LyXRC & rc) const;
318 void update(LyXRC const & rc);
321 void on_spellcheckerCB_currentIndexChanged(int);
325 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
329 PrefConverters(GuiPreferences * form);
331 void apply(LyXRC & rc) const;
332 void update(LyXRC const & rc);
338 void updateConverter();
339 void switchConverter();
340 void removeConverter();
341 void changeConverter();
342 void on_cacheCB_stateChanged(int state);
345 void updateButtons();
349 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
353 PrefFileformats(GuiPreferences * form);
355 void apply(LyXRC & rc) const;
356 void update(LyXRC const & rc);
360 void formatsChanged();
363 void on_copierED_textEdited(const QString & s);
364 void on_extensionED_textEdited(const QString &);
365 void on_viewerED_textEdited(const QString &);
366 void on_editorED_textEdited(const QString &);
367 void on_shortcutED_textEdited(const QString &);
368 void on_formatED_editingFinished();
369 void on_formatED_textChanged(const QString &);
370 void on_formatsCB_currentIndexChanged(int);
371 void on_formatsCB_editTextChanged(const QString &);
372 void on_formatNewPB_clicked();
373 void on_formatRemovePB_clicked();
374 void on_viewerCO_currentIndexChanged(int i);
375 void on_editorCO_currentIndexChanged(int i);
377 void updatePrettyname();
380 Format & currentFormat();
382 void updateViewers();
384 void updateEditors();
386 LyXRC::Alternatives viewer_alternatives;
388 LyXRC::Alternatives editor_alternatives;
392 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
396 PrefLanguage(GuiPreferences * form);
398 void apply(LyXRC & rc) const;
399 void update(LyXRC const & rc);
402 void on_uiLanguageCO_currentIndexChanged(int);
403 void on_languagePackageCO_currentIndexChanged(int);
407 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
411 PrefPrinter(GuiPreferences * form);
413 void apply(LyXRC & rc) const;
414 void update(LyXRC const & rc);
418 class PrefUserInterface : public PrefModule, public Ui::PrefUi
422 PrefUserInterface(GuiPreferences * form);
424 void apply(LyXRC & rc) const;
425 void update(LyXRC const & rc);
429 void on_clearSessionPB_clicked();
432 /// icon names and their translations
433 std::vector<std::pair<std::string, QString> > icon_names_;
437 class PrefEdit : public PrefModule, public Ui::PrefEditUi
441 PrefEdit(GuiPreferences * form);
443 void apply(LyXRC & rc) const;
444 void update(LyXRC const & rc);
449 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
452 GuiShortcutDialog(QWidget * parent);
456 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
460 PrefShortcuts(GuiPreferences * form);
462 void apply(LyXRC & rc) const;
463 void update(LyXRC const & rc);
464 void updateShortcutsTW();
465 void modifyShortcut();
466 void removeShortcut();
468 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
469 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
470 KeySequence const & shortcut, KeyMap::ItemType tag);
474 void on_modifyPB_pressed();
475 void on_newPB_pressed();
476 void on_removePB_pressed();
477 void on_searchLE_textEdited();
479 void on_shortcutsTW_itemSelectionChanged();
480 void on_shortcutsTW_itemDoubleClicked();
482 void shortcutOkPressed();
483 void shortcutCancelPressed();
484 void shortcutClearPressed();
485 void shortcutRemovePressed();
489 GuiShortcutDialog * shortcut_;
491 ButtonController shortcut_bc_;
493 QTreeWidgetItem * editItem_;
494 QTreeWidgetItem * mathItem_;
495 QTreeWidgetItem * bufferItem_;
496 QTreeWidgetItem * layoutItem_;
497 QTreeWidgetItem * systemItem_;
498 // system_bind_ holds bindings from rc.bind_file
499 // user_bind_ holds \bind bindings from user.bind
500 // user_unbind_ holds \unbind bindings from user.bind
501 // When an item is inserted, it is added to user_bind_
502 // When an item from system_bind_ is deleted, it is added to user_unbind_
503 // When an item in user_bind_ or user_unbind_ is deleted, it is
513 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
517 PrefIdentity(GuiPreferences * form);
519 void apply(LyXRC & rc) const;
520 void update(LyXRC const & rc);
524 } // namespace frontend