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);
81 std::vector<PrefModule *> modules_;
84 bool initialiseParams(std::string const &);
88 void dispatchParams();
90 bool isBufferDependent() const { 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 virtual void applyRC(LyXRC & rc) const;
165 virtual void updateRC(LyXRC const & rc);
169 class PrefInput : public PrefModule, public Ui::PrefInputUi
173 PrefInput(GuiPreferences * form);
175 virtual void applyRC(LyXRC & rc) const;
176 virtual void updateRC(LyXRC const & rc);
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 virtual void applyRC(LyXRC & rc) const;
196 virtual void updateRC(LyXRC const & rc);
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 virtual void applyRC(LyXRC & rc) const;
211 virtual void updateRC(LyXRC const & rc);
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 virtual void applyRC(LyXRC & rc) const;
235 virtual void updateRC(LyXRC const & rc);
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;
254 void updateRC(LyXRC const & rc);
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;
286 void updateRC(LyXRC const & rc);
289 void on_instantPreviewCO_currentIndexChanged(int);
293 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
297 PrefPaths(GuiPreferences * form);
299 void applyRC(LyXRC & rc) const;
300 void updateRC(LyXRC const & rc);
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;
322 void updateRC(LyXRC const & rc);
325 void on_spellcheckerCB_currentIndexChanged(int);
329 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
333 PrefConverters(GuiPreferences * form);
335 void applyRC(LyXRC & rc) const;
336 void updateRC(LyXRC const & rc);
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;
362 void updateRC(LyXRC const & rc);
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;
406 void updateRC(LyXRC const & rc);
409 void on_uiLanguageCO_currentIndexChanged(int);
410 void on_languagePackageCO_currentIndexChanged(int);
414 class PrefUserInterface : public PrefModule, public Ui::PrefUi
418 PrefUserInterface(GuiPreferences * form);
420 void applyRC(LyXRC & rc) const;
421 void updateRC(LyXRC const & rc);
428 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
432 PrefDocHandling(GuiPreferences * form);
434 void applyRC(LyXRC & rc) const;
435 void updateRC(LyXRC const & rc);
438 void on_clearSessionPB_clicked();
443 class PrefEdit : public PrefModule, public Ui::PrefEditUi
447 PrefEdit(GuiPreferences * form);
449 void applyRC(LyXRC & rc) const;
450 void updateRC(LyXRC const & rc);
455 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
458 GuiShortcutDialog(QWidget * parent);
462 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
466 PrefShortcuts(GuiPreferences * form);
468 void applyRC(LyXRC & rc) const;
469 void updateRC(LyXRC const & rc);
470 void updateShortcutsTW();
474 void on_modifyPB_pressed();
475 void on_newPB_pressed();
476 void on_removePB_pressed();
477 void on_searchLE_textEdited();
479 void on_shortcutsTW_itemSelectionChanged();
480 void on_shortcutsTW_itemDoubleClicked();
482 void shortcutOkPressed();
483 void shortcutCancelPressed();
484 void shortcutClearPressed();
485 void shortcutRemovePressed();
488 void modifyShortcut();
489 /// remove selected binding, restore default value
490 void removeShortcut();
491 /// remove bindings, do not restore default values
492 void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
493 /// check the new binding k->func, and remove existing bindings to k after
494 /// asking the user. We exclude lfun_to_modify from this test: we assume
495 /// that if the user clicked "modify" then they agreed to modify the
496 /// binding. Returns false if the shortcut is invalid or the user cancels.
497 bool validateNewShortcut(FuncRequest const & func,
498 KeySequence const & k,
499 QString const & lfun_to_modify);
500 /// compute current active shortcut
501 FuncRequest currentBinding(KeySequence const & k);
503 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
505 static KeyMap::ItemType itemType(QTreeWidgetItem & item);
506 /// some items need to be always hidden, for instance empty rebound
508 static bool isAlwaysHidden(QTreeWidgetItem & item);
509 /// unhide an empty system binding that may have been hidden
510 /// returns either null or the unhidden shortcut
511 void unhideEmpty(QString const & lfun, bool select);
513 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
514 KeySequence const & shortcut, KeyMap::ItemType tag);
516 GuiShortcutDialog * shortcut_;
518 ButtonController shortcut_bc_;
520 QTreeWidgetItem * editItem_;
521 QTreeWidgetItem * mathItem_;
522 QTreeWidgetItem * bufferItem_;
523 QTreeWidgetItem * layoutItem_;
524 QTreeWidgetItem * systemItem_;
525 // system_bind_ holds bindings from rc.bind_file
526 // user_bind_ holds \bind bindings from user.bind
527 // user_unbind_ holds \unbind bindings from user.bind
528 // When an item is inserted, it is added to user_bind_
529 // When an item from system_bind_ is deleted, it is added to user_unbind_
530 // When an item in user_bind_ or user_unbind_ is deleted, it is
540 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
544 PrefIdentity(GuiPreferences * form);
546 void applyRC(LyXRC & rc) const;
547 void updateRC(LyXRC const & rc);
551 } // namespace frontend