Implement pressed state

svn path=/trunk/KDE/kdebase/workspace/; revision=831765
This commit is contained in:
Huynh Huu Long 2008-07-13 09:50:51 +00:00
parent 20ee14550f
commit d29c446e3c
2 changed files with 24 additions and 9 deletions

View file

@ -139,15 +139,31 @@ void OxygenButton::leaveEvent(QEvent *e)
}
//////////////////////////////////////////////////////////////////////////////
// pressSlot()
// mousePressEvent()
// ------------
// Mouse has pressed the button
// TODO: never called?
void OxygenButton::pressSlot()
void OxygenButton::mousePressEvent(QMouseEvent *e)
{
status_ = Oxygen::Pressed;
update();
KCommonDecorationButton::mousePressEvent(e);
}
//////////////////////////////////////////////////////////////////////////////
// mouseReleaseEvent()
// ------------
// Mouse has released the button
void OxygenButton::mouseReleaseEvent(QMouseEvent *e)
{
status_ = Oxygen::Normal;
update();
KCommonDecorationButton::mouseReleaseEvent(e);
}
//////////////////////////////////////////////////////////////////////////////
// drawButton()
// ------------
@ -182,17 +198,15 @@ void OxygenButton::paintEvent(QPaintEvent *)
QColor bg = helper_.backgroundTopColor(pal.window());
QColor color = buttonDetailColor(pal);
if(status_ == Oxygen::Hovered || status_ == Oxygen::Pressed) {
if(type_ == ButtonClose)
color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
else
color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color();
}
QLinearGradient lg = helper_.decoGradient(QRect(4,4,13,13), color);
painter.drawPixmap(0, 0, helper_.windecoButton(pal.button(), status_ == Oxygen::Pressed));
painter.drawPixmap(0, 0, helper_.windecoButton(pal.window(), status_ == Oxygen::Pressed));
if (client_.isActive()) {
painter.setRenderHints(QPainter::Antialiasing);

View file

@ -55,6 +55,10 @@ public:
const int lastMousePress(){return lastmouse_;}
void reset(long unsigned int){repaint();}
protected:
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
private:
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
@ -62,9 +66,6 @@ private:
void drawIcon(QPainter *p, QPalette &pal, ButtonType &type);
QColor buttonDetailColor(const QPalette &palette);
private Q_SLOTS:
void pressSlot();
private:
OxygenClient &client_;
OxygenHelper &helper_;