summary refs log tree commit diff
path: root/src/ui/LoadingIndicator.h
blob: 33095c4c4f14232464c7c5775be3e3e55b4daf51 (plain) (blame)
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
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QColor>
#include <QWidget>

class QPainter;
class QTimer;
class QPaintEvent;
class LoadingIndicator : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)

public:
    LoadingIndicator(QWidget *parent = nullptr);

    void paintEvent(QPaintEvent *e) override;

    void start();
    void stop();

    QColor color() { return color_; }
    void setColor(QColor color)
    {
        color_ = color;
        emit colorChanged();
    }

    int interval() { return interval_; }
    void setInterval(int interval) { interval_ = interval; }

private slots:
    void onTimeout();

signals:
    void colorChanged();

private:
    int interval_;
    int angle_;

    QColor color_;
    QTimer *timer_;
};