37 lines
889 B
C++
37 lines
889 B
C++
|
|
#include "BusyIndicator.h"
|
||
|
|
#include <QLabel>
|
||
|
|
#include <QMovie>
|
||
|
|
#include <QVBoxLayout>
|
||
|
|
|
||
|
|
BusyIndicator::BusyIndicator(QWidget* parent)
|
||
|
|
: QWidget { parent }
|
||
|
|
{
|
||
|
|
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||
|
|
|
||
|
|
QLabel* icon = new QLabel;
|
||
|
|
_busy_movie = new QMovie(":gif/BusyIndicator.gif"); // 转圈 GIF
|
||
|
|
icon->setMovie(_busy_movie);
|
||
|
|
_busy_movie->start();
|
||
|
|
QLabel* text = new QLabel(QStringLiteral(u"加载数据中......"));
|
||
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||
|
|
layout->addStretch();
|
||
|
|
layout->addWidget(icon, 0, Qt::AlignCenter);
|
||
|
|
layout->addWidget(text, 0, Qt::AlignCenter);
|
||
|
|
layout->addStretch();
|
||
|
|
setLayout(layout);
|
||
|
|
}
|
||
|
|
|
||
|
|
void BusyIndicator::Start()
|
||
|
|
{
|
||
|
|
// _busy_movie->start();
|
||
|
|
this->setVisible(true);
|
||
|
|
this->update();
|
||
|
|
}
|
||
|
|
|
||
|
|
void BusyIndicator::Stop()
|
||
|
|
{
|
||
|
|
// _busy_movie->stop();
|
||
|
|
this->setVisible(false);
|
||
|
|
this->update();
|
||
|
|
}
|