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