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