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();
78 std::vector<PrefModule *> modules_;
81 bool initialiseParams(std::string const &);
85 void dispatchParams();
87 bool isBufferDependent() const { return false; }
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;
95 QString browse(QString const & file, QString const & title) const;
98 void setColor(ColorCode col, QString const & hex);
100 /// update the screen fonts after change
101 void updateScreenFonts();
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;
108 LyXRC & rc() { return rc_; }
109 Converters & converters() { return converters_; }
110 Formats & formats() { return formats_; }
111 Movers & movers() { return movers_; }
115 void addModule(PrefModule * module);
119 /// temporary converters
120 Converters converters_;
121 /// temporary formats
126 /// A list of colors to be dispatched
127 std::vector<std::string> colors_;
130 bool update_screen_font_;
134 class PrefModule : public QWidget
138 PrefModule(QString const & cat, QString const & t,
139 GuiPreferences * form)
140 : QWidget(form), category_(cat), title_(t), form_(form)
143 virtual void apply(LyXRC & rc) const = 0;
144 virtual void update(LyXRC const & rc) = 0;
146 QString const & category() const { return category_; }
147 QString const & title() const { return title_; }
152 GuiPreferences * form_;
159 class PrefOutput : public PrefModule, public Ui::PrefOutputUi
163 PrefOutput(GuiPreferences * form);
165 virtual void apply(LyXRC & rc) const;
166 virtual void update(LyXRC const & rc);
169 void on_DateED_textChanged(const QString &);
173 class PrefInput : public PrefModule, public Ui::PrefInputUi
177 PrefInput(GuiPreferences * form);
179 virtual void apply(LyXRC & rc) const;
180 virtual void update(LyXRC const & rc);
183 void on_firstKeymapPB_clicked(bool);
184 void on_secondKeymapPB_clicked(bool);
185 void on_keymapCB_toggled(bool);
186 void on_scrollzoomEnableCB_toggled(bool);
189 QString testKeymap(QString const & keymap);
193 class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
197 PrefCompletion(GuiPreferences * form);
199 virtual void apply(LyXRC & rc) const;
200 virtual void update(LyXRC const & rc);
201 virtual void enableCB();
203 void on_popupTextCB_clicked();
204 void on_inlineTextCB_clicked();
208 class PrefLatex : public PrefModule, public Ui::PrefLatexUi
212 PrefLatex(GuiPreferences * form);
214 virtual void apply(LyXRC & rc) const;
215 virtual void update(LyXRC const & rc);
218 void on_latexEncodingCB_stateChanged(int state);
219 void on_latexBibtexCO_activated(int n);
220 void on_latexIndexCO_activated(int n);
224 std::set<std::string> bibtex_alternatives;
226 std::set<std::string> index_alternatives;
230 class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
234 PrefScreenFonts(GuiPreferences * form);
236 virtual void apply(LyXRC & rc) const;
237 virtual void update(LyXRC const & rc);
240 void selectRoman(const QString&);
241 void selectSans(const QString&);
242 void selectTypewriter(const QString&);
246 class PrefColors : public PrefModule, public Ui::PrefColorsUi
250 PrefColors(GuiPreferences * form);
252 void apply(LyXRC & rc) const;
253 void update(LyXRC const & rc);
257 void changeSysColor();
258 void changeLyxObjectsSelection();
261 std::vector<ColorCode> lcolors_;
262 std::vector<QString> curcolors_;
263 std::vector<QString> newcolors_;
267 class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
271 PrefDisplay(GuiPreferences * form);
273 void apply(LyXRC & rc) const;
274 void update(LyXRC const & rc);
277 void on_instantPreviewCO_currentIndexChanged(int);
281 class PrefPaths : public PrefModule, public Ui::PrefPathsUi
285 PrefPaths(GuiPreferences * form);
287 void apply(LyXRC & rc) const;
288 void update(LyXRC const & rc);
291 void selectExampledir();
292 void selectTemplatedir();
293 void selectTempdir();
294 void selectBackupdir();
295 void selectWorkingdir();
296 void selectThesaurusdir();
297 void selectHunspelldir();
298 void selectLyxPipe();
303 class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
307 PrefSpellchecker(GuiPreferences * form);
309 void apply(LyXRC & rc) const;
310 void update(LyXRC const & rc);
315 class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
319 PrefConverters(GuiPreferences * form);
321 void apply(LyXRC & rc) const;
322 void update(LyXRC const & rc);
328 void updateConverter();
329 void switchConverter();
330 void removeConverter();
331 void changeConverter();
332 void on_cacheCB_stateChanged(int state);
335 void updateButtons();
339 class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
343 PrefFileformats(GuiPreferences * form);
345 void apply(LyXRC & rc) const;
346 void update(LyXRC const & rc);
350 void formatsChanged();
353 void on_copierED_textEdited(const QString & s);
354 void on_extensionED_textEdited(const QString &);
355 void on_viewerED_textEdited(const QString &);
356 void on_editorED_textEdited(const QString &);
357 void on_shortcutED_textEdited(const QString &);
358 void on_formatED_editingFinished();
359 void on_formatED_textChanged(const QString &);
360 void on_formatsCB_currentIndexChanged(int);
361 void on_formatsCB_editTextChanged(const QString &);
362 void on_formatNewPB_clicked();
363 void on_formatRemovePB_clicked();
364 void on_viewerCO_currentIndexChanged(int i);
365 void on_editorCO_currentIndexChanged(int i);
367 void updatePrettyname();
370 Format & currentFormat();
372 void updateViewers();
374 void updateEditors();
376 LyXRC::Alternatives viewer_alternatives;
378 LyXRC::Alternatives editor_alternatives;
382 class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
386 PrefLanguage(GuiPreferences * form);
388 void apply(LyXRC & rc) const;
389 void update(LyXRC const & rc);
392 void on_uiLanguageCO_currentIndexChanged(int);
396 class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
400 PrefPrinter(GuiPreferences * form);
402 void apply(LyXRC & rc) const;
403 void update(LyXRC const & rc);
407 class PrefUserInterface : public PrefModule, public Ui::PrefUi
411 PrefUserInterface(GuiPreferences * form);
413 void apply(LyXRC & rc) const;
414 void update(LyXRC const & rc);
418 void on_clearSessionPB_clicked();
422 class PrefEdit : public PrefModule, public Ui::PrefEditUi
426 PrefEdit(GuiPreferences * form);
428 void apply(LyXRC & rc) const;
429 void update(LyXRC const & rc);
434 class GuiShortcutDialog : public QDialog, public Ui::shortcutUi
437 GuiShortcutDialog(QWidget * parent);
441 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
445 PrefShortcuts(GuiPreferences * form);
447 void apply(LyXRC & rc) const;
448 void update(LyXRC const & rc);
449 void updateShortcutsTW();
450 void modifyShortcut();
451 void removeShortcut();
453 void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
454 QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
455 KeySequence const & shortcut, KeyMap::ItemType tag);
459 void on_modifyPB_pressed();
460 void on_newPB_pressed();
461 void on_removePB_pressed();
462 void on_searchLE_textEdited();
464 void on_shortcutsTW_itemSelectionChanged();
465 void on_shortcutsTW_itemDoubleClicked();
467 void shortcutOkPressed();
468 void shortcutCancelPressed();
469 void shortcutClearPressed();
470 void shortcutRemovePressed();
474 GuiShortcutDialog * shortcut_;
476 ButtonController shortcut_bc_;
478 QTreeWidgetItem * editItem_;
479 QTreeWidgetItem * mathItem_;
480 QTreeWidgetItem * bufferItem_;
481 QTreeWidgetItem * layoutItem_;
482 QTreeWidgetItem * systemItem_;
483 // system_bind_ holds bindings from rc.bind_file
484 // user_bind_ holds \bind bindings from user.bind
485 // user_unbind_ holds \unbind bindings from user.bind
486 // When an item is inserted, it is added to user_bind_
487 // When an item from system_bind_ is deleted, it is added to user_unbind_
488 // When an item in user_bind_ or user_unbind_ is deleted, it is
498 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
502 PrefIdentity(GuiPreferences * form);
504 void apply(LyXRC & rc) const;
505 void update(LyXRC const & rc);
509 } // namespace frontend