|
|
|
@ -21,6 +21,8 @@ |
|
|
|
|
#include <math.h> |
|
|
|
|
#include <QPainter> |
|
|
|
|
#include <QRectF> |
|
|
|
|
#include "PwmConfig.h" |
|
|
|
|
#include "main.h" |
|
|
|
|
#include "WaitAnimationWidget.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,9 +30,28 @@ WaitAnimationWidget::WaitAnimationWidget(QWidget* parent):QWidget(parent){ |
|
|
|
|
speed=60; |
|
|
|
|
setRefreshRate(25); |
|
|
|
|
CurAngle=0; |
|
|
|
|
connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation())); |
|
|
|
|
timer.start(); |
|
|
|
|
for(int i=0;i<6;i++){ |
|
|
|
|
float diff=CurAngle-i*0.16666667f; |
|
|
|
|
if(diff>0.5f) |
|
|
|
|
diff=1.0f-diff; |
|
|
|
|
if(diff<-0.5f) |
|
|
|
|
diff=1.0f+diff; |
|
|
|
|
CircSizes[i]=1.0+exp(-14.0f*diff*diff);
|
|
|
|
|
} |
|
|
|
|
connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation()));
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WaitAnimationWidget::~WaitAnimationWidget(){ |
|
|
|
|
timer.stop();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WaitAnimationWidget::start(){ |
|
|
|
|
timer.start();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WaitAnimationWidget::stop(){ |
|
|
|
|
timer.stop(); |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WaitAnimationWidget::setRefreshRate(int fps){ |
|
|
|
@ -53,16 +74,17 @@ void WaitAnimationWidget::refreshAnimation(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WaitAnimationWidget::paintEvent(QPaintEvent* event){ |
|
|
|
|
QPainter painter(this); |
|
|
|
|
painter.setRenderHints(QPainter::Antialiasing,true); |
|
|
|
|
painter.setBrush(QColor(255,255,255));
|
|
|
|
|
painter.setPen(QColor(255,255,255)); |
|
|
|
|
for(int i=0;i<6;i++){ |
|
|
|
|
float d=CircSizes[i]*5.0; |
|
|
|
|
QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d); |
|
|
|
|
painter.drawEllipse(rect);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(timer.isActive()){ |
|
|
|
|
QPainter painter(this); |
|
|
|
|
painter.setRenderHints(QPainter::Antialiasing,true); |
|
|
|
|
painter.setBrush(config.BannerTextColor);
|
|
|
|
|
painter.setPen(config.BannerTextColor); |
|
|
|
|
for(int i=0;i<6;i++){ |
|
|
|
|
float d=CircSizes[i]*5.0; |
|
|
|
|
QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d); |
|
|
|
|
painter.drawEllipse(rect);
|
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WaitAnimationWidget::resizeEvent(QResizeEvent* event){ |
|
|
|
@ -75,5 +97,5 @@ void WaitAnimationWidget::resizeEvent(QResizeEvent* event){ |
|
|
|
|
CircPositions[i].setX((r-10)*cos(-2.0*3.14159265*(0.16666667*i))+r); |
|
|
|
|
CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|