1 /***************************************************************************
2 * Copyright (C) 2005-2006 by Tarek Saidi *
3 * tarek.saidi@arcor.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "WaitAnimationWidget.h"
23 WaitAnimationWidget::WaitAnimationWidget(QWidget* parent):QWidget(parent){
28 float diff=CurAngle-i*0.16666667f;
33 CircSizes[i]=1.0+exp(-14.0f*diff*diff);
35 connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation()));
38 WaitAnimationWidget::~WaitAnimationWidget(){
42 void WaitAnimationWidget::start(){
46 void WaitAnimationWidget::stop(){
51 void WaitAnimationWidget::setRefreshRate(int fps){
52 DiffAngle=1.0f/((60.0f/(float)speed)*(float)fps);
53 timer.setInterval((int) ((1.0f/(float)fps)*1000.0f));
56 void WaitAnimationWidget::refreshAnimation(){
58 if(CurAngle>1.0f)CurAngle-=1.0f;
60 float diff=CurAngle-i*0.16666667f;
65 CircSizes[i]=1.0+exp(-14.0f*diff*diff);
70 void WaitAnimationWidget::paintEvent(QPaintEvent* event){
73 QPainter painter(this);
74 painter.setRenderHints(QPainter::Antialiasing,true);
75 painter.setBrush(Qt::black);
76 painter.setPen(Qt::black);
78 float d=CircSizes[i]*5.0;
79 QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d);
80 painter.drawEllipse(rect);
85 void WaitAnimationWidget::resizeEvent(QResizeEvent* event){
93 CircPositions[i].setX((r-10)*cos(-2.0*3.14159265*(0.16666667*i))+r);
94 CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r);