-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDesktopWidget.h
102 lines (82 loc) · 3.03 KB
/
DesktopWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
File: DesktopWidget.h
Created on: 25/11/2015
Author: Felix de las Pozas Alvarez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DESKTOPWIDGET_H_
#define DESKTOPWIDGET_H_
// Qt
#include <QWidget>
#include <QColor>
/** \class DesktopWidget
* \brief Widget to be on the desktop, invisible to events and always on top,
* showing the title and progression of the alarm.
*/
class DesktopWidget
: public QWidget
{
Q_OBJECT
public:
static const int WIDGET_SIZE; /** height and width of the widget in pixels. */
/** \brief DesktopWidget class constructor.
* \param[in] dragEnable true to make the widget react to events and false to make the widget transparent to input.
*
*/
explicit DesktopWidget(bool dragEnable, QWidget *parent);
/** \brief DesktopWidget class virtual destructor.
*
*/
virtual ~DesktopWidget()
{};
/** \brief Sets the progress of the widget.
* \param[in] value progress value in [0.0-100.0].
*
*/
void setProgress(double value);
/** \brief Sets the widget position on the screen.
* \param[in] position position coordinates.
*
*/
void setPosition(const QPoint &position);
/** \brief Modifies the widget opacity.
* \param[in] opacity opacity value in [0-100].
*
*/
void setOpacity(const int opacity);
/** \brief Sets the widget color.
* \param[in] color widget color.
*
*/
void setColor(const QColor &color);
/** \brief Sets the name of the widget.
*
*/
void setName(const QString &name);
signals:
void beingDragged();
protected:
virtual void mousePressEvent(QMouseEvent *e) override final;
virtual void mouseReleaseEvent(QMouseEvent *e) override final;
virtual void mouseMoveEvent(QMouseEvent *e) override final;
private:
virtual void paintEvent(QPaintEvent *e) override final;
double m_progress; /** progress of the widget in [0.0-100.0]. */
QColor m_color; /** color of the widget. */
QColor m_contrastColor; /** contrast color in relation to m_color, always black or white. */
QString m_name; /** alarm name */
bool m_buttonDown; /** true if the left mouse button is down and false otherwise. */
QPoint m_point; /** dragging point. */
int m_limitX; /** X limit in global screen coordinates. */
int m_limitY; /** Y limit in global screen coordinates. */
};
#endif // DESKTOPWIDGET_H_