Merging from old trunk:
r645971 | montanaro | 2007-03-24 02:51:55 +0100 (Sat, 24 Mar 2007) | 2 lines Ported to QAbstractButton svn path=/trunk/KDE/kdebase/workspace/; revision=659569
This commit is contained in:
parent
932444eeef
commit
52ba1d2e69
3 changed files with 20 additions and 20 deletions
|
@ -12,7 +12,7 @@ kde4_automoc(${kwin3_b2_PART_SRCS})
|
|||
|
||||
kde4_add_plugin(kwin3_b2 ${kwin3_b2_PART_SRCS})
|
||||
|
||||
target_link_libraries(kwin3_b2 kdecorations ${QT_QT3SUPPORT_LIBRARY})
|
||||
target_link_libraries(kwin3_b2 kdecorations)
|
||||
|
||||
install(TARGETS kwin3_b2 DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
||||
|
|
|
@ -1055,13 +1055,13 @@ static void redraw_pixmaps()
|
|||
|
||||
// pin
|
||||
for (i = 0; i < NumStates; i++) {
|
||||
bool isDown = (i == Down || i == IDown);
|
||||
const bool isDown = (i == Down || i == IDown);
|
||||
unsigned const char *white = isDown ? pindown_white_bits : pinup_white_bits;
|
||||
unsigned const char *gray = isDown ? pindown_gray_bits : pinup_gray_bits;
|
||||
unsigned const char *dgray =isDown ? pindown_dgray_bits : pinup_dgray_bits;
|
||||
unsigned const char *dgray = isDown ? pindown_dgray_bits : pinup_dgray_bits;
|
||||
p.begin(pixmap[P_PINUP * NumStates + i]);
|
||||
kColorBitmaps(&p, (i < 3) ? aGrp : iGrp, 0, 0, 16, 16, true, white,
|
||||
gray, NULL, dgray, NULL, NULL);
|
||||
kColorBitmaps(&p, (i < 3) ? aGrp : iGrp, 0, 0, 16, 16, true,
|
||||
white, gray, NULL, dgray, NULL, NULL);
|
||||
p.end();
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ bool B2Client::eventFilter(QObject *o, QEvent *e)
|
|||
|
||||
B2Button::B2Button(B2Client *_client, QWidget *parent,
|
||||
const QString& tip, const int realizeBtns)
|
||||
: Q3Button(parent, 0), hover(false)
|
||||
: QAbstractButton(parent), hover(false)
|
||||
{
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
@ -1239,19 +1239,20 @@ QSizePolicy B2Button::sizePolicy() const
|
|||
return(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
}
|
||||
|
||||
void B2Button::drawButton(QPainter *p)
|
||||
void B2Button::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
QPixmap* gradient = titleGradient[client->isActive() ? 0 : 1];
|
||||
if (gradient) {
|
||||
p->drawTiledPixmap(0, 0, buttonSize, buttonSize, *gradient, 0, 2);
|
||||
p.drawTiledPixmap(0, 0, buttonSize, buttonSize, *gradient, 0, 2);
|
||||
} else {
|
||||
p->fillRect(rect(), bg);
|
||||
p.fillRect(rect(), bg);
|
||||
}
|
||||
if (useMiniIcon) {
|
||||
QPixmap miniIcon = client->icon().pixmap(
|
||||
style()->pixelMetric(QStyle::PM_SmallIconSize),
|
||||
client->isActive() ? QIcon::Normal : QIcon::Disabled);
|
||||
p->drawPixmap((width() - miniIcon.width()) / 2,
|
||||
p.drawPixmap((width() - miniIcon.width()) / 2,
|
||||
(height() - miniIcon.height()) / 2, miniIcon);
|
||||
} else {
|
||||
int type;
|
||||
|
@ -1270,7 +1271,7 @@ void B2Button::drawButton(QPainter *p)
|
|||
else
|
||||
type = INorm;
|
||||
}
|
||||
p->drawPixmap((width() - icon[type]->width()) / 2,
|
||||
p.drawPixmap((width() - icon[type]->width()) / 2,
|
||||
(height() - icon[type]->height()) / 2, *icon[type]);
|
||||
}
|
||||
}
|
||||
|
@ -1291,7 +1292,7 @@ void B2Button::mousePressEvent(QMouseEvent * e)
|
|||
(e->button() & realizeButtons) ? Qt::LeftButton : Qt::NoButton,
|
||||
(e->button() & realizeButtons) ? Qt::LeftButton : Qt::NoButton,
|
||||
e->modifiers());
|
||||
Q3Button::mousePressEvent(&me);
|
||||
QAbstractButton::mousePressEvent(&me);
|
||||
}
|
||||
|
||||
void B2Button::mouseReleaseEvent(QMouseEvent * e)
|
||||
|
@ -1301,21 +1302,21 @@ void B2Button::mouseReleaseEvent(QMouseEvent * e)
|
|||
(e->button() & realizeButtons) ? Qt::LeftButton : Qt::NoButton,
|
||||
(e->button() & realizeButtons) ? Qt::LeftButton : Qt::NoButton,
|
||||
e->modifiers());
|
||||
Q3Button::mouseReleaseEvent(&me);
|
||||
QAbstractButton::mouseReleaseEvent(&me);
|
||||
}
|
||||
|
||||
void B2Button::enterEvent(QEvent *e)
|
||||
{
|
||||
hover = true;
|
||||
repaint();
|
||||
Q3Button::enterEvent(e);
|
||||
QAbstractButton::enterEvent(e);
|
||||
}
|
||||
|
||||
void B2Button::leaveEvent(QEvent *e)
|
||||
{
|
||||
hover = false;
|
||||
repaint();
|
||||
Q3Button::leaveEvent(e);
|
||||
QAbstractButton::leaveEvent(e);
|
||||
}
|
||||
|
||||
// =====================================
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#define __B2CLIENT_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <q3button.h>
|
||||
#include <QBitmap>
|
||||
#include <QAbstractButton>
|
||||
//Added by qt3to4:
|
||||
#include <QPaintEvent>
|
||||
#include <QGridLayout>
|
||||
|
@ -20,6 +19,7 @@
|
|||
#include <QShowEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QBitmap>
|
||||
#include <QPixmap>
|
||||
#include <kdecoration.h>
|
||||
#include <kdecorationfactory.h>
|
||||
|
@ -32,7 +32,7 @@ namespace B2 {
|
|||
|
||||
class B2Client;
|
||||
|
||||
class B2Button : public Q3Button
|
||||
class B2Button : public QAbstractButton
|
||||
{
|
||||
public:
|
||||
B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL, const int realizeBtns = Qt::LeftButton);
|
||||
|
@ -48,8 +48,7 @@ public:
|
|||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
protected:
|
||||
virtual void drawButton(QPainter *p);
|
||||
void drawButtonLabel(QPainter *){;}
|
||||
virtual void paintEvent(QPaintEvent *e);
|
||||
|
||||
void mousePressEvent( QMouseEvent* e );
|
||||
void mouseReleaseEvent( QMouseEvent* e );
|
||||
|
|
Loading…
Reference in a new issue