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