4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
11 * Full author contact details are available in file CREDITS.
17 #include "GuiDialog.h"
19 #include "ColorCode.h"
20 #include "Converter.h"
27 #include "ui_PrefsUi.h"
29 #include "ui_PrefPlaintextUi.h"
30 #include "ui_PrefDateUi.h"
31 #include "ui_PrefInputUi.h"
32 #include "ui_PrefLatexUi.h"
33 #include "ui_PrefScreenFontsUi.h"
34 #include "ui_PrefCompletionUi.h"
35 #include "ui_PrefColorsUi.h"
36 #include "ui_PrefDisplayUi.h"
37 #include "ui_PrefEditUi.h"
38 #include "ui_PrefPathsUi.h"
39 #include "ui_PrefShortcutsUi.h"
40 #include "ui_PrefSpellcheckerUi.h"
41 #include "ui_PrefConvertersUi.h"
42 #include "ui_PrefFileformatsUi.h"
43 #include "ui_PrefLanguageUi.h"
44 #include "ui_PrefPrinterUi.h"
45 #include "ui_PrefUi.h"
46 #include "ui_PrefIdentityUi.h"
47 #include "ui_ShortcutUi.h"
63 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
67 GuiPreferences(GuiView & lv);
69 void apply(LyXRC & rc) const;
70 void updateRc(LyXRC const & rc);
73 void change_adaptor();
79 std::vector<PrefModule *> modules_;
82 bool initialiseParams(std::string const &);
86 void dispatchParams();
88 bool isBufferDependent() const { return false; }
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;
96 QString browse(QString const & file, QString const & title) const;
99 void setColor(ColorCode col, QString const & hex);
101 /// update the screen fonts after change
102 void updateScreenFonts();
104 /// adjust the prefs paper sizes
105 PAPER_SIZE toPaperSize(int i) const;
106 /// adjust the prefs paper sizes
107 int fromPaperSize(PAPER_SIZE papersize) const;
109 LyXRC & rc() { return rc_; }
110 Converters & converters() { return converters_; }
111 Formats & formats() { return formats_; }
112 Movers & movers() { return movers_; }
116 void addModule(PrefModule * module);
120 /// temporary converters
121 Converters converters_;
122 /// temporary formats
127 /// A list of colors to be dispatched
128 std::vector<std::string> colors_;
131 bool update_screen_font_;
135 class PrefModule : public QWidget
139 PrefModule(QString const & cat, QString const & t,
140 GuiPreferences * form)
141 : QWidget(form), category_(cat), title_(t), form_(form)
144 virtual void apply(LyXRC & rc) const = 0;
145 virtual void update(LyXRC const & rc) = 0;
147 QString const & category() const { return category_; }
148 QString const & title() const { return title_; }
153 GuiPreferences * form_;
160 class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
164 PrefPlaintext(GuiPreferences * form);
166 virtual void apply(LyXRC & rc) const;
167 virtual void update(LyXRC const & rc);
171 class PrefDate : public PrefModule, public Ui::PrefDateUi
175 PrefDate(GuiPreferences * form);
177 virtual void apply(LyXRC & rc) const;
178 virtual void update(LyXRC const & rc);
181 void on_DateED_textChanged(const QString &);
185 class PrefInput : public PrefModule, public Ui::PrefInputUi
189 PrefInput(GuiPreferences * form);
191 virtual void apply(LyXRC & rc) const;
192 virtual void update(LyXRC const & rc);
195 void on_firstKeymapPB_clicked(bool);
196 void on_secondKeymapPB_clicked(bool);
197 void on_keymapCB_toggled(bool);
200 QString testKeymap(QString const & keymap);
204 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
208 PrefCompletion(GuiPreferences * form);
210 virtual void apply(LyXRC & rc) const;
211 virtual void update(LyXRC const & rc);
212 virtual void enableCB();
214 void on_popupTextCB_clicked();
215 void on_inlineTextCB_clicked();
219 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
223 PrefLatex(GuiPreferences * form);
225 virtual void apply(LyXRC & rc) const;
226 virtual void update(LyXRC const & rc);
229 void on_latexBibtexCO_activated(int n);
230 void on_latexIndexCO_activated(int n);
234 std::set<std::string> bibtex_alternatives;
236 std::set<std::string> index_alternatives;
240 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
244 PrefScreenFonts(GuiPreferences * form);
246 virtual void apply(LyXRC & rc) const;
247 virtual void update(LyXRC const & rc);
250 void selectRoman(const QString&);
251 void selectSans(const QString&);
252 void selectTypewriter(const QString&);
256 class PrefColors : public PrefModule, public Ui::PrefColorsUi
260 PrefColors(GuiPreferences * form);
262 void apply(LyXRC & rc) const;
263 void update(LyXRC const & rc);
267 void changeLyxObjectsSelection();
270 std::vector<ColorCode> lcolors_;
271 std::vector<QString> curcolors_;
272 std::vector<QString> newcolors_;
276 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
280 PrefDisplay(GuiPreferences * form);
282 void apply(LyXRC & rc) const;
283 void update(LyXRC const & rc);
286 void on_instantPreviewCO_currentIndexChanged(int);
290 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
294 PrefPaths(GuiPreferences * form);
296 void apply(LyXRC & rc) const;
297 void update(LyXRC const & rc);
300 void selectExampledir();
301 void selectTemplatedir();
302 void selectTempdir();
303 void selectBackupdir();
304 void selectWorkingdir();
305 void selectThesaurusdir();
306 void selectHunspelldir();
307 void selectLyxPipe();
312 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
316 PrefSpellchecker(GuiPreferences * form);
318 void apply(LyXRC & rc) const;
319 void update(LyXRC const & rc);
324 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
328 PrefConverters(GuiPreferences * form);
330 void apply(LyXRC & rc) const;
331 void update(LyXRC const & rc);
337 void updateConverter();
338 void switchConverter();
339 void removeConverter();
340 void changeConverter();
341 void on_cacheCB_stateChanged(int state);
344 void updateButtons();
348 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
352 PrefFileformats(GuiPreferences * form);
354 void apply(LyXRC & rc) const;
355 void update(LyXRC const & rc);
359 void formatsChanged();
362 void on_copierED_textEdited(const QString & s);
363 void on_extensionED_textEdited(const QString &);
364 void on_viewerED_textEdited(const QString &);
365 void on_editorED_textEdited(const QString &);
366 void on_shortcutED_textEdited(const QString &);
367 void on_formatED_editingFinished();
368 void on_formatED_textChanged(const QString &);
369 void on_formatsCB_currentIndexChanged(int);
370 void on_formatsCB_editTextChanged(const QString &);
371 void on_formatNewPB_clicked();
372 void on_formatRemovePB_clicked();
373 void on_viewerCO_currentIndexChanged(int i);
374 void on_editorCO_currentIndexChanged(int i);
376 void updatePrettyname();
379 Format & currentFormat();
381 void updateViewers();
383 void updateEditors();
385 LyXRC::Alternatives viewer_alternatives;
387 LyXRC::Alternatives editor_alternatives;
391 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
395 PrefLanguage(GuiPreferences * form);
397 void apply(LyXRC & rc) const;
398 void update(LyXRC const & rc);
401 void on_uiLanguageCO_currentIndexChanged(int);
405 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
409 PrefPrinter(GuiPreferences * form);
411 void apply(LyXRC & rc) const;
412 void update(LyXRC const & rc);
416 class PrefUserInterface : public PrefModule, public Ui::PrefUi
420 PrefUserInterface(GuiPreferences * form);
422 void apply(LyXRC & rc) const;
423 void update(LyXRC const & rc);
427 void on_clearSessionPB_clicked();
431 class PrefEdit : public PrefModule, public Ui::PrefEditUi
435 PrefEdit(GuiPreferences * form);
437 void apply(LyXRC & rc) const;
438 void update(LyXRC const & rc);
443 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
446 GuiShortcutDialog(QWidget * parent);
450 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
454 PrefShortcuts(GuiPreferences * form);
456 void apply(LyXRC & rc) const;
457 void update(LyXRC const & rc);
458 void updateShortcutsTW();
459 void modifyShortcut();
460 void removeShortcut();
462 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
463 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
464 KeySequence const & shortcut, KeyMap::ItemType tag);
468 void on_modifyPB_pressed();
469 void on_newPB_pressed();
470 void on_removePB_pressed();
471 void on_searchLE_textEdited();
473 void on_shortcutsTW_itemSelectionChanged();
474 void on_shortcutsTW_itemDoubleClicked();
476 void shortcutOkPressed();
477 void shortcutCancelPressed();
478 void shortcutClearPressed();
479 void shortcutRemovePressed();
483 GuiShortcutDialog * shortcut_;
485 ButtonController shortcut_bc_;
487 QTreeWidgetItem * editItem_;
488 QTreeWidgetItem * mathItem_;
489 QTreeWidgetItem * bufferItem_;
490 QTreeWidgetItem * layoutItem_;
491 QTreeWidgetItem * systemItem_;
492 // system_bind_ holds bindings from rc.bind_file
493 // user_bind_ holds \bind bindings from user.bind
494 // user_unbind_ holds \unbind bindings from user.bind
495 // When an item is inserted, it is added to user_bind_
496 // When an item from system_bind_ is deleted, it is added to user_unbind_
497 // When an item in user_bind_ or user_unbind_ is deleted, it is
507 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
511 PrefIdentity(GuiPreferences * form);
513 void apply(LyXRC & rc) const;
514 void update(LyXRC const & rc);
518 } // namespace frontend