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