]> vaikene.ee Git - evaf/blob - src/plugins/SdiWindow/sdiwindow.h
Ported to Qt5
[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 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
35 class QVBoxLayout;
36
37 namespace eVaf {
38 namespace SdiWindow {
39 namespace Internal {
40
41 /**
42 * Main window widget implementing the iSdiWindow interface
43 */
44 class MainWindow : public QWidget, public iSdiWindow
45 {
46 Q_OBJECT
47 Q_INTERFACES(eVaf::SdiWindow::iSdiWindow)
48
49 public:
50
51 MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
52
53 virtual ~MainWindow();
54
55 virtual bool init(QString const & args);
56
57 virtual void done();
58
59 virtual bool isReady() { return mReady; }
60
61 virtual void addPanel(QString const & name, Gui::Panel * panel);
62
63 virtual Gui::Panel * panel(QString const & name) const;
64
65 virtual bool showPanel(QString const & name);
66
67 virtual void changeEvent(QEvent * e);
68
69 virtual void closeEvent(QCloseEvent * e);
70
71
72 protected: // Methods
73
74
75 private: // Methods
76
77 void setWindowSize();
78
79 void saveSettings();
80
81 void restoreSettings();
82
83
84 private: // Members
85
86 /// Ready flag
87 bool mReady;
88
89 /// The layout of the main window
90 QVBoxLayout * mLayout;
91
92 /// Name of the main panel that becomes part of this window
93 QString mMainPanelName;
94
95 /// List of GUI::Panel objects added to the manager
96 QList<Gui::Panel *> mPanels;
97
98 /// List of minimized GUI::Panel objects
99 QVector<Gui::Panel *> mMinimizedPanels;
100
101 /// Hash with panel names
102 QHash<QString, Gui::Panel *> mPanelNames;
103
104 /// Current main panel added to this window
105 Gui::Panel * mMainPanel;
106
107
108 private: // Methods
109
110 /// Gets the main panel name from module attributes
111 QString getMainPanelName(QString const & args) const;
112
113
114 private slots:
115
116 /// Panel destroyed signal. We need to remove the panel from all the
117 /// lists.
118 void panelDestroyed(QObject * obj = 0);
119
120 };
121
122 /**
123 * SdiWindow module's implementation
124 */
125 class SdiWindowPlugin : public Plugins::iPlugin
126 {
127 Q_OBJECT
128 Q_INTERFACES(eVaf::Plugins::iPlugin)
129
130 public:
131
132 SdiWindowPlugin();
133
134 virtual ~SdiWindowPlugin();
135
136 virtual bool init(const QString & args);
137
138 virtual void done();
139
140 virtual bool isReady() const { return mWindow != 0 && mWindow->isReady(); }
141
142
143 private:
144
145 /// iSdiWindow interface implementation
146 MainWindow * mWindow;
147 };
148
149 } // namespace eVaf::SdiWindow::Internal
150 } // namespace eVaf::SdiWindow
151 } // namespace eVaf
152
153 #endif // sdiwindow.h