Implement pressed state
svn path=/trunk/KDE/kdebase/workspace/; revision=831765
This commit is contained in:
parent
20ee14550f
commit
d29c446e3c
2 changed files with 24 additions and 9 deletions
|
@ -139,15 +139,31 @@ void OxygenButton::leaveEvent(QEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// pressSlot()
|
// mousePressEvent()
|
||||||
// ------------
|
// ------------
|
||||||
// Mouse has pressed the button
|
// Mouse has pressed the button
|
||||||
// TODO: never called?
|
|
||||||
void OxygenButton::pressSlot()
|
void OxygenButton::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
status_ = Oxygen::Pressed;
|
status_ = Oxygen::Pressed;
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
KCommonDecorationButton::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// mouseReleaseEvent()
|
||||||
|
// ------------
|
||||||
|
// Mouse has released the button
|
||||||
|
|
||||||
|
void OxygenButton::mouseReleaseEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
status_ = Oxygen::Normal;
|
||||||
|
update();
|
||||||
|
|
||||||
|
KCommonDecorationButton::mouseReleaseEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// drawButton()
|
// drawButton()
|
||||||
// ------------
|
// ------------
|
||||||
|
@ -182,17 +198,15 @@ void OxygenButton::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
QColor bg = helper_.backgroundTopColor(pal.window());
|
QColor bg = helper_.backgroundTopColor(pal.window());
|
||||||
|
|
||||||
|
|
||||||
QColor color = buttonDetailColor(pal);
|
QColor color = buttonDetailColor(pal);
|
||||||
if(status_ == Oxygen::Hovered || status_ == Oxygen::Pressed) {
|
if(status_ == Oxygen::Hovered || status_ == Oxygen::Pressed) {
|
||||||
if(type_ == ButtonClose)
|
if(type_ == ButtonClose)
|
||||||
color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
|
color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
|
||||||
else
|
else
|
||||||
color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color();
|
color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color();
|
||||||
|
|
||||||
}
|
}
|
||||||
QLinearGradient lg = helper_.decoGradient(QRect(4,4,13,13), 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()) {
|
if (client_.isActive()) {
|
||||||
painter.setRenderHints(QPainter::Antialiasing);
|
painter.setRenderHints(QPainter::Antialiasing);
|
||||||
|
|
|
@ -55,6 +55,10 @@ public:
|
||||||
const int lastMousePress(){return lastmouse_;}
|
const int lastMousePress(){return lastmouse_;}
|
||||||
void reset(long unsigned int){repaint();}
|
void reset(long unsigned int){repaint();}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *e);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enterEvent(QEvent *e);
|
void enterEvent(QEvent *e);
|
||||||
void leaveEvent(QEvent *e);
|
void leaveEvent(QEvent *e);
|
||||||
|
@ -62,9 +66,6 @@ private:
|
||||||
void drawIcon(QPainter *p, QPalette &pal, ButtonType &type);
|
void drawIcon(QPainter *p, QPalette &pal, ButtonType &type);
|
||||||
QColor buttonDetailColor(const QPalette &palette);
|
QColor buttonDetailColor(const QPalette &palette);
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void pressSlot();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OxygenClient &client_;
|
OxygenClient &client_;
|
||||||
OxygenHelper &helper_;
|
OxygenHelper &helper_;
|
||||||
|
|
Loading…
Reference in a new issue