50 lines
892 B
C++
Executable File
50 lines
892 B
C++
Executable File
#ifndef PROGRESSBAR_H
|
|
#define PROGRESSBAR_H
|
|
|
|
#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);
|
|
inline QString secToString(int msc);
|
|
|
|
private slots:
|
|
void onTimeout();
|
|
|
|
private:
|
|
Ui::ProgressBar* ui;
|
|
int duration;
|
|
QString durationStr;
|
|
|
|
QTimer* timer;
|
|
bool isMax = true;
|
|
|
|
QString sliderMaxStyles;
|
|
QString sliderMinStyles;
|
|
};
|
|
|
|
inline QString ProgressBar::secToString(int msc)
|
|
{
|
|
QString formatStr = QTime(0, 0, 0).addSecs(msc).toString(QString::fromUtf8("hh:mm:ss"));
|
|
return formatStr;
|
|
}
|
|
|
|
#endif // PROGRESSBAR_H
|