]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QPrefsDialog.h
* src/frontends/qt4/GuiWorkArea.[Ch]:
[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         std::vector<QString> prefcolors_;
169         std::vector<QString> newcolors_;
170
171 };
172
173
174 class PrefCygwinPath :  public PrefModule, public Ui::QPrefCygwinPathUi
175 {
176         Q_OBJECT
177 public:
178         PrefCygwinPath(QWidget * parent = 0);
179         ~PrefCygwinPath() {}
180
181         void apply(LyXRC & rc) const;
182         void update(LyXRC const & rc);
183 };
184
185
186 class PrefDisplay :  public PrefModule, public Ui::QPrefDisplayUi
187 {
188         Q_OBJECT
189 public:
190         PrefDisplay(QWidget * parent = 0);
191         ~PrefDisplay() {}
192
193         void apply(LyXRC & rc) const;
194         void update(LyXRC const & rc);
195 };
196
197
198 class PrefPaths :  public PrefModule, public Ui::QPrefPathsUi
199 {
200         Q_OBJECT
201 public:
202         PrefPaths(QPrefs * form, QWidget * parent = 0);
203         ~PrefPaths() {}
204
205         void apply(LyXRC & rc) const;
206         void update(LyXRC const & rc);
207
208 private Q_SLOTS:
209         void select_templatedir();
210         void select_tempdir();
211         void select_backupdir();
212         void select_workingdir();
213         void select_lyxpipe();
214
215 };
216
217
218 class PrefSpellchecker :  public PrefModule, public Ui::QPrefSpellcheckerUi
219 {
220         Q_OBJECT
221 public:
222         PrefSpellchecker(QPrefs * form, QWidget * parent = 0);
223         ~PrefSpellchecker() {}
224
225         void apply(LyXRC & rc) const;
226         void update(LyXRC const & rc);
227
228 private Q_SLOTS:
229         void select_dict();
230 };
231
232
233 class PrefConverters :  public PrefModule, public Ui::QPrefConvertersUi
234 {
235         Q_OBJECT
236 public:
237         PrefConverters(QPrefs * form, QWidget * parent = 0);
238         ~PrefConverters() {}
239
240         void apply(LyXRC & rc) const;
241         void update(LyXRC const & rc);
242
243 public Q_SLOTS:
244         void updateGui();
245
246 private Q_SLOTS:
247         void update_converter();
248         void switch_converter();
249         void converter_changed();
250         void remove_converter();
251
252 private:
253         void updateButtons();
254 };
255
256
257 class PrefCopiers :  public PrefModule, public Ui::QPrefCopiersUi
258 {
259         Q_OBJECT
260 public:
261         PrefCopiers(QPrefs * form, QWidget * parent = 0);
262         ~PrefCopiers() {}
263
264         void apply(LyXRC & rc) const;
265         void update(LyXRC const & rc);
266
267         void update();
268
269 private Q_SLOTS:
270         void switch_copierLB(int nr);
271         void switch_copierCO(int nr);
272         void copiers_changed();
273         void new_copier();
274         void modify_copier();
275         void remove_copier();
276
277 private:
278         void updateButtons();
279 };
280
281
282 class PrefFileformats :  public PrefModule, public Ui::QPrefFileformatsUi
283 {
284         Q_OBJECT
285 public:
286         PrefFileformats(QPrefs * form, QWidget * parent = 0);
287         ~PrefFileformats() {}
288
289         void apply(LyXRC & rc) const;
290         void update(LyXRC const & rc);
291
292         void update();
293 Q_SIGNALS:
294         void formatsChanged();
295 private:
296         void updateButtons();
297
298 private Q_SLOTS:
299         void switch_format(int);
300         void fileformat_changed();
301         void new_format();
302         void modify_format();
303         void remove_format();
304 };
305
306
307 class PrefLanguage :  public PrefModule, public Ui::QPrefLanguageUi
308 {
309         Q_OBJECT
310 public:
311         PrefLanguage(QWidget * parent = 0);
312         ~PrefLanguage() {}
313
314         void apply(LyXRC & rc) const;
315         void update(LyXRC const & rc);
316
317 private:
318         std::vector<std::string> lang_;
319
320 };
321
322
323 class PrefPrinter :  public PrefModule, public Ui::QPrefPrinterUi
324 {
325         Q_OBJECT
326 public:
327         PrefPrinter(QWidget * parent = 0);
328         ~PrefPrinter() {}
329
330         void apply(LyXRC & rc) const;
331         void update(LyXRC const & rc);
332 };
333
334
335 class PrefUserInterface :  public PrefModule, public Ui::QPrefUi
336 {
337         Q_OBJECT
338 public:
339         PrefUserInterface(QPrefs * form, QWidget * parent = 0);
340         ~PrefUserInterface() {}
341
342         void apply(LyXRC & rc) const;
343         void update(LyXRC const & rc);
344
345 public Q_SLOTS:
346         void select_ui();
347         void select_bind();
348         void on_loadWindowSizeCB_toggled(bool);
349
350 };
351
352
353 class PrefIdentity :  public PrefModule, public Ui::QPrefIdentityUi
354 {
355         Q_OBJECT
356 public:
357         PrefIdentity(QWidget * parent = 0);
358         ~PrefIdentity() {}
359
360         void apply(LyXRC & rc) const;
361         void update(LyXRC const & rc);
362 };
363
364 ///
365 class QPrefsDialog : public QDialog, public Ui::QPrefsUi
366 {
367         Q_OBJECT
368 public:
369         QPrefsDialog(QPrefs *);
370
371         ~QPrefsDialog();
372
373         void apply(LyXRC & rc) const;
374         void updateRc(LyXRC const & rc);
375
376 public Q_SLOTS:
377         void change_adaptor();
378
379 protected:
380         void closeEvent(QCloseEvent * e);
381
382 private:
383         void add(PrefModule * module);
384
385 private:
386         QPrefs * form_;
387         std::vector<PrefModule *> modules_;
388 };
389
390 } // namespace frontend
391 } // namespace lyx
392
393 #endif // PREFSDIALOG_H