Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SideElement.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef SIDE_ELEMENT_
51 #define SIDE_ELEMENT_
52 
53 //=============================================================================
54 //
55 // CLASS SideElement
56 //
57 //=============================================================================
58 
59 //== INCLUDES =================================================================
60 
61 #include <QWidget>
62 #include <QSettings>
63 
64 //== FORWARDDECLARATIONS ======================================================
65 
66 class QIcon;
67 class QLabel;
68 class QToolButton;
69 class QAction;
70 class QDialog;
71 class QVBoxLayout;
72 
73 class SideArea;
74 
75 
76 //== CLASS DEFINITION =========================================================
77 
78 
85 class SideElement : public QWidget
86 {
87  Q_OBJECT
88 
89  public:
97  SideElement (SideArea *_parent, QWidget *_w, QString _name, QIcon* _icon,
98  QWidget *_headerAreaWidget);
99 
101  ~SideElement ();
102 
104  void setActive(bool _active);
105 
107  void saveState (QSettings &_settings);
108 
110  void restoreState (QSettings &_settings);
111 
113  const QString& name();
114 
116  bool active();
117 
119  QWidget const * widget();
120 
121  signals:
122  void toggleActive(bool);
123 
124  private:
125 
127  class TopArea : public QWidget
128  {
129  public:
130  TopArea (SideElement *_e);
131 
132  virtual void mousePressEvent (QMouseEvent *_event);
133  private:
134  SideElement *e_;
135  };
136 
138  void labelPress ();
139 
140  private slots:
141 
143  void detachPressed (bool _checked);
144 
146  void dialogClosed ();
147 
148  private:
149 
150  // parent
151  SideArea *parent_;
152 
153  // plugin widget
154  QWidget *widget_, *headerAreaWidget_;
155 
156  // plugin name
157  QString name_;
158 
159  // Icon
160  QIcon* icon_;
161 
162  // main layout
163  QVBoxLayout *mainLayout_;
164 
165  // status
166  bool active_;
167 
168  // label that display the plugin name
169  QLabel *label_;
170  QLabel *iconHolder_;
171 
172  // detach button & action
173  QToolButton *detachButton_;
174  QAction *detachAction_;
175 
176  // dialog for detached widget
177  QDialog *dialog_;
178 };
179 
180 //=============================================================================
181 //=============================================================================
182 #endif // SIDE_ELEMENT_ defined
183 //=============================================================================
void labelPress()
Called on mouse press.
Definition: SideElement.cc:155
void restoreState(QSettings &_settings)
restores the state
Definition: SideElement.cc:274
const QString & name()
return the name
Definition: SideElement.cc:304
void setActive(bool _active)
Set the element as active.
Definition: SideElement.cc:180
QWidget const * widget()
returns the pointer to the plugin tool widget
Definition: SideElement.cc:316
void saveState(QSettings &_settings)
saves the current state
Definition: SideElement.cc:264
bool active()
returns if the SideElement is active
Definition: SideElement.cc:310
void dialogClosed()
Called if a detached dialog was closed.
Definition: SideElement.cc:245
~SideElement()
Destructor.
Definition: SideElement.cc:142
Clickable area inside of the side element.
Definition: SideElement.hh:127
SideElement(SideArea *_parent, QWidget *_w, QString _name, QIcon *_icon, QWidget *_headerAreaWidget)
Definition: SideElement.cc:67
void detachPressed(bool _checked)
Called if the detach button was pressed.
Definition: SideElement.cc:206