Mercurial > hg > easaier-soundaccess
view widgets/WaitingWidget.cpp @ 108:c107866fd387
first draft to the list result
author | benoitrigolleau |
---|---|
date | Fri, 14 Sep 2007 16:44:36 +0000 |
parents | |
children | 1c638a8e9897 |
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; color2.setAlpha(50); 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(); } }