]> vaikene.ee Git - evaf/blob - src/plugins/SdiWindow/sdiwindow.h
757ed28cfeaa51f452954cc7ee0c62992aa3a71d
[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 #include <QWeakPointer>
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 = 0, Qt::WindowFlags flags = 0);
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 /// Garbage collector timer
76 virtual void timerEvent(QTimerEvent * e);
77
78
79 private: // Methods
80
81 void setWindowSize();
82
83 void saveSettings();
84
85 void restoreSettings();
86
87
88 private: // Members
89
90 /// Ready flag
91 bool mReady;
92
93 /// The layout of the main window
94 QVBoxLayout * mLayout;
95
96 /// Name of the main panel that becomes part of this window
97 QString mMainPanelName;
98
99 /// List of GUI::Panel objects added to the manager
100 QList<QWeakPointer<Gui::Panel> > mPanels;
101
102 /// List of minimized GUI::Panel objects
103 QVector<QWeakPointer<Gui::Panel> > mMinimizedPanels;
104
105 /// Hash with panel names
106 QHash<QString, QWeakPointer<Gui::Panel> > mPanelNames;
107
108 /// Current main panel added to this window
109 QWeakPointer<Gui::Panel> mMainPanel;
110
111 /// Garbage collector timer ID
112 int mTimerId;
113
114
115 private: // Methods
116
117 /// Gets the main panel name from module attributes
118 QString getMainPanelName(QString const & args) const;
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