qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
spinner.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 <QObject>
25 #include <QPixmap>
26 #include <QTimer>
27 
28 class QVariantAnimation;
29 
30 class Spinner : public ChatLineContent
31 {
32  Q_OBJECT
33 public:
34  Spinner(const QString& img, QSize size, qreal speed);
35 
36  QRectF boundingRect() const override;
37  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
38  QWidget* widget) override;
39  void setWidth(qreal width) override;
40  qreal getAscent() const override;
41 
42 private slots:
43  void timeout();
44 
45 private:
46  static constexpr int framerate = 30; // 30Hz
47  QSize size;
48  QPixmap pmap;
49  qreal rotSpeed;
50  qreal curRot;
51  QTimer timer;
52  qreal alpha = 0.0;
53  QVariantAnimation* blendAnimation;
54 };
Spinner::getAscent
qreal getAscent() const override
Definition: spinner.cpp:83
Spinner::curRot
qreal curRot
Definition: spinner.h:50
Spinner
Definition: spinner.h:30
Spinner::alpha
qreal alpha
Definition: spinner.h:52
Spinner::blendAnimation
QVariantAnimation * blendAnimation
Definition: spinner.h:53
Spinner::framerate
static constexpr int framerate
Definition: spinner.h:46
Spinner::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition: spinner.cpp:59
ChatLineContent
Definition: chatlinecontent.h:26
Spinner::timeout
void timeout()
Definition: spinner.cpp:88
Spinner::rotSpeed
qreal rotSpeed
Definition: spinner.h:49
Spinner::setWidth
void setWidth(qreal width) override
Definition: spinner.cpp:78
Spinner::timer
QTimer timer
Definition: spinner.h:51
Spinner::Spinner
Spinner(const QString &img, QSize size, qreal speed)
Definition: spinner.cpp:31
Spinner::size
QSize size
Definition: spinner.h:47
Spinner::boundingRect
QRectF boundingRect() const override
Definition: spinner.cpp:54
Spinner::pmap
QPixmap pmap
Definition: spinner.h:48