#include "LoadingWidget.h" #include #include #include #include LoadingWidget::LoadingWidget(QWidget* aParent) : QWidget(aParent) , mTimer(new QTimer(this)) , mColor(QColor(Qt::white)) , mCount(12) , mMaxDiameter(30) , mMinDiameter(5) { connect(mTimer,&QTimer::timeout,this,QOverload<>::of(&QWidget::repaint)); initPaintArea(); } LoadingWidget::~LoadingWidget() { } void LoadingWidget::setMaxDiameter(const int aValue) { mMaxDiameter = aValue; } void LoadingWidget::setMinDiameter(const int aValue) { mMinDiameter = aValue; } void LoadingWidget::setColor(const QColor& aColor) { mColor = aColor; } void LoadingWidget::setCount(const int aCount) { mCount = aCount; } void LoadingWidget::resizeEvent(QResizeEvent *aEvent) { QWidget::resizeEvent(aEvent); initPaintArea(); } void LoadingWidget::showEvent(QShowEvent *aEvent) { QWidget::showEvent(aEvent); mTimer->start(60); } void LoadingWidget::hideEvent(QHideEvent *aEvent) { QWidget::hideEvent(aEvent); mTimer->stop(); } void LoadingWidget::initPaintArea() { double halfWidth = width() /2; double halfHeight = height() /2; double half = qMin(width(),height())/2; double distance = half - mMaxDiameter/2 - 1; double gap = (mMaxDiameter - mMinDiameter)/(mCount-1)/2; double angleGap = 360/mCount; mPointList.clear(); mRadiusList.clear(); for(int i=0;i