32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#ifndef Progress_Bar_H
|
|
#define Progress_Bar_H
|
|
#include <utility>
|
|
#include <vector>
|
|
#include "../Global.h"
|
|
struct Tick {
|
|
QString text;
|
|
QColor color;
|
|
double value = 0;
|
|
Tick(QString text, QColor color) : text(std::move(text)), color(std::move(color)) {
|
|
QString that = (this->text.startsWith('+') || this->text.startsWith('-') || this->text.startsWith('<') || this->text.startsWith('>')) ? this->text.mid(1) : this->text;
|
|
value = that.toDouble();
|
|
}
|
|
Tick(QString text, QColor color, double value) : text(std::move(text)), color(std::move(color)), value(value) {
|
|
}
|
|
};
|
|
class Progress_Bar : public QWidget {
|
|
public:
|
|
explicit Progress_Bar(const std::vector<Tick>& tick_list, QWidget *parent = nullptr);
|
|
double tick_space_w = 1;
|
|
double value = 0;
|
|
int timer;
|
|
std::function<void(void)> set_value = nullptr;
|
|
double get_draw_width(double value);
|
|
void setValue(double value);
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void timerEvent(QTimerEvent *event) override;
|
|
std::vector<Tick> tick_list;
|
|
};
|
|
#endif
|