Emit error signal when login fails
[situare] / src / ui / zoombuttonpanel.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Pekka Nissinen - pekka.nissinen@ixonos.com
6        Kaj Wallin - kaj.wallin@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 ZOOMBUTTONPANEL_H
24 #define ZOOMBUTTONPANEL_H
25
26 #include <QGraphicsItem>
27 #include <QGridLayout>
28 #include <QTimer>
29 #include <QWidget>
30
31 #include "zoombutton.h"
32
33 /**
34  * @brief Panel for zoom buttons
35  *
36  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
37  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
38  */
39 class ZoomButtonPanel : public QWidget
40 {
41     Q_OBJECT
42
43 public:
44     /**
45      * @brief Constructor
46      *
47      * @param parent Parent
48      */
49     ZoomButtonPanel(QWidget *parent = 0);
50
51 /*******************************************************************************
52  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
53  ******************************************************************************/
54 protected:
55     /**
56      * @brief Move event for the zoom button panel
57      *
58      * @param event Event
59      */
60     void mouseMoveEvent(QMouseEvent *event);
61
62     /**
63      * @brief Press event for the zoom button panel
64      *
65      * @param event Event
66      */
67     void mousePressEvent(QMouseEvent *event);
68
69     /**
70      * @brief Event handler for mouse release events
71      *
72      * @param event Mouse event
73      */
74     void mouseReleaseEvent(QMouseEvent *event);
75
76     /**
77      * @brief Event handler for paint events
78      *
79      * Paints the panel
80      * @param event Paint event
81      */
82     void paintEvent(QPaintEvent *event);
83
84 /*******************************************************************************
85  * MEMBER FUNCTIONS AND SLOTS
86  ******************************************************************************/
87 public:
88     /**
89      * @brief Getter for the zoom in button
90      *
91      * @return Pointer to the zoomInButton
92      */
93     const ZoomButton* zoomInButton() const;
94
95     /**
96      * @brief Getter for the zoom out button
97      *
98      * @return Pointer to the zoomOutButton
99      */
100     const ZoomButton* zoomOutButton() const;
101
102 public slots:
103     /**
104      * @brief Disables the zoom in button
105      */
106     void disableZoomInButton();
107
108     /**
109      * @brief Disables the zoom out button
110      */
111     void disableZoomOutButton();
112
113     /**
114      * @brief Reset zoom button states to normal
115      */
116     void resetButtons();
117
118     /**
119      * @brief Toggle zoom panel draggability
120      */
121     void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
122
123     /**
124      * @brief Slot to redraw the panel after window resize event
125      *
126      * @param size Size of the new screen
127      */
128     void screenResized(const QSize &size);
129
130 private slots:
131     /**
132      * @brief Safeguard slot to release mouse grab if something goes horribly wrong
133      */
134     void forceMouseRelease();
135
136     /**
137      * @brief Slot that handles drag initialization once timer has timed out
138      */
139     void timerExpired();
140
141 /******************************************************************************
142  * SIGNALS
143  ******************************************************************************/
144 signals:
145     /**
146     * @brief Dragging mode triggered.
147     */
148     void draggingModeTriggered();
149
150 /*******************************************************************************
151  * DATA MEMBERS
152  ******************************************************************************/
153 private:
154     bool m_isDraggable;             ///< Boolean for tracking the draggability state
155     bool m_zoomInMode;              ///< Boolean for storing zoom in button mode before dragging
156     bool m_zoomOutMode;             ///< Boolean for storing zoom out button mode before dragging
157
158     QGridLayout m_panelLayout;      ///< Panel layout
159
160     QPoint m_dragPosition;          ///< Location from where the widget is grabbed
161
162     QSize m_screenSize;             ///< Store for the screen size
163
164     QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
165     QTimer *m_forceReleaseTimer;    ///< Timer to run forceMouseRelease;
166
167     ZoomButton *m_zoomInButton;    ///< Button for zoom in
168     ZoomButton *m_zoomOutButton;   ///< Button for zoom out
169 };
170
171 #endif // ZOOMBUTTONPANEL_H