aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/button.cpp26
-rw-r--r--src/ui/button.h7
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 <forkotov02@hotmail.ru>
+ @author Ilya Kotov <forkotov02@hotmail.ru>
*/
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;