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