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 "Converter.h"
25 #include "ui_PrefsUi.h"
27 #include "ui_PrefOutputUi.h"
28 #include "ui_PrefInputUi.h"
29 #include "ui_PrefLatexUi.h"
30 #include "ui_PrefScreenFontsUi.h"
31 #include "ui_PrefCompletionUi.h"
32 #include "ui_PrefColorsUi.h"
33 #include "ui_PrefDisplayUi.h"
34 #include "ui_PrefDocHandlingUi.h"
35 #include "ui_PrefEditUi.h"
36 #include "ui_PrefPathsUi.h"
37 #include "ui_PrefShortcutsUi.h"
38 #include "ui_PrefSpellcheckerUi.h"
39 #include "ui_PrefConvertersUi.h"
40 #include "ui_PrefFileformatsUi.h"
41 #include "ui_PrefLanguageUi.h"
42 #include "ui_PrefPrinterUi.h"
43 #include "ui_PrefUi.h"
44 #include "ui_PrefIdentityUi.h"
45 #include "ui_ShortcutUi.h"
61 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
65 GuiPreferences(GuiView & lv);
67 void apply(LyXRC & rc) const;
68 void updateRc(LyXRC const & rc);
71 void change_adaptor();
74 void prefsApplied(LyXRC const & rc);
80 std::vector<PrefModule *> modules_;
83 bool initialiseParams(std::string const &);
87 void dispatchParams();
89 bool isBufferDependent() const { return false; }
91 /// various file pickers
92 QString browsebind(QString const & file) const;
93 QString browseUI(QString const & file) const;
94 QString browsekbmap(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 LyXRC & rc() { return rc_; }
106 Converters & converters() { return converters_; }
107 Formats & formats() { return formats_; }
108 Movers & movers() { return movers_; }
112 void addModule(PrefModule * module);
116 /// temporary converters
117 Converters converters_;
118 /// temporary formats
123 /// A list of colors to be dispatched
124 std::vector<std::string> colors_;
126 bool update_screen_font_;
130 class PrefModule : public QWidget
134 PrefModule(QString const & cat, QString const & t,
135 GuiPreferences * form)
136 : QWidget(form), category_(cat), title_(t), form_(form)
139 virtual void apply(LyXRC & rc) const = 0;
140 virtual void update(LyXRC const & rc) = 0;
142 QString const & category() const { return category_; }
143 QString const & title() const { return title_; }
148 GuiPreferences * form_;
155 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
159 PrefOutput(GuiPreferences * form);
161 virtual void apply(LyXRC & rc) const;
162 virtual void update(LyXRC const & rc);
165 void on_DateED_textChanged(const QString &);
169 class PrefInput : public PrefModule, public Ui::PrefInputUi
173 PrefInput(GuiPreferences * form);
175 virtual void apply(LyXRC & rc) const;
176 virtual void update(LyXRC const & rc);
179 void on_firstKeymapPB_clicked(bool);
180 void on_secondKeymapPB_clicked(bool);
181 void on_keymapCB_toggled(bool);
182 void on_scrollzoomEnableCB_toggled(bool);
185 QString testKeymap(QString const & keymap);
189 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
193 PrefCompletion(GuiPreferences * form);
195 virtual void apply(LyXRC & rc) const;
196 virtual void update(LyXRC const & rc);
197 virtual void enableCB();
199 void on_popupTextCB_clicked();
200 void on_inlineTextCB_clicked();
204 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
208 PrefLatex(GuiPreferences * form);
210 virtual void apply(LyXRC & rc) const;
211 virtual void update(LyXRC const & rc);
214 void on_latexEncodingCB_stateChanged(int state);
215 void on_latexBibtexCO_activated(int n);
216 void on_latexIndexCO_activated(int n);
220 std::set<std::string> bibtex_alternatives;
222 std::set<std::string> index_alternatives;
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 selectRoman(const QString&);
237 void selectSans(const QString&);
238 void selectTypewriter(const QString&);
241 void updateScreenFontSizes(LyXRC const & rc);
245 class PrefColors : public PrefModule, public Ui::PrefColorsUi
249 PrefColors(GuiPreferences * form);
251 void apply(LyXRC & rc) const;
252 void update(LyXRC const & rc);
256 void changeSysColor();
257 void changeLyxObjectsSelection();
260 std::vector<ColorCode> lcolors_;
261 std::vector<QString> curcolors_;
262 std::vector<QString> newcolors_;
266 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
270 PrefDisplay(GuiPreferences * form);
272 void apply(LyXRC & rc) const;
273 void update(LyXRC const & rc);
276 void on_instantPreviewCO_currentIndexChanged(int);
280 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
284 PrefPaths(GuiPreferences * form);
286 void apply(LyXRC & rc) const;
287 void update(LyXRC const & rc);
290 void selectExampledir();
291 void selectTemplatedir();
292 void selectTempdir();
293 void selectBackupdir();
294 void selectWorkingdir();
295 void selectThesaurusdir();
296 void selectHunspelldir();
297 void selectLyxPipe();
302 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
306 PrefSpellchecker(GuiPreferences * form);
308 void apply(LyXRC & rc) const;
309 void update(LyXRC const & rc);
312 void on_spellcheckerCB_currentIndexChanged(int);
316 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
320 PrefConverters(GuiPreferences * form);
322 void apply(LyXRC & rc) const;
323 void update(LyXRC const & rc);
329 void updateConverter();
330 void switchConverter();
331 void removeConverter();
332 void changeConverter();
333 void on_cacheCB_stateChanged(int state);
336 void updateButtons();
340 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
344 PrefFileformats(GuiPreferences * form);
346 void apply(LyXRC & rc) const;
347 void update(LyXRC const & rc);
351 void formatsChanged();
354 void on_copierED_textEdited(const QString & s);
355 void on_extensionsED_textEdited(const QString &);
356 void on_viewerED_textEdited(const QString &);
357 void on_editorED_textEdited(const QString &);
358 void on_mimeED_textEdited(const QString &);
359 void on_shortcutED_textEdited(const QString &);
360 void on_formatED_editingFinished();
361 void on_formatED_textChanged(const QString &);
362 void on_formatsCB_currentIndexChanged(int);
363 void on_formatsCB_editTextChanged(const QString &);
364 void on_formatNewPB_clicked();
365 void on_formatRemovePB_clicked();
366 void on_viewerCO_currentIndexChanged(int i);
367 void on_editorCO_currentIndexChanged(int i);
369 void updatePrettyname();
372 Format & currentFormat();
374 void updateViewers();
376 void updateEditors();
378 LyXRC::Alternatives viewer_alternatives;
380 LyXRC::Alternatives editor_alternatives;
384 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
388 PrefLanguage(GuiPreferences * form);
390 void apply(LyXRC & rc) const;
391 void update(LyXRC const & rc);
394 void on_uiLanguageCO_currentIndexChanged(int);
395 void on_languagePackageCO_currentIndexChanged(int);
399 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
403 PrefPrinter(GuiPreferences * form);
405 void apply(LyXRC & rc) const;
406 void update(LyXRC const & rc);
410 class PrefUserInterface : public PrefModule, public Ui::PrefUi
414 PrefUserInterface(GuiPreferences * form);
416 void apply(LyXRC & rc) const;
417 void update(LyXRC const & rc);
424 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
428 PrefDocHandling(GuiPreferences * form);
430 void apply(LyXRC & rc) const;
431 void update(LyXRC const & rc);
434 void on_clearSessionPB_clicked();
439 class PrefEdit : public PrefModule, public Ui::PrefEditUi
443 PrefEdit(GuiPreferences * form);
445 void apply(LyXRC & rc) const;
446 void update(LyXRC const & rc);
451 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
454 GuiShortcutDialog(QWidget * parent);
458 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
462 PrefShortcuts(GuiPreferences * form);
464 void apply(LyXRC & rc) const;
465 void update(LyXRC const & rc);
466 void updateShortcutsTW();
467 void modifyShortcut();
468 void removeShortcut();
470 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
471 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
472 KeySequence const & shortcut, KeyMap::ItemType tag);
476 void on_modifyPB_pressed();
477 void on_newPB_pressed();
478 void on_removePB_pressed();
479 void on_searchLE_textEdited();
481 void on_shortcutsTW_itemSelectionChanged();
482 void on_shortcutsTW_itemDoubleClicked();
484 void shortcutOkPressed();
485 void shortcutCancelPressed();
486 void shortcutClearPressed();
487 void shortcutRemovePressed();
491 GuiShortcutDialog * shortcut_;
493 ButtonController shortcut_bc_;
495 QTreeWidgetItem * editItem_;
496 QTreeWidgetItem * mathItem_;
497 QTreeWidgetItem * bufferItem_;
498 QTreeWidgetItem * layoutItem_;
499 QTreeWidgetItem * systemItem_;
500 // system_bind_ holds bindings from rc.bind_file
501 // user_bind_ holds \bind bindings from user.bind
502 // user_unbind_ holds \unbind bindings from user.bind
503 // When an item is inserted, it is added to user_bind_
504 // When an item from system_bind_ is deleted, it is added to user_unbind_
505 // When an item in user_bind_ or user_unbind_ is deleted, it is
515 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
519 PrefIdentity(GuiPreferences * form);
521 void apply(LyXRC & rc) const;
522 void update(LyXRC const & rc);
526 } // namespace frontend