X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FDialog.h;h=57e63c1022bd1588f935bfd4b47af6cd88ebe076;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=8f6cea63170d46a2c52d7d3c96c676f446ff528b;hpb=10cc0a8842d147462d4f26ba8353ebb163d34d9c;p=lyx.git diff --git a/src/frontends/qt4/Dialog.h b/src/frontends/qt4/Dialog.h index 8f6cea6317..57e63c1022 100644 --- a/src/frontends/qt4/Dialog.h +++ b/src/frontends/qt4/Dialog.h @@ -12,15 +12,22 @@ #ifndef DIALOG_H #define DIALOG_H -#include "lfuns.h" +#include "FuncCode.h" + +#include "insets/InsetCode.h" #include "support/strfwd.h" +#include + +class QWidget; + namespace lyx { class Buffer; class BufferView; class FuncRequest; +class Inset; namespace frontend { @@ -47,10 +54,34 @@ public: /// \param lv is the access point for the dialog to the LyX kernel. /// \param name is the identifier given to the dialog by its parent /// container. - Dialog(GuiView & lv, std::string const & name); + /// \param title is the window title used for decoration. + Dialog(GuiView & lv, QString const & name, QString const & title); virtual ~Dialog(); + virtual QWidget * asQWidget() = 0; + virtual QWidget const * asQWidget() const = 0; + + /// Session key. + /** + * This key must be used for any session setting. + **/ + QString sessionKey() const; + + /// Save session settings. + /** + * This default implementation saves the geometry state. + * Reimplement to save more settings. + **/ + virtual void saveSession() const; + + /// Restore session settings. + /** + * This default implementation restores the geometry state. + * Reimplement to restore more settings. + **/ + virtual void restoreSession(); + /** \name Container Access * These methods are publicly accessible because they are invoked * by the parent container acting on commands from the LyX kernel. @@ -58,30 +89,23 @@ public: //@{ /// \param data is a string encoding of the data to be displayed. /// It is passed to the Controller to be translated into a useable form. - virtual void showData(std::string const & /*data*/) {} - virtual void updateData(std::string const & /*data*/) {} - - virtual void hide() {} - + virtual void showData(std::string const & data); //@} + /// \return inset at current cursor location. + Inset const * inset(InsetCode code) const; + /** Check whether we may apply our data. * * The buttons are disabled if not and (re-)enabled if yes. */ - virtual void checkStatus() {} + virtual void checkStatus(); /** When applying, it's useful to know whether the dialog is about * to close or not (no point refreshing the display for example). */ virtual bool isClosing() const { return false; } - - /** \c Button controller part - */ - virtual void setButtonsValid(bool /*valid*/) {} - - /** \c View part * of a Model-Controller-View split of a generic dialog. * These few methods are all that a generic dialog needs of a @@ -95,20 +119,32 @@ public: virtual void applyView() = 0; /// Hide the dialog from sight - virtual void hideView() = 0; + void hideView(); - /// Create the dialog if necessary, update it and display it. - virtual void showView() = 0; + /// Prepare dialog and display it. + void showView(); + + /// Prepare dialog before view. + void prepareView(); + + /// Decide wether the dialog should grab thekeyboard focus when shown. + /// This method defaults to true, override if a different behaviour + /// is wanted. + virtual bool wantInitialFocus() const { return true; } /// Update the display of the dialog whilst it is still visible. virtual void updateView() = 0; + // Default Implementation does nothing. + // Each dialog has to choose what control to enable or disable. + virtual void enableView(bool /*enable*/) {} + /// \return true if the dialog is visible. - virtual bool isVisibleView() const = 0; + virtual bool isVisibleView() const; //@} - /// - std::string name() const; + /// Dialog identifier. + QString name() const { return name_; } //@{ /** Enable the controller to initialise its data structures. @@ -142,7 +178,7 @@ public: * It should be used in dispatchParams(), too for consistency reasons. * \returns the lfun that is sent for applying the data. */ - virtual kb_action getLfun() const { return LFUN_INSET_APPLY; } + virtual FuncCode getLfun() const { return LFUN_INSET_APPLY; } /** Check whether we may apply our data. * @@ -162,11 +198,6 @@ public: */ virtual bool disconnectOnApply() const { return false; } - /** \return true if Dialog::View::show() should not display the dialog - * after running update. Currently, only ControlSpellchecker - * makes use of that. - */ - virtual bool exitEarly() const { return false; } //@} /** \c Kernel part: a wrapper making the LyX kernel available to the dialog. @@ -195,7 +226,6 @@ public: * stored by the dialog are not applied to the inset currently * connected to the dialog. Instead, they will be used to generate * a new inset at the cursor position. - * \param name is used to identify the dialog to the kernel. */ void disconnect() const; @@ -205,7 +235,7 @@ public: //@{ bool isBufferAvailable() const; bool isBufferReadonly() const; - std::string const bufferFilepath() const; + QString bufferFilepath() const; //@} /// The type of the current buffer. @@ -216,24 +246,24 @@ public: * We should aim to reduce/remove these from the interface. */ //@{ - GuiView & lyxview() { return *lyxview_; } GuiView const & lyxview() const { return *lyxview_; } - - Buffer & buffer(); Buffer const & buffer() const; - - BufferView * bufferview(); BufferView const * bufferview() const; //@} protected: - virtual void apply() {} + /// + void setTitle(QString const & title) { title_ = title; } + /// + virtual void apply(); private: /** The Dialog's name is the means by which a dialog identifies * itself to the LyXView. */ - char const * const name_; + QString const name_; + /// + QString title_; /// GuiView * lyxview_;