TabbedPanel now emits panelOpened/Closed signals after the animation has stopped.
[situare] / src / ui / indicatorbutton.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Katri Kaikkonen - katri.kaikkonen@ixonos.com
6         Sami Rämö - sami.ramo@ixonos.com
7
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21 */
22
23 #ifndef INDICATORBUTTON_H
24 #define INDICATORBUTTON_H
25
26 #include <QMouseEvent>
27 #include <QTimer>
28 #include <QToolButton>
29
30 /**
31  * @brief Indicator button class
32  *
33  * @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
34  * @author Sami Rämö - sami.ramo (at) ixonos.com
35  *
36  * @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
37  */
38 class IndicatorButton : public  QToolButton
39 {
40     Q_OBJECT
41
42 public:
43     /**
44      * @brief Constructor
45      *
46      * @param parent Parent widget
47      */
48     IndicatorButton(QWidget *parent = 0);
49
50     /**
51      * @brief Desctructor
52      */
53     ~IndicatorButton();
54
55 /*******************************************************************************
56  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
57  ******************************************************************************/
58 protected:
59     /**
60      * @brief Event handler for mouse move events
61      *
62      * @param event Mouse event
63      */
64     void mouseMoveEvent(QMouseEvent *event);
65
66     /**
67      * @brief Event handler for mouse press events
68      *
69      * @param event Mouse event
70      */
71     void mousePressEvent(QMouseEvent *event);
72
73     /**
74      * @brief Event handler for mouse release events
75      *
76      * @param event Mouse event
77      */
78     void mouseReleaseEvent(QMouseEvent *event);
79
80     /**
81      * @brief Event handler for paint events
82      *
83      * Paints the button and its icon
84      * @param event Paint event
85      */
86     void paintEvent(QPaintEvent *event);
87
88 /*******************************************************************************
89  * MEMBER FUNCTIONS AND SLOTS
90  ******************************************************************************/
91 public slots:
92     /**
93      * @brief Relative position of the event inside the widget
94      */
95     const QPoint& eventPosition();
96
97     /**
98      * @brief Sets direction information for the distance indicator button
99      *
100      * Paints the button and its icon
101      * @param Direction to the GPS position (in degrees)
102      * @param Draw direction triangle
103      */
104     void setDirection(qreal direction, bool draw);
105
106 /*******************************************************************************
107  * SIGNALS
108  ******************************************************************************/
109 signals:
110     /**
111      * @brief Automatic centering setting changed by user
112      *
113      * @param enabled True if automatic centering is enabled, otherwise false
114      */
115     void autoCenteringTriggered(bool enabled);
116
117 /*******************************************************************************
118  * DATA MEMBERS
119  ******************************************************************************/
120 private:
121     bool m_drawTriangle;                    ///< Should the direction triange be drawn
122
123     qreal m_direction;                      ///< Direction to the GPS position (in degrees)
124
125     QColor *m_normalColor;                  ///< Normal background color
126
127     QLinearGradient *m_selectedGradient;    ///< Selected background
128
129     QPixmap m_indicatorLeds[2];             ///< Placeholder for images
130
131     QPoint m_dragPosition;                  ///< Location from where the widget is grabbed
132     QPoint m_eventPosition;                 ///< Position of mousePressEvent
133 };
134
135 #endif // INDICATORBUTTON_H