Fixed FacebookLoginBrowser::destroyed() signal handling
[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         Kaj Wallin - kaj.wallin@ixonos.com
7         Sami Rämö - sami.ramo@ixonos.com
8
9     Situare is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License
11     version 2 as published by the Free Software Foundation.
12
13     Situare is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with Situare; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
21     USA.
22 */
23
24 #ifndef INDICATORBUTTON_H
25 #define INDICATORBUTTON_H
26
27 #include <QMouseEvent>
28 #include <QTimer>
29 #include <QToolButton>
30
31 /**
32  * @brief Indicator button class
33  *
34  * @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
35  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
36  * @author Sami Rämö - sami.ramo (at) ixonos.com
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 press events
61      *
62      * @param event Mouse event
63      */
64     void mousePressEvent(QMouseEvent *event);
65
66     /**
67      * @brief Event handler for mouse release events
68      *
69      * @param event Mouse event
70      */
71     void mouseReleaseEvent(QMouseEvent *event);
72
73     /**
74      * @brief Event handler for paint events
75      *
76      * Paints the button and its icon
77      * @param event Paint event
78      */
79     void paintEvent(QPaintEvent *event);
80
81 /*******************************************************************************
82  * MEMBER FUNCTIONS AND SLOTS
83  ******************************************************************************/
84 public slots:
85     /**
86      * @brief Relative position of the event inside the widget
87      */
88     const QPoint& eventPosition();
89
90     /**
91      * @brief Sets direction information for the distance indicator button
92      *
93      * Paints the button and its icon
94      *
95      * @param direction Direction to the GPS position (in degrees)
96      * @param draw True if direction triangle should be drawn
97      */
98     void setDirection(qreal direction, bool draw);
99
100 /*******************************************************************************
101  * SIGNALS
102  ******************************************************************************/
103 signals:
104     /**
105      * @brief Automatic centering setting changed by user
106      *
107      * @param enabled True if automatic centering is enabled, otherwise false
108      */
109     void autoCenteringTriggered(bool enabled);
110
111 /*******************************************************************************
112  * DATA MEMBERS
113  ******************************************************************************/
114 private:
115     bool m_drawTriangle;                    ///< Should the direction triange be drawn
116
117     qreal m_direction;                      ///< Direction to the GPS position (in degrees)
118
119     QColor *m_normalColor;                  ///< Normal background color
120
121     QLinearGradient *m_selectedGradient;    ///< Selected background
122
123     QPixmap m_indicatorLeds[2];             ///< Placeholder for images
124
125     QPoint m_dragPosition;                  ///< Location from where the widget is grabbed
126     QPoint m_eventPosition;                 ///< Position of mousePressEvent
127 };
128
129 #endif // INDICATORBUTTON_H