/*!
 \reimp
 */
void KDCircularProgressIndicator::paintEvent( QPaintEvent * )
{
    if( !isActive() )
        return;

    QPainter p( this );

    const int size = qMin( height(), width() );

    const QRectF bar( size / -17.0, size / (-17.0/7.0) - 1.0, size/17.0 * 1.75, size/17.0*4.5 );

    p.setRenderHint( QPainter::Antialiasing, true );
    p.translate( rect().center() );

    p.rotate( d->animationStep * 360.0 / numAnimationSteps );

    p.setPen( Qt::transparent );
    p.setBrush( palette().color( QPalette::Foreground ) );

    const QColor foreground = palette().color( QPalette::WindowText );

    for( unsigned int i = 0; i < numAnimationSteps; ++i )
    {
        p.setBrush( mixColor( Qt::transparent, i / static_cast<qreal>(numAnimationSteps+1), foreground ) );
        p.drawEllipse( bar );
        p.rotate( -360.0 / numAnimationSteps );
    }
}
Exemple #2
0
int main(int argc, char **argv)
{
	XGCValues gcv;
	unsigned long gcm;
	int exact,left,right,device_index,i;
	XpmAttributes xpmattr;
	XpmColorSymbol xpmcsym[4];
	elementinfo *e;

	scanArgs(argc, argv);
	initXWin(argc, argv);
	exact=left=right=device_index=-1;

	init_mixer();
	cure=element;
	e=element;
	while(e)
	{
		if(!strcasecmp(e->info.eid.name,"Master Volume"))
			e->icon=0;
		else if(!strcasecmp(e->info.eid.name,"PCM Volume"))
			e->icon=1;
		else if(!strcasecmp(e->info.eid.name,"MIC Volume"))
			e->icon=5;
		else if(!strcasecmp(e->info.eid.name,"Line Volume"))
			e->icon=4;
		else if(!strcasecmp(e->info.eid.name,"CD Volume"))
			e->icon=3;
		else if(!strcasecmp(e->info.eid.name,"Synth Volume"))
			e->icon=2;
		else if(!strcasecmp(e->info.eid.name,"PC Speaker Volume"))
			e->icon=6;
		/*
		 * bass = 7
		 * treble = 8
		 */
		else
			e->icon=9;
		e=e->next;
	}

	gcm=GCGraphicsExposures;
	gcv.graphics_exposures=0;
	gc_gc=XCreateGC(d_display, w_root, gcm, &gcv);

	color[0]=mixColor(ledcolor, 0, backcolor, 100);
	color[1]=mixColor(ledcolor, 100, backcolor, 0);
	color[2]=mixColor(ledcolor, 60, backcolor, 40);
	color[3]=mixColor(ledcolor, 25, backcolor, 75);

	xpmcsym[0].name="back_color";
	xpmcsym[0].value=NULL;;
	xpmcsym[0].pixel=color[0];
	xpmcsym[1].name="led_color_high";
	xpmcsym[1].value=NULL;;
	xpmcsym[1].pixel=color[1];
	xpmcsym[2].name="led_color_med";
	xpmcsym[2].value=NULL;;
	xpmcsym[2].pixel=color[2];
	xpmcsym[3].name="led_color_low";
	xpmcsym[3].value=NULL;;
	xpmcsym[3].pixel=color[3];
	xpmattr.numsymbols=4;
	xpmattr.colorsymbols=xpmcsym;
	xpmattr.exactColors=0;
	xpmattr.closeness=40000;
	xpmattr.valuemask=XpmColorSymbols | XpmExactColors | XpmCloseness;
	XpmCreatePixmapFromData(d_display, w_root, wmmixer_xpm, &pm_main, &pm_mask, &xpmattr);
	XpmCreatePixmapFromData(d_display, w_root, tile_xpm, &pm_tile, NULL, &xpmattr);
	XpmCreatePixmapFromData(d_display, w_root, icons_xpm, &pm_icon, NULL, &xpmattr);
	pm_disp=XCreatePixmap(d_display, w_root, 64, 64, DefaultDepth(d_display, DefaultScreen(d_display)));

	if(wmaker || ushape || astep)
		XShapeCombineMask(d_display, w_activewin, ShapeBounding, winsize/2-32, winsize/2-32, pm_mask, ShapeSet);
	else
		XCopyArea(d_display, pm_tile, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0);

	XSetClipMask(d_display, gc_gc, pm_mask);
	XCopyArea(d_display, pm_main, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0);
	XSetClipMask(d_display, gc_gc, None);

	if(count==0)
		fprintf(stderr,"%s : Sorry, no supported channels found.\n", NAME);
	else
	{
		int done=0;
		XEvent xev;

		checkVol();
		XSelectInput(d_display, w_activewin, ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
		XMapWindow(d_display, w_main);

		while(!done)
		{
			while(XPending(d_display))
			{
				XNextEvent(d_display, &xev);
				switch(xev.type)
				{
					case Expose:
						repaint();
						break;
					case ButtonPress:
						pressEvent(&xev.xbutton);
						break;
					case ButtonRelease:
						releaseEvent(&xev.xbutton);
						break;
					case MotionNotify:
						motionEvent(&xev.xmotion);
						break;
					case ClientMessage:
						if(xev.xclient.data.l[0]==deleteWin)
							done=1;
						break;
				}
			}

			if(btnstate & (BTNPREV | BTNNEXT))
			{
				rpttimer++;
				if(rpttimer>=RPTINTERVAL)
				{
					if(btnstate & BTNNEXT)
					{
						cure=cure->next;
						if(!cure)
							cure=element;
					}
					else
					{
						cure=cure->prev;
						if(!cure)
						{
							elementinfo *e;
							e=element;
							while(e->next)
								e=e->next;
							cure=e;
						}
					}
					checkVol();
					rpttimer=0;
				}
			}
			else
				checkVol();
			XFlush(d_display);
			usleep(50000);
		}
	}
	XFreeGC(d_display, gc_gc);
	XFreePixmap(d_display, pm_main);
	XFreePixmap(d_display, pm_tile);
	XFreePixmap(d_display, pm_disp);
	XFreePixmap(d_display, pm_mask);
	XFreePixmap(d_display, pm_icon);
	freeXWin();
	return 0;
}