]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
Join PrefDateUi and PrefPlaintextUi into PrefOutputUi
[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  * \author Bo Peng
9  * \author Edwin Leuven
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIPREFS_H
15 #define GUIPREFS_H
16
17 #include "GuiDialog.h"
18
19 #include "ColorCode.h"
20 #include "Converter.h"
21 #include "Format.h"
22 #include "FuncCode.h"
23 #include "KeyMap.h"
24 #include "LyXRC.h"
25 #include "Mover.h"
26
27 #include "ui_PrefsUi.h"
28
29 #include "ui_PrefOutputUi.h"
30 #include "ui_PrefInputUi.h"
31 #include "ui_PrefLatexUi.h"
32 #include "ui_PrefScreenFontsUi.h"
33 #include "ui_PrefCompletionUi.h"
34 #include "ui_PrefColorsUi.h"
35 #include "ui_PrefDisplayUi.h"
36 #include "ui_PrefEditUi.h"
37 #include "ui_PrefPathsUi.h"
38 #include "ui_PrefShortcutsUi.h"
39 #include "ui_PrefSpellcheckerUi.h"
40 #include "ui_PrefConvertersUi.h"
41 #include "ui_PrefFileformatsUi.h"
42 #include "ui_PrefLanguageUi.h"
43 #include "ui_PrefPrinterUi.h"
44 #include "ui_PrefUi.h"
45 #include "ui_PrefIdentityUi.h"
46 #include "ui_ShortcutUi.h"
47
48 #include <string>
49 #include <vector>
50
51
52 namespace lyx {
53
54 class Converters;
55 class Formats;
56 class Movers;
57
58 namespace frontend {
59
60 class PrefModule;
61
62 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
63 {
64         Q_OBJECT
65 public:
66         GuiPreferences(GuiView & lv);
67
68         void apply(LyXRC & rc) const;
69         void updateRc(LyXRC const & rc);
70
71 public Q_SLOTS:
72         void change_adaptor();
73
74 public:
75         /// Apply changes
76         void applyView();
77
78         std::vector<PrefModule *> modules_;
79
80         ///
81         bool initialiseParams(std::string const &);
82         ///
83         void clearParams() {}
84         ///
85         void dispatchParams();
86         ///
87         bool isBufferDependent() const { return false; }
88
89         /// various file pickers
90         QString browsebind(QString const & file) const;
91         QString browseUI(QString const & file) const;
92         QString browsekbmap(QString const & file) const;
93
94         /// general browse
95         QString browse(QString const & file, QString const & title) const;
96
97         /// set a color
98         void setColor(ColorCode col, QString const & hex);
99
100         /// update the screen fonts after change
101         void updateScreenFonts();
102
103         /// adjust the prefs paper sizes
104         PAPER_SIZE toPaperSize(int i) const;
105         /// adjust the prefs paper sizes
106         int fromPaperSize(PAPER_SIZE papersize) const;
107
108         LyXRC & rc() { return rc_; }
109         Converters & converters() { return converters_; }
110         Formats & formats() { return formats_; }
111         Movers & movers() { return movers_; }
112
113 private:
114         ///
115         void addModule(PrefModule * module);
116
117         /// temporary lyxrc
118         LyXRC rc_;
119         /// temporary converters
120         Converters converters_;
121         /// temporary formats
122         Formats formats_;
123         /// temporary movers
124         Movers movers_;
125
126         /// A list of colors to be dispatched
127         std::vector<std::string> colors_;
128
129         bool redraw_gui_;
130         bool update_screen_font_;
131 };
132
133
134 class PrefModule : public QWidget
135 {
136         Q_OBJECT
137 public:
138         PrefModule(QString const & cat, QString const & t,
139                         GuiPreferences * form)
140                 : QWidget(form), category_(cat), title_(t), form_(form)
141         {}
142
143         virtual void apply(LyXRC & rc) const = 0;
144         virtual void update(LyXRC const & rc) = 0;
145
146         QString const & category() const { return category_; }
147         QString const & title() const { return title_; }
148
149 protected:
150         QString category_;
151         QString title_;
152         GuiPreferences * form_;
153
154 Q_SIGNALS:
155         void changed();
156 };
157
158
159 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
160 {
161         Q_OBJECT
162 public:
163         PrefOutput(GuiPreferences * form);
164
165         virtual void apply(LyXRC & rc) const;
166         virtual void update(LyXRC const & rc);
167
168 private Q_SLOTS:
169         void on_DateED_textChanged(const QString &);
170 };
171
172
173 class PrefInput : public PrefModule, public Ui::PrefInputUi
174 {
175         Q_OBJECT
176 public:
177         PrefInput(GuiPreferences * form);
178
179         virtual void apply(LyXRC & rc) const;
180         virtual void update(LyXRC const & rc);
181
182 private Q_SLOTS:
183         void on_firstKeymapPB_clicked(bool);
184         void on_secondKeymapPB_clicked(bool);
185         void on_keymapCB_toggled(bool);
186
187 private:
188         QString testKeymap(QString const & keymap);
189 };
190
191
192 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
193 {
194         Q_OBJECT
195 public:
196         PrefCompletion(GuiPreferences * form);
197
198         virtual void apply(LyXRC & rc) const;
199         virtual void update(LyXRC const & rc);
200         virtual void enableCB();
201 private Q_SLOTS:
202         void on_popupTextCB_clicked();
203         void on_inlineTextCB_clicked();
204 };
205
206
207 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
208 {
209         Q_OBJECT
210 public:
211         PrefLatex(GuiPreferences * form);
212
213         virtual void apply(LyXRC & rc) const;
214         virtual void update(LyXRC const & rc);
215
216 private Q_SLOTS:
217         void on_latexEncodingCB_stateChanged(int state);
218         void on_latexBibtexCO_activated(int n);
219         void on_latexIndexCO_activated(int n);
220
221 private:
222         ///
223         std::set<std::string> bibtex_alternatives;
224         ///
225         std::set<std::string> index_alternatives;
226 };
227
228
229 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
230 {
231         Q_OBJECT
232 public:
233         PrefScreenFonts(GuiPreferences * form);
234
235         virtual void apply(LyXRC & rc) const;
236         virtual void update(LyXRC const & rc);
237
238 private Q_SLOTS:
239         void selectRoman(const QString&);
240         void selectSans(const QString&);
241         void selectTypewriter(const QString&);
242 };
243
244
245 class PrefColors : public PrefModule, public Ui::PrefColorsUi
246 {
247         Q_OBJECT
248 public:
249         PrefColors(GuiPreferences * form);
250
251         void apply(LyXRC & rc) const;
252         void update(LyXRC const & rc);
253
254 private Q_SLOTS:
255         void changeColor();
256         void changeLyxObjectsSelection();
257
258 private:
259         std::vector<ColorCode> lcolors_;
260         std::vector<QString> curcolors_;
261         std::vector<QString> newcolors_;
262 };
263
264
265 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
266 {
267         Q_OBJECT
268 public:
269         PrefDisplay(GuiPreferences * form);
270
271         void apply(LyXRC & rc) const;
272         void update(LyXRC const & rc);
273
274 private Q_SLOTS:
275         void on_instantPreviewCO_currentIndexChanged(int);
276 };
277
278
279 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
280 {
281         Q_OBJECT
282 public:
283         PrefPaths(GuiPreferences * form);
284
285         void apply(LyXRC & rc) const;
286         void update(LyXRC const & rc);
287
288 private Q_SLOTS:
289         void selectExampledir();
290         void selectTemplatedir();
291         void selectTempdir();
292         void selectBackupdir();
293         void selectWorkingdir();
294         void selectThesaurusdir();
295         void selectHunspelldir();
296         void selectLyxPipe();
297
298 };
299
300
301 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
302 {
303         Q_OBJECT
304 public:
305         PrefSpellchecker(GuiPreferences * form);
306
307         void apply(LyXRC & rc) const;
308         void update(LyXRC const & rc);
309
310 };
311
312
313 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
314 {
315         Q_OBJECT
316 public:
317         PrefConverters(GuiPreferences * form);
318
319         void apply(LyXRC & rc) const;
320         void update(LyXRC const & rc);
321
322 public Q_SLOTS:
323         void updateGui();
324
325 private Q_SLOTS:
326         void updateConverter();
327         void switchConverter();
328         void removeConverter();
329         void changeConverter();
330         void on_cacheCB_stateChanged(int state);
331
332 private:
333         void updateButtons();
334 };
335
336
337 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
338 {
339         Q_OBJECT
340 public:
341         PrefFileformats(GuiPreferences * form);
342
343         void apply(LyXRC & rc) const;
344         void update(LyXRC const & rc);
345         void updateView();
346
347 Q_SIGNALS:
348         void formatsChanged();
349
350 private Q_SLOTS:
351         void on_copierED_textEdited(const QString & s);
352         void on_extensionED_textEdited(const QString &);
353         void on_viewerED_textEdited(const QString &);
354         void on_editorED_textEdited(const QString &);
355         void on_shortcutED_textEdited(const QString &);
356         void on_formatED_editingFinished();
357         void on_formatED_textChanged(const QString &);
358         void on_formatsCB_currentIndexChanged(int);
359         void on_formatsCB_editTextChanged(const QString &);
360         void on_formatNewPB_clicked();
361         void on_formatRemovePB_clicked();
362         void on_viewerCO_currentIndexChanged(int i);
363         void on_editorCO_currentIndexChanged(int i);
364         void setFlags();
365         void updatePrettyname();
366
367 private:
368         Format & currentFormat();
369         ///
370         void updateViewers();
371         ///
372         void updateEditors();
373         ///
374         LyXRC::Alternatives viewer_alternatives;
375         ///
376         LyXRC::Alternatives editor_alternatives;
377 };
378
379
380 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
381 {
382         Q_OBJECT
383 public:
384         PrefLanguage(GuiPreferences * form);
385
386         void apply(LyXRC & rc) const;
387         void update(LyXRC const & rc);
388
389 private Q_SLOTS:
390         void on_uiLanguageCO_currentIndexChanged(int);
391 };
392
393
394 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
395 {
396         Q_OBJECT
397 public:
398         PrefPrinter(GuiPreferences * form);
399
400         void apply(LyXRC & rc) const;
401         void update(LyXRC const & rc);
402 };
403
404
405 class PrefUserInterface : public PrefModule, public Ui::PrefUi
406 {
407         Q_OBJECT
408 public:
409         PrefUserInterface(GuiPreferences * form);
410
411         void apply(LyXRC & rc) const;
412         void update(LyXRC const & rc);
413
414 public Q_SLOTS:
415         void selectUi();
416         void on_clearSessionPB_clicked();
417 };
418
419
420 class PrefEdit : public PrefModule, public Ui::PrefEditUi
421 {
422         Q_OBJECT
423 public:
424         PrefEdit(GuiPreferences * form);
425
426         void apply(LyXRC & rc) const;
427         void update(LyXRC const & rc);
428 };
429
430
431
432 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
433 {
434 public:
435         GuiShortcutDialog(QWidget * parent);
436 };
437
438
439 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
440 {
441         Q_OBJECT
442 public:
443         PrefShortcuts(GuiPreferences * form);
444
445         void apply(LyXRC & rc) const;
446         void update(LyXRC const & rc);
447         void updateShortcutsTW();
448         void modifyShortcut();
449         void removeShortcut();
450         ///
451         void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
452         QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
453                 KeySequence const & shortcut, KeyMap::ItemType tag);
454
455 public Q_SLOTS:
456         void selectBind();
457         void on_modifyPB_pressed();
458         void on_newPB_pressed();
459         void on_removePB_pressed();
460         void on_searchLE_textEdited();
461         ///
462         void on_shortcutsTW_itemSelectionChanged();
463         void on_shortcutsTW_itemDoubleClicked();
464         ///
465         void shortcutOkPressed();
466         void shortcutCancelPressed();
467         void shortcutClearPressed();
468         void shortcutRemovePressed();
469
470 private:
471         ///
472         GuiShortcutDialog * shortcut_;
473         ///
474         ButtonController shortcut_bc_;
475         /// category items
476         QTreeWidgetItem * editItem_;
477         QTreeWidgetItem * mathItem_;
478         QTreeWidgetItem * bufferItem_;
479         QTreeWidgetItem * layoutItem_;
480         QTreeWidgetItem * systemItem_;
481         // system_bind_ holds bindings from rc.bind_file
482         // user_bind_ holds \bind bindings from user.bind
483         // user_unbind_ holds \unbind bindings from user.bind
484         // When an item is inserted, it is added to user_bind_
485         // When an item from system_bind_ is deleted, it is added to user_unbind_
486         // When an item in user_bind_ or user_unbind_ is deleted, it is 
487         //      deleted (unbind)
488         KeyMap system_bind_;
489         KeyMap user_bind_;
490         KeyMap user_unbind_;
491         ///
492         QString save_lfun_;
493 };
494
495
496 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
497 {
498         Q_OBJECT
499 public:
500         PrefIdentity(GuiPreferences * form);
501
502         void apply(LyXRC & rc) const;
503         void update(LyXRC const & rc);
504 };
505
506
507 } // namespace frontend
508 } // namespace lyx
509
510 #endif // GUIPREFS_H