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