]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/ButtonController.h
MasterChild.ui: Group radio buttons (part of #12470)
[lyx.git] / src / frontends / qt / ButtonController.h
1 // -*- C++ -*-
2 /**
3  * \file ButtonController.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Allan Rae
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BUTTONCONTROLLER_H
13 #define BUTTONCONTROLLER_H
14
15 #include "ButtonPolicy.h"
16
17 class QWidget;
18 class QPushButton;
19 class QLineEdit;
20 class QCheckBox;
21 class QString;
22
23 namespace lyx {
24 namespace frontend {
25
26 /** General purpose button controller for up to four buttons.
27     Controls the activation of the OK, Apply and Cancel buttons.
28     Actually supports 4 buttons in all and it's up to the user to decide on
29     the activation policy and which buttons correspond to which output of the
30     state machine.
31 */
32
33
34 /** \c ButtonController controls the activation of the OK, Apply and
35  *  Cancel buttons.
36  *
37  * It actually supports 4 buttons in all and it's up to the user to decide on
38  * the activation policy and which buttons correspond to which output of the
39  * state machine.
40  */
41
42 class ButtonController
43 {
44 public:
45         ButtonController();
46         ~ButtonController();
47
48         //@{
49         /// Methods to set and get the ButtonPolicy.
50         void setPolicy(ButtonPolicy::Policy policy);
51         ButtonPolicy const & policy() const;
52         ButtonPolicy & policy();
53         //@}
54
55         ///
56         void input(ButtonPolicy::SMInput);
57
58         //@{
59         /// Tell the BC that a particular button has been pressed.
60         void ok();
61         void apply();
62         void cancel();
63         void restore();
64         void autoApply();
65         //@}
66
67         /// Tell the BC that the dialog is being hidden
68         void hide();
69
70         /**Refresh the activation state of the Ok, Apply, Close and
71          * Restore buttons.
72          */
73         void refresh() const;
74
75         /** Passthrough function -- returns its input value
76          *  Tell the BC about the read-only status of the underlying buffer.
77          */
78         bool setReadOnly(bool);
79
80         /**
81          *  Sets the activation state of the buttons immediately.
82          * \param validity Tell the BC that the data is, or is not, valid.
83          */
84         void setValid(bool);
85
86         //
87         // View
88         //
89
90         //@{
91         /// Store pointers to these widgets. \param default_button determines
92         /// the default button of the dialog (bound to return). This is
93         /// OK by default.
94         void setOK(QPushButton * obj, bool const default_button = true);
95         void setApply(QPushButton * obj, bool const default_button = false);
96         void setCancel(QPushButton * obj, bool const default_button = false);
97         void setRestore(QPushButton * obj, bool const default_button = false);
98         void setAutoApply(QCheckBox * obj);
99         //@}
100
101         /** Add a pointer to the list of widgets whose activation
102          *  state is dependent upon the read-only status of the
103          *  underlying buffer.
104          */
105         void addReadOnly(QWidget * obj);
106
107         /** Add a widget to the list of all widgets whose validity should
108          *  be checked explicitly when the buttons are refreshed.
109          */
110         void addCheckedLineEdit(QLineEdit * input, QWidget * target = 0, int tabindex = -1);
111
112         /** Add a widget to the list of all widgets whose validity should
113          *  be checked explicitly when the buttons are refreshed.
114          */
115         void addCheckedLineEditPanel(QLineEdit * input, QWidget * target, QString const panel);
116
117 private:
118         /// noncopyable
119         ButtonController(ButtonController const &);
120         void operator=(ButtonController const &);
121
122         /// pimpl
123         class Private;
124         Private * d;
125 };
126
127 } // namespace frontend
128 } // namespace lyx
129
130 #endif // BUTTONCONTROLLER_H