]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
More llvm/clang warnings
[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 "ColorCode.h"
20 #include "Converter.h"
21 #include "Format.h"
22 #include "FuncCode.h"
23 #include "KeyMap.h"
24 #include "LyXRC.h"
25 #include "Mover.h"
26
27 #include "ui_PrefsUi.h"
28
29 #include "ui_PrefOutputUi.h"
30 #include "ui_PrefInputUi.h"
31 #include "ui_PrefLatexUi.h"
32 #include "ui_PrefScreenFontsUi.h"
33 #include "ui_PrefCompletionUi.h"
34 #include "ui_PrefColorsUi.h"
35 #include "ui_PrefDisplayUi.h"
36 #include "ui_PrefDocHandlingUi.h"
37 #include "ui_PrefEditUi.h"
38 #include "ui_PrefPathsUi.h"
39 #include "ui_PrefShortcutsUi.h"
40 #include "ui_PrefSpellcheckerUi.h"
41 #include "ui_PrefConvertersUi.h"
42 #include "ui_PrefFileformatsUi.h"
43 #include "ui_PrefLanguageUi.h"
44 #include "ui_PrefPrinterUi.h"
45 #include "ui_PrefUi.h"
46 #include "ui_PrefIdentityUi.h"
47 #include "ui_ShortcutUi.h"
48
49 #include <string>
50 #include <vector>
51
52
53 namespace lyx {
54
55 class Converters;
56 class Formats;
57 class Movers;
58
59 namespace frontend {
60
61 class PrefModule;
62
63 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
64 {
65         Q_OBJECT
66 public:
67         GuiPreferences(GuiView & lv);
68
69         void apply(LyXRC & rc) const;
70         void updateRc(LyXRC const & rc);
71
72 public Q_SLOTS:
73         void change_adaptor();
74
75 Q_SIGNALS:
76         void prefsApplied(LyXRC const & rc);
77
78 public:
79         /// Apply changes
80         void applyView();
81
82         std::vector<PrefModule *> modules_;
83
84         ///
85         bool initialiseParams(std::string const &);
86         ///
87         void clearParams() {}
88         ///
89         void dispatchParams();
90         ///
91         bool isBufferDependent() const { return false; }
92
93         /// various file pickers
94         QString browsebind(QString const & file) const;
95         QString browseUI(QString const & file) const;
96         QString browsekbmap(QString const & file) const;
97
98         /// general browse
99         QString browse(QString const & file, QString const & title) const;
100
101         /// set a color
102         void setColor(ColorCode col, QString const & hex);
103
104         /// update the screen fonts after change
105         void updateScreenFonts();
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 };
130
131
132 class PrefModule : public QWidget
133 {
134         Q_OBJECT
135 public:
136         PrefModule(QString const & cat, QString const & t,
137                         GuiPreferences * form)
138                 : QWidget(form), category_(cat), title_(t), form_(form)
139         {}
140
141         virtual void apply(LyXRC & rc) const = 0;
142         virtual void update(LyXRC const & rc) = 0;
143
144         QString const & category() const { return category_; }
145         QString const & title() const { return title_; }
146
147 protected:
148         QString category_;
149         QString title_;
150         GuiPreferences * form_;
151
152 Q_SIGNALS:
153         void changed();
154 };
155
156
157 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
158 {
159         Q_OBJECT
160 public:
161         PrefOutput(GuiPreferences * form);
162
163         virtual void apply(LyXRC & rc) const;
164         virtual void update(LyXRC const & rc);
165
166 private Q_SLOTS:
167         void on_DateED_textChanged(const QString &);
168 };
169
170
171 class PrefInput : public PrefModule, public Ui::PrefInputUi
172 {
173         Q_OBJECT
174 public:
175         PrefInput(GuiPreferences * form);
176
177         virtual void apply(LyXRC & rc) const;
178         virtual void update(LyXRC const & rc);
179
180 private Q_SLOTS:
181         void on_firstKeymapPB_clicked(bool);
182         void on_secondKeymapPB_clicked(bool);
183         void on_keymapCB_toggled(bool);
184         void on_scrollzoomEnableCB_toggled(bool);
185
186 private:
187         QString testKeymap(QString const & keymap);
188 };
189
190
191 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
192 {
193         Q_OBJECT
194 public:
195         PrefCompletion(GuiPreferences * form);
196
197         virtual void apply(LyXRC & rc) const;
198         virtual void update(LyXRC const & rc);
199         virtual void enableCB();
200 private Q_SLOTS:
201         void on_popupTextCB_clicked();
202         void on_inlineTextCB_clicked();
203 };
204
205
206 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
207 {
208         Q_OBJECT
209 public:
210         PrefLatex(GuiPreferences * form);
211
212         virtual void apply(LyXRC & rc) const;
213         virtual void update(LyXRC const & rc);
214
215 private Q_SLOTS:
216         void on_latexEncodingCB_stateChanged(int state);
217         void on_latexBibtexCO_activated(int n);
218         void on_latexIndexCO_activated(int n);
219
220 private:
221         ///
222         std::set<std::string> bibtex_alternatives;
223         ///
224         std::set<std::string> index_alternatives;
225 };
226
227
228 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
229 {
230         Q_OBJECT
231 public:
232         PrefScreenFonts(GuiPreferences * form);
233
234         virtual void apply(LyXRC & rc) const;
235         virtual void update(LyXRC const & rc);
236
237 private Q_SLOTS:
238         void selectRoman(const QString&);
239         void selectSans(const QString&);
240         void selectTypewriter(const QString&);
241
242 public Q_SLOTS:
243         void updateScreenFontSizes(LyXRC const & rc);
244 };
245
246
247 class PrefColors : public PrefModule, public Ui::PrefColorsUi
248 {
249         Q_OBJECT
250 public:
251         PrefColors(GuiPreferences * form);
252
253         void apply(LyXRC & rc) const;
254         void update(LyXRC const & rc);
255
256 private Q_SLOTS:
257         void changeColor();
258         void changeSysColor();
259         void changeLyxObjectsSelection();
260
261 private:
262         std::vector<ColorCode> lcolors_;
263         std::vector<QString> curcolors_;
264         std::vector<QString> newcolors_;
265 };
266
267
268 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
269 {
270         Q_OBJECT
271 public:
272         PrefDisplay(GuiPreferences * form);
273
274         void apply(LyXRC & rc) const;
275         void update(LyXRC const & rc);
276
277 private Q_SLOTS:
278         void on_instantPreviewCO_currentIndexChanged(int);
279 };
280
281
282 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
283 {
284         Q_OBJECT
285 public:
286         PrefPaths(GuiPreferences * form);
287
288         void apply(LyXRC & rc) const;
289         void update(LyXRC const & rc);
290
291 private Q_SLOTS:
292         void selectExampledir();
293         void selectTemplatedir();
294         void selectTempdir();
295         void selectBackupdir();
296         void selectWorkingdir();
297         void selectThesaurusdir();
298         void selectHunspelldir();
299         void selectLyxPipe();
300
301 };
302
303
304 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
305 {
306         Q_OBJECT
307 public:
308         PrefSpellchecker(GuiPreferences * form);
309
310         void apply(LyXRC & rc) const;
311         void update(LyXRC const & rc);
312
313 private Q_SLOTS:
314         void on_spellcheckerCB_currentIndexChanged(int);
315 };
316
317
318 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
319 {
320         Q_OBJECT
321 public:
322         PrefConverters(GuiPreferences * form);
323
324         void apply(LyXRC & rc) const;
325         void update(LyXRC const & rc);
326
327 public Q_SLOTS:
328         void updateGui();
329
330 private Q_SLOTS:
331         void updateConverter();
332         void switchConverter();
333         void removeConverter();
334         void changeConverter();
335         void on_cacheCB_stateChanged(int state);
336
337 private:
338         void updateButtons();
339 };
340
341
342 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
343 {
344         Q_OBJECT
345 public:
346         PrefFileformats(GuiPreferences * form);
347
348         void apply(LyXRC & rc) const;
349         void update(LyXRC const & rc);
350         void updateView();
351
352 Q_SIGNALS:
353         void formatsChanged();
354
355 private Q_SLOTS:
356         void on_copierED_textEdited(const QString & s);
357         void on_extensionsED_textEdited(const QString &);
358         void on_viewerED_textEdited(const QString &);
359         void on_editorED_textEdited(const QString &);
360         void on_mimeED_textEdited(const QString &);
361         void on_shortcutED_textEdited(const QString &);
362         void on_formatED_editingFinished();
363         void on_formatED_textChanged(const QString &);
364         void on_formatsCB_currentIndexChanged(int);
365         void on_formatsCB_editTextChanged(const QString &);
366         void on_formatNewPB_clicked();
367         void on_formatRemovePB_clicked();
368         void on_viewerCO_currentIndexChanged(int i);
369         void on_editorCO_currentIndexChanged(int i);
370         void setFlags();
371         void updatePrettyname();
372
373 private:
374         Format & currentFormat();
375         ///
376         void updateViewers();
377         ///
378         void updateEditors();
379         ///
380         LyXRC::Alternatives viewer_alternatives;
381         ///
382         LyXRC::Alternatives editor_alternatives;
383 };
384
385
386 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
387 {
388         Q_OBJECT
389 public:
390         PrefLanguage(GuiPreferences * form);
391
392         void apply(LyXRC & rc) const;
393         void update(LyXRC const & rc);
394
395 private Q_SLOTS:
396         void on_uiLanguageCO_currentIndexChanged(int);
397         void on_languagePackageCO_currentIndexChanged(int);
398 };
399
400
401 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
402 {
403         Q_OBJECT
404 public:
405         PrefPrinter(GuiPreferences * form);
406
407         void apply(LyXRC & rc) const;
408         void update(LyXRC const & rc);
409 };
410
411
412 class PrefUserInterface : public PrefModule, public Ui::PrefUi
413 {
414         Q_OBJECT
415 public:
416         PrefUserInterface(GuiPreferences * form);
417
418         void apply(LyXRC & rc) const;
419         void update(LyXRC const & rc);
420
421 public Q_SLOTS:
422         void selectUi();
423 };
424
425
426 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
427 {
428         Q_OBJECT
429 public:
430         PrefDocHandling(GuiPreferences * form);
431
432         void apply(LyXRC & rc) const;
433         void update(LyXRC const & rc);
434
435 public Q_SLOTS:
436         void on_clearSessionPB_clicked();
437 };
438
439
440
441 class PrefEdit : public PrefModule, public Ui::PrefEditUi
442 {
443         Q_OBJECT
444 public:
445         PrefEdit(GuiPreferences * form);
446
447         void apply(LyXRC & rc) const;
448         void update(LyXRC const & rc);
449 };
450
451
452
453 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
454 {
455 public:
456         GuiShortcutDialog(QWidget * parent);
457 };
458
459
460 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
461 {
462         Q_OBJECT
463 public:
464         PrefShortcuts(GuiPreferences * form);
465
466         void apply(LyXRC & rc) const;
467         void update(LyXRC const & rc);
468         void updateShortcutsTW();
469         void modifyShortcut();
470         void removeShortcut();
471         ///
472         void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
473         QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
474                 KeySequence const & shortcut, KeyMap::ItemType tag);
475
476 public Q_SLOTS:
477         void selectBind();
478         void on_modifyPB_pressed();
479         void on_newPB_pressed();
480         void on_removePB_pressed();
481         void on_searchLE_textEdited();
482         ///
483         void on_shortcutsTW_itemSelectionChanged();
484         void on_shortcutsTW_itemDoubleClicked();
485         ///
486         void shortcutOkPressed();
487         void shortcutCancelPressed();
488         void shortcutClearPressed();
489         void shortcutRemovePressed();
490
491 private:
492         ///
493         GuiShortcutDialog * shortcut_;
494         ///
495         ButtonController shortcut_bc_;
496         /// category items
497         QTreeWidgetItem * editItem_;
498         QTreeWidgetItem * mathItem_;
499         QTreeWidgetItem * bufferItem_;
500         QTreeWidgetItem * layoutItem_;
501         QTreeWidgetItem * systemItem_;
502         // system_bind_ holds bindings from rc.bind_file
503         // user_bind_ holds \bind bindings from user.bind
504         // user_unbind_ holds \unbind bindings from user.bind
505         // When an item is inserted, it is added to user_bind_
506         // When an item from system_bind_ is deleted, it is added to user_unbind_
507         // When an item in user_bind_ or user_unbind_ is deleted, it is 
508         //      deleted (unbind)
509         KeyMap system_bind_;
510         KeyMap user_bind_;
511         KeyMap user_unbind_;
512         ///
513         QString save_lfun_;
514 };
515
516
517 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
518 {
519         Q_OBJECT
520 public:
521         PrefIdentity(GuiPreferences * form);
522
523         void apply(LyXRC & rc) const;
524         void update(LyXRC const & rc);
525 };
526
527
528 } // namespace frontend
529 } // namespace lyx
530
531 #endif // GUIPREFS_H