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"
26 #include "ui_PrefsUi.h"
28 #include "ui_PrefOutputUi.h"
29 #include "ui_PrefInputUi.h"
30 #include "ui_PrefLatexUi.h"
31 #include "ui_PrefScreenFontsUi.h"
32 #include "ui_PrefCompletionUi.h"
33 #include "ui_PrefColorsUi.h"
34 #include "ui_PrefDisplayUi.h"
35 #include "ui_PrefDocHandlingUi.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_PrefUi.h"
44 #include "ui_PrefIdentityUi.h"
45 #include "ui_ShortcutUi.h"
58 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
62 GuiPreferences(GuiView & lv);
64 void applyRC(LyXRC & rc) const;
65 void updateRC(LyXRC const & rc);
68 void change_adaptor();
69 void slotFileSelected(QString);
72 void prefsApplied(LyXRC const & rc);
76 void applyView() override;
78 std::vector<PrefModule *> modules_;
81 bool initialiseParams(std::string const &) override;
83 void clearParams() override {}
85 void dispatchParams() override;
87 bool isBufferDependent() const override { return false; }
89 /// various file pickers
90 QString browsebind(QString const & file);
91 QString browseUI(QString const & file);
92 QString browsekbmap(QString const & file);
95 QString browse(QString const & file, QString const & title) const;
98 void setColor(ColorCode col, QString const & hex);
100 LyXRC & rc() { return rc_; }
101 Converters & converters() { return converters_; }
102 Formats & formats() { return formats_; }
103 Movers & movers() { return movers_; }
107 void addModule(PrefModule * module);
109 QString browseLibFile(QString const & dir,
110 QString const & name, QString const & ext);
114 /// temporary converters
115 Converters converters_;
116 /// temporary formats
121 /// A list of colors to be dispatched
122 std::vector<std::string> colors_;
124 GuiLyXFiles * guilyxfiles_;
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 applyRC(LyXRC & rc) const = 0;
140 virtual void updateRC(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 void applyRC(LyXRC & rc) const override;
162 void updateRC(LyXRC const & rc) override;
166 class PrefInput : public PrefModule, public Ui::PrefInputUi
170 PrefInput(GuiPreferences * form);
172 void applyRC(LyXRC & rc) const override;
173 void updateRC(LyXRC const & rc) override;
176 void on_firstKeymapPB_clicked(bool);
177 void on_secondKeymapPB_clicked(bool);
178 void on_keymapCB_toggled(bool);
179 void on_scrollzoomEnableCB_toggled(bool);
182 QString testKeymap(QString const & keymap);
186 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
190 PrefCompletion(GuiPreferences * form);
192 void applyRC(LyXRC & rc) const override;
193 void updateRC(LyXRC const & rc) override;
194 virtual void enableCB();
196 void on_popupTextCB_clicked();
197 void on_inlineTextCB_clicked();
201 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
205 PrefLatex(GuiPreferences * form);
207 void applyRC(LyXRC & rc) const override;
208 void updateRC(LyXRC const & rc) override;
211 void on_latexBibtexCO_activated(int n);
212 void on_latexJBibtexCO_activated(int n);
213 void on_latexIndexCO_activated(int n);
217 std::set<std::string> bibtex_alternatives;
219 std::set<std::string> jbibtex_alternatives;
221 std::set<std::string> index_alternatives;
225 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
229 PrefScreenFonts(GuiPreferences * form);
231 void applyRC(LyXRC & rc) const override;
232 void updateRC(LyXRC const & rc) override;
235 void selectRoman(const QString&);
236 void selectSans(const QString&);
237 void selectTypewriter(const QString&);
240 void updateScreenFontSizes(LyXRC const & rc);
244 class PrefColors : public PrefModule, public Ui::PrefColorsUi
248 PrefColors(GuiPreferences * form);
250 void applyRC(LyXRC & rc) const override;
251 void updateRC(LyXRC const & rc) override;
256 void resetAllColor();
257 void changeSysColor();
258 void changeLyxObjectsSelection();
259 bool setColor(int const row, QColor const & new_color,
260 QString const & old_color);
261 bool isDefaultColor(int const row, QString const & color);
262 void setDisabledResets();
266 QColor getDefaultColorByRow(int const row);
268 std::vector<ColorCode> lcolors_;
270 std::vector<QString> curcolors_;
272 std::vector<QString> newcolors_;
276 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
280 PrefDisplay(GuiPreferences * form);
282 void applyRC(LyXRC & rc) const override;
283 void updateRC(LyXRC const & rc) override;
286 void on_instantPreviewCO_currentIndexChanged(int);
290 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
294 PrefPaths(GuiPreferences * form);
296 void applyRC(LyXRC & rc) const override;
297 void updateRC(LyXRC const & rc) override;
300 void selectExampledir();
301 void selectTemplatedir();
302 void selectTempdir();
303 void selectBackupdir();
304 void selectWorkingdir();
305 void selectThesaurusdir();
306 void selectHunspelldir();
307 void selectLyxPipe();
312 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
316 PrefSpellchecker(GuiPreferences * form);
318 void applyRC(LyXRC & rc) const override;
319 void updateRC(LyXRC const & rc) override;
322 void on_spellcheckerCB_currentIndexChanged(int);
326 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
330 PrefConverters(GuiPreferences * form);
332 void applyRC(LyXRC & rc) const override;
333 void updateRC(LyXRC const & rc) override;
339 void updateConverter();
340 void switchConverter();
341 void removeConverter();
342 void changeConverter();
343 void on_cacheCB_stateChanged(int state);
344 void on_needauthForbiddenCB_toggled(bool);
345 void on_needauthCB_toggled(bool);
348 void updateButtons();
352 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
356 PrefFileformats(GuiPreferences * form);
358 void applyRC(LyXRC & rc) const override;
359 void updateRC(LyXRC const & rc) override;
363 void formatsChanged();
366 void on_copierED_textEdited(const QString & s);
367 void on_extensionsED_textEdited(const QString &);
368 void on_viewerED_textEdited(const QString &);
369 void on_editorED_textEdited(const QString &);
370 void on_mimeED_textEdited(const QString &);
371 void on_shortcutED_textEdited(const QString &);
372 void on_formatED_editingFinished();
373 void on_formatED_textChanged(const QString &);
374 void on_formatsCB_currentIndexChanged(int);
375 void on_formatsCB_editTextChanged(const QString &);
376 void on_formatNewPB_clicked();
377 void on_formatRemovePB_clicked();
378 void on_viewerCO_currentIndexChanged(int i);
379 void on_editorCO_currentIndexChanged(int i);
381 void updatePrettyname();
384 Format & currentFormat();
386 void updateViewers();
388 void updateEditors();
390 LyXRC::Alternatives viewer_alternatives;
392 LyXRC::Alternatives editor_alternatives;
396 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
400 PrefLanguage(GuiPreferences * form);
402 void applyRC(LyXRC & rc) const override;
403 void updateRC(LyXRC const & rc) override;
406 void on_uiLanguageCO_currentIndexChanged(int);
407 void on_languagePackageCO_currentIndexChanged(int);
408 void on_defaultDecimalSepCO_currentIndexChanged(int);
411 QString save_langpack_;
415 class PrefUserInterface : public PrefModule, public Ui::PrefUi
419 PrefUserInterface(GuiPreferences * form);
421 void applyRC(LyXRC & rc) const override;
422 void updateRC(LyXRC const & rc) override;
429 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
433 PrefDocHandling(GuiPreferences * form);
435 void applyRC(LyXRC & rc) const override;
436 void updateRC(LyXRC const & rc) override;
439 void on_clearSessionPB_clicked();
444 class PrefEdit : public PrefModule, public Ui::PrefEditUi
448 PrefEdit(GuiPreferences * form);
450 void applyRC(LyXRC & rc) const override;
451 void updateRC(LyXRC const & rc) override;
454 void on_screenLimitCB_toggled(bool);
455 void on_citationSearchCB_toggled(bool);
460 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
463 GuiShortcutDialog(QWidget * parent);
467 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
471 PrefShortcuts(GuiPreferences * form);
473 void applyRC(LyXRC & rc) const override;
474 void updateRC(LyXRC const & rc) override;
475 void updateShortcutsTW();
479 void on_modifyPB_pressed();
480 void on_newPB_pressed();
481 void on_removePB_pressed();
482 void on_searchLE_textEdited();
484 void on_shortcutsTW_itemSelectionChanged();
485 void on_shortcutsTW_itemDoubleClicked();
487 void shortcutOkPressed();
488 void shortcutCancelPressed();
489 void shortcutClearPressed();
490 void shortcutRemovePressed();
493 void modifyShortcut();
494 /// remove selected binding, restore default value
495 void removeShortcut();
496 /// remove bindings, do not restore default values
497 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
498 /// check the new binding k->func, and remove existing bindings to k after
499 /// asking the user. We exclude lfun_to_modify from this test: we assume
500 /// that if the user clicked "modify" then they agreed to modify the
501 /// binding. Returns false if the shortcut is invalid or the user cancels.
502 bool validateNewShortcut(FuncRequest const & func,
503 KeySequence const & k,
504 QString const & lfun_to_modify);
505 /// compute current active shortcut
506 FuncRequest currentBinding(KeySequence const & k);
508 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
510 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
511 /// some items need to be always hidden, for instance empty rebound
513 static bool isAlwaysHidden(QTreeWidgetItem & item);
514 /// unhide an empty system binding that may have been hidden
515 /// returns either null or the unhidden shortcut
516 void unhideEmpty(QString const & lfun, bool select);
518 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
519 KeySequence const & shortcut, KeyMap::ItemType tag);
521 GuiShortcutDialog * shortcut_;
523 ButtonController shortcut_bc_;
525 QTreeWidgetItem * editItem_;
526 QTreeWidgetItem * mathItem_;
527 QTreeWidgetItem * bufferItem_;
528 QTreeWidgetItem * layoutItem_;
529 QTreeWidgetItem * systemItem_;
530 // system_bind_ holds bindings from rc.bind_file
531 // user_bind_ holds \bind bindings from user.bind
532 // user_unbind_ holds \unbind bindings from user.bind
533 // When an item is inserted, it is added to user_bind_
534 // When an item from system_bind_ is deleted, it is added to user_unbind_
535 // When an item in user_bind_ or user_unbind_ is deleted, it is
545 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
549 PrefIdentity(GuiPreferences * form);
551 void applyRC(LyXRC & rc) const override;
552 void updateRC(LyXRC const & rc) override;
556 } // namespace frontend