Developer Documentation
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 #ifndef SIDE_ELEMENT_
45 #define SIDE_ELEMENT_
46 
47 //=============================================================================
48 //
49 // CLASS SideElement
50 //
51 //=============================================================================
52 
53 //== INCLUDES =================================================================
54 
55 #include <QWidget>
56 #include <QSettings>
57 
58 //== FORWARDDECLARATIONS ======================================================
59 
60 class QIcon;
61 class QLabel;
62 class QToolButton;
63 class QAction;
64 class QDialog;
65 class QVBoxLayout;
66 
67 class SideArea;
68 
69 
70 //== CLASS DEFINITION =========================================================
71 
72 
79 class SideElement : public QWidget
80 {
81  Q_OBJECT
82 
83  public:
91  SideElement (SideArea *_parent, QWidget *_w, QString _name, QIcon* _icon,
92  QWidget *_headerAreaWidget);
93 
95  ~SideElement ();
96 
98  void setActive(bool _active);
99 
101  void saveState (QSettings &_settings);
102 
104  void restoreState (QSettings &_settings);
105 
107  const QString& name();
108 
110  bool active();
111 
113  QWidget const * widget();
114 
115  signals:
116  void toggleActive(bool);
117 
118  private:
119 
121  class TopArea : public QWidget
122  {
123  public:
124  explicit TopArea (SideElement *_e);
125 
126  virtual void mousePressEvent (QMouseEvent *_event);
127  private:
128  SideElement *e_;
129  };
130 
132  void labelPress ();
133 
134  private slots:
135 
137  void detachPressed (bool _checked);
138 
140  void dialogClosed ();
141 
142  private:
143 
144  // parent
145  SideArea *parent_;
146 
147  // plugin widget
148  QWidget *widget_, *headerAreaWidget_;
149 
150  // plugin name
151  QString name_;
152 
153  // Icon
154  QIcon* icon_;
155 
156  // main layout
157  QVBoxLayout *mainLayout_;
158 
159  // status
160  bool active_;
161 
162  // label that display the plugin name
163  QLabel *label_;
164  QLabel *iconHolder_;
165 
166  // detach button & action
167  QToolButton *detachButton_;
168  QAction *detachAction_;
169 
170  // dialog for detached widget
171  QDialog *dialog_;
172 };
173 
174 //=============================================================================
175 //=============================================================================
176 #endif // SIDE_ELEMENT_ defined
177 //=============================================================================
QWidget const * widget()
returns the pointer to the plugin tool widget
Definition: SideElement.cc:310
~SideElement()
Destructor.
Definition: SideElement.cc:136
bool active()
returns if the SideElement is active
Definition: SideElement.cc:304
void setActive(bool _active)
Set the element as active.
Definition: SideElement.cc:174
Clickable area inside of the side element.
Definition: SideElement.hh:121
void restoreState(QSettings &_settings)
restores the state
Definition: SideElement.cc:268
void detachPressed(bool _checked)
Called if the detach button was pressed.
Definition: SideElement.cc:200
void dialogClosed()
Called if a detached dialog was closed.
Definition: SideElement.cc:239
SideElement(SideArea *_parent, QWidget *_w, QString _name, QIcon *_icon, QWidget *_headerAreaWidget)
Definition: SideElement.cc:61
void saveState(QSettings &_settings)
saves the current state
Definition: SideElement.cc:258
const QString & name()
return the name
Definition: SideElement.cc:298
void labelPress()
Called on mouse press.
Definition: SideElement.cc:149