Added new scalable panels, deleted obsolite bitmaps and made some minor cosmetic...
[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  * MEMBER FUNCTIONS AND SLOTS
78  ******************************************************************************/
79 public:
80     /**
81     * @brief Getter for the zoom in button
82     *
83     * @return Pointer to the zoomInButton
84     */
85     const ZoomButton* zoomInButton();
86
87     /**
88     * @brief Getter for the zoom out button
89     *
90     * @return Pointer to the zoomOutButton
91     */
92     const ZoomButton* zoomOutButton();
93
94 public slots:
95     /**
96      * @brief Disables the zoom in button
97      */
98     void disableZoomInButton();
99
100     /**
101      * @brief Disables the zoom out button
102      */
103     void disableZoomOutButton();
104
105     /**
106      * @brief Reset zoom button states to normal
107      */
108     void resetButtons();
109
110     /**
111      * @brief Toggle zoom panel draggability
112      */
113     void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
114
115     /**
116     * @brief Slot to redraw the panel after window resize event
117     *
118     * @param size Size of the new screen
119     */
120     void screenResized(const QSize &size);
121
122 private slots:
123     /**
124      * @brief Safeguard slot to release mouse grab if something goes horribly wrong
125      */
126     void forceMouseRelease();
127
128     /**
129      * @brief Slot that handles drag initialization once timer has timed out
130      */
131     void timerExpired();
132
133 /*******************************************************************************
134  * DATA MEMBERS
135  ******************************************************************************/
136 private:
137     bool m_isDraggable;             ///< Boolean for tracking the draggability state
138
139     QGridLayout m_panelLayout;      ///< Panel layout
140
141     QPoint m_dragPosition;          ///< Location from where the widget is grabbed
142
143     QIcon::Mode m_zoomInMode;       ///< Store for zoom in button mode before dragging
144     QIcon::Mode m_zoomOutMode;      ///< Store for zoom out button mode before dragging
145
146     QSize m_screenSize;             ///< Store for the screen size
147
148     QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
149     QTimer *m_forceReleaseTimer;    ///< Timer to run forceMouseRelease;
150
151     ZoomButton *m_zoomInButton;    ///< Button for zoom in
152     ZoomButton *m_zoomOutButton;   ///< Button for zoom out
153 };
154
155 #endif // ZOOMBUTTONPANEL_H