X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiPrefs.h;h=2a0405fb3ec337eb1a482fd30757f8fe31bf801a;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=b5bf6ff381c4dad5466da350823e74b2eed8b21b;hpb=0780a505eb22c31b210592474763c29e2b16a4ab;p=lyx.git diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index b5bf6ff381..2a0405fb3e 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -5,6 +5,8 @@ * Licence details can be found in the file COPYING. * * \author John Levon + * \author Bo Peng + * \author Edwin Leuven * * Full author contact details are available in file CREDITS. */ @@ -14,9 +16,11 @@ #include "GuiDialog.h" -#include "Color.h" +#include "ColorCode.h" #include "Converter.h" #include "Format.h" +#include "FuncCode.h" +#include "KeyMap.h" #include "LyXRC.h" #include "Mover.h" @@ -24,11 +28,13 @@ #include "ui_PrefPlaintextUi.h" #include "ui_PrefDateUi.h" -#include "ui_PrefKeyboardUi.h" +#include "ui_PrefInputUi.h" #include "ui_PrefLatexUi.h" #include "ui_PrefScreenFontsUi.h" +#include "ui_PrefCompletionUi.h" #include "ui_PrefColorsUi.h" #include "ui_PrefDisplayUi.h" +#include "ui_PrefEditUi.h" #include "ui_PrefPathsUi.h" #include "ui_PrefShortcutsUi.h" #include "ui_PrefSpellcheckerUi.h" @@ -40,40 +46,110 @@ #include "ui_PrefIdentityUi.h" #include "ui_ShortcutUi.h" -#include -#include - #include #include namespace lyx { -class Color_color; class Converters; class Formats; class Movers; namespace frontend { -class GuiPreferences; +class PrefModule; + +class GuiPreferences : public GuiDialog, public Ui::PrefsUi +{ + Q_OBJECT +public: + GuiPreferences(GuiView & lv); + + void apply(LyXRC & rc) const; + void updateRc(LyXRC const & rc); + +public Q_SLOTS: + void change_adaptor(); + +public: + /// Apply changes + void applyView(); + + std::vector modules_; + + /// + bool initialiseParams(std::string const &); + /// + void clearParams() {} + /// + void dispatchParams(); + /// + bool isBufferDependent() const { return false; } + + /// various file pickers + QString browsebind(QString const & file) const; + QString browseUI(QString const & file) const; + QString browsekbmap(QString const & file) const; + + /// general browse + QString browse(QString const & file, QString const & title) const; + + /// set a color + void setColor(ColorCode col, QString const & hex); + + /// update the screen fonts after change + void updateScreenFonts(); + + /// adjust the prefs paper sizes + PAPER_SIZE toPaperSize(int i) const; + /// adjust the prefs paper sizes + int fromPaperSize(PAPER_SIZE papersize) const; + + LyXRC & rc() { return rc_; } + Converters & converters() { return converters_; } + Formats & formats() { return formats_; } + Movers & movers() { return movers_; } + +private: + /// + void addModule(PrefModule * module); + + /// temporary lyxrc + LyXRC rc_; + /// temporary converters + Converters converters_; + /// temporary formats + Formats formats_; + /// temporary movers + Movers movers_; + + /// A list of colors to be dispatched + std::vector colors_; + + bool redraw_gui_; + bool update_screen_font_; +}; + class PrefModule : public QWidget { Q_OBJECT public: - PrefModule(docstring const & t, - GuiPreferences * form = 0, QWidget * parent = 0) - : QWidget(parent), title_(t), form_(form) + PrefModule(QString const & cat, QString const & t, + GuiPreferences * form) + : QWidget(form), category_(cat), title_(t), form_(form) {} virtual void apply(LyXRC & rc) const = 0; virtual void update(LyXRC const & rc) = 0; - docstring const & title() const { return title_; } + QString const & category() const { return category_; } + QString const & title() const { return title_; } protected: - docstring title_; + QString category_; + QString title_; GuiPreferences * form_; Q_SIGNALS: @@ -85,7 +161,7 @@ class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi { Q_OBJECT public: - PrefPlaintext(QWidget * parent = 0); + PrefPlaintext(GuiPreferences * form); virtual void apply(LyXRC & rc) const; virtual void update(LyXRC const & rc); @@ -96,18 +172,21 @@ class PrefDate : public PrefModule, public Ui::PrefDateUi { Q_OBJECT public: - PrefDate(QWidget * parent = 0); + PrefDate(GuiPreferences * form); virtual void apply(LyXRC & rc) const; virtual void update(LyXRC const & rc); + +private Q_SLOTS: + void on_DateED_textChanged(const QString &); }; -class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi +class PrefInput : public PrefModule, public Ui::PrefInputUi { Q_OBJECT public: - PrefKeyboard(GuiPreferences * form, QWidget * parent = 0); + PrefInput(GuiPreferences * form); virtual void apply(LyXRC & rc) const; virtual void update(LyXRC const & rc); @@ -118,7 +197,22 @@ private Q_SLOTS: void on_keymapCB_toggled(bool); private: - QString testKeymap(QString keymap); + QString testKeymap(QString const & keymap); +}; + + +class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi +{ + Q_OBJECT +public: + PrefCompletion(GuiPreferences * form); + + virtual void apply(LyXRC & rc) const; + virtual void update(LyXRC const & rc); + virtual void enableCB(); +private Q_SLOTS: + void on_popupTextCB_clicked(); + void on_inlineTextCB_clicked(); }; @@ -126,10 +220,21 @@ class PrefLatex : public PrefModule, public Ui::PrefLatexUi { Q_OBJECT public: - PrefLatex(GuiPreferences * form, QWidget * parent = 0); + PrefLatex(GuiPreferences * form); virtual void apply(LyXRC & rc) const; virtual void update(LyXRC const & rc); + +private Q_SLOTS: + void on_latexEncodingCB_stateChanged(int state); + void on_latexBibtexCO_activated(int n); + void on_latexIndexCO_activated(int n); + +private: + /// + std::set bibtex_alternatives; + /// + std::set index_alternatives; }; @@ -137,15 +242,15 @@ class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi { Q_OBJECT public: - PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0); + PrefScreenFonts(GuiPreferences * form); virtual void apply(LyXRC & rc) const; virtual void update(LyXRC const & rc); private Q_SLOTS: - void select_roman(const QString&); - void select_sans(const QString&); - void select_typewriter(const QString&); + void selectRoman(const QString&); + void selectSans(const QString&); + void selectTypewriter(const QString&); }; @@ -153,23 +258,19 @@ class PrefColors : public PrefModule, public Ui::PrefColorsUi { Q_OBJECT public: - PrefColors(GuiPreferences * form, QWidget * parent = 0); + PrefColors(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); private Q_SLOTS: - void change_color(); - void change_lyxObjects_selection(); + void changeColor(); + void changeLyxObjectsSelection(); private: - std::vector lcolors_; - // FIXME the use of mutable here is required due to the - // fact that initialization is not done in the controller - // but in the constructor. + std::vector lcolors_; std::vector curcolors_; std::vector newcolors_; - }; @@ -177,10 +278,13 @@ class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi { Q_OBJECT public: - PrefDisplay(QWidget * parent = 0); + PrefDisplay(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); + +private Q_SLOTS: + void on_instantPreviewCO_currentIndexChanged(int); }; @@ -188,17 +292,20 @@ class PrefPaths : public PrefModule, public Ui::PrefPathsUi { Q_OBJECT public: - PrefPaths(GuiPreferences * form, QWidget * parent = 0); + PrefPaths(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); private Q_SLOTS: - void select_templatedir(); - void select_tempdir(); - void select_backupdir(); - void select_workingdir(); - void select_lyxpipe(); + void selectExampledir(); + void selectTemplatedir(); + void selectTempdir(); + void selectBackupdir(); + void selectWorkingdir(); + void selectThesaurusdir(); + void selectHunspelldir(); + void selectLyxPipe(); }; @@ -207,13 +314,11 @@ class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi { Q_OBJECT public: - PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0); + PrefSpellchecker(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); -private Q_SLOTS: - void select_dict(); }; @@ -221,7 +326,7 @@ class PrefConverters : public PrefModule, public Ui::PrefConvertersUi { Q_OBJECT public: - PrefConverters(GuiPreferences * form, QWidget * parent = 0); + PrefConverters(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); @@ -230,10 +335,10 @@ public Q_SLOTS: void updateGui(); private Q_SLOTS: - void update_converter(); - void switch_converter(); - void converter_changed(); - void remove_converter(); + void updateConverter(); + void switchConverter(); + void removeConverter(); + void changeConverter(); void on_cacheCB_stateChanged(int state); private: @@ -241,41 +346,11 @@ private: }; -class FormatValidator : public QValidator -{ -public: - FormatValidator(QWidget *, Formats const & f); - void fixup(QString & input) const; - QValidator::State validate(QString & input, int & pos) const; -private: - virtual std::string str(Formats::const_iterator it) const = 0; - int nr() const; - Formats const & formats_; -}; - - -class FormatNameValidator : public FormatValidator -{ -public: - FormatNameValidator(QWidget *, Formats const & f); -private: - std::string str(Formats::const_iterator it) const; -}; - -class FormatPrettynameValidator : public FormatValidator -{ -public: - FormatPrettynameValidator(QWidget *, Formats const & f); -private: - std::string str(Formats::const_iterator it) const; -}; - - class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi { Q_OBJECT public: - PrefFileformats(GuiPreferences * form, QWidget * parent = 0); + PrefFileformats(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); @@ -296,11 +371,21 @@ private Q_SLOTS: void on_formatsCB_editTextChanged(const QString &); void on_formatNewPB_clicked(); void on_formatRemovePB_clicked(); + void on_viewerCO_currentIndexChanged(int i); + void on_editorCO_currentIndexChanged(int i); void setFlags(); void updatePrettyname(); private: Format & currentFormat(); + /// + void updateViewers(); + /// + void updateEditors(); + /// + LyXRC::Alternatives viewer_alternatives; + /// + LyXRC::Alternatives editor_alternatives; }; @@ -308,13 +393,13 @@ class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi { Q_OBJECT public: - PrefLanguage(QWidget * parent = 0); + PrefLanguage(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); -private: - std::vector lang_; +private Q_SLOTS: + void on_uiLanguageCO_currentIndexChanged(int); }; @@ -322,7 +407,7 @@ class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi { Q_OBJECT public: - PrefPrinter(QWidget * parent = 0); + PrefPrinter(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); @@ -333,138 +418,101 @@ class PrefUserInterface : public PrefModule, public Ui::PrefUi { Q_OBJECT public: - PrefUserInterface(GuiPreferences * form, QWidget * parent = 0); + PrefUserInterface(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); public Q_SLOTS: - void select_ui(); - void on_loadWindowSizeCB_toggled(bool); - -}; - - -class GuiShortcutDialog : public QDialog, public Ui::ShortcutUi -{ -public: - GuiShortcutDialog(QWidget * parent) : QDialog(parent) - { - Ui::ShortcutUi::setupUi(this); - QDialog::setModal(true); - } + void selectUi(); + void on_clearSessionPB_clicked(); }; -class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts +class PrefEdit : public PrefModule, public Ui::PrefEditUi { Q_OBJECT public: - PrefShortcuts(GuiPreferences * form, QWidget * parent = 0); + PrefEdit(GuiPreferences * form); void apply(LyXRC & rc) const; void update(LyXRC const & rc); - -public Q_SLOTS: - void select_bind(); - void on_newPB_pressed(); - void on_modifyPB_pressed(); - void on_removePB_pressed(); - void on_searchPB_pressed(); -private: - GuiShortcutDialog * shortcut_; }; -class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi + +class GuiShortcutDialog : public QDialog, public Ui::shortcutUi { - Q_OBJECT public: - PrefIdentity(QWidget * parent = 0); - - void apply(LyXRC & rc) const; - void update(LyXRC const & rc); + GuiShortcutDialog(QWidget * parent); }; -class GuiPreferences : public GuiDialog, public Ui::PrefsUi +class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts { Q_OBJECT public: - GuiPreferences(LyXView & lv); + PrefShortcuts(GuiPreferences * form); void apply(LyXRC & rc) const; - void updateRc(LyXRC const & rc); + void update(LyXRC const & rc); + void updateShortcutsTW(); + void modifyShortcut(); + void removeShortcut(); + /// + void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag); + QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, + KeySequence const & shortcut, KeyMap::ItemType tag); public Q_SLOTS: - void change_adaptor(); - -public: - // - void closeEvent(QCloseEvent * e); + void selectBind(); + void on_modifyPB_pressed(); + void on_newPB_pressed(); + void on_removePB_pressed(); + void on_searchLE_textEdited(); /// - void add(PrefModule * module); - /// Apply changes - void applyView(); - /// update (do we need this?) - void updateContents(); - - std::vector modules_; - + void on_shortcutsTW_itemSelectionChanged(); + void on_shortcutsTW_itemDoubleClicked(); /// - bool initialiseParams(std::string const &); + void shortcutOkPressed(); + void shortcutCancelPressed(); + void shortcutClearPressed(); + void shortcutRemovePressed(); + +private: /// - void clearParams() {} + GuiShortcutDialog * shortcut_; /// - void dispatchParams(); + ButtonController shortcut_bc_; + /// category items + QTreeWidgetItem * editItem_; + QTreeWidgetItem * mathItem_; + QTreeWidgetItem * bufferItem_; + QTreeWidgetItem * layoutItem_; + QTreeWidgetItem * systemItem_; + // system_bind_ holds bindings from rc.bind_file + // user_bind_ holds \bind bindings from user.bind + // user_unbind_ holds \unbind bindings from user.bind + // When an item is inserted, it is added to user_bind_ + // When an item from system_bind_ is deleted, it is added to user_unbind_ + // When an item in user_bind_ or user_unbind_ is deleted, it is + // deleted (unbind) + KeyMap system_bind_; + KeyMap user_bind_; + KeyMap user_unbind_; /// - bool isBufferDependent() const { return false; } - - /// various file pickers - docstring const browsebind(docstring const & file) const; - docstring const browseUI(docstring const & file) const; - docstring const browsekbmap(docstring const & file) const; - docstring const browsedict(docstring const & file) const; - - /// general browse - docstring const browse(docstring const & file, - docstring const & title) const; - - /// browse directory - docstring const browsedir(docstring const & path, - docstring const & title) const; - - /// set a color - void setColor(Color_color col, std::string const & hex); - - /// update the screen fonts after change - void updateScreenFonts(); - - /// adjust the prefs paper sizes - PAPER_SIZE toPaperSize(int i) const; - /// adjust the prefs paper sizes - int fromPaperSize(PAPER_SIZE papersize) const; - - LyXRC & rc() { return rc_; } - Converters & converters() { return converters_; } - Formats & formats() { return formats_; } - Movers & movers() { return movers_; } + QString save_lfun_; +}; -private: - /// temporary lyxrc - LyXRC rc_; - /// temporary converters - Converters converters_; - /// temporary formats - Formats formats_; - /// temporary movers - Movers movers_; - /// A list of colors to be dispatched - std::vector colors_; +class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi +{ + Q_OBJECT +public: + PrefIdentity(GuiPreferences * form); - bool redraw_gui_; - bool update_screen_font_; + void apply(LyXRC & rc) const; + void update(LyXRC const & rc); };