Mercurial > hg > easaier-soundaccess
view widgets/WaitingWidget.cpp @ 216:3045ced14a59
modify the animation in the WaitingWidget class
author | benoitrigolleau |
---|---|
date | Thu, 07 Feb 2008 15:15:52 +0000 |
parents | 1c638a8e9897 |
children | 7b2a7880a501 |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sound Access EASAIER client application. Silogic 2007. Benoit Rigolleau. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #include "WaitingWidget.h" #include <QPainter> #include <QLayout> #include <QPalette> WaitingWidget::WaitingWidget(QWidget *parent):QWidget(parent){ m_ind=0; colors[0]=QRgb(0xffddf756); colors[1]=QRgb(0xffccf756); colors[2]=QRgb(0xffbbf756); colors[3]=QRgb(0xffaaf756); colors[4]=QRgb(0xff99f756); colors[5]=QRgb(0xff88f756); colors[6]=QRgb(0xff77f756); colors[7]=QRgb(0xff66f756); } void WaitingWidget::paintEvent(QPaintEvent *event){ QWidget::paintEvent(event); if(timer.isActive()){ QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, false); draw(&painter); } } void WaitingWidget::draw(QPainter *painter){ QColor color1(QRgb(0x000000)); color1.setAlpha(60); painter->setBrush(QBrush(color1, Qt::SolidPattern)); painter->drawRect(0,0,this->width(), this->height()); int xm = this->width()/2; int ym = this->height()/2; painter->translate(xm,ym); for(int i=0; i < 8; i++){ QColor penColor(colors[(m_ind+i)%8]); penColor.setAlpha(180); painter->setPen(QPen(penColor,8,Qt::SolidLine,Qt::RoundCap)); float angle = (360.0f/8.0f); painter->rotate(-angle); painter->drawLine(20,0,35,0); } } void WaitingWidget::setAnimation(bool animate) { timer.stop(); if (animate) timer.start(50, this); } void WaitingWidget::timerEvent(QTimerEvent *e) { if (e->timerId() == timer.timerId()) { setUpdatesEnabled(false); m_ind = (m_ind+1)%8; setUpdatesEnabled(true); update(); } }