]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.h
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiPrefs.h
index 8d9028042d1f6379d91ce5c3fa1dd257d8ac5ee7..df16fde51b04adf3eaaa2f4ee760c7fb1a707b83 100644 (file)
 #define GUIPREFS_H
 
 #include "GuiDialog.h"
+#include "GuiLyXFiles.h"
 
-#include "ColorCode.h"
 #include "Converter.h"
 #include "Format.h"
-#include "FuncCode.h"
 #include "KeyMap.h"
 #include "LyXRC.h"
 #include "Mover.h"
@@ -33,6 +32,7 @@
 #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"
@@ -40,7 +40,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"
@@ -65,11 +64,12 @@ 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();
+       void slotFileSelected(QString);
 
 Q_SIGNALS:
        void prefsApplied(LyXRC const & rc);
@@ -90,9 +90,9 @@ public:
        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;
+       QString browsebind(QString const & file);
+       QString browseUI(QString const & file);
+       QString browsekbmap(QString const & file);
 
        /// general browse
        QString browse(QString const & file, QString const & title) const;
@@ -100,9 +100,6 @@ public:
        /// set a color
        void setColor(ColorCode col, QString const & hex);
 
-       /// update the screen fonts after change
-       void updateScreenFonts();
-
        LyXRC & rc() { return rc_; }
        Converters & converters() { return converters_; }
        Formats & formats() { return formats_; }
@@ -111,6 +108,9 @@ public:
 private:
        ///
        void addModule(PrefModule * module);
+       ///
+       QString browseLibFile(QString const & dir,
+               QString const & name, QString const & ext);
 
        /// temporary lyxrc
        LyXRC rc_;
@@ -123,9 +123,10 @@ private:
 
        /// A list of colors to be dispatched
        std::vector<std::string> colors_;
-
-       bool redraw_gui_;
-       bool update_screen_font_;
+       /// UI file selector
+       GuiLyXFiles * guilyxfiles_;
+       /// Selected UI file
+       QString uifile_;
 };
 
 
@@ -138,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_; }
@@ -160,11 +161,8 @@ class PrefOutput : public PrefModule, public Ui::PrefOutputUi
 public:
        PrefOutput(GuiPreferences * form);
 
-       virtual void apply(LyXRC & rc) const;
-       virtual void update(LyXRC const & rc);
-
-private Q_SLOTS:
-       void on_DateED_textChanged(const QString &);
+       virtual void applyRC(LyXRC & rc) const;
+       virtual void updateRC(LyXRC const & rc);
 };
 
 
@@ -174,8 +172,8 @@ 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);
@@ -194,8 +192,8 @@ 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();
@@ -209,18 +207,20 @@ 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;
 };
 
@@ -231,8 +231,8 @@ 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 selectRoman(const QString&);
@@ -250,17 +250,28 @@ 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 changeColor();
+       void resetColor();
+       void resetAllColor();
        void changeSysColor();
        void changeLyxObjectsSelection();
+       bool setColor(int const row, QColor const new_color,
+                     QString const old_color);
+       bool isDefaultColor(int const row, QString const color);
+       void setDisabledResets();
 
 private:
+       ///
+       QColor getDefaultColorByRow(int const row);
+       ///
        std::vector<ColorCode> lcolors_;
+       ///
        std::vector<QString> curcolors_;
+       ///
        std::vector<QString> newcolors_;
 };
 
@@ -271,12 +282,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);
-       void on_displayGraphicsCB_toggled(bool);
 };
 
 
@@ -286,8 +296,8 @@ 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 selectExampledir();
@@ -308,8 +318,8 @@ 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 on_spellcheckerCB_currentIndexChanged(int);
@@ -322,8 +332,8 @@ 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();
@@ -334,6 +344,8 @@ private Q_SLOTS:
        void removeConverter();
        void changeConverter();
        void on_cacheCB_stateChanged(int state);
+       void on_needauthForbiddenCB_toggled(bool);
+       void on_needauthCB_toggled(bool);
 
 private:
        void updateButtons();
@@ -346,8 +358,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:
@@ -390,8 +402,8 @@ 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);
@@ -399,40 +411,43 @@ private Q_SLOTS:
 };
 
 
-class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
+class PrefUserInterface : public PrefModule, public Ui::PrefUi
 {
        Q_OBJECT
 public:
-       PrefPrinter(GuiPreferences * form);
+       PrefUserInterface(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 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 selectUi();
        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);
 };
 
 
@@ -450,15 +465,9 @@ class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
 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 removeShortcut();
-       ///
-       void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
-       QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, 
-               KeySequence const & shortcut, KeyMap::ItemType tag);
 
 public Q_SLOTS:
        void selectBind();
@@ -476,6 +485,33 @@ public Q_SLOTS:
        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_;
        ///
@@ -491,7 +527,7 @@ private:
        // 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 
+       // When an item in user_bind_ or user_unbind_ is deleted, it is
        //      deleted (unbind)
        KeyMap system_bind_;
        KeyMap user_bind_;
@@ -507,8 +543,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);
 };