From 26fe811fd00b92f8d53659e856f75d757c6a0307 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 14 May 2011 15:38:37 +0000 Subject: fixed skinned button bug git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2193 90c681e8-e032-0410-971d-27865f9a5e38 --- src/ui/button.cpp | 26 ++++++++++++++------------ src/ui/button.h | 7 ++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 9b96f8f52..f07088b0b 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ilya Kotov * + * Copyright (C) 2007-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * Based on Promoe, an XMMS2 Client * @@ -31,6 +31,7 @@ Button::Button (QWidget *parent, uint normal, uint pressed, uint cursor) name_normal = normal; name_pressed = pressed; name_cursor = cursor; + m_pressed = false; skin = Skin::instance(); setON (false); setCursor (skin->getCursor (name_cursor)); @@ -56,25 +57,26 @@ void Button::setON (bool on) } void Button::mousePressEvent (QMouseEvent *e) { + if(e->button() != Qt::LeftButton) + return; setON (true); - m_cursorin = true; + m_pressed = true; QWidget::mousePressEvent(e); } -void Button::mouseReleaseEvent (QMouseEvent*) +void Button::mouseReleaseEvent (QMouseEvent *e) { - setON (false); - if (m_cursorin) + if (!m_pressed) + return; + m_pressed = false; + if(rect().contains(e->pos())) + { + setON (false); emit clicked(); + } } void Button::mouseMoveEvent (QMouseEvent *e) { - if ( !m_cursorin && rect().contains(e->pos()) ) { - m_cursorin = true; - setON (true); - } else if ( m_cursorin && !rect().contains(e->pos()) ) { - m_cursorin = false; - setON (false); - } + setON (m_pressed && rect().contains(e->pos())); } diff --git a/src/ui/button.h b/src/ui/button.h index ce8651ffe..e00bd7dc7 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2011 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -25,7 +25,7 @@ class Skin; /** - @author Ilya Kotov + @author Ilya Kotov */ class Button : public PixmapWidget { @@ -43,7 +43,8 @@ private slots: private: Skin *skin; - bool m_cursorin; + //bool m_cursorin; + bool m_pressed; void setON(bool); uint name_normal, name_pressed; uint name_cursor; -- cgit v1.2.3-13-gbd6f