RecordControlApplication/ProgressBar.h

52 lines
934 B
C
Raw Permalink Normal View History

#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
2024-08-12 11:26:42 +08:00
#include <QDebug>
#include <QTime>
#include <QTimer>
#include <QWidget>
namespace Ui {
class ProgressBar;
}
class ProgressBar : public QWidget {
Q_OBJECT
public:
enum PlayState {
Play,
Pause
};
explicit ProgressBar(QWidget* parent = 0);
~ProgressBar();
void showMax();
void setDuration(int dur);
void setCurrent(int cur);
void setState(PlayState state);
2024-08-12 11:26:42 +08:00
inline QString msecToString(int msc);
private slots:
void onTimeout();
private:
Ui::ProgressBar* ui;
int duration;
QString durationStr;
QTimer* timer;
bool isMax = true;
QString sliderMaxStyles;
QString sliderMinStyles;
};
2024-08-12 11:26:42 +08:00
inline QString ProgressBar::msecToString(int msc)
{
2024-08-12 11:26:42 +08:00
QString formatStr = QTime(0, 0, 0).addMSecs(msc).toString(QString::fromUtf8("hh:mm:ss"));
qDebug() << msc;
return formatStr;
}
#endif // PROGRESSBAR_H