-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLineProgress.h
More file actions
75 lines (58 loc) · 1.6 KB
/
LineProgress.h
File metadata and controls
75 lines (58 loc) · 1.6 KB
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
#pragma once
#include "SmoothOpacity.h"
#include <QWidget>
#include <QPropertyAnimation>
#include <QTimer>
#include <QPainter>
#include <QPaintEvent>
#include <QColor>
#include <QEasingCurve>
#include <QFont>
#include <QtMath>
#include <algorithm>
#include <QHash>
class LineProgress : public QWidget {
Q_OBJECT
public:
enum LineColor {
BackgroundLight,
BackgroundDark,
ForegroundLight,
ForegroundDark
};
explicit LineProgress(QWidget *parent = nullptr);
void setColor(const LineColor &state, const QColor &color);
void setFixedSize(QSize s);
void setDarkMode(bool value);
void setText(const QString &text);
void setIndeterminate(bool value);
void start();
void stop();
void setValue(int value);
int getValue() const;
inline uint qHash(const LineColor &state, uint seed = 0) {
return ::qHash(static_cast<int>(state), seed);
}
protected:
void paintEvent(QPaintEvent *event) override;
private:
void fadeIn();
void fadeOut();
void loadDefaultColors();
QColor color(const LineColor &state) const;
// Colors
QHash<LineColor, QColor> _colors;
bool isDarkMode = false;
bool isIndeterminate = false;
double offset = 0.0;
double currentValue = 0.0;
double minimum = 0.0;
double maximum = 1.0;
const int margin = 12;
const int lineHeight = 8;
const int radius = lineHeight / 2;
QTimer *timer = nullptr;
QPropertyAnimation *animation = nullptr;
SmoothOpacity *opacity = nullptr;
QString loaderText;
};