]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDialog.h
Account for old versions of Pygments
[lyx.git] / src / frontends / qt4 / GuiDialog.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDialog.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GUIDIALOG_H
13 #define GUIDIALOG_H
14
15 #include "Dialog.h"
16 #include "ButtonController.h"
17
18 #include <QDialog>
19
20
21 namespace lyx {
22 namespace frontend {
23
24 /// Base class for historical LyX dialogs.
25 /** 
26   * \warning New dialogs should use the leaner classes \c DialogView or
27   * \c DockView depending on the intent. Eventually, old dialogs should be
28   * converted to \c DialogView too.
29   */
30 class GuiDialog : public QDialog, public Dialog
31 {
32         Q_OBJECT
33
34 public:
35         /// \param lv is the access point for the dialog to the LyX kernel.
36         /// \param name is the identifier given to the dialog by its parent
37         /// container.
38         /// \param title is the window title used for decoration.
39         GuiDialog(GuiView & lv, QString const & name, QString const & title);
40
41         virtual QWidget * asQWidget() { return this; }
42         virtual QWidget const * asQWidget() const { return this; }
43
44 public Q_SLOTS:
45         /** \name Buttons
46          *  These methods are publicly accessible because they are invoked
47          *  by the View when the user presses... guess what ;-)
48          */
49         // Restore button clicked
50         void slotRestore();
51         // OK button clicked
52         void slotOK();
53         // Apply button clicked
54         void slotApply();
55         // AutoApply checkbox clicked
56         void slotAutoApply();
57         // Close button clicked or closed from WindowManager
58         void slotClose();
59         ///
60         void closeEvent(QCloseEvent * e);
61
62 protected Q_SLOTS:
63         void onBufferViewChanged() {};//override
64
65 public:
66         /** Check whether we may apply our data.
67          *
68          *  The buttons are disabled if not and (re-)enabled if yes.
69          */
70         void setButtonsValid(bool valid);
71
72         /** \name Dialog Components
73          *  Methods to access the various components making up a dialog.
74          */
75         //@{
76         ButtonController const & bc() const { return bc_; }
77         ButtonController & bc() { return bc_; }
78         //@}
79
80         /// the dialog has changed contents
81         virtual void changed();
82
83         virtual void enableView(bool enable);
84
85         /// default: do nothing
86         virtual void applyView() {}
87         /// default: do nothing
88         virtual void updateContents() {}
89
90 public:
91         /// is the dialog currently valid ?
92         virtual bool isValid() { return true; }
93
94 public:
95
96         /** When applying, it's useful to know whether the dialog is about
97          *  to close or not (no point refreshing the display for example).
98          */
99         bool isClosing() const { return is_closing_; }
100         
101         ///
102         bool needBufferOpen() const { return isBufferDependent(); }
103
104         /// Update the display of the dialog whilst it is still visible.
105         virtual void updateView();
106
107 private:
108         ButtonController bc_;
109         /// are we updating ?
110         bool updating_;
111
112         bool is_closing_;
113 };
114
115
116 } // namespace frontend
117 } // namespace lyx
118
119 #endif // GUIDIALOG_H