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_PrefUi.h"
43 #include "ui_PrefIdentityUi.h"
44 #include "ui_ShortcutUi.h"
60 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
64 GuiPreferences(GuiView & lv);
66 void applyRC(LyXRC & rc) const;
67 void updateRC(LyXRC const & rc);
70 void change_adaptor();
73 void prefsApplied(LyXRC const & rc);
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;
96 QString browse(QString const & file, QString const & title) const;
99 void setColor(ColorCode col, QString const & hex);
101 /// update the screen fonts after change
102 void updateScreenFonts();
104 /// update the previews after change
105 void updatePreviews();
107 LyXRC & rc() { return rc_; }
108 Converters & converters() { return converters_; }
109 Formats & formats() { return formats_; }
110 Movers & movers() { return movers_; }
114 void addModule(PrefModule * module);
118 /// temporary converters
119 Converters converters_;
120 /// temporary formats
125 /// A list of colors to be dispatched
126 std::vector<std::string> colors_;
128 bool update_screen_font_;
129 bool update_previews_;
133 class PrefModule : public QWidget
137 PrefModule(QString const & cat, QString const & t,
138 GuiPreferences * form)
139 : QWidget(form), category_(cat), title_(t), form_(form)
142 virtual void applyRC(LyXRC & rc) const = 0;
143 virtual void updateRC(LyXRC const & rc) = 0;
145 QString const & category() const { return category_; }
146 QString const & title() const { return title_; }
151 GuiPreferences * form_;
158 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
162 PrefOutput(GuiPreferences * form);
164 virtual void applyRC(LyXRC & rc) const;
165 virtual void updateRC(LyXRC const & rc);
168 void on_DateED_textChanged(const QString &);
172 class PrefInput : public PrefModule, public Ui::PrefInputUi
176 PrefInput(GuiPreferences * form);
178 virtual void applyRC(LyXRC & rc) const;
179 virtual void updateRC(LyXRC const & rc);
182 void on_firstKeymapPB_clicked(bool);
183 void on_secondKeymapPB_clicked(bool);
184 void on_keymapCB_toggled(bool);
185 void on_scrollzoomEnableCB_toggled(bool);
188 QString testKeymap(QString const & keymap);
192 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
196 PrefCompletion(GuiPreferences * form);
198 virtual void applyRC(LyXRC & rc) const;
199 virtual void updateRC(LyXRC const & rc);
200 virtual void enableCB();
202 void on_popupTextCB_clicked();
203 void on_inlineTextCB_clicked();
207 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
211 PrefLatex(GuiPreferences * form);
213 virtual void applyRC(LyXRC & rc) const;
214 virtual void updateRC(LyXRC const & rc);
217 void on_latexEncodingCB_stateChanged(int state);
218 void on_latexBibtexCO_activated(int n);
219 void on_latexJBibtexCO_activated(int n);
220 void on_latexIndexCO_activated(int n);
224 std::set<std::string> bibtex_alternatives;
226 std::set<std::string> jbibtex_alternatives;
228 std::set<std::string> index_alternatives;
232 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
236 PrefScreenFonts(GuiPreferences * form);
238 virtual void applyRC(LyXRC & rc) const;
239 virtual void updateRC(LyXRC const & rc);
242 void selectRoman(const QString&);
243 void selectSans(const QString&);
244 void selectTypewriter(const QString&);
247 void updateScreenFontSizes(LyXRC const & rc);
251 class PrefColors : public PrefModule, public Ui::PrefColorsUi
255 PrefColors(GuiPreferences * form);
257 void applyRC(LyXRC & rc) const;
258 void updateRC(LyXRC const & rc);
262 void changeSysColor();
263 void changeLyxObjectsSelection();
266 std::vector<ColorCode> lcolors_;
267 std::vector<QString> curcolors_;
268 std::vector<QString> newcolors_;
272 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
276 PrefDisplay(GuiPreferences * form);
278 void applyRC(LyXRC & rc) const;
279 void updateRC(LyXRC const & rc);
282 void on_instantPreviewCO_currentIndexChanged(int);
286 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
290 PrefPaths(GuiPreferences * form);
292 void applyRC(LyXRC & rc) const;
293 void updateRC(LyXRC const & rc);
296 void selectExampledir();
297 void selectTemplatedir();
298 void selectTempdir();
299 void selectBackupdir();
300 void selectWorkingdir();
301 void selectThesaurusdir();
302 void selectHunspelldir();
303 void selectLyxPipe();
308 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
312 PrefSpellchecker(GuiPreferences * form);
314 void applyRC(LyXRC & rc) const;
315 void updateRC(LyXRC const & rc);
318 void on_spellcheckerCB_currentIndexChanged(int);
322 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
326 PrefConverters(GuiPreferences * form);
328 void applyRC(LyXRC & rc) const;
329 void updateRC(LyXRC const & rc);
335 void updateConverter();
336 void switchConverter();
337 void removeConverter();
338 void changeConverter();
339 void on_cacheCB_stateChanged(int state);
340 void on_needauthForbiddenCB_toggled(bool);
343 void updateButtons();
347 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
351 PrefFileformats(GuiPreferences * form);
353 void applyRC(LyXRC & rc) const;
354 void updateRC(LyXRC const & rc);
358 void formatsChanged();
361 void on_copierED_textEdited(const QString & s);
362 void on_extensionsED_textEdited(const QString &);
363 void on_viewerED_textEdited(const QString &);
364 void on_editorED_textEdited(const QString &);
365 void on_mimeED_textEdited(const QString &);
366 void on_shortcutED_textEdited(const QString &);
367 void on_formatED_editingFinished();
368 void on_formatED_textChanged(const QString &);
369 void on_formatsCB_currentIndexChanged(int);
370 void on_formatsCB_editTextChanged(const QString &);
371 void on_formatNewPB_clicked();
372 void on_formatRemovePB_clicked();
373 void on_viewerCO_currentIndexChanged(int i);
374 void on_editorCO_currentIndexChanged(int i);
376 void updatePrettyname();
379 Format & currentFormat();
381 void updateViewers();
383 void updateEditors();
385 LyXRC::Alternatives viewer_alternatives;
387 LyXRC::Alternatives editor_alternatives;
391 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
395 PrefLanguage(GuiPreferences * form);
397 void applyRC(LyXRC & rc) const;
398 void updateRC(LyXRC const & rc);
401 void on_uiLanguageCO_currentIndexChanged(int);
402 void on_languagePackageCO_currentIndexChanged(int);
406 class PrefUserInterface : public PrefModule, public Ui::PrefUi
410 PrefUserInterface(GuiPreferences * form);
412 void applyRC(LyXRC & rc) const;
413 void updateRC(LyXRC const & rc);
420 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
424 PrefDocHandling(GuiPreferences * form);
426 void applyRC(LyXRC & rc) const;
427 void updateRC(LyXRC const & rc);
430 void on_clearSessionPB_clicked();
435 class PrefEdit : public PrefModule, public Ui::PrefEditUi
439 PrefEdit(GuiPreferences * form);
441 void applyRC(LyXRC & rc) const;
442 void updateRC(LyXRC const & rc);
447 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
450 GuiShortcutDialog(QWidget * parent);
454 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
458 PrefShortcuts(GuiPreferences * form);
460 void applyRC(LyXRC & rc) const;
461 void updateRC(LyXRC const & rc);
462 void updateShortcutsTW();
466 void on_modifyPB_pressed();
467 void on_newPB_pressed();
468 void on_removePB_pressed();
469 void on_searchLE_textEdited();
471 void on_shortcutsTW_itemSelectionChanged();
472 void on_shortcutsTW_itemDoubleClicked();
474 void shortcutOkPressed();
475 void shortcutCancelPressed();
476 void shortcutClearPressed();
477 void shortcutRemovePressed();
480 void modifyShortcut();
481 /// remove selected binding, restore default value
482 void removeShortcut();
483 /// remove bindings, do not restore default values
484 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
485 /// check the new binding k->func, and remove existing bindings to k after
486 /// asking the user. We exclude lfun_to_modify from this test: we assume
487 /// that if the user clicked "modify" then they agreed to modify the
488 /// binding. Returns false if the shortcut is invalid or the user cancels.
489 bool validateNewShortcut(FuncRequest const & func,
490 KeySequence const & k,
491 QString const & lfun_to_modify);
492 /// compute current active shortcut
493 FuncRequest currentBinding(KeySequence const & k);
495 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
497 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
498 /// some items need to be always hidden, for instance empty rebound
500 static bool isAlwaysHidden(QTreeWidgetItem & item);
501 /// unhide an empty system binding that may have been hidden
502 /// returns either null or the unhidden shortcut
503 void unhideEmpty(QString const & lfun, bool select);
505 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
506 KeySequence const & shortcut, KeyMap::ItemType tag);
508 GuiShortcutDialog * shortcut_;
510 ButtonController shortcut_bc_;
512 QTreeWidgetItem * editItem_;
513 QTreeWidgetItem * mathItem_;
514 QTreeWidgetItem * bufferItem_;
515 QTreeWidgetItem * layoutItem_;
516 QTreeWidgetItem * systemItem_;
517 // system_bind_ holds bindings from rc.bind_file
518 // user_bind_ holds \bind bindings from user.bind
519 // user_unbind_ holds \unbind bindings from user.bind
520 // When an item is inserted, it is added to user_bind_
521 // When an item from system_bind_ is deleted, it is added to user_unbind_
522 // When an item in user_bind_ or user_unbind_ is deleted, it is
532 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
536 PrefIdentity(GuiPreferences * form);
538 void applyRC(LyXRC & rc) const;
539 void updateRC(LyXRC const & rc);
543 } // namespace frontend