]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
Amend f441590c
[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_latexIndexCO_activated(int n);
220
221 private:
222         ///
223         std::set<std::string> bibtex_alternatives;
224         ///
225         std::set<std::string> index_alternatives;
226 };
227
228
229 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
230 {
231         Q_OBJECT
232 public:
233         PrefScreenFonts(GuiPreferences * form);
234
235         virtual void applyRC(LyXRC & rc) const;
236         virtual void updateRC(LyXRC const & rc);
237
238 private Q_SLOTS:
239         void selectRoman(const QString&);
240         void selectSans(const QString&);
241         void selectTypewriter(const QString&);
242
243 public Q_SLOTS:
244         void updateScreenFontSizes(LyXRC const & rc);
245 };
246
247
248 class PrefColors : public PrefModule, public Ui::PrefColorsUi
249 {
250         Q_OBJECT
251 public:
252         PrefColors(GuiPreferences * form);
253
254         void applyRC(LyXRC & rc) const;
255         void updateRC(LyXRC const & rc);
256
257 private Q_SLOTS:
258         void changeColor();
259         void changeSysColor();
260         void changeLyxObjectsSelection();
261
262 private:
263         std::vector<ColorCode> lcolors_;
264         std::vector<QString> curcolors_;
265         std::vector<QString> newcolors_;
266 };
267
268
269 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
270 {
271         Q_OBJECT
272 public:
273         PrefDisplay(GuiPreferences * form);
274
275         void applyRC(LyXRC & rc) const;
276         void updateRC(LyXRC const & rc);
277
278 private Q_SLOTS:
279         void on_instantPreviewCO_currentIndexChanged(int);
280 };
281
282
283 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
284 {
285         Q_OBJECT
286 public:
287         PrefPaths(GuiPreferences * form);
288
289         void applyRC(LyXRC & rc) const;
290         void updateRC(LyXRC const & rc);
291
292 private Q_SLOTS:
293         void selectExampledir();
294         void selectTemplatedir();
295         void selectTempdir();
296         void selectBackupdir();
297         void selectWorkingdir();
298         void selectThesaurusdir();
299         void selectHunspelldir();
300         void selectLyxPipe();
301
302 };
303
304
305 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
306 {
307         Q_OBJECT
308 public:
309         PrefSpellchecker(GuiPreferences * form);
310
311         void applyRC(LyXRC & rc) const;
312         void updateRC(LyXRC const & rc);
313
314 private Q_SLOTS:
315         void on_spellcheckerCB_currentIndexChanged(int);
316 };
317
318
319 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
320 {
321         Q_OBJECT
322 public:
323         PrefConverters(GuiPreferences * form);
324
325         void applyRC(LyXRC & rc) const;
326         void updateRC(LyXRC const & rc);
327
328 public Q_SLOTS:
329         void updateGui();
330
331 private Q_SLOTS:
332         void updateConverter();
333         void switchConverter();
334         void removeConverter();
335         void changeConverter();
336         void on_cacheCB_stateChanged(int state);
337
338 private:
339         void updateButtons();
340 };
341
342
343 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
344 {
345         Q_OBJECT
346 public:
347         PrefFileformats(GuiPreferences * form);
348
349         void applyRC(LyXRC & rc) const;
350         void updateRC(LyXRC const & rc);
351         void updateView();
352
353 Q_SIGNALS:
354         void formatsChanged();
355
356 private Q_SLOTS:
357         void on_copierED_textEdited(const QString & s);
358         void on_extensionsED_textEdited(const QString &);
359         void on_viewerED_textEdited(const QString &);
360         void on_editorED_textEdited(const QString &);
361         void on_mimeED_textEdited(const QString &);
362         void on_shortcutED_textEdited(const QString &);
363         void on_formatED_editingFinished();
364         void on_formatED_textChanged(const QString &);
365         void on_formatsCB_currentIndexChanged(int);
366         void on_formatsCB_editTextChanged(const QString &);
367         void on_formatNewPB_clicked();
368         void on_formatRemovePB_clicked();
369         void on_viewerCO_currentIndexChanged(int i);
370         void on_editorCO_currentIndexChanged(int i);
371         void setFlags();
372         void updatePrettyname();
373
374 private:
375         Format & currentFormat();
376         ///
377         void updateViewers();
378         ///
379         void updateEditors();
380         ///
381         LyXRC::Alternatives viewer_alternatives;
382         ///
383         LyXRC::Alternatives editor_alternatives;
384 };
385
386
387 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
388 {
389         Q_OBJECT
390 public:
391         PrefLanguage(GuiPreferences * form);
392
393         void applyRC(LyXRC & rc) const;
394         void updateRC(LyXRC const & rc);
395
396 private Q_SLOTS:
397         void on_uiLanguageCO_currentIndexChanged(int);
398         void on_languagePackageCO_currentIndexChanged(int);
399 };
400
401
402 class PrefUserInterface : public PrefModule, public Ui::PrefUi
403 {
404         Q_OBJECT
405 public:
406         PrefUserInterface(GuiPreferences * form);
407
408         void applyRC(LyXRC & rc) const;
409         void updateRC(LyXRC const & rc);
410
411 public Q_SLOTS:
412         void selectUi();
413 };
414
415
416 class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
417 {
418         Q_OBJECT
419 public:
420         PrefDocHandling(GuiPreferences * form);
421
422         void applyRC(LyXRC & rc) const;
423         void updateRC(LyXRC const & rc);
424
425 public Q_SLOTS:
426         void on_clearSessionPB_clicked();
427 };
428
429
430
431 class PrefEdit : public PrefModule, public Ui::PrefEditUi
432 {
433         Q_OBJECT
434 public:
435         PrefEdit(GuiPreferences * form);
436
437         void applyRC(LyXRC & rc) const;
438         void updateRC(LyXRC const & rc);
439 };
440
441
442
443 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
444 {
445 public:
446         GuiShortcutDialog(QWidget * parent);
447 };
448
449
450 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
451 {
452         Q_OBJECT
453 public:
454         PrefShortcuts(GuiPreferences * form);
455
456         void applyRC(LyXRC & rc) const;
457         void updateRC(LyXRC const & rc);
458         void updateShortcutsTW();
459         void modifyShortcut();
460         void removeShortcut();
461         ///
462         void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
463         QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
464                 KeySequence const & shortcut, KeyMap::ItemType tag);
465
466 public Q_SLOTS:
467         void selectBind();
468         void on_modifyPB_pressed();
469         void on_newPB_pressed();
470         void on_removePB_pressed();
471         void on_searchLE_textEdited();
472         ///
473         void on_shortcutsTW_itemSelectionChanged();
474         void on_shortcutsTW_itemDoubleClicked();
475         ///
476         void shortcutOkPressed();
477         void shortcutCancelPressed();
478         void shortcutClearPressed();
479         void shortcutRemovePressed();
480
481 private:
482         ///
483         GuiShortcutDialog * shortcut_;
484         ///
485         ButtonController shortcut_bc_;
486         /// category items
487         QTreeWidgetItem * editItem_;
488         QTreeWidgetItem * mathItem_;
489         QTreeWidgetItem * bufferItem_;
490         QTreeWidgetItem * layoutItem_;
491         QTreeWidgetItem * systemItem_;
492         // system_bind_ holds bindings from rc.bind_file
493         // user_bind_ holds \bind bindings from user.bind
494         // user_unbind_ holds \unbind bindings from user.bind
495         // When an item is inserted, it is added to user_bind_
496         // When an item from system_bind_ is deleted, it is added to user_unbind_
497         // When an item in user_bind_ or user_unbind_ is deleted, it is 
498         //      deleted (unbind)
499         KeyMap system_bind_;
500         KeyMap user_bind_;
501         KeyMap user_unbind_;
502         ///
503         QString save_lfun_;
504 };
505
506
507 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
508 {
509         Q_OBJECT
510 public:
511         PrefIdentity(GuiPreferences * form);
512
513         void applyRC(LyXRC & rc) const;
514         void updateRC(LyXRC const & rc);
515 };
516
517
518 } // namespace frontend
519 } // namespace lyx
520
521 #endif // GUIPREFS_H