Files
Radio/module/radio/component/ProgressBar.h
T
2026-06-16 13:38:08 +08:00

38 lines
990 B
C++

#ifndef ProgressBar_H
#define ProgressBar_H
#include <utility>
#include "../Global.h"
struct Tick{
QString mText;
QColor mColor;
double mValue = 0;
Tick(QString text, QColor color) : mText(std::move(text)), mColor(std::move(color)){
QString that = (mText[0] == '+' || mText[0] == '-' || mText[0] == '<' || mText[0] == '>') ? mText.mid(1) : mText;
mValue = that.toDouble();
}
Tick(QString text, QColor color, double value) : mText(std::move(text)), mColor(std::move(color)){
mValue = value;
}
};
class ProgressBar : public QWidget {
public:
explicit ProgressBar(const QVector<Tick>& tickList, QWidget *parent = nullptr);
double mTickSpaceW = 1;
double mValue = 0;
int mTimer;
std::function<void(void)> mSetValue = nullptr;
double getDrawWidth(double value);
protected:
void paintEvent(QPaintEvent *event) override;
void timerEvent(QTimerEvent *event) override;
QVector<Tick> mTickList;
};
#endif