]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
GuiBibtex: Use appropriate title when using Biblatex
[lyx.git] / src / frontends / qt4 / GuiPrefs.h
1 // -*- C++ -*-
2 /**
3  * \file GuiPrefs.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Bo Peng
9  * \author Edwin Leuven
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIPREFS_H
15 #define GUIPREFS_H
16
17 #include "GuiDialog.h"
18
19 #include "Converter.h"
20 #include "Format.h"
21 #include "KeyMap.h"
22 #include "LyXRC.h"
23 #include "Mover.h"
24
25 #include "ui_PrefsUi.h"
26
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"
45
46 #include <string>
47 #include <vector>
48
49
50 namespace lyx {
51
52 class Converters;
53 class Formats;
54 class Movers;
55
56 namespace frontend {
57
58 class PrefModule;
59
60 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
61 {
62         Q_OBJECT
63 public:
64         GuiPreferences(GuiView & lv);
65
66         void applyRC(LyXRC & rc) const;
67         void updateRC(LyXRC const & rc);
68
69 public Q_SLOTS:
70         void change_adaptor();
71
72 Q_SIGNALS:
73         void prefsApplied(LyXRC const & rc);
74
75 public:
76         /// Apply changes
77         void applyView();
78
79         std::vector<PrefModule *> modules_;
80
81         ///
82         bool initialiseParams(std::string const &);
83         ///
84         void clearParams() {}
85         ///
86         void dispatchParams();
87         ///
88         bool isBufferDependent() const { return false; }
89
90         /// various file pickers
91         QString browsebind(QString const & file) const;
92         QString browseUI(QString const & file) const;
93         QString browsekbmap(QString const & file) const;
94
95         /// general browse
96         QString browse(QString const & file, QString const & title) const;
97
98         /// set a color
99         void setColor(ColorCode col, QString const & hex);
100
101         /// update the screen fonts after change
102         void updateScreenFonts();
103
104         /// update the previews after change
105         void updatePreviews();
106
107         LyXRC & rc() { return rc_; }
108         Converters & converters() { return converters_; }
109         Formats & formats() { return formats_; }
110         Movers & movers() { return movers_; }
111
112 private:
113         ///
114         void addModule(PrefModule * module);
115
116         /// temporary lyxrc
117         LyXRC rc_;
118         /// temporary converters
119         Converters converters_;
120         /// temporary formats
121         Formats formats_;
122         /// temporary movers
123         Movers movers_;
124
125         /// A list of colors to be dispatched
126         std::vector<std::string> colors_;
127
128         bool update_screen_font_;
129         bool update_previews_;
130 };
131
132
133 class PrefModule : public QWidget
134 {
135         Q_OBJECT
136 public:
137         PrefModule(QString const & cat, QString const & t,
138                         GuiPreferences * form)
139                 : QWidget(form), category_(cat), title_(t), form_(form)
140         {}
141
142         virtual void applyRC(LyXRC & rc) const = 0;
143         virtual void updateRC(LyXRC const & rc) = 0;
144
145         QString const & category() const { return category_; }
146         QString const & title() const { return title_; }
147
148 protected:
149         QString category_;
150         QString title_;
151         GuiPreferences * form_;
152
153 Q_SIGNALS:
154         void changed();
155 };
156
157
158 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
159 {
160         Q_OBJECT
161 public:
162         PrefOutput(GuiPreferences * form);
163
164         virtual void applyRC(LyXRC & rc) const;
165         virtual void updateRC(LyXRC const & rc);
166
167 private Q_SLOTS:
168         void on_DateED_textChanged(const QString &);
169 };
170
171
172 class PrefInput : public PrefModule, public Ui::PrefInputUi
173 {
174         Q_OBJECT
175 public:
176         PrefInput(GuiPreferences * form);
177
178         virtual void applyRC(LyXRC & rc) const;
179         virtual void updateRC(LyXRC const & rc);
180
181 private Q_SLOTS:
182         void on_firstKeymapPB_clicked(bool);
183         void on_secondKeymapPB_clicked(bool);
184         void on_keymapCB_toggled(bool);
185         void on_scrollzoomEnableCB_toggled(bool);
186
187 private:
188         QString testKeymap(QString const & keymap);
189 };
190
191
192 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
193 {
194         Q_OBJECT
195 public:
196         PrefCompletion(GuiPreferences * form);
197
198         virtual void applyRC(LyXRC & rc) const;
199         virtual void updateRC(LyXRC const & rc);
200         virtual void enableCB();
201 private Q_SLOTS:
202         void on_popupTextCB_clicked();
203         void on_inlineTextCB_clicked();
204 };
205
206
207 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
208 {
209         Q_OBJECT
210 public:
211         PrefLatex(GuiPreferences * form);
212
213         virtual void applyRC(LyXRC & rc) const;
214         virtual void updateRC(LyXRC const & rc);
215
216 private Q_SLOTS:
217         void on_latexEncodingCB_stateChanged(int state);
218         void on_latexBibtexCO_activated(int n);
219         void on_latexJBibtexCO_activated(int n);
220         void on_latexIndexCO_activated(int n);
221
222 private:
223         ///
224         std::set<std::string> bibtex_alternatives;
225         ///
226         std::set<std::string> jbibtex_alternatives;
227         ///
228         std::set<std::string> index_alternatives;
229 };
230
231
232 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
233 {
234         Q_OBJECT
235 public:
236         PrefScreenFonts(GuiPreferences * form);
237
238         virtual void applyRC(LyXRC & rc) const;
239         virtual void updateRC(LyXRC const & rc);
240
241 private Q_SLOTS:
242         void selectRoman(const QString&);
243         void selectSans(const QString&);
244         void selectTypewriter(const QString&);
245
246 public Q_SLOTS:
247         void updateScreenFontSizes(LyXRC const & rc);
248 };
249
250
251 class PrefColors : public PrefModule, public Ui::PrefColorsUi
252 {
253         Q_OBJECT
254 public:
255         PrefColors(GuiPreferences * form);
256
257         void applyRC(LyXRC & rc) const;
258         void updateRC(LyXRC const & rc);
259
260 private Q_SLOTS:
261         void changeColor();
262         void changeSysColor();
263         void changeLyxObjectsSelection();
264
265 private:
266         std::vector<ColorCode> lcolors_;
267         std::vector<QString> curcolors_;
268         std::vector<QString> newcolors_;
269 };
270
271
272 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
273 {
274         Q_OBJECT
275 public:
276         PrefDisplay(GuiPreferences * form);
277
278         void applyRC(LyXRC & rc) const;
279         void updateRC(LyXRC const & rc);
280
281 private Q_SLOTS:
282         void on_instantPreviewCO_currentIndexChanged(int);
283 };
284
285
286 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
287 {
288         Q_OBJECT
289 public:
290         PrefPaths(GuiPreferences * form);
291
292         void applyRC(LyXRC & rc) const;
293         void updateRC(LyXRC const & rc);
294
295 private Q_SLOTS:
296         void selectExampledir();
297         void selectTemplatedir();
298         void selectTempdir();
299         void selectBackupdir();
300         void selectWorkingdir();
301         void selectThesaurusdir();
302         void selectHunspelldir();
303         void selectLyxPipe();
304
305 };
306
307
308 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
309 {
310         Q_OBJECT
311 public:
312         PrefSpellchecker(GuiPreferences * form);
313
314         void applyRC(LyXRC & rc) const;
315         void updateRC(LyXRC const & rc);
316
317 private Q_SLOTS:
318         void on_spellcheckerCB_currentIndexChanged(int);
319 };
320
321
322 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
323 {
324         Q_OBJECT
325 public:
326         PrefConverters(GuiPreferences * form);
327
328         void applyRC(LyXRC & rc) const;
329         void updateRC(LyXRC const & rc);
330
331 public Q_SLOTS:
332         void updateGui();
333
334 private Q_SLOTS:
335         void updateConverter();
336         void switchConverter();
337         void removeConverter();
338         void changeConverter();
339         void on_cacheCB_stateChanged(int state);
340         void on_needauthForbiddenCB_toggled(bool);
341         void on_needauthCB_toggled(bool);
342
343 private:
344         void updateButtons();
345 };
346
347
348 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
349 {
350         Q_OBJECT
351 public:
352         PrefFileformats(GuiPreferences * form);
353
354         void applyRC(LyXRC & rc) const;
355         void updateRC(LyXRC const & rc);
356         void updateView();
357
358 Q_SIGNALS:
359         void formatsChanged();
360
361 private Q_SLOTS:
362         void on_copierED_textEdited(const QString & s);
363         void on_extensionsED_textEdited(const QString &);
364         void on_viewerED_textEdited(const QString &);
365         void on_editorED_textEdited(const QString &);
366         void on_mimeED_textEdited(const QString &);
367         void on_shortcutED_textEdited(const QString &);
368         void on_formatED_editingFinished();
369         void on_formatED_textChanged(const QString &);
370         void on_formatsCB_currentIndexChanged(int);
371         void on_formatsCB_editTextChanged(const QString &);
372         void on_formatNewPB_clicked();
373         void on_formatRemovePB_clicked();
374         void on_viewerCO_currentIndexChanged(int i);
375         void on_editorCO_currentIndexChanged(int i);
376         void setFlags();
377         void updatePrettyname();
378
379 private:
380         Format & currentFormat();
381         ///
382         void updateViewers();
383         ///
384         void updateEditors();
385         ///
386         LyXRC::Alternatives viewer_alternatives;
387         ///
388         LyXRC::Alternatives editor_alternatives;
389 };
390
391
392 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
393 {
394         Q_OBJECT
395 public:
396         PrefLanguage(GuiPreferences * form);
397
398         void applyRC(LyXRC & rc) const;
399         void updateRC(LyXRC const & rc);
400
401 private Q_SLOTS:
402         void on_uiLanguageCO_currentIndexChanged(int);
403         void on_languagePackageCO_currentIndexChanged(int);
404 };
405
406
407 class PrefUserInterface : public PrefModule, public Ui::PrefUi
408 {
409         Q_OBJECT
410 public:
411         PrefUserInterface(GuiPreferences * form);
412
413         void applyRC(LyXRC & rc) const;
414         void updateRC(LyXRC const & rc);
415
416 public Q_SLOTS:
417         void selectUi();
418 };
419
420
421 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
422 {
423         Q_OBJECT
424 public:
425         PrefDocHandling(GuiPreferences * form);
426
427         void applyRC(LyXRC & rc) const;
428         void updateRC(LyXRC const & rc);
429
430 public Q_SLOTS:
431         void on_clearSessionPB_clicked();
432 };
433
434
435
436 class PrefEdit : public PrefModule, public Ui::PrefEditUi
437 {
438         Q_OBJECT
439 public:
440         PrefEdit(GuiPreferences * form);
441
442         void applyRC(LyXRC & rc) const;
443         void updateRC(LyXRC const & rc);
444 };
445
446
447
448 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
449 {
450 public:
451         GuiShortcutDialog(QWidget * parent);
452 };
453
454
455 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
456 {
457         Q_OBJECT
458 public:
459         PrefShortcuts(GuiPreferences * form);
460
461         void applyRC(LyXRC & rc) const;
462         void updateRC(LyXRC const & rc);
463         void updateShortcutsTW();
464
465 public Q_SLOTS:
466         void selectBind();
467         void on_modifyPB_pressed();
468         void on_newPB_pressed();
469         void on_removePB_pressed();
470         void on_searchLE_textEdited();
471         ///
472         void on_shortcutsTW_itemSelectionChanged();
473         void on_shortcutsTW_itemDoubleClicked();
474         ///
475         void shortcutOkPressed();
476         void shortcutCancelPressed();
477         void shortcutClearPressed();
478         void shortcutRemovePressed();
479
480 private:
481         void modifyShortcut();
482         /// remove selected binding, restore default value
483         void removeShortcut();
484         /// remove bindings, do not restore default values
485         void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
486         /// check the new binding k->func, and remove existing bindings to k after
487         /// asking the user. We exclude lfun_to_modify from this test: we assume
488         /// that if the user clicked "modify" then they agreed to modify the
489         /// binding. Returns false if the shortcut is invalid or the user cancels.
490         bool validateNewShortcut(FuncRequest const & func,
491                                  KeySequence const & k,
492                                  QString const & lfun_to_modify);
493         /// compute current active shortcut
494         FuncRequest currentBinding(KeySequence const & k);
495         ///
496         void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
497         ///
498         static KeyMap::ItemType itemType(QTreeWidgetItem & item);
499         /// some items need to be always hidden, for instance empty rebound
500         /// system keys
501         static bool isAlwaysHidden(QTreeWidgetItem & item);
502         /// unhide an empty system binding that may have been hidden
503         /// returns either null or the unhidden shortcut
504         void unhideEmpty(QString const & lfun, bool select);
505         ///
506         QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
507                 KeySequence const & shortcut, KeyMap::ItemType tag);
508         ///
509         GuiShortcutDialog * shortcut_;
510         ///
511         ButtonController shortcut_bc_;
512         /// category items
513         QTreeWidgetItem * editItem_;
514         QTreeWidgetItem * mathItem_;
515         QTreeWidgetItem * bufferItem_;
516         QTreeWidgetItem * layoutItem_;
517         QTreeWidgetItem * systemItem_;
518         // system_bind_ holds bindings from rc.bind_file
519         // user_bind_ holds \bind bindings from user.bind
520         // user_unbind_ holds \unbind bindings from user.bind
521         // When an item is inserted, it is added to user_bind_
522         // When an item from system_bind_ is deleted, it is added to user_unbind_
523         // When an item in user_bind_ or user_unbind_ is deleted, it is
524         //      deleted (unbind)
525         KeyMap system_bind_;
526         KeyMap user_bind_;
527         KeyMap user_unbind_;
528         ///
529         QString save_lfun_;
530 };
531
532
533 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
534 {
535         Q_OBJECT
536 public:
537         PrefIdentity(GuiPreferences * form);
538
539         void applyRC(LyXRC & rc) const;
540         void updateRC(LyXRC const & rc);
541 };
542
543
544 } // namespace frontend
545 } // namespace lyx
546
547 #endif // GUIPREFS_H