Added a new widget pixmapbutton, which will be the new baseclass for all

buttons used in promoe
This commit is contained in:
Thomas Frauendorfer 2008-01-27 07:54:47 +01:00
parent b7ae919014
commit e2fdb4e009
3 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,30 @@
#include "pixmapbutton.h"
#include <QIcon>
#include <QPainter>
#include <QPaintEvent>
#include <QPixmap>
PixmapButton::PixmapButton (QWidget *parent) : QAbstractButton (parent)
{
}
PixmapButton::~PixmapButton ()
{
}
void
PixmapButton::paintEvent( QPaintEvent * event )
{
QPixmap pixmap = icon().pixmap (size(),
isDown() ? QIcon::Active : QIcon::Normal,
isChecked() ? QIcon::On : QIcon::Off);
QPainter p;
p.begin(this);
p.drawPixmap( rect(), pixmap, pixmap.rect() );
p.end();
}

View file

@ -0,0 +1,37 @@
/**
* This file is a part of Promoe, an XMMS2 CLient
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __PIXMAPBUTTON_H__
#define __PIXMAPBUTTON_H__
#include <QAbstractButton>
class QPaintEvent;
class QWidget;
class PixmapButton : public QAbstractButton {
Q_OBJECT
public:
PixmapButton (QWidget *parent);
~PixmapButton ();
protected:
void paintEvent ( QPaintEvent * event );
};
#endif

6
src/widgets/widgets.pri Normal file
View file

@ -0,0 +1,6 @@
HEADERS += pixmapbutton.h
SOURCES += pixmapbutton.cpp
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD