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);
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&);
238 void screenFontsChanged();
241 void updateScreenFontSizes(LyXRC const & rc);
245 class PrefColors : public PrefModule, public Ui::PrefColorsUi
249 PrefColors(GuiPreferences * form);
251 void applyRC(LyXRC & rc) const override;
252 void updateRC(LyXRC const & rc) override;
257 void resetAllColor();
258 void changeSysColor();
259 void changeLyxObjectsSelection();
260 bool setColor(int const row, QColor const & new_color,
261 QString const & old_color);
262 bool isDefaultColor(int const row, QString const & color);
263 void setDisabledResets();
267 QColor getDefaultColorByRow(int const row);
269 std::vector<ColorCode> lcolors_;
271 std::vector<QString> curcolors_;
273 std::vector<QString> newcolors_;
277 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
281 PrefDisplay(GuiPreferences * form);
283 void applyRC(LyXRC & rc) const override;
284 void updateRC(LyXRC const & rc) override;
287 void on_instantPreviewCO_currentIndexChanged(int);
291 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
295 PrefPaths(GuiPreferences * form);
297 void applyRC(LyXRC & rc) const override;
298 void updateRC(LyXRC const & rc) override;
301 void selectExampledir();
302 void selectTemplatedir();
303 void selectTempdir();
304 void selectBackupdir();
305 void selectWorkingdir();
306 void selectThesaurusdir();
307 void selectHunspelldir();
308 void selectLyxPipe();
313 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
317 PrefSpellchecker(GuiPreferences * form);
319 void applyRC(LyXRC & rc) const override;
320 void updateRC(LyXRC const & rc) override;
323 void on_spellcheckerCB_currentIndexChanged(int);
327 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
331 PrefConverters(GuiPreferences * form);
333 void applyRC(LyXRC & rc) const override;
334 void updateRC(LyXRC const & rc) override;
340 void updateConverter();
341 void switchConverter();
342 void removeConverter();
343 void changeConverter();
344 void on_cacheCB_stateChanged(int state);
345 void on_needauthForbiddenCB_toggled(bool);
346 void on_needauthCB_toggled(bool);
349 void updateButtons();
353 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
357 PrefFileformats(GuiPreferences * form);
359 void applyRC(LyXRC & rc) const override;
360 void updateRC(LyXRC const & rc) override;
364 void formatsChanged();
367 void on_copierED_textEdited(const QString & s);
368 void on_extensionsED_textEdited(const QString &);
369 void on_viewerED_textEdited(const QString &);
370 void on_editorED_textEdited(const QString &);
371 void on_mimeED_textEdited(const QString &);
372 void on_shortcutED_textEdited(const QString &);
373 void on_formatED_editingFinished();
374 void on_formatED_textChanged(const QString &);
375 void on_formatsCB_currentIndexChanged(int);
376 void on_formatsCB_editTextChanged(const QString &);
377 void on_formatNewPB_clicked();
378 void on_formatRemovePB_clicked();
379 void on_viewerCO_currentIndexChanged(int i);
380 void on_editorCO_currentIndexChanged(int i);
382 void updatePrettyname();
385 Format & currentFormat();
387 void updateViewers();
389 void updateEditors();
391 LyXRC::Alternatives viewer_alternatives;
393 LyXRC::Alternatives editor_alternatives;
397 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
401 PrefLanguage(GuiPreferences * form);
403 void applyRC(LyXRC & rc) const override;
404 void updateRC(LyXRC const & rc) override;
407 void on_uiLanguageCO_currentIndexChanged(int);
408 void on_languagePackageCO_currentIndexChanged(int);
409 void on_defaultDecimalSepCO_currentIndexChanged(int);
412 QString save_langpack_;
416 class PrefUserInterface : public PrefModule, public Ui::PrefUi
420 PrefUserInterface(GuiPreferences * form);
422 void applyRC(LyXRC & rc) const override;
423 void updateRC(LyXRC const & rc) override;
430 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
434 PrefDocHandling(GuiPreferences * form);
436 void applyRC(LyXRC & rc) const override;
437 void updateRC(LyXRC const & rc) override;
440 void on_clearSessionPB_clicked();
445 class PrefEdit : public PrefModule, public Ui::PrefEditUi
449 PrefEdit(GuiPreferences * form);
451 void applyRC(LyXRC & rc) const override;
452 void updateRC(LyXRC const & rc) override;
455 void on_screenLimitCB_toggled(bool);
456 void on_citationSearchCB_toggled(bool);
461 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
465 GuiShortcutDialog(QWidget * parent);
468 void on_lfunLE_textChanged();
473 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
477 PrefShortcuts(GuiPreferences * form);
479 void applyRC(LyXRC & rc) const override;
480 void updateRC(LyXRC const & rc) override;
481 void updateShortcutsTW();
485 void on_modifyPB_pressed();
486 void on_newPB_pressed();
487 void on_removePB_pressed();
488 void on_searchLE_textEdited();
490 void on_shortcutsTW_itemSelectionChanged();
491 void on_shortcutsTW_itemDoubleClicked();
493 void shortcutOkPressed();
494 void shortcutCancelPressed();
495 void shortcutClearPressed();
496 void shortcutRemovePressed();
499 void modifyShortcut();
500 /// remove selected binding, restore default value
501 void removeShortcut();
502 /// remove bindings, do not restore default values
503 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
504 /// check the new binding k->func, and remove existing bindings to k after
505 /// asking the user. We exclude lfun_to_modify from this test: we assume
506 /// that if the user clicked "modify" then they agreed to modify the
507 /// binding. Returns false if the shortcut is invalid or the user cancels.
508 bool validateNewShortcut(FuncRequest const & func,
509 KeySequence const & k,
510 QString const & lfun_to_modify);
511 /// compute current active shortcut
512 FuncRequest currentBinding(KeySequence const & k);
514 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
516 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
517 /// some items need to be always hidden, for instance empty rebound
519 static bool isAlwaysHidden(QTreeWidgetItem & item);
520 /// unhide an empty system binding that may have been hidden
521 /// returns either null or the unhidden shortcut
522 void unhideEmpty(QString const & lfun, bool select);
524 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
525 KeySequence const & shortcut, KeyMap::ItemType tag);
527 GuiShortcutDialog * shortcut_;
529 ButtonController shortcut_bc_;
531 QTreeWidgetItem * editItem_;
532 QTreeWidgetItem * mathItem_;
533 QTreeWidgetItem * bufferItem_;
534 QTreeWidgetItem * layoutItem_;
535 QTreeWidgetItem * systemItem_;
536 // system_bind_ holds bindings from rc.bind_file
537 // user_bind_ holds \bind bindings from user.bind
538 // user_unbind_ holds \unbind bindings from user.bind
539 // When an item is inserted, it is added to user_bind_
540 // When an item from system_bind_ is deleted, it is added to user_unbind_
541 // When an item in user_bind_ or user_unbind_ is deleted, it is
551 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
555 PrefIdentity(GuiPreferences * form);
557 void applyRC(LyXRC & rc) const override;
558 void updateRC(LyXRC const & rc) override;
562 } // namespace frontend