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"
18 #include "GuiLyXFiles.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"
61 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
65 GuiPreferences(GuiView & lv);
67 void applyRC(LyXRC & rc) const;
68 void updateRC(LyXRC const & rc);
71 void change_adaptor();
72 void slotFileSelected(QString);
75 void prefsApplied(LyXRC const & rc);
79 void applyView() override;
81 std::vector<PrefModule *> modules_;
84 bool initialiseParams(std::string const &) override;
86 void clearParams() override {}
88 void dispatchParams() override;
90 bool isBufferDependent() const override { return false; }
92 /// various file pickers
93 QString browsebind(QString const & file);
94 QString browseUI(QString const & file);
95 QString browsekbmap(QString const & file);
98 QString browse(QString const & file, QString const & title) const;
101 void setColor(ColorCode col, QString const & hex);
103 LyXRC & rc() { return rc_; }
104 Converters & converters() { return converters_; }
105 Formats & formats() { return formats_; }
106 Movers & movers() { return movers_; }
110 void addModule(PrefModule * module);
112 QString browseLibFile(QString const & dir,
113 QString const & name, QString const & ext);
117 /// temporary converters
118 Converters converters_;
119 /// temporary formats
124 /// A list of colors to be dispatched
125 std::vector<std::string> colors_;
127 GuiLyXFiles * guilyxfiles_;
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 void applyRC(LyXRC & rc) const override;
165 void updateRC(LyXRC const & rc) override;
169 class PrefInput : public PrefModule, public Ui::PrefInputUi
173 PrefInput(GuiPreferences * form);
175 void applyRC(LyXRC & rc) const override;
176 void updateRC(LyXRC const & rc) override;
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 void applyRC(LyXRC & rc) const override;
196 void updateRC(LyXRC const & rc) override;
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 void applyRC(LyXRC & rc) const override;
211 void updateRC(LyXRC const & rc) override;
214 void on_latexBibtexCO_activated(int n);
215 void on_latexJBibtexCO_activated(int n);
216 void on_latexIndexCO_activated(int n);
220 std::set<std::string> bibtex_alternatives;
222 std::set<std::string> jbibtex_alternatives;
224 std::set<std::string> index_alternatives;
228 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
232 PrefScreenFonts(GuiPreferences * form);
234 void applyRC(LyXRC & rc) const override;
235 void updateRC(LyXRC const & rc) override;
238 void selectRoman(const QString&);
239 void selectSans(const QString&);
240 void selectTypewriter(const QString&);
243 void updateScreenFontSizes(LyXRC const & rc);
247 class PrefColors : public PrefModule, public Ui::PrefColorsUi
251 PrefColors(GuiPreferences * form);
253 void applyRC(LyXRC & rc) const override;
254 void updateRC(LyXRC const & rc) override;
259 void resetAllColor();
260 void changeSysColor();
261 void changeLyxObjectsSelection();
262 bool setColor(int const row, QColor const new_color,
263 QString const old_color);
264 bool isDefaultColor(int const row, QString const color);
265 void setDisabledResets();
269 QColor getDefaultColorByRow(int const row);
271 std::vector<ColorCode> lcolors_;
273 std::vector<QString> curcolors_;
275 std::vector<QString> newcolors_;
279 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
283 PrefDisplay(GuiPreferences * form);
285 void applyRC(LyXRC & rc) const override;
286 void updateRC(LyXRC const & rc) override;
289 void on_instantPreviewCO_currentIndexChanged(int);
293 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
297 PrefPaths(GuiPreferences * form);
299 void applyRC(LyXRC & rc) const override;
300 void updateRC(LyXRC const & rc) override;
303 void selectExampledir();
304 void selectTemplatedir();
305 void selectTempdir();
306 void selectBackupdir();
307 void selectWorkingdir();
308 void selectThesaurusdir();
309 void selectHunspelldir();
310 void selectLyxPipe();
315 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
319 PrefSpellchecker(GuiPreferences * form);
321 void applyRC(LyXRC & rc) const override;
322 void updateRC(LyXRC const & rc) override;
325 void on_spellcheckerCB_currentIndexChanged(int);
329 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
333 PrefConverters(GuiPreferences * form);
335 void applyRC(LyXRC & rc) const override;
336 void updateRC(LyXRC const & rc) override;
342 void updateConverter();
343 void switchConverter();
344 void removeConverter();
345 void changeConverter();
346 void on_cacheCB_stateChanged(int state);
347 void on_needauthForbiddenCB_toggled(bool);
348 void on_needauthCB_toggled(bool);
351 void updateButtons();
355 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
359 PrefFileformats(GuiPreferences * form);
361 void applyRC(LyXRC & rc) const override;
362 void updateRC(LyXRC const & rc) override;
366 void formatsChanged();
369 void on_copierED_textEdited(const QString & s);
370 void on_extensionsED_textEdited(const QString &);
371 void on_viewerED_textEdited(const QString &);
372 void on_editorED_textEdited(const QString &);
373 void on_mimeED_textEdited(const QString &);
374 void on_shortcutED_textEdited(const QString &);
375 void on_formatED_editingFinished();
376 void on_formatED_textChanged(const QString &);
377 void on_formatsCB_currentIndexChanged(int);
378 void on_formatsCB_editTextChanged(const QString &);
379 void on_formatNewPB_clicked();
380 void on_formatRemovePB_clicked();
381 void on_viewerCO_currentIndexChanged(int i);
382 void on_editorCO_currentIndexChanged(int i);
384 void updatePrettyname();
387 Format & currentFormat();
389 void updateViewers();
391 void updateEditors();
393 LyXRC::Alternatives viewer_alternatives;
395 LyXRC::Alternatives editor_alternatives;
399 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
403 PrefLanguage(GuiPreferences * form);
405 void applyRC(LyXRC & rc) const override;
406 void updateRC(LyXRC const & rc) override;
409 void on_uiLanguageCO_currentIndexChanged(int);
410 void on_languagePackageCO_currentIndexChanged(int);
411 void on_defaultDecimalSepCO_currentIndexChanged(int);
414 QString save_langpack_;
418 class PrefUserInterface : public PrefModule, public Ui::PrefUi
422 PrefUserInterface(GuiPreferences * form);
424 void applyRC(LyXRC & rc) const override;
425 void updateRC(LyXRC const & rc) override;
432 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
436 PrefDocHandling(GuiPreferences * form);
438 void applyRC(LyXRC & rc) const override;
439 void updateRC(LyXRC const & rc) override;
442 void on_clearSessionPB_clicked();
447 class PrefEdit : public PrefModule, public Ui::PrefEditUi
451 PrefEdit(GuiPreferences * form);
453 void applyRC(LyXRC & rc) const override;
454 void updateRC(LyXRC const & rc) override;
457 void on_fullscreenLimitCB_toggled(bool);
458 void on_citationSearchCB_toggled(bool);
463 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
466 GuiShortcutDialog(QWidget * parent);
470 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
474 PrefShortcuts(GuiPreferences * form);
476 void applyRC(LyXRC & rc) const override;
477 void updateRC(LyXRC const & rc) override;
478 void updateShortcutsTW();
482 void on_modifyPB_pressed();
483 void on_newPB_pressed();
484 void on_removePB_pressed();
485 void on_searchLE_textEdited();
487 void on_shortcutsTW_itemSelectionChanged();
488 void on_shortcutsTW_itemDoubleClicked();
490 void shortcutOkPressed();
491 void shortcutCancelPressed();
492 void shortcutClearPressed();
493 void shortcutRemovePressed();
496 void modifyShortcut();
497 /// remove selected binding, restore default value
498 void removeShortcut();
499 /// remove bindings, do not restore default values
500 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
501 /// check the new binding k->func, and remove existing bindings to k after
502 /// asking the user. We exclude lfun_to_modify from this test: we assume
503 /// that if the user clicked "modify" then they agreed to modify the
504 /// binding. Returns false if the shortcut is invalid or the user cancels.
505 bool validateNewShortcut(FuncRequest const & func,
506 KeySequence const & k,
507 QString const & lfun_to_modify);
508 /// compute current active shortcut
509 FuncRequest currentBinding(KeySequence const & k);
511 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
513 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
514 /// some items need to be always hidden, for instance empty rebound
516 static bool isAlwaysHidden(QTreeWidgetItem & item);
517 /// unhide an empty system binding that may have been hidden
518 /// returns either null or the unhidden shortcut
519 void unhideEmpty(QString const & lfun, bool select);
521 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
522 KeySequence const & shortcut, KeyMap::ItemType tag);
524 GuiShortcutDialog * shortcut_;
526 ButtonController shortcut_bc_;
528 QTreeWidgetItem * editItem_;
529 QTreeWidgetItem * mathItem_;
530 QTreeWidgetItem * bufferItem_;
531 QTreeWidgetItem * layoutItem_;
532 QTreeWidgetItem * systemItem_;
533 // system_bind_ holds bindings from rc.bind_file
534 // user_bind_ holds \bind bindings from user.bind
535 // user_unbind_ holds \unbind bindings from user.bind
536 // When an item is inserted, it is added to user_bind_
537 // When an item from system_bind_ is deleted, it is added to user_unbind_
538 // When an item in user_bind_ or user_unbind_ is deleted, it is
548 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
552 PrefIdentity(GuiPreferences * form);
554 void applyRC(LyXRC & rc) const override;
555 void updateRC(LyXRC const & rc) override;
559 } // namespace frontend