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_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"
62 class GuiPreferences : public GuiDialog, public Ui::PrefsUi
66 GuiPreferences(GuiView & lv);
68 void apply(LyXRC & rc) const;
69 void updateRc(LyXRC const & rc);
72 void change_adaptor();
75 void prefsApplied(LyXRC const & rc);
81 std::vector<PrefModule *> modules_;
84 bool initialiseParams(std::string const &);
88 void dispatchParams();
90 bool isBufferDependent() const { return false; }
92 /// various file pickers
93 QString browsebind(QString const & file) const;
94 QString browseUI(QString const & file) const;
95 QString browsekbmap(QString const & file) const;
98 QString browse(QString const & file, QString const & title) const;
101 void setColor(ColorCode col, QString const & hex);
103 /// update the screen fonts after change
104 void updateScreenFonts();
106 /// adjust the prefs paper sizes
107 PAPER_SIZE toPaperSize(int i) const;
108 /// adjust the prefs paper sizes
109 int fromPaperSize(PAPER_SIZE papersize) const;
111 LyXRC & rc() { return rc_; }
112 Converters & converters() { return converters_; }
113 Formats & formats() { return formats_; }
114 Movers & movers() { return movers_; }
118 void addModule(PrefModule * module);
122 /// temporary converters
123 Converters converters_;
124 /// temporary formats
129 /// A list of colors to be dispatched
130 std::vector<std::string> colors_;
133 bool update_screen_font_;
137 class PrefModule : public QWidget
141 PrefModule(QString const & cat, QString const & t,
142 GuiPreferences * form)
143 : QWidget(form), category_(cat), title_(t), form_(form)
146 virtual void apply(LyXRC & rc) const = 0;
147 virtual void update(LyXRC const & rc) = 0;
149 QString const & category() const { return category_; }
150 QString const & title() const { return title_; }
155 GuiPreferences * form_;
162 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
166 PrefOutput(GuiPreferences * form);
168 virtual void apply(LyXRC & rc) const;
169 virtual void update(LyXRC const & rc);
172 void on_DateED_textChanged(const QString &);
176 class PrefInput : public PrefModule, public Ui::PrefInputUi
180 PrefInput(GuiPreferences * form);
182 virtual void apply(LyXRC & rc) const;
183 virtual void update(LyXRC const & rc);
186 void on_firstKeymapPB_clicked(bool);
187 void on_secondKeymapPB_clicked(bool);
188 void on_keymapCB_toggled(bool);
189 void on_scrollzoomEnableCB_toggled(bool);
192 QString testKeymap(QString const & keymap);
196 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
200 PrefCompletion(GuiPreferences * form);
202 virtual void apply(LyXRC & rc) const;
203 virtual void update(LyXRC const & rc);
204 virtual void enableCB();
206 void on_popupTextCB_clicked();
207 void on_inlineTextCB_clicked();
211 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
215 PrefLatex(GuiPreferences * form);
217 virtual void apply(LyXRC & rc) const;
218 virtual void update(LyXRC const & rc);
221 void on_latexEncodingCB_stateChanged(int state);
222 void on_latexBibtexCO_activated(int n);
223 void on_latexIndexCO_activated(int n);
227 std::set<std::string> bibtex_alternatives;
229 std::set<std::string> index_alternatives;
233 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
237 PrefScreenFonts(GuiPreferences * form);
239 virtual void apply(LyXRC & rc) const;
240 virtual void update(LyXRC const & rc);
243 void selectRoman(const QString&);
244 void selectSans(const QString&);
245 void selectTypewriter(const QString&);
248 void updateScreenFontSizes(LyXRC const & rc);
252 class PrefColors : public PrefModule, public Ui::PrefColorsUi
256 PrefColors(GuiPreferences * form);
258 void apply(LyXRC & rc) const;
259 void update(LyXRC const & rc);
263 void changeSysColor();
264 void changeLyxObjectsSelection();
267 std::vector<ColorCode> lcolors_;
268 std::vector<QString> curcolors_;
269 std::vector<QString> newcolors_;
273 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
277 PrefDisplay(GuiPreferences * form);
279 void apply(LyXRC & rc) const;
280 void update(LyXRC const & rc);
283 void on_instantPreviewCO_currentIndexChanged(int);
287 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
291 PrefPaths(GuiPreferences * form);
293 void apply(LyXRC & rc) const;
294 void update(LyXRC const & rc);
297 void selectExampledir();
298 void selectTemplatedir();
299 void selectTempdir();
300 void selectBackupdir();
301 void selectWorkingdir();
302 void selectThesaurusdir();
303 void selectHunspelldir();
304 void selectLyxPipe();
309 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
313 PrefSpellchecker(GuiPreferences * form);
315 void apply(LyXRC & rc) const;
316 void update(LyXRC const & rc);
319 void on_spellcheckerCB_currentIndexChanged(int);
323 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
327 PrefConverters(GuiPreferences * form);
329 void apply(LyXRC & rc) const;
330 void update(LyXRC const & rc);
336 void updateConverter();
337 void switchConverter();
338 void removeConverter();
339 void changeConverter();
340 void on_cacheCB_stateChanged(int state);
343 void updateButtons();
347 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
351 PrefFileformats(GuiPreferences * form);
353 void apply(LyXRC & rc) const;
354 void update(LyXRC const & rc);
358 void formatsChanged();
361 void on_copierED_textEdited(const QString & s);
362 void on_extensionED_textEdited(const QString &);
363 void on_viewerED_textEdited(const QString &);
364 void on_editorED_textEdited(const QString &);
365 void on_shortcutED_textEdited(const QString &);
366 void on_formatED_editingFinished();
367 void on_formatED_textChanged(const QString &);
368 void on_formatsCB_currentIndexChanged(int);
369 void on_formatsCB_editTextChanged(const QString &);
370 void on_formatNewPB_clicked();
371 void on_formatRemovePB_clicked();
372 void on_viewerCO_currentIndexChanged(int i);
373 void on_editorCO_currentIndexChanged(int i);
375 void updatePrettyname();
378 Format & currentFormat();
380 void updateViewers();
382 void updateEditors();
384 LyXRC::Alternatives viewer_alternatives;
386 LyXRC::Alternatives editor_alternatives;
390 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
394 PrefLanguage(GuiPreferences * form);
396 void apply(LyXRC & rc) const;
397 void update(LyXRC const & rc);
400 void on_uiLanguageCO_currentIndexChanged(int);
401 void on_languagePackageCO_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