qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
notificationicon.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "../chatlinecontent.h"
23 
24 #include <QLinearGradient>
25 #include <QPixmap>
26 #include <QTimer>
27 
29 {
30  Q_OBJECT
31 public:
32  explicit NotificationIcon(QSize size);
33 
34  QRectF boundingRect() const override;
35  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
36  QWidget* widget) override;
37  void setWidth(qreal width) override;
38  qreal getAscent() const override;
39 
40 private slots:
41  void updateGradient();
42 
43 private:
44  static constexpr int framerate = 30; // 30Hz
45 
46  QSize size;
47  QPixmap pmap;
48  QLinearGradient grad;
49  QTimer updateTimer;
50 
51  qreal dotWidth = 0.2;
52  qreal alpha = 0.0;
53 };
NotificationIcon::boundingRect
QRectF boundingRect() const override
Definition: notificationicon.cpp:41
NotificationIcon::NotificationIcon
NotificationIcon(QSize size)
Definition: notificationicon.cpp:28
NotificationIcon::setWidth
void setWidth(qreal width) override
Definition: notificationicon.cpp:64
NotificationIcon::getAscent
qreal getAscent() const override
Definition: notificationicon.cpp:69
ChatLineContent
Definition: chatlinecontent.h:26
NotificationIcon::pmap
QPixmap pmap
Definition: notificationicon.h:47
NotificationIcon::size
QSize size
Definition: notificationicon.h:46
NotificationIcon::dotWidth
qreal dotWidth
Definition: notificationicon.h:51
NotificationIcon::grad
QLinearGradient grad
Definition: notificationicon.h:48
NotificationIcon::framerate
static constexpr int framerate
Definition: notificationicon.h:44
NotificationIcon::alpha
qreal alpha
Definition: notificationicon.h:52
NotificationIcon
Definition: notificationicon.h:28
NotificationIcon::updateGradient
void updateGradient()
Definition: notificationicon.cpp:74
NotificationIcon::updateTimer
QTimer updateTimer
Definition: notificationicon.h:49
NotificationIcon::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition: notificationicon.cpp:46