Mercurial > hg > easaier-soundaccess
view widgets/WaitingWidget.cpp @ 220:7b2a7880a501
antialiasing
author | benoitrigolleau |
---|---|
date | Thu, 07 Feb 2008 15:53:32 +0000 |
parents | 3045ced14a59 |
children |
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(0xfffec000); colors[1]=QRgb(0xffdbf756); colors[2]=QRgb(0xffb7f151); colors[3]=QRgb(0xffb6d1aa); colors[4]=QRgb(0xff71b19d); colors[5]=QRgb(0xff9dd8ec); colors[6]=QRgb(0xff808080); colors[7]=QRgb(0xffcccccc); } 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()); painter->setRenderHint (QPainter::Antialiasing, true ); 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]); QColor penColor(colors[1]); penColor.setAlpha(((m_ind+i)%8+1)*30); 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(); } }