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"
57 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
61 GuiPreferences(GuiView & lv);
63 void applyRC(LyXRC & rc) const;
64 void updateRC(LyXRC const & rc);
67 void change_adaptor();
68 void slotFileSelected(QString);
71 void prefsApplied(LyXRC const & rc);
75 void applyView() override;
77 std::vector<PrefModule *> modules_;
80 bool initialiseParams(std::string const &) override;
82 void clearParams() override {}
84 void dispatchParams() override;
86 bool isBufferDependent() const override { return false; }
88 /// various file pickers
89 QString browsebind(QString const & file);
90 QString browseUI(QString const & file);
91 QString browsekbmap(QString const & file);
94 QString browse(QString const & file, QString const & title) const;
97 void setColor(ColorCode col, QString const & hex);
99 LyXRC & rc() { return rc_; }
100 Converters & converters() { return converters_; }
101 Formats & formats() { return formats_; }
102 Movers & movers() { return movers_; }
106 void addModule(PrefModule * module);
108 QString browseLibFile(QString const & dir,
109 QString const & name, QString const & ext);
113 /// temporary converters
114 Converters converters_;
115 /// temporary formats
120 /// A list of colors to be dispatched
121 std::vector<std::string> colors_;
123 GuiLyXFiles * guilyxfiles_;
129 class PrefModule : public QWidget
133 PrefModule(QString const & cat, QString const & t,
134 GuiPreferences * form)
135 : QWidget(form), category_(cat), title_(t), form_(form)
138 virtual void applyRC(LyXRC & rc) const = 0;
139 virtual void updateRC(LyXRC const & rc) = 0;
141 QString const & category() const { return category_; }
142 QString const & title() const { return title_; }
147 GuiPreferences * form_;
154 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
158 PrefOutput(GuiPreferences * form);
160 void applyRC(LyXRC & rc) const override;
161 void updateRC(LyXRC const & rc) override;
165 class PrefInput : public PrefModule, public Ui::PrefInputUi
169 PrefInput(GuiPreferences * form);
171 void applyRC(LyXRC & rc) const override;
172 void updateRC(LyXRC const & rc) override;
175 void on_firstKeymapPB_clicked(bool);
176 void on_secondKeymapPB_clicked(bool);
177 void on_keymapCB_toggled(bool);
178 void on_scrollzoomEnableCB_toggled(bool);
181 QString testKeymap(QString const & keymap);
185 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
189 PrefCompletion(GuiPreferences * form);
191 void applyRC(LyXRC & rc) const override;
192 void updateRC(LyXRC const & rc) override;
193 virtual void enableCB();
195 void on_popupTextCB_clicked();
196 void on_inlineTextCB_clicked();
200 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
204 PrefLatex(GuiPreferences * form);
206 void applyRC(LyXRC & rc) const override;
207 void updateRC(LyXRC const & rc) override;
210 void on_latexBibtexCO_activated(int n);
211 void on_latexJBibtexCO_activated(int n);
212 void on_latexIndexCO_activated(int n);
216 std::set<std::string> bibtex_alternatives;
218 std::set<std::string> jbibtex_alternatives;
220 std::set<std::string> index_alternatives;
224 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
228 PrefScreenFonts(GuiPreferences * form);
230 void applyRC(LyXRC & rc) const override;
231 void updateRC(LyXRC const & rc) override;
234 void selectRoman(const QString&);
235 void selectSans(const QString&);
236 void selectTypewriter(const QString&);
239 void updateScreenFontSizes(LyXRC const & rc);
243 class PrefColors : public PrefModule, public Ui::PrefColorsUi
247 PrefColors(GuiPreferences * form);
249 void applyRC(LyXRC & rc) const override;
250 void updateRC(LyXRC const & rc) override;
255 void resetAllColor();
256 void changeSysColor();
257 void changeLyxObjectsSelection();
258 bool setColor(int const row, QColor const & new_color,
259 QString const & old_color);
260 bool isDefaultColor(int const row, QString const & color);
261 void setDisabledResets();
265 QColor getDefaultColorByRow(int const row);
267 std::vector<ColorCode> lcolors_;
269 std::vector<QString> curcolors_;
271 std::vector<QString> newcolors_;
275 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
279 PrefDisplay(GuiPreferences * form);
281 void applyRC(LyXRC & rc) const override;
282 void updateRC(LyXRC const & rc) override;
285 void on_instantPreviewCO_currentIndexChanged(int);
289 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
293 PrefPaths(GuiPreferences * form);
295 void applyRC(LyXRC & rc) const override;
296 void updateRC(LyXRC const & rc) override;
299 void selectExampledir();
300 void selectTemplatedir();
301 void selectTempdir();
302 void selectBackupdir();
303 void selectWorkingdir();
304 void selectThesaurusdir();
305 void selectHunspelldir();
306 void selectLyxPipe();
311 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
315 PrefSpellchecker(GuiPreferences * form);
317 void applyRC(LyXRC & rc) const override;
318 void updateRC(LyXRC const & rc) override;
321 void on_spellcheckerCB_currentIndexChanged(int);
325 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
329 PrefConverters(GuiPreferences * form);
331 void applyRC(LyXRC & rc) const override;
332 void updateRC(LyXRC const & rc) override;
338 void updateConverter();
339 void switchConverter();
340 void removeConverter();
341 void changeConverter();
342 void on_cacheCB_stateChanged(int state);
343 void on_needauthForbiddenCB_toggled(bool);
344 void on_needauthCB_toggled(bool);
347 void updateButtons();
351 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
355 PrefFileformats(GuiPreferences * form);
357 void applyRC(LyXRC & rc) const override;
358 void updateRC(LyXRC const & rc) override;
362 void formatsChanged();
365 void on_copierED_textEdited(const QString & s);
366 void on_extensionsED_textEdited(const QString &);
367 void on_viewerED_textEdited(const QString &);
368 void on_editorED_textEdited(const QString &);
369 void on_mimeED_textEdited(const QString &);
370 void on_shortcutED_textEdited(const QString &);
371 void on_formatED_editingFinished();
372 void on_formatED_textChanged(const QString &);
373 void on_formatsCB_currentIndexChanged(int);
374 void on_formatsCB_editTextChanged(const QString &);
375 void on_formatNewPB_clicked();
376 void on_formatRemovePB_clicked();
377 void on_viewerCO_currentIndexChanged(int i);
378 void on_editorCO_currentIndexChanged(int i);
380 void updatePrettyname();
383 Format & currentFormat();
385 void updateViewers();
387 void updateEditors();
389 LyXRC::Alternatives viewer_alternatives;
391 LyXRC::Alternatives editor_alternatives;
395 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
399 PrefLanguage(GuiPreferences * form);
401 void applyRC(LyXRC & rc) const override;
402 void updateRC(LyXRC const & rc) override;
405 void on_uiLanguageCO_currentIndexChanged(int);
406 void on_languagePackageCO_currentIndexChanged(int);
407 void on_defaultDecimalSepCO_currentIndexChanged(int);
410 QString save_langpack_;
414 class PrefUserInterface : public PrefModule, public Ui::PrefUi
418 PrefUserInterface(GuiPreferences * form);
420 void applyRC(LyXRC & rc) const override;
421 void updateRC(LyXRC const & rc) override;
428 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
432 PrefDocHandling(GuiPreferences * form);
434 void applyRC(LyXRC & rc) const override;
435 void updateRC(LyXRC const & rc) override;
438 void on_clearSessionPB_clicked();
443 class PrefEdit : public PrefModule, public Ui::PrefEditUi
447 PrefEdit(GuiPreferences * form);
449 void applyRC(LyXRC & rc) const override;
450 void updateRC(LyXRC const & rc) override;
453 void on_fullscreenLimitCB_toggled(bool);
454 void on_citationSearchCB_toggled(bool);
459 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
462 GuiShortcutDialog(QWidget * parent);
466 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
470 PrefShortcuts(GuiPreferences * form);
472 void applyRC(LyXRC & rc) const override;
473 void updateRC(LyXRC const & rc) override;
474 void updateShortcutsTW();
478 void on_modifyPB_pressed();
479 void on_newPB_pressed();
480 void on_removePB_pressed();
481 void on_searchLE_textEdited();
483 void on_shortcutsTW_itemSelectionChanged();
484 void on_shortcutsTW_itemDoubleClicked();
486 void shortcutOkPressed();
487 void shortcutCancelPressed();
488 void shortcutClearPressed();
489 void shortcutRemovePressed();
492 void modifyShortcut();
493 /// remove selected binding, restore default value
494 void removeShortcut();
495 /// remove bindings, do not restore default values
496 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
497 /// check the new binding k->func, and remove existing bindings to k after
498 /// asking the user. We exclude lfun_to_modify from this test: we assume
499 /// that if the user clicked "modify" then they agreed to modify the
500 /// binding. Returns false if the shortcut is invalid or the user cancels.
501 bool validateNewShortcut(FuncRequest const & func,
502 KeySequence const & k,
503 QString const & lfun_to_modify);
504 /// compute current active shortcut
505 FuncRequest currentBinding(KeySequence const & k);
507 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
509 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
510 /// some items need to be always hidden, for instance empty rebound
512 static bool isAlwaysHidden(QTreeWidgetItem & item);
513 /// unhide an empty system binding that may have been hidden
514 /// returns either null or the unhidden shortcut
515 void unhideEmpty(QString const & lfun, bool select);
517 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
518 KeySequence const & shortcut, KeyMap::ItemType tag);
520 GuiShortcutDialog * shortcut_;
522 ButtonController shortcut_bc_;
524 QTreeWidgetItem * editItem_;
525 QTreeWidgetItem * mathItem_;
526 QTreeWidgetItem * bufferItem_;
527 QTreeWidgetItem * layoutItem_;
528 QTreeWidgetItem * systemItem_;
529 // system_bind_ holds bindings from rc.bind_file
530 // user_bind_ holds \bind bindings from user.bind
531 // user_unbind_ holds \unbind bindings from user.bind
532 // When an item is inserted, it is added to user_bind_
533 // When an item from system_bind_ is deleted, it is added to user_unbind_
534 // When an item in user_bind_ or user_unbind_ is deleted, it is
544 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
548 PrefIdentity(GuiPreferences * form);
550 void applyRC(LyXRC & rc) const override;
551 void updateRC(LyXRC const & rc) override;
555 } // namespace frontend