]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QPrefsDialog.h
enable Font cache only for MacOSX and inline width() for other platform.
[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(std::string const & cat, std::string 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         std::string const & category() {
73                 return category_;
74         }
75
76         std::string const & title() {
77                 return title_;
78         }
79
80 protected:
81         std::string category_;
82         std::string 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         void updateGui();
253
254 private Q_SLOTS:
255         void switch_converter(int);
256         void converter_changed();
257         void new_converter();
258         void modify_converter();
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
303         void setConverters(PrefConverters *);
304
305 private:
306         void updateButtons();
307
308 private Q_SLOTS:
309         void switch_format(int);
310         void fileformat_changed();
311         void new_format();
312         void modify_format();
313         void remove_format();
314
315 private:
316         PrefConverters * converters_;
317
318 };
319
320
321 class PrefLanguage :  public PrefModule, public Ui::QPrefLanguageUi
322 {
323         Q_OBJECT
324 public:
325         PrefLanguage(QWidget * parent = 0);
326         ~PrefLanguage() {}
327
328         void apply(LyXRC & rc) const;
329         void update(LyXRC const & rc);
330
331 private:
332         std::vector<std::string> lang_;
333
334 };
335
336
337 class PrefPrinter :  public PrefModule, public Ui::QPrefPrinterUi
338 {
339         Q_OBJECT
340 public:
341         PrefPrinter(QWidget * parent = 0);
342         ~PrefPrinter() {}
343
344         void apply(LyXRC & rc) const;
345         void update(LyXRC const & rc);
346 };
347
348
349 class PrefUserInterface :  public PrefModule, public Ui::QPrefUi
350 {
351         Q_OBJECT
352 public:
353         PrefUserInterface(QPrefs * form, QWidget * parent = 0);
354         ~PrefUserInterface() {}
355
356         void apply(LyXRC & rc) const;
357         void update(LyXRC const & rc);
358
359 public Q_SLOTS:
360         void select_ui();
361         void select_bind();
362
363 };
364
365
366 class PrefIdentity :  public PrefModule, public Ui::QPrefIdentityUi
367 {
368         Q_OBJECT
369 public:
370         PrefIdentity(QWidget * parent = 0);
371         ~PrefIdentity() {}
372
373         void apply(LyXRC & rc) const;
374         void update(LyXRC const & rc);
375 };
376
377 ///
378 class QPrefsDialog : public QDialog, public Ui::QPrefsUi
379 {
380         Q_OBJECT
381 public:
382         QPrefsDialog(QPrefs *);
383
384         ~QPrefsDialog();
385
386         void apply(LyXRC & rc) const;
387         void update(LyXRC const & rc);
388
389 public Q_SLOTS:
390         void change_adaptor();
391
392 protected:
393         void closeEvent(QCloseEvent * e);
394
395 private:
396         void add(PrefModule * module);
397
398 private:
399         QPrefs * form_;
400         std::vector<PrefModule *> modules_;
401 };
402
403 } // namespace frontend
404 } // namespace lyx
405
406 #endif // PREFSDIALOG_H