]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.h
Add missing initialization
[lyx.git] / src / frontends / qt4 / GuiPrefs.h
index b2e6813199901e6de60a62e9098ba9c087d3081f..ca93781c4b9ec508cdb3a4b6d1be31ed7dc035f1 100644 (file)
 
 #include "GuiDialog.h"
 
-#include "ColorCode.h"
 #include "Converter.h"
 #include "Format.h"
-#include "FuncCode.h"
 #include "KeyMap.h"
 #include "LyXRC.h"
 #include "Mover.h"
 
 #include "ui_PrefsUi.h"
 
-#include "ui_PrefPlaintextUi.h"
-#include "ui_PrefDateUi.h"
+#include "ui_PrefOutputUi.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_PrefDocHandlingUi.h"
 #include "ui_PrefEditUi.h"
 #include "ui_PrefPathsUi.h"
 #include "ui_PrefShortcutsUi.h"
@@ -41,7 +39,6 @@
 #include "ui_PrefConvertersUi.h"
 #include "ui_PrefFileformatsUi.h"
 #include "ui_PrefLanguageUi.h"
-#include "ui_PrefPrinterUi.h"
 #include "ui_PrefUi.h"
 #include "ui_PrefIdentityUi.h"
 #include "ui_ShortcutUi.h"
@@ -66,12 +63,15 @@ class GuiPreferences : public GuiDialog, public Ui::PrefsUi
 public:
        GuiPreferences(GuiView & lv);
 
-       void apply(LyXRC & rc) const;
-       void updateRc(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 public Q_SLOTS:
        void change_adaptor();
 
+Q_SIGNALS:
+       void prefsApplied(LyXRC const & rc);
+
 public:
        /// Apply changes
        void applyView();
@@ -91,7 +91,6 @@ public:
        QString browsebind(QString const & file) const;
        QString browseUI(QString const & file) const;
        QString browsekbmap(QString const & file) const;
-       QString browsedict(QString const & file) const;
 
        /// general browse
        QString browse(QString const & file, QString const & title) const;
@@ -102,10 +101,8 @@ public:
        /// 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;
+       /// update the previews after change
+       void updatePreviews();
 
        LyXRC & rc() { return rc_; }
        Converters & converters() { return converters_; }
@@ -128,8 +125,8 @@ private:
        /// A list of colors to be dispatched
        std::vector<std::string> colors_;
 
-       bool redraw_gui_;
        bool update_screen_font_;
+       bool update_previews_;
 };
 
 
@@ -142,8 +139,8 @@ public:
                : QWidget(form), category_(cat), title_(t), form_(form)
        {}
 
-       virtual void apply(LyXRC & rc) const = 0;
-       virtual void update(LyXRC const & rc) = 0;
+       virtual void applyRC(LyXRC & rc) const = 0;
+       virtual void updateRC(LyXRC const & rc) = 0;
 
        QString const & category() const { return category_; }
        QString const & title() const { return title_; }
@@ -158,25 +155,17 @@ Q_SIGNALS:
 };
 
 
-class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
+class PrefOutput : public PrefModule, public Ui::PrefOutputUi
 {
        Q_OBJECT
 public:
-       PrefPlaintext(GuiPreferences * form);
-
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
-};
+       PrefOutput(GuiPreferences * form);
 
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(LyXRC const & rc);
 
-class PrefDate : public PrefModule, public Ui::PrefDateUi
-{
-       Q_OBJECT
-public:
-       PrefDate(GuiPreferences * form);
-
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
+private Q_SLOTS:
+       void on_DateED_textChanged(const QString &);
 };
 
 
@@ -186,13 +175,14 @@ class PrefInput : public PrefModule, public Ui::PrefInputUi
 public:
        PrefInput(GuiPreferences * form);
 
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(LyXRC const & rc);
 
 private Q_SLOTS:
        void on_firstKeymapPB_clicked(bool);
        void on_secondKeymapPB_clicked(bool);
        void on_keymapCB_toggled(bool);
+       void on_scrollzoomEnableCB_toggled(bool);
 
 private:
        QString testKeymap(QString const & keymap);
@@ -205,8 +195,12 @@ class PrefCompletion : public PrefModule, public Ui::PrefCompletionUi
 public:
        PrefCompletion(GuiPreferences * form);
 
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(LyXRC const & rc);
+       virtual void enableCB();
+private Q_SLOTS:
+       void on_popupTextCB_clicked();
+       void on_inlineTextCB_clicked();
 };
 
 
@@ -216,8 +210,22 @@ class PrefLatex : public PrefModule, public Ui::PrefLatexUi
 public:
        PrefLatex(GuiPreferences * form);
 
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(LyXRC const & rc);
+
+private Q_SLOTS:
+       void on_latexEncodingCB_stateChanged(int state);
+       void on_latexBibtexCO_activated(int n);
+       void on_latexJBibtexCO_activated(int n);
+       void on_latexIndexCO_activated(int n);
+
+private:
+       ///
+       std::set<std::string> bibtex_alternatives;
+       ///
+       std::set<std::string> jbibtex_alternatives;
+       ///
+       std::set<std::string> index_alternatives;
 };
 
 
@@ -227,13 +235,16 @@ class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
 public:
        PrefScreenFonts(GuiPreferences * form);
 
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(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&);
+
+public Q_SLOTS:
+       void updateScreenFontSizes(LyXRC const & rc);
 };
 
 
@@ -243,12 +254,13 @@ class PrefColors : public PrefModule, public Ui::PrefColorsUi
 public:
        PrefColors(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 private Q_SLOTS:
-       void change_color();
-       void change_lyxObjects_selection();
+       void changeColor();
+       void changeSysColor();
+       void changeLyxObjectsSelection();
 
 private:
        std::vector<ColorCode> lcolors_;
@@ -263,8 +275,11 @@ class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
 public:
        PrefDisplay(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
+
+private Q_SLOTS:
+       void on_instantPreviewCO_currentIndexChanged(int);
 };
 
 
@@ -274,16 +289,18 @@ class PrefPaths : public PrefModule, public Ui::PrefPathsUi
 public:
        PrefPaths(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 private Q_SLOTS:
-       void select_exampledir();
-       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();
 
 };
 
@@ -294,11 +311,11 @@ class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
 public:
        PrefSpellchecker(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 private Q_SLOTS:
-       void select_dict();
+       void on_spellcheckerCB_currentIndexChanged(int);
 };
 
 
@@ -308,18 +325,19 @@ class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
 public:
        PrefConverters(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 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);
+       void on_needauthForbiddenCB_toggled(bool);
 
 private:
        void updateButtons();
@@ -332,8 +350,8 @@ class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
 public:
        PrefFileformats(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
        void updateView();
 
 Q_SIGNALS:
@@ -341,9 +359,10 @@ Q_SIGNALS:
 
 private Q_SLOTS:
        void on_copierED_textEdited(const QString & s);
-       void on_extensionED_textEdited(const QString &);
+       void on_extensionsED_textEdited(const QString &);
        void on_viewerED_textEdited(const QString &);
        void on_editorED_textEdited(const QString &);
+       void on_mimeED_textEdited(const QString &);
        void on_shortcutED_textEdited(const QString &);
        void on_formatED_editingFinished();
        void on_formatED_textChanged(const QString &);
@@ -351,11 +370,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;
 };
 
 
@@ -365,47 +394,52 @@ class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
 public:
        PrefLanguage(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 private Q_SLOTS:
        void on_uiLanguageCO_currentIndexChanged(int);
+       void on_languagePackageCO_currentIndexChanged(int);
 };
 
 
-class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
+class PrefUserInterface : public PrefModule, public Ui::PrefUi
 {
        Q_OBJECT
 public:
-       PrefPrinter(GuiPreferences * form);
+       PrefUserInterface(GuiPreferences * form);
+
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+public Q_SLOTS:
+       void selectUi();
 };
 
 
-class PrefUserInterface : public PrefModule, public Ui::PrefUi
+class PrefDocHandling : public PrefModule, public Ui::PrefDocHandlingUi
 {
        Q_OBJECT
 public:
-       PrefUserInterface(GuiPreferences * form);
+       PrefDocHandling(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 
 public Q_SLOTS:
-       void select_ui();
+       void on_clearSessionPB_clicked();
 };
 
 
+
 class PrefEdit : public PrefModule, public Ui::PrefEditUi
 {
        Q_OBJECT
 public:
        PrefEdit(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 };
 
 
@@ -420,42 +454,56 @@ public:
 class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
 {
        Q_OBJECT
-private:
-       enum ItemType {
-               System,         //< loaded from a bind file
-               UserBind,       //< \bind loaded from user.bind
-               UserUnbind,     //< \unbind loaded from user.bind, with corresponding
-                               //<    entry in system bind file
-               UserExtraUnbind //< \unbind loaded from user.bind, without
-                               //<    corresponding entry in system bind file.
-       };
 public:
        PrefShortcuts(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
        void updateShortcutsTW();
-       void modifyShortcut();
-       ///
-       void setItemType(QTreeWidgetItem * item, ItemType tag);
-       QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
-               KeySequence const & shortcut, ItemType tag);
 
 public Q_SLOTS:
-       void select_bind();
+       void selectBind();
        void on_modifyPB_pressed();
        void on_newPB_pressed();
        void on_removePB_pressed();
        void on_searchLE_textEdited();
        ///
        void on_shortcutsTW_itemSelectionChanged();
-       void shortcut_okPB_pressed();
-       void shortcut_cancelPB_pressed();
-       void shortcut_clearPB_pressed();
-       void shortcut_removePB_pressed();
        void on_shortcutsTW_itemDoubleClicked();
+       ///
+       void shortcutOkPressed();
+       void shortcutCancelPressed();
+       void shortcutClearPressed();
+       void shortcutRemovePressed();
 
 private:
+       void modifyShortcut();
+       /// remove selected binding, restore default value
+       void removeShortcut();
+       /// remove bindings, do not restore default values
+       void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
+       /// check the new binding k->func, and remove existing bindings to k after
+       /// asking the user. We exclude lfun_to_modify from this test: we assume
+       /// that if the user clicked "modify" then they agreed to modify the
+       /// binding. Returns false if the shortcut is invalid or the user cancels.
+       bool validateNewShortcut(FuncRequest const & func,
+                                KeySequence const & k,
+                                QString const & lfun_to_modify);
+       /// compute current active shortcut
+       FuncRequest currentBinding(KeySequence const & k);
+       ///
+       void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
+       ///
+       static KeyMap::ItemType itemType(QTreeWidgetItem & item);
+       /// some items need to be always hidden, for instance empty rebound
+       /// system keys
+       static bool isAlwaysHidden(QTreeWidgetItem & item);
+       /// unhide an empty system binding that may have been hidden
+       /// returns either null or the unhidden shortcut
+       void unhideEmpty(QString const & lfun, bool select);
+       ///
+       QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
+               KeySequence const & shortcut, KeyMap::ItemType tag);
        ///
        GuiShortcutDialog * shortcut_;
        ///
@@ -476,6 +524,8 @@ private:
        KeyMap system_bind_;
        KeyMap user_bind_;
        KeyMap user_unbind_;
+       ///
+       QString save_lfun_;
 };
 
 
@@ -485,8 +535,8 @@ class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
 public:
        PrefIdentity(GuiPreferences * form);
 
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       void applyRC(LyXRC & rc) const;
+       void updateRC(LyXRC const & rc);
 };