view widgets/WaitingWidget.cpp @ 112:1c638a8e9897

bye bye from silo114
author benoitrigolleau
date Wed, 19 Sep 2007 15:54:32 +0000
parents c107866fd387
children 3045ced14a59
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;
}

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(0xffdbf756));
	QColor color2 = color1;
	color1.setAlpha(80);
	painter->setPen(QPen(palette().foreground(),1,Qt::NoPen,Qt::RoundCap));

	int rectsize = this->width()/20;
	for(int i=0;i<=20;i++){
		if((i+m_ind)%2){
			painter->setBrush(QBrush(color1, Qt::SolidPattern));
		}
		else{
			painter->setBrush(QBrush(Qt::white, Qt::SolidPattern));	
		}
		painter->drawRect(i*rectsize,0,this->width(), this->height());
	}

	/*QLinearGradient rectRadian(0,0,this->width(),0);

	for(int i=0;i<10;i++){
		if((i+m_ind)%2){
			rectRadian.setColorAt(0.1*i,color1);
		}
		else{
			rectRadian.setColorAt(0.1*i,color2);	
		}
	}
	painter->setPen(QPen(palette().foreground(),1,Qt::NoPen,Qt::RoundCap));
	painter->setBrush(rectRadian);
	painter->drawRect(0,0,this->width(), this->height());*/
}


void WaitingWidget::setAnimation(bool animate)
{
    timer.stop();
    if (animate)
        timer.start(200, this);
}

void WaitingWidget::timerEvent(QTimerEvent *e)
{
    if (e->timerId() == timer.timerId()) {
        setUpdatesEnabled(false);
		m_ind++;
        setUpdatesEnabled(true);
        update();
    }
}