]> vaikene.ee Git - evaf/blob - src/plugins/SdiWindow/sdiwindow.h
Warning fixes and copyright update.
[evaf] / src / plugins / SdiWindow / sdiwindow.h
1 /**
2 * @file SdiWindow/sdiwindow.h
3 * @brief SdiWindow module's implementation
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011-2019 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __SDIWINDOW_SDIWINDOW_H
21 # define __SDIWINDOW_SDIWINDOW_H
22
23 #include "isdiwindow.h"
24
25 #include <Plugins/iPlugin>
26 #include <Gui/Panel>
27
28 #include <QObject>
29 #include <QString>
30 #include <QWidget>
31 #include <QList>
32 #include <QVector>
33 #include <QHash>
34 #include <QScopedPointer>
35
36 class QVBoxLayout;
37
38 namespace eVaf {
39 namespace SdiWindow {
40 namespace Internal {
41
42 /**
43 * Main window widget implementing the iSdiWindow interface
44 */
45 class MainWindow : public QWidget, public iSdiWindow
46 {
47 Q_OBJECT
48 Q_INTERFACES(eVaf::SdiWindow::iSdiWindow)
49
50 public:
51
52 MainWindow(QWidget * parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
53
54 virtual ~MainWindow();
55
56 virtual bool init(QString const & args);
57
58 virtual void done();
59
60 virtual bool isReady() { return mReady; }
61
62 virtual void addPanel(QString const & name, Gui::Panel * panel);
63
64 virtual Gui::Panel * panel(QString const & name) const;
65
66 virtual bool showPanel(QString const & name);
67
68 virtual void changeEvent(QEvent * e);
69
70 virtual void closeEvent(QCloseEvent * e);
71
72
73 protected: // Methods
74
75
76 private: // Methods
77
78 void setWindowSize();
79
80 void saveSettings();
81
82 void restoreSettings();
83
84
85 private: // Members
86
87 /// Ready flag
88 bool mReady;
89
90 /// The layout of the main window
91 QVBoxLayout * mLayout;
92
93 /// Name of the main panel that becomes part of this window
94 QString mMainPanelName;
95
96 /// List of GUI::Panel objects added to the manager
97 QList<Gui::Panel *> mPanels;
98
99 /// List of minimized GUI::Panel objects
100 QVector<Gui::Panel *> mMinimizedPanels;
101
102 /// Hash with panel names
103 QHash<QString, Gui::Panel *> mPanelNames;
104
105 /// Current main panel added to this window
106 Gui::Panel * mMainPanel;
107
108
109 private: // Methods
110
111 /// Gets the main panel name from module attributes
112 QString getMainPanelName(QString const & args) const;
113
114
115 private slots:
116
117 /// Panel destroyed signal. We need to remove the panel from all the
118 /// lists.
119 void panelDestroyed(QObject * obj = nullptr);
120
121 };
122
123 /**
124 * SdiWindow module's implementation
125 */
126 class SdiWindowPlugin : public Plugins::iPlugin
127 {
128 Q_OBJECT
129 Q_INTERFACES(eVaf::Plugins::iPlugin)
130
131 public:
132
133 SdiWindowPlugin();
134
135 virtual ~SdiWindowPlugin();
136
137 virtual bool init(const QString & args);
138
139 virtual void done();
140
141 virtual bool isReady() const { return mWindow != nullptr && mWindow->isReady(); }
142
143
144 private:
145
146 /// iSdiWindow interface implementation
147 QScopedPointer<MainWindow> mWindow;
148 };
149
150 } // namespace eVaf::SdiWindow::Internal
151 } // namespace eVaf::SdiWindow
152 } // namespace eVaf
153
154 #endif // sdiwindow.h