]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
This is the last of a series of patches that merges the layout modules development...
[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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GUIPREFS_H
13 #define GUIPREFS_H
14
15 #include "GuiDialog.h"
16 #include "ControlPrefs.h"
17 #include "Color.h"
18 #include "LyXRC.h"
19
20 #include "ui_PrefsUi.h"
21
22 #include "ui_PrefPlaintextUi.h"
23 #include "ui_PrefDateUi.h"
24 #include "ui_PrefKeyboardUi.h"
25 #include "ui_PrefLatexUi.h"
26 #include "ui_PrefScreenFontsUi.h"
27 #include "ui_PrefColorsUi.h"
28 #include "ui_PrefDisplayUi.h"
29 #include "ui_PrefPathsUi.h"
30 #include "ui_PrefSpellcheckerUi.h"
31 #include "ui_PrefConvertersUi.h"
32 #include "ui_PrefCopiersUi.h"
33 #include "ui_PrefFileformatsUi.h"
34 #include "ui_PrefLanguageUi.h"
35 #include "ui_PrefPrinterUi.h"
36 #include "ui_PrefUi.h"
37 #include "ui_PrefIdentityUi.h"
38
39 #include <QDialog>
40
41 #include <vector>
42
43 namespace lyx {
44
45 class Converters;
46 class Formats;
47 class Movers;
48
49 namespace frontend {
50
51 class GuiPrefsDialog;
52
53 class PrefModule : public QWidget
54 {
55         Q_OBJECT
56 public:
57         PrefModule(docstring const & t,
58                         GuiPrefsDialog * form = 0, QWidget * parent = 0)
59                 : QWidget(parent), title_(t), form_(form)
60         {}
61
62         virtual void apply(LyXRC & rc) const = 0;
63         virtual void update(LyXRC const & rc) = 0;
64
65         docstring const & title() const { return title_; }
66
67 protected:
68         docstring title_;
69         GuiPrefsDialog * form_;
70
71 Q_SIGNALS:
72         void changed();
73 };
74
75
76 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
77 {
78         Q_OBJECT
79 public:
80         PrefPlaintext(QWidget * parent = 0);
81
82         virtual void apply(LyXRC & rc) const;
83         virtual void update(LyXRC const & rc);
84 };
85
86
87 class PrefDate : public PrefModule, public Ui::PrefDateUi
88 {
89         Q_OBJECT
90 public:
91         PrefDate(QWidget * parent = 0);
92
93         virtual void apply(LyXRC & rc) const;
94         virtual void update(LyXRC const & rc);
95 };
96
97
98 class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
99 {
100         Q_OBJECT
101 public:
102         PrefKeyboard(GuiPrefsDialog * form, QWidget * parent = 0);
103
104         virtual void apply(LyXRC & rc) const;
105         virtual void update(LyXRC const & rc);
106
107 private Q_SLOTS:
108         void on_firstKeymapPB_clicked(bool);
109         void on_secondKeymapPB_clicked(bool);
110         void on_keymapCB_toggled(bool);
111
112 private:
113         QString testKeymap(QString keymap);
114 };
115
116
117 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
118 {
119         Q_OBJECT
120 public:
121         PrefLatex(GuiPrefsDialog * form, QWidget * parent = 0);
122
123         virtual void apply(LyXRC & rc) const;
124         virtual void update(LyXRC const & rc);
125 };
126
127
128 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
129 {
130         Q_OBJECT
131 public:
132         PrefScreenFonts(GuiPrefsDialog * form, QWidget * parent = 0);
133
134         virtual void apply(LyXRC & rc) const;
135         virtual void update(LyXRC const & rc);
136
137 private Q_SLOTS:
138         void select_roman(const QString&);
139         void select_sans(const QString&);
140         void select_typewriter(const QString&);
141 };
142
143
144 class PrefColors : public PrefModule, public Ui::PrefColorsUi
145 {
146         Q_OBJECT
147 public:
148         PrefColors(GuiPrefsDialog * form, QWidget * parent = 0);
149
150         void apply(LyXRC & rc) const;
151         void update(LyXRC const & rc);
152
153 private Q_SLOTS:
154         void change_color();
155         void change_lyxObjects_selection();
156
157 private:
158         std::vector<Color_color> lcolors_;
159         // FIXME the use of mutable here is required due to the
160         // fact that initialization is not done in the controller
161         // but in the constructor.
162         std::vector<QString> curcolors_;
163         std::vector<QString> newcolors_;
164
165 };
166
167
168 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
169 {
170         Q_OBJECT
171 public:
172         PrefDisplay(QWidget * parent = 0);
173
174         void apply(LyXRC & rc) const;
175         void update(LyXRC const & rc);
176 };
177
178
179 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
180 {
181         Q_OBJECT
182 public:
183         PrefPaths(GuiPrefsDialog * form, QWidget * parent = 0);
184
185         void apply(LyXRC & rc) const;
186         void update(LyXRC const & rc);
187
188 private Q_SLOTS:
189         void select_templatedir();
190         void select_tempdir();
191         void select_backupdir();
192         void select_workingdir();
193         void select_lyxpipe();
194
195 };
196
197
198 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
199 {
200         Q_OBJECT
201 public:
202         PrefSpellchecker(GuiPrefsDialog * form, QWidget * parent = 0);
203
204         void apply(LyXRC & rc) const;
205         void update(LyXRC const & rc);
206
207 private Q_SLOTS:
208         void select_dict();
209 };
210
211
212 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
213 {
214         Q_OBJECT
215 public:
216         PrefConverters(GuiPrefsDialog * form, QWidget * parent = 0);
217
218         void apply(LyXRC & rc) const;
219         void update(LyXRC const & rc);
220
221 public Q_SLOTS:
222         void updateGui();
223
224 private Q_SLOTS:
225         void update_converter();
226         void switch_converter();
227         void converter_changed();
228         void remove_converter();
229         void on_cacheCB_stateChanged(int state);
230
231 private:
232         void updateButtons();
233 };
234
235
236 class PrefCopiers : public PrefModule, public Ui::PrefCopiersUi
237 {
238         Q_OBJECT
239 public:
240         PrefCopiers(GuiPrefsDialog * form, QWidget * parent = 0);
241
242         void apply(LyXRC & rc) const;
243         void update(LyXRC const & rc);
244
245         void updateView();
246
247 private Q_SLOTS:
248         void switch_copierLB(int nr);
249         void switch_copierCO(int nr);
250         void copiers_changed();
251         void new_copier();
252         void modify_copier();
253         void remove_copier();
254
255 private:
256         void updateButtons();
257 };
258
259
260 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
261 {
262         Q_OBJECT
263 public:
264         PrefFileformats(GuiPrefsDialog * form, QWidget * parent = 0);
265
266         void apply(LyXRC & rc) const;
267         void update(LyXRC const & rc);
268
269         void updateView();
270 Q_SIGNALS:
271         void formatsChanged();
272 private:
273         void updateButtons();
274
275 private Q_SLOTS:
276         void switch_format(int);
277         void fileformat_changed();
278         void new_format();
279         void modify_format();
280         void remove_format();
281 };
282
283
284 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
285 {
286         Q_OBJECT
287 public:
288         PrefLanguage(QWidget * parent = 0);
289
290         void apply(LyXRC & rc) const;
291         void update(LyXRC const & rc);
292
293 private:
294         std::vector<std::string> lang_;
295 };
296
297
298 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
299 {
300         Q_OBJECT
301 public:
302         PrefPrinter(QWidget * parent = 0);
303
304         void apply(LyXRC & rc) const;
305         void update(LyXRC const & rc);
306 };
307
308
309 class PrefUserInterface : public PrefModule, public Ui::PrefUi
310 {
311         Q_OBJECT
312 public:
313         PrefUserInterface(GuiPrefsDialog * form, QWidget * parent = 0);
314
315         void apply(LyXRC & rc) const;
316         void update(LyXRC const & rc);
317
318 public Q_SLOTS:
319         void select_ui();
320         void select_bind();
321         void on_loadWindowSizeCB_toggled(bool);
322
323 };
324
325
326 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
327 {
328         Q_OBJECT
329 public:
330         PrefIdentity(QWidget * parent = 0);
331
332         void apply(LyXRC & rc) const;
333         void update(LyXRC const & rc);
334 };
335
336 ///
337 class GuiPrefsDialog : public GuiDialog, public Ui::PrefsUi
338 {
339         Q_OBJECT
340 public:
341         GuiPrefsDialog(LyXView & lv);
342
343         void apply(LyXRC & rc) const;
344         void updateRc(LyXRC const & rc);
345
346 public Q_SLOTS:
347         void change_adaptor();
348
349 public:
350         //
351         void closeEvent(QCloseEvent * e);
352         ///
353         void add(PrefModule * module);
354         ///
355         Converters & converters();
356         ///
357         Formats & formats();
358         ///
359         Movers & movers();
360         /// parent controller
361         ControlPrefs & controller();
362         /// Apply changes
363         void applyView();
364         /// update (do we need this?)
365         void updateContents();
366
367         std::vector<PrefModule *> modules_;
368 };
369
370
371 } // namespace frontend
372 } // namespace lyx
373
374 #endif // GUIPREFS_H