Debian Codegraph @

src/GUI/DialogStateController.hxx

raw symbols SCIP
1 // Copyright (C) 2020 James Turner <[email protected]>
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 #ifndef DialogStateController_h
18 #define DialogStateController_h
19
20 #include <QJSValue>
21 #include <QMap>
22 #include <QObject>
23
24 class DialogStateController : public QObject
25 {
26 Q_OBJECT
27
28 Q_PROPERTY(bool canRestoreDefaults READ canRestoreDefaults WRITE setCanRestoreDefaults NOTIFY canRestoreDefaultsChanged)
29 Q_PROPERTY(bool canApply READ canApply NOTIFY canApplyChanged)
30 public:
31 Q_INVOKABLE void add(QString key, QJSValue cb);
32
33 bool canApply() const
34 {
35 return m_canApply;
36 }
37
38 bool canRestoreDefaults() const
39 {
40 return m_canRestoreDefaults;
41 }
42
43 public slots:
44
45 void apply();
46
47 void cancel();
48
49 void restoreDefaults();
50
51 void setCanRestoreDefaults(bool canRestoreDefaults);
52
53 signals:
54 void canApplyChanged(bool canApply);
55
56 void canRestoreDefaultsChanged(bool canRestoreDefaults);
57
58 private:
59 // list of tracked changes
60 QMap<QString, QJSValue> m_changes;
61
62 bool m_canApply = false;
63 bool m_canRestoreDefaults = false;
64 };
65
66 #endif /* DialogStateController_h */