2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Katri Kaikkonen - katri.kaikkonen@ixonos.com
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.
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.
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,
23 #ifndef INDICATORBUTTON_H
24 #define INDICATORBUTTON_H
26 #include <QMouseEvent>
28 #include <QToolButton>
31 #include "../user/user.h"
34 * @brief Indicator button class
36 * @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
37 * @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
39 class IndicatorButton : public QToolButton
47 * @param parent Parent widget
49 IndicatorButton(QWidget *parent = 0);
56 /*******************************************************************************
57 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
58 ******************************************************************************/
61 * @brief Move event for the distance indicator button
63 * @param event Mouse event
65 void mouseMoveEvent(QMouseEvent *event);
68 * @brief Press event for the distance indicator button
70 * @param event Mouse event
72 void mousePressEvent(QMouseEvent *event);
75 * @brief Event handler for mouse release events
77 * @param event Mouse event
79 void mouseReleaseEvent(QMouseEvent *event);
82 * @brief Event handler for paint events
84 * Paints the button and its icon
85 * @param event Paint event
87 void paintEvent(QPaintEvent *event);
89 /*******************************************************************************
90 * MEMBER FUNCTIONS AND SLOTS
91 ******************************************************************************/
94 * @brief Relative position of the event inside the widget
96 const QPoint& eventPosition();
99 * @brief Slot to redraw the panel after window resize event
101 * @param size Size of the new screen
103 void screenResized(const QSize &size);
106 * @brief Toggle distance indicator button draggability
108 void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
112 * @brief Safeguard slot to release mouse grab if something goes horribly wrong
114 void forceMouseRelease();
117 * @brief Slot that handles drag initialization once timer has timed out
121 /*******************************************************************************
123 ******************************************************************************/
126 * @brief Automatic centering setting changed by user
128 * @param enabled True if automatic centering is enabled, otherwise false
130 void autoCenteringTriggered(bool enabled);
132 /*******************************************************************************
134 ******************************************************************************/
137 bool m_isDraggable; ///< Boolean for tracking the draggability state
139 QColor *m_normalColor; ///< Normal background color
141 QLinearGradient *m_selectedGradient; ///< Selected background
143 QPainterPath m_backgroundPath; ///< Item shape path
145 QPixmap m_indicatorLeds[2]; ///< Placeholder for images
147 QPoint m_dragPosition; ///< Location from where the widget is grabbed
148 QPoint m_eventPosition; ///< Position of mousePressEvent
150 QSize m_screenSize; ///< Store for the screen size
152 QTimer *m_dragStartTimer; ///< Timer to init draggability of the distance indicator button
153 QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease
156 #endif // INDICATORBUTTON_H