From d29c446e3cfdbc9da53e02999e41d0f04961ff49 Mon Sep 17 00:00:00 2001 From: Huynh Huu Long Date: Sun, 13 Jul 2008 09:50:51 +0000 Subject: [PATCH] Implement pressed state svn path=/trunk/KDE/kdebase/workspace/; revision=831765 --- clients/oxygen/oxygenbutton.cpp | 26 ++++++++++++++++++++------ clients/oxygen/oxygenbutton.h | 7 ++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/clients/oxygen/oxygenbutton.cpp b/clients/oxygen/oxygenbutton.cpp index 7e84c92a1e..35311a86b6 100644 --- a/clients/oxygen/oxygenbutton.cpp +++ b/clients/oxygen/oxygenbutton.cpp @@ -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); diff --git a/clients/oxygen/oxygenbutton.h b/clients/oxygen/oxygenbutton.h index e44a615852..a74af55069 100644 --- a/clients/oxygen/oxygenbutton.h +++ b/clients/oxygen/oxygenbutton.h @@ -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_;