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