]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.h
next one
[lyx.git] / src / frontends / qt4 / GuiPrefs.h
index 00dd244292e323831ff85f23e5cf34f0c5fa6c42..8421fc3bc6f5f3fe5c12f7298f5bddf722780907 100644 (file)
 #ifndef GUIPREFS_H
 #define GUIPREFS_H
 
-#include "GuiDialogView.h"
-#include "ControlPrefs.h"
+#include "GuiDialog.h"
+
 #include "Color.h"
+#include "Converter.h"
+#include "Format.h"
 #include "LyXRC.h"
+#include "Mover.h"
 
 #include "ui_PrefsUi.h"
 
 #include "ui_PrefLatexUi.h"
 #include "ui_PrefScreenFontsUi.h"
 #include "ui_PrefColorsUi.h"
-#include "ui_PrefCygwinPathUi.h"
 #include "ui_PrefDisplayUi.h"
 #include "ui_PrefPathsUi.h"
 #include "ui_PrefSpellcheckerUi.h"
 #include "ui_PrefConvertersUi.h"
-#include "ui_PrefCopiersUi.h"
 #include "ui_PrefFileformatsUi.h"
 #include "ui_PrefLanguageUi.h"
 #include "ui_PrefPrinterUi.h"
 #include "ui_PrefIdentityUi.h"
 
 #include <QDialog>
+#include <QValidator>
 
+#include <string>
 #include <vector>
 
+
 namespace lyx {
 
+class Color_color;
 class Converters;
 class Formats;
 class Movers;
 
 namespace frontend {
 
-class GuiPrefs;
+class GuiPreferences;
 
 class PrefModule : public QWidget
 {
        Q_OBJECT
 public:
        PrefModule(docstring const & t,
-                       GuiPrefs * form = 0, QWidget * parent = 0)
+                       GuiPreferences * form = 0, QWidget * parent = 0)
                : QWidget(parent), title_(t), form_(form)
        {}
 
@@ -67,14 +72,14 @@ public:
 
 protected:
        docstring title_;
-       GuiPrefs * form_;
+       GuiPreferences * form_;
 
 Q_SIGNALS:
        void changed();
 };
 
 
-class PrefPlaintext :  public PrefModule, public Ui::PrefPlaintextUi
+class PrefPlaintext : public PrefModule, public Ui::PrefPlaintextUi
 {
        Q_OBJECT
 public:
@@ -85,7 +90,7 @@ public:
 };
 
 
-class PrefDate :  public PrefModule, public Ui::PrefDateUi
+class PrefDate : public PrefModule, public Ui::PrefDateUi
 {
        Q_OBJECT
 public:
@@ -96,11 +101,11 @@ public:
 };
 
 
-class PrefKeyboard :  public PrefModule, public Ui::PrefKeyboardUi
+class PrefKeyboard : public PrefModule, public Ui::PrefKeyboardUi
 {
        Q_OBJECT
 public:
-       PrefKeyboard(GuiPrefs * form, QWidget * parent = 0);
+       PrefKeyboard(GuiPreferences * form, QWidget * parent = 0);
 
        virtual void apply(LyXRC & rc) const;
        virtual void update(LyXRC const & rc);
@@ -115,22 +120,22 @@ private:
 };
 
 
-class PrefLatex :  public PrefModule, public Ui::PrefLatexUi
+class PrefLatex : public PrefModule, public Ui::PrefLatexUi
 {
        Q_OBJECT
 public:
-       PrefLatex(GuiPrefs * form, QWidget * parent = 0);
+       PrefLatex(GuiPreferences * form, QWidget * parent = 0);
 
        virtual void apply(LyXRC & rc) const;
        virtual void update(LyXRC const & rc);
 };
 
 
-class PrefScreenFonts :  public PrefModule, public Ui::PrefScreenFontsUi
+class PrefScreenFonts : public PrefModule, public Ui::PrefScreenFontsUi
 {
        Q_OBJECT
 public:
-       PrefScreenFonts(GuiPrefs * form, QWidget * parent = 0);
+       PrefScreenFonts(GuiPreferences * form, QWidget * parent = 0);
 
        virtual void apply(LyXRC & rc) const;
        virtual void update(LyXRC const & rc);
@@ -142,11 +147,11 @@ private Q_SLOTS:
 };
 
 
-class PrefColors :  public PrefModule, public Ui::PrefColorsUi
+class PrefColors : public PrefModule, public Ui::PrefColorsUi
 {
        Q_OBJECT
 public:
-       PrefColors(GuiPrefs * form, QWidget * parent = 0);
+       PrefColors(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
@@ -166,18 +171,7 @@ private:
 };
 
 
-class PrefCygwinPath :  public PrefModule, public Ui::PrefCygwinPathUi
-{
-       Q_OBJECT
-public:
-       PrefCygwinPath(QWidget * parent = 0);
-
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
-};
-
-
-class PrefDisplay :  public PrefModule, public Ui::PrefDisplayUi
+class PrefDisplay : public PrefModule, public Ui::PrefDisplayUi
 {
        Q_OBJECT
 public:
@@ -188,11 +182,11 @@ public:
 };
 
 
-class PrefPaths :  public PrefModule, public Ui::PrefPathsUi
+class PrefPaths : public PrefModule, public Ui::PrefPathsUi
 {
        Q_OBJECT
 public:
-       PrefPaths(GuiPrefs * form, QWidget * parent = 0);
+       PrefPaths(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
@@ -207,11 +201,11 @@ private Q_SLOTS:
 };
 
 
-class PrefSpellchecker :  public PrefModule, public Ui::PrefSpellcheckerUi
+class PrefSpellchecker : public PrefModule, public Ui::PrefSpellcheckerUi
 {
        Q_OBJECT
 public:
-       PrefSpellchecker(GuiPrefs * form, QWidget * parent = 0);
+       PrefSpellchecker(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
@@ -221,11 +215,11 @@ private Q_SLOTS:
 };
 
 
-class PrefConverters :  public PrefModule, public Ui::PrefConvertersUi
+class PrefConverters : public PrefModule, public Ui::PrefConvertersUi
 {
        Q_OBJECT
 public:
-       PrefConverters(GuiPrefs * form, QWidget * parent = 0);
+       PrefConverters(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
@@ -245,55 +239,70 @@ private:
 };
 
 
-class PrefCopiers :  public PrefModule, public Ui::PrefCopiersUi
+class FormatValidator : public QValidator
 {
-       Q_OBJECT
 public:
-       PrefCopiers(GuiPrefs * form, QWidget * parent = 0);
-
-       void apply(LyXRC & rc) const;
-       void update(LyXRC const & rc);
+       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_;
+};
 
-       void update();
 
-private Q_SLOTS:
-       void switch_copierLB(int nr);
-       void switch_copierCO(int nr);
-       void copiers_changed();
-       void new_copier();
-       void modify_copier();
-       void remove_copier();
+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:
-       void updateButtons();
+       std::string str(Formats::const_iterator it) const;
 };
 
 
-class PrefFileformats :  public PrefModule, public Ui::PrefFileformatsUi
+class PrefFileformats : public PrefModule, public Ui::PrefFileformatsUi
 {
        Q_OBJECT
 public:
-       PrefFileformats(GuiPrefs * form, QWidget * parent = 0);
+       PrefFileformats(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
+       void updateView();
 
-       void update();
 Q_SIGNALS:
        void formatsChanged();
-private:
-       void updateButtons();
 
 private Q_SLOTS:
-       void switch_format(int);
-       void fileformat_changed();
-       void new_format();
-       void modify_format();
-       void remove_format();
+       void on_copierED_textEdited(const QString & s);
+       void on_extensionED_textEdited(const QString &);
+       void on_viewerED_textEdited(const QString &);
+       void on_editorED_textEdited(const QString &);
+       void on_shortcutED_textEdited(const QString &);
+       void on_formatED_editingFinished();
+       void on_formatED_textChanged(const QString &);
+       void on_formatsCB_currentIndexChanged(int);
+       void on_formatsCB_editTextChanged(const QString &);
+       void on_formatNewPB_clicked();
+       void on_formatRemovePB_clicked();
+       void setFlags();
+       void updatePrettyname();
+
+private:
+       Format & currentFormat();
 };
 
 
-class PrefLanguage :  public PrefModule, public Ui::PrefLanguageUi
+class PrefLanguage : public PrefModule, public Ui::PrefLanguageUi
 {
        Q_OBJECT
 public:
@@ -307,7 +316,7 @@ private:
 };
 
 
-class PrefPrinter :  public PrefModule, public Ui::PrefPrinterUi
+class PrefPrinter : public PrefModule, public Ui::PrefPrinterUi
 {
        Q_OBJECT
 public:
@@ -318,11 +327,11 @@ public:
 };
 
 
-class PrefUserInterface :  public PrefModule, public Ui::PrefUi
+class PrefUserInterface : public PrefModule, public Ui::PrefUi
 {
        Q_OBJECT
 public:
-       PrefUserInterface(GuiPrefs * form, QWidget * parent = 0);
+       PrefUserInterface(GuiPreferences * form, QWidget * parent = 0);
 
        void apply(LyXRC & rc) const;
        void update(LyXRC const & rc);
@@ -335,7 +344,7 @@ public Q_SLOTS:
 };
 
 
-class PrefIdentity :  public PrefModule, public Ui::PrefIdentityUi
+class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
 {
        Q_OBJECT
 public:
@@ -345,12 +354,12 @@ public:
        void update(LyXRC const & rc);
 };
 
-///
-class GuiPrefsDialog : public QDialog, public Ui::PrefsUi
+
+class GuiPreferences : public GuiDialog, public Ui::PrefsUi, public Controller
 {
        Q_OBJECT
 public:
-       GuiPrefsDialog(GuiPrefs *);
+       GuiPreferences(LyXView & lv);
 
        void apply(LyXRC & rc) const;
        void updateRc(LyXRC const & rc);
@@ -358,44 +367,77 @@ public:
 public Q_SLOTS:
        void change_adaptor();
 
-protected:
+public:
+       //
        void closeEvent(QCloseEvent * e);
-
-private:
+       ///
        void add(PrefModule * module);
-
-private:
-       GuiPrefs * form_;
-       std::vector<PrefModule *> modules_;
-};
-
-
-class GuiPrefs : public GuiView<GuiPrefsDialog>
-{
-public:
-       GuiPrefs(Dialog &);
-
-       Converters & converters();
-       Formats & formats();
-       Movers & movers();
-       /// parent controller
-       ControlPrefs & controller()
-       { return static_cast<ControlPrefs &>(this->getController()); }
        /// parent controller
-       ControlPrefs const & controller() const
-       { return static_cast<ControlPrefs const &>(this->getController()); }
-private:
+       Controller & controller() { return *this; }
        /// Apply changes
-       virtual void apply();
-
+       void applyView();
        /// update (do we need this?)
-       virtual void update_contents();
+       void updateContents();
+
+       std::vector<PrefModule *> modules_;
 
-       /// build the dialog
-       virtual void build_dialog();
+       ///
+       bool initialiseParams(std::string const &);
+       ///
+       void clearParams() {}
+       ///
+       void dispatchParams();
+       ///
+       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_; }
 
+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<std::string> colors_;
+
+       bool redraw_gui_;
+       bool update_screen_font_;
 };
 
+
 } // namespace frontend
 } // namespace lyx