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_latexIndexCO_activated(int n);
223 std::set<std::string> bibtex_alternatives;
225 std::set<std::string> index_alternatives;
229 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
233 PrefScreenFonts(GuiPreferences * form);
235 virtual void applyRC(LyXRC & rc) const;
236 virtual void updateRC(LyXRC const & rc);
239 void selectRoman(const QString&);
240 void selectSans(const QString&);
241 void selectTypewriter(const QString&);
244 void updateScreenFontSizes(LyXRC const & rc);
248 class PrefColors : public PrefModule, public Ui::PrefColorsUi
252 PrefColors(GuiPreferences * form);
254 void applyRC(LyXRC & rc) const;
255 void updateRC(LyXRC const & rc);
259 void changeSysColor();
260 void changeLyxObjectsSelection();
263 std::vector<ColorCode> lcolors_;
264 std::vector<QString> curcolors_;
265 std::vector<QString> newcolors_;
269 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
273 PrefDisplay(GuiPreferences * form);
275 void applyRC(LyXRC & rc) const;
276 void updateRC(LyXRC const & rc);
279 void on_instantPreviewCO_currentIndexChanged(int);
283 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
287 PrefPaths(GuiPreferences * form);
289 void applyRC(LyXRC & rc) const;
290 void updateRC(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 applyRC(LyXRC & rc) const;
312 void updateRC(LyXRC const & rc);
315 void on_spellcheckerCB_currentIndexChanged(int);
319 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
323 PrefConverters(GuiPreferences * form);
325 void applyRC(LyXRC & rc) const;
326 void updateRC(LyXRC const & rc);
332 void updateConverter();
333 void switchConverter();
334 void removeConverter();
335 void changeConverter();
336 void on_cacheCB_stateChanged(int state);
337 void on_needauthForbiddenCB_toggled(bool);
340 void updateButtons();
344 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
348 PrefFileformats(GuiPreferences * form);
350 void applyRC(LyXRC & rc) const;
351 void updateRC(LyXRC const & rc);
355 void formatsChanged();
358 void on_copierED_textEdited(const QString & s);
359 void on_extensionsED_textEdited(const QString &);
360 void on_viewerED_textEdited(const QString &);
361 void on_editorED_textEdited(const QString &);
362 void on_mimeED_textEdited(const QString &);
363 void on_shortcutED_textEdited(const QString &);
364 void on_formatED_editingFinished();
365 void on_formatED_textChanged(const QString &);
366 void on_formatsCB_currentIndexChanged(int);
367 void on_formatsCB_editTextChanged(const QString &);
368 void on_formatNewPB_clicked();
369 void on_formatRemovePB_clicked();
370 void on_viewerCO_currentIndexChanged(int i);
371 void on_editorCO_currentIndexChanged(int i);
373 void updatePrettyname();
376 Format & currentFormat();
378 void updateViewers();
380 void updateEditors();
382 LyXRC::Alternatives viewer_alternatives;
384 LyXRC::Alternatives editor_alternatives;
388 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
392 PrefLanguage(GuiPreferences * form);
394 void applyRC(LyXRC & rc) const;
395 void updateRC(LyXRC const & rc);
398 void on_uiLanguageCO_currentIndexChanged(int);
399 void on_languagePackageCO_currentIndexChanged(int);
403 class PrefUserInterface : public PrefModule, public Ui::PrefUi
407 PrefUserInterface(GuiPreferences * form);
409 void applyRC(LyXRC & rc) const;
410 void updateRC(LyXRC const & rc);
417 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
421 PrefDocHandling(GuiPreferences * form);
423 void applyRC(LyXRC & rc) const;
424 void updateRC(LyXRC const & rc);
427 void on_clearSessionPB_clicked();
432 class PrefEdit : public PrefModule, public Ui::PrefEditUi
436 PrefEdit(GuiPreferences * form);
438 void applyRC(LyXRC & rc) const;
439 void updateRC(LyXRC const & rc);
444 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
447 GuiShortcutDialog(QWidget * parent);
451 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
455 PrefShortcuts(GuiPreferences * form);
457 void applyRC(LyXRC & rc) const;
458 void updateRC(LyXRC const & rc);
459 void updateShortcutsTW();
463 void on_modifyPB_pressed();
464 void on_newPB_pressed();
465 void on_removePB_pressed();
466 void on_searchLE_textEdited();
468 void on_shortcutsTW_itemSelectionChanged();
469 void on_shortcutsTW_itemDoubleClicked();
471 void shortcutOkPressed();
472 void shortcutCancelPressed();
473 void shortcutClearPressed();
474 void shortcutRemovePressed();
477 void modifyShortcut();
478 /// remove selected binding, restore default value
479 void removeShortcut();
480 /// remove bindings, do not restore default values
481 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
482 /// check the new binding k->func, and remove existing bindings to k after
483 /// asking the user. We exclude lfun_to_modify from this test: we assume
484 /// that if the user clicked "modify" then they agreed to modify the
485 /// binding. Returns false if the shortcut is invalid or the user cancels.
486 bool validateNewShortcut(FuncRequest const & func,
487 KeySequence const & k,
488 QString const & lfun_to_modify);
489 /// compute current active shortcut
490 FuncRequest currentBinding(KeySequence const & k);
492 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
494 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
495 /// some items need to be always hidden, for instance empty rebound
497 static bool isAlwaysHidden(QTreeWidgetItem & item);
498 /// unhide an empty system binding that may have been hidden
499 /// returns either null or the unhidden shortcut
500 void unhideEmpty(QString const & lfun, bool select);
502 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
503 KeySequence const & shortcut, KeyMap::ItemType tag);
505 GuiShortcutDialog * shortcut_;
507 ButtonController shortcut_bc_;
509 QTreeWidgetItem * editItem_;
510 QTreeWidgetItem * mathItem_;
511 QTreeWidgetItem * bufferItem_;
512 QTreeWidgetItem * layoutItem_;
513 QTreeWidgetItem * systemItem_;
514 // system_bind_ holds bindings from rc.bind_file
515 // user_bind_ holds \bind bindings from user.bind
516 // user_unbind_ holds \unbind bindings from user.bind
517 // When an item is inserted, it is added to user_bind_
518 // When an item from system_bind_ is deleted, it is added to user_unbind_
519 // When an item in user_bind_ or user_unbind_ is deleted, it is
529 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
533 PrefIdentity(GuiPreferences * form);
535 void applyRC(LyXRC & rc) const;
536 void updateRC(LyXRC const & rc);
540 } // namespace frontend