]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
00dd244292e323831ff85f23e5cf34f0c5fa6c42
[lyx.git] / src / frontends / qt4 / GuiPrefs.h
1 // -*- C++ -*-
2 /**
3  * \file GuiPrefs.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 GUIPREFS_H
13 #define GUIPREFS_H
14
15 #include "GuiDialogView.h"
16 #include "ControlPrefs.h"
17 #include "Color.h"
18 #include "LyXRC.h"
19
20 #include "ui_PrefsUi.h"
21
22 #include "ui_PrefPlaintextUi.h"
23 #include "ui_PrefDateUi.h"
24 #include "ui_PrefKeyboardUi.h"
25 #include "ui_PrefLatexUi.h"
26 #include "ui_PrefScreenFontsUi.h"
27 #include "ui_PrefColorsUi.h"
28 #include "ui_PrefCygwinPathUi.h"
29 #include "ui_PrefDisplayUi.h"
30 #include "ui_PrefPathsUi.h"
31 #include "ui_PrefSpellcheckerUi.h"
32 #include "ui_PrefConvertersUi.h"
33 #include "ui_PrefCopiersUi.h"
34 #include "ui_PrefFileformatsUi.h"
35 #include "ui_PrefLanguageUi.h"
36 #include "ui_PrefPrinterUi.h"
37 #include "ui_PrefUi.h"
38 #include "ui_PrefIdentityUi.h"
39
40 #include <QDialog>
41
42 #include <vector>
43
44 namespace lyx {
45
46 class Converters;
47 class Formats;
48 class Movers;
49
50 namespace frontend {
51
52 class GuiPrefs;
53
54 class PrefModule : public QWidget
55 {
56         Q_OBJECT
57 public:
58         PrefModule(docstring const & t,
59                         GuiPrefs * form = 0, QWidget * parent = 0)
60                 : QWidget(parent), title_(t), form_(form)
61         {}
62
63         virtual void apply(LyXRC & rc) const = 0;
64         virtual void update(LyXRC const & rc) = 0;
65
66         docstring const & title() const { return title_; }
67
68 protected:
69         docstring title_;
70         GuiPrefs * form_;
71
72 Q_SIGNALS:
73         void changed();
74 };
75
76
77 class PrefPlaintext :  public PrefModule, public Ui::PrefPlaintextUi
78 {
79         Q_OBJECT
80 public:
81         PrefPlaintext(QWidget * parent = 0);
82
83         virtual void apply(LyXRC & rc) const;
84         virtual void update(LyXRC const & rc);
85 };
86
87
88 class PrefDate :  public PrefModule, public Ui::PrefDateUi
89 {
90         Q_OBJECT
91 public:
92         PrefDate(QWidget * parent = 0);
93
94         virtual void apply(LyXRC & rc) const;
95         virtual void update(LyXRC const & rc);
96 };
97
98
99 class PrefKeyboard :  public PrefModule, public Ui::PrefKeyboardUi
100 {
101         Q_OBJECT
102 public:
103         PrefKeyboard(GuiPrefs * form, QWidget * parent = 0);
104
105         virtual void apply(LyXRC & rc) const;
106         virtual void update(LyXRC const & rc);
107
108 private Q_SLOTS:
109         void on_firstKeymapPB_clicked(bool);
110         void on_secondKeymapPB_clicked(bool);
111         void on_keymapCB_toggled(bool);
112
113 private:
114         QString testKeymap(QString keymap);
115 };
116
117
118 class PrefLatex :  public PrefModule, public Ui::PrefLatexUi
119 {
120         Q_OBJECT
121 public:
122         PrefLatex(GuiPrefs * form, QWidget * parent = 0);
123
124         virtual void apply(LyXRC & rc) const;
125         virtual void update(LyXRC const & rc);
126 };
127
128
129 class PrefScreenFonts :  public PrefModule, public Ui::PrefScreenFontsUi
130 {
131         Q_OBJECT
132 public:
133         PrefScreenFonts(GuiPrefs * form, QWidget * parent = 0);
134
135         virtual void apply(LyXRC & rc) const;
136         virtual void update(LyXRC const & rc);
137
138 private Q_SLOTS:
139         void select_roman(const QString&);
140         void select_sans(const QString&);
141         void select_typewriter(const QString&);
142 };
143
144
145 class PrefColors :  public PrefModule, public Ui::PrefColorsUi
146 {
147         Q_OBJECT
148 public:
149         PrefColors(GuiPrefs * form, QWidget * parent = 0);
150
151         void apply(LyXRC & rc) const;
152         void update(LyXRC const & rc);
153
154 private Q_SLOTS:
155         void change_color();
156         void change_lyxObjects_selection();
157
158 private:
159         std::vector<Color_color> lcolors_;
160         // FIXME the use of mutable here is required due to the
161         // fact that initialization is not done in the controller
162         // but in the constructor.
163         std::vector<QString> curcolors_;
164         std::vector<QString> newcolors_;
165
166 };
167
168
169 class PrefCygwinPath :  public PrefModule, public Ui::PrefCygwinPathUi
170 {
171         Q_OBJECT
172 public:
173         PrefCygwinPath(QWidget * parent = 0);
174
175         void apply(LyXRC & rc) const;
176         void update(LyXRC const & rc);
177 };
178
179
180 class PrefDisplay :  public PrefModule, public Ui::PrefDisplayUi
181 {
182         Q_OBJECT
183 public:
184         PrefDisplay(QWidget * parent = 0);
185
186         void apply(LyXRC & rc) const;
187         void update(LyXRC const & rc);
188 };
189
190
191 class PrefPaths :  public PrefModule, public Ui::PrefPathsUi
192 {
193         Q_OBJECT
194 public:
195         PrefPaths(GuiPrefs * form, QWidget * parent = 0);
196
197         void apply(LyXRC & rc) const;
198         void update(LyXRC const & rc);
199
200 private Q_SLOTS:
201         void select_templatedir();
202         void select_tempdir();
203         void select_backupdir();
204         void select_workingdir();
205         void select_lyxpipe();
206
207 };
208
209
210 class PrefSpellchecker :  public PrefModule, public Ui::PrefSpellcheckerUi
211 {
212         Q_OBJECT
213 public:
214         PrefSpellchecker(GuiPrefs * form, QWidget * parent = 0);
215
216         void apply(LyXRC & rc) const;
217         void update(LyXRC const & rc);
218
219 private Q_SLOTS:
220         void select_dict();
221 };
222
223
224 class PrefConverters :  public PrefModule, public Ui::PrefConvertersUi
225 {
226         Q_OBJECT
227 public:
228         PrefConverters(GuiPrefs * form, QWidget * parent = 0);
229
230         void apply(LyXRC & rc) const;
231         void update(LyXRC const & rc);
232
233 public Q_SLOTS:
234         void updateGui();
235
236 private Q_SLOTS:
237         void update_converter();
238         void switch_converter();
239         void converter_changed();
240         void remove_converter();
241         void on_cacheCB_stateChanged(int state);
242
243 private:
244         void updateButtons();
245 };
246
247
248 class PrefCopiers :  public PrefModule, public Ui::PrefCopiersUi
249 {
250         Q_OBJECT
251 public:
252         PrefCopiers(GuiPrefs * form, QWidget * parent = 0);
253
254         void apply(LyXRC & rc) const;
255         void update(LyXRC const & rc);
256
257         void update();
258
259 private Q_SLOTS:
260         void switch_copierLB(int nr);
261         void switch_copierCO(int nr);
262         void copiers_changed();
263         void new_copier();
264         void modify_copier();
265         void remove_copier();
266
267 private:
268         void updateButtons();
269 };
270
271
272 class PrefFileformats :  public PrefModule, public Ui::PrefFileformatsUi
273 {
274         Q_OBJECT
275 public:
276         PrefFileformats(GuiPrefs * form, QWidget * parent = 0);
277
278         void apply(LyXRC & rc) const;
279         void update(LyXRC const & rc);
280
281         void update();
282 Q_SIGNALS:
283         void formatsChanged();
284 private:
285         void updateButtons();
286
287 private Q_SLOTS:
288         void switch_format(int);
289         void fileformat_changed();
290         void new_format();
291         void modify_format();
292         void remove_format();
293 };
294
295
296 class PrefLanguage :  public PrefModule, public Ui::PrefLanguageUi
297 {
298         Q_OBJECT
299 public:
300         PrefLanguage(QWidget * parent = 0);
301
302         void apply(LyXRC & rc) const;
303         void update(LyXRC const & rc);
304
305 private:
306         std::vector<std::string> lang_;
307 };
308
309
310 class PrefPrinter :  public PrefModule, public Ui::PrefPrinterUi
311 {
312         Q_OBJECT
313 public:
314         PrefPrinter(QWidget * parent = 0);
315
316         void apply(LyXRC & rc) const;
317         void update(LyXRC const & rc);
318 };
319
320
321 class PrefUserInterface :  public PrefModule, public Ui::PrefUi
322 {
323         Q_OBJECT
324 public:
325         PrefUserInterface(GuiPrefs * form, QWidget * parent = 0);
326
327         void apply(LyXRC & rc) const;
328         void update(LyXRC const & rc);
329
330 public Q_SLOTS:
331         void select_ui();
332         void select_bind();
333         void on_loadWindowSizeCB_toggled(bool);
334
335 };
336
337
338 class PrefIdentity :  public PrefModule, public Ui::PrefIdentityUi
339 {
340         Q_OBJECT
341 public:
342         PrefIdentity(QWidget * parent = 0);
343
344         void apply(LyXRC & rc) const;
345         void update(LyXRC const & rc);
346 };
347
348 ///
349 class GuiPrefsDialog : public QDialog, public Ui::PrefsUi
350 {
351         Q_OBJECT
352 public:
353         GuiPrefsDialog(GuiPrefs *);
354
355         void apply(LyXRC & rc) const;
356         void updateRc(LyXRC const & rc);
357
358 public Q_SLOTS:
359         void change_adaptor();
360
361 protected:
362         void closeEvent(QCloseEvent * e);
363
364 private:
365         void add(PrefModule * module);
366
367 private:
368         GuiPrefs * form_;
369         std::vector<PrefModule *> modules_;
370 };
371
372
373 class GuiPrefs : public GuiView<GuiPrefsDialog>
374 {
375 public:
376         GuiPrefs(Dialog &);
377
378         Converters & converters();
379         Formats & formats();
380         Movers & movers();
381         /// parent controller
382         ControlPrefs & controller()
383         { return static_cast<ControlPrefs &>(this->getController()); }
384         /// parent controller
385         ControlPrefs const & controller() const
386         { return static_cast<ControlPrefs const &>(this->getController()); }
387 private:
388         /// Apply changes
389         virtual void apply();
390
391         /// update (do we need this?)
392         virtual void update_contents();
393
394         /// build the dialog
395         virtual void build_dialog();
396
397 };
398
399 } // namespace frontend
400 } // namespace lyx
401
402 #endif // GUIPREFS_H