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