]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrefs.h
* UI changes in anticipation of polyglossia support:
[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         void on_scrollzoomEnableCB_toggled(bool);
187
188 private:
189         QString testKeymap(QString const & keymap);
190 };
191
192
193 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
194 {
195         Q_OBJECT
196 public:
197         PrefCompletion(GuiPreferences * form);
198
199         virtual void apply(LyXRC & rc) const;
200         virtual void update(LyXRC const & rc);
201         virtual void enableCB();
202 private Q_SLOTS:
203         void on_popupTextCB_clicked();
204         void on_inlineTextCB_clicked();
205 };
206
207
208 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
209 {
210         Q_OBJECT
211 public:
212         PrefLatex(GuiPreferences * form);
213
214         virtual void apply(LyXRC & rc) const;
215         virtual void update(LyXRC const & rc);
216
217 private Q_SLOTS:
218         void on_latexEncodingCB_stateChanged(int state);
219         void on_latexBibtexCO_activated(int n);
220         void on_latexIndexCO_activated(int n);
221
222 private:
223         ///
224         std::set<std::string> bibtex_alternatives;
225         ///
226         std::set<std::string> index_alternatives;
227 };
228
229
230 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
231 {
232         Q_OBJECT
233 public:
234         PrefScreenFonts(GuiPreferences * form);
235
236         virtual void apply(LyXRC & rc) const;
237         virtual void update(LyXRC const & rc);
238
239 private Q_SLOTS:
240         void selectRoman(const QString&);
241         void selectSans(const QString&);
242         void selectTypewriter(const QString&);
243 };
244
245
246 class PrefColors : public PrefModule, public Ui::PrefColorsUi
247 {
248         Q_OBJECT
249 public:
250         PrefColors(GuiPreferences * form);
251
252         void apply(LyXRC & rc) const;
253         void update(LyXRC const & rc);
254
255 private Q_SLOTS:
256         void changeColor();
257         void changeSysColor();
258         void changeLyxObjectsSelection();
259
260 private:
261         std::vector<ColorCode> lcolors_;
262         std::vector<QString> curcolors_;
263         std::vector<QString> newcolors_;
264 };
265
266
267 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
268 {
269         Q_OBJECT
270 public:
271         PrefDisplay(GuiPreferences * form);
272
273         void apply(LyXRC & rc) const;
274         void update(LyXRC const & rc);
275
276 private Q_SLOTS:
277         void on_instantPreviewCO_currentIndexChanged(int);
278 };
279
280
281 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
282 {
283         Q_OBJECT
284 public:
285         PrefPaths(GuiPreferences * form);
286
287         void apply(LyXRC & rc) const;
288         void update(LyXRC const & rc);
289
290 private Q_SLOTS:
291         void selectExampledir();
292         void selectTemplatedir();
293         void selectTempdir();
294         void selectBackupdir();
295         void selectWorkingdir();
296         void selectThesaurusdir();
297         void selectHunspelldir();
298         void selectLyxPipe();
299
300 };
301
302
303 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
304 {
305         Q_OBJECT
306 public:
307         PrefSpellchecker(GuiPreferences * form);
308
309         void apply(LyXRC & rc) const;
310         void update(LyXRC const & rc);
311
312 private Q_SLOTS:
313         void on_spellcheckerCB_currentIndexChanged(int);
314 };
315
316
317 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
318 {
319         Q_OBJECT
320 public:
321         PrefConverters(GuiPreferences * form);
322
323         void apply(LyXRC & rc) const;
324         void update(LyXRC const & rc);
325
326 public Q_SLOTS:
327         void updateGui();
328
329 private Q_SLOTS:
330         void updateConverter();
331         void switchConverter();
332         void removeConverter();
333         void changeConverter();
334         void on_cacheCB_stateChanged(int state);
335
336 private:
337         void updateButtons();
338 };
339
340
341 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
342 {
343         Q_OBJECT
344 public:
345         PrefFileformats(GuiPreferences * form);
346
347         void apply(LyXRC & rc) const;
348         void update(LyXRC const & rc);
349         void updateView();
350
351 Q_SIGNALS:
352         void formatsChanged();
353
354 private Q_SLOTS:
355         void on_copierED_textEdited(const QString & s);
356         void on_extensionED_textEdited(const QString &);
357         void on_viewerED_textEdited(const QString &);
358         void on_editorED_textEdited(const QString &);
359         void on_shortcutED_textEdited(const QString &);
360         void on_formatED_editingFinished();
361         void on_formatED_textChanged(const QString &);
362         void on_formatsCB_currentIndexChanged(int);
363         void on_formatsCB_editTextChanged(const QString &);
364         void on_formatNewPB_clicked();
365         void on_formatRemovePB_clicked();
366         void on_viewerCO_currentIndexChanged(int i);
367         void on_editorCO_currentIndexChanged(int i);
368         void setFlags();
369         void updatePrettyname();
370
371 private:
372         Format & currentFormat();
373         ///
374         void updateViewers();
375         ///
376         void updateEditors();
377         ///
378         LyXRC::Alternatives viewer_alternatives;
379         ///
380         LyXRC::Alternatives editor_alternatives;
381 };
382
383
384 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
385 {
386         Q_OBJECT
387 public:
388         PrefLanguage(GuiPreferences * form);
389
390         void apply(LyXRC & rc) const;
391         void update(LyXRC const & rc);
392
393 private Q_SLOTS:
394         void on_uiLanguageCO_currentIndexChanged(int);
395         void on_languagePackageCO_currentIndexChanged(int);
396 };
397
398
399 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
400 {
401         Q_OBJECT
402 public:
403         PrefPrinter(GuiPreferences * form);
404
405         void apply(LyXRC & rc) const;
406         void update(LyXRC const & rc);
407 };
408
409
410 class PrefUserInterface : public PrefModule, public Ui::PrefUi
411 {
412         Q_OBJECT
413 public:
414         PrefUserInterface(GuiPreferences * form);
415
416         void apply(LyXRC & rc) const;
417         void update(LyXRC const & rc);
418
419 public Q_SLOTS:
420         void selectUi();
421         void on_clearSessionPB_clicked();
422 };
423
424
425 class PrefEdit : public PrefModule, public Ui::PrefEditUi
426 {
427         Q_OBJECT
428 public:
429         PrefEdit(GuiPreferences * form);
430
431         void apply(LyXRC & rc) const;
432         void update(LyXRC const & rc);
433 };
434
435
436
437 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
438 {
439 public:
440         GuiShortcutDialog(QWidget * parent);
441 };
442
443
444 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
445 {
446         Q_OBJECT
447 public:
448         PrefShortcuts(GuiPreferences * form);
449
450         void apply(LyXRC & rc) const;
451         void update(LyXRC const & rc);
452         void updateShortcutsTW();
453         void modifyShortcut();
454         void removeShortcut();
455         ///
456         void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
457         QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
458                 KeySequence const & shortcut, KeyMap::ItemType tag);
459
460 public Q_SLOTS:
461         void selectBind();
462         void on_modifyPB_pressed();
463         void on_newPB_pressed();
464         void on_removePB_pressed();
465         void on_searchLE_textEdited();
466         ///
467         void on_shortcutsTW_itemSelectionChanged();
468         void on_shortcutsTW_itemDoubleClicked();
469         ///
470         void shortcutOkPressed();
471         void shortcutCancelPressed();
472         void shortcutClearPressed();
473         void shortcutRemovePressed();
474
475 private:
476         ///
477         GuiShortcutDialog * shortcut_;
478         ///
479         ButtonController shortcut_bc_;
480         /// category items
481         QTreeWidgetItem * editItem_;
482         QTreeWidgetItem * mathItem_;
483         QTreeWidgetItem * bufferItem_;
484         QTreeWidgetItem * layoutItem_;
485         QTreeWidgetItem * systemItem_;
486         // system_bind_ holds bindings from rc.bind_file
487         // user_bind_ holds \bind bindings from user.bind
488         // user_unbind_ holds \unbind bindings from user.bind
489         // When an item is inserted, it is added to user_bind_
490         // When an item from system_bind_ is deleted, it is added to user_unbind_
491         // When an item in user_bind_ or user_unbind_ is deleted, it is 
492         //      deleted (unbind)
493         KeyMap system_bind_;
494         KeyMap user_bind_;
495         KeyMap user_unbind_;
496         ///
497         QString save_lfun_;
498 };
499
500
501 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
502 {
503         Q_OBJECT
504 public:
505         PrefIdentity(GuiPreferences * form);
506
507         void apply(LyXRC & rc) const;
508         void update(LyXRC const & rc);
509 };
510
511
512 } // namespace frontend
513 } // namespace lyx
514
515 #endif // GUIPREFS_H