aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@nokia.com>2010-11-30 16:02:05 +0200
committerDaniel d'Andrada <daniel.dandrada@nokia.com>2010-12-07 10:29:01 +0200
commit995d3fa98310c7ea28f032ba60fe0794533eb3d2 (patch)
treecace181dd33426cc1331cf165f8625a201b8ce72
parent411bd63dd2f871ed1080c4c107ca238195316704 (diff)
Fixes: NB#199685 - Tab-switching is sluggish - actions react on button-release
New: MButtonTabView RevBy: Dominik Kapusta Details: Introducing a view class for buttons in tab bar. Those kind of buttons react on mouse press instead of mouse release Modified version of original patch from Dominik Kapusta
-rw-r--r--src/views/mbuttontabview.cpp67
-rw-r--r--src/views/mbuttontabview.h84
-rw-r--r--src/views/mbuttontabview_p.h36
-rw-r--r--src/views/views.pri2
4 files changed, 189 insertions, 0 deletions
diff --git a/src/views/mbuttontabview.cpp b/src/views/mbuttontabview.cpp
new file mode 100644
index 00000000..c639e5b0
--- /dev/null
+++ b/src/views/mbuttontabview.cpp
@@ -0,0 +1,67 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#include "mbuttontabview.h"
+#include "mbuttontabview_p.h"
+#include "mviewconstants.h"
+
+#include <QGraphicsSceneMouseEvent>
+
+MButtonTabView::MButtonTabView(MButton *controller) :
+ MButtonView(* new MButtonTabViewPrivate, controller)
+{
+}
+
+MButtonTabView::MButtonTabView(MButtonTabViewPrivate &dd, MButton *controller) :
+ MButtonView(dd, controller)
+{
+}
+
+MButtonTabView::~MButtonTabView()
+{
+}
+
+void MButtonTabView::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+
+ if (model()->checkable() && !model()->checked()) {
+ style()->pressFeedback().play();
+
+ // Activate it (i.e. "click") straight away.
+ model()->click();
+ }
+}
+
+void MButtonTabView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+void MButtonTabView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+void MButtonTabView::cancelEvent(MCancelEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+M_REGISTER_VIEW_NEW(MButtonTabView, MButton)
diff --git a/src/views/mbuttontabview.h b/src/views/mbuttontabview.h
new file mode 100644
index 00000000..1e18ac38
--- /dev/null
+++ b/src/views/mbuttontabview.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef MBUTTONTABVIEW_H
+#define MBUTTONTABVIEW_H
+
+#include <mbuttonview.h>
+#include <mbuttonmodel.h>
+#include <mbuttonstyle.h>
+
+class MButtonTabViewPrivate;
+class MButton;
+
+class QGraphicsSceneResizeEvent;
+
+/*!
+ \class MButtonTabView
+ \brief View class for tab bar buttons.
+
+ \ingroup views
+
+ This view class provides a view for a button that's placed in a tab bar.
+ In comparison to standard button reacting on mouse release, it reacts on mouse press,
+ just like tabs in common toolkits.
+
+ In order for this view to work correctly, the button must be checkable.
+
+ \sa MButton MButtonView MButtonStyle MToolBar
+*/
+
+class M_VIEWS_EXPORT MButtonTabView : public MButtonView
+{
+ Q_OBJECT
+ M_VIEW(MButtonModel, MButtonStyle)
+
+public:
+
+ /*!
+ \brief Constructs the view.
+ \param Pointer to the controller.
+ */
+ MButtonTabView(MButton *controller);
+
+ /*!
+ \brief Destructs the view.
+ */
+ virtual ~MButtonTabView();
+
+protected:
+
+ //! \reimp
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ virtual void cancelEvent(MCancelEvent *event);
+ //! \reimp_end
+
+ //! \internal
+ MButtonTabView(MButtonTabViewPrivate &dd, MButton *controller);
+ //! \internal_end
+
+private:
+ Q_DISABLE_COPY(MButtonTabView)
+ Q_DECLARE_PRIVATE(MButtonTabView)
+
+};
+
+#endif
diff --git a/src/views/mbuttontabview_p.h b/src/views/mbuttontabview_p.h
new file mode 100644
index 00000000..bb45d382
--- /dev/null
+++ b/src/views/mbuttontabview_p.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef MBUTTONTABVIEW_P_H
+#define MBUTTONTABVIEW_P_H
+
+#include "mbuttonview_p.h"
+#include "mbuttontabview.h"
+#include <QIcon>
+
+class MScalableImage;
+class MLabel;
+class QTimer;
+
+class MButtonTabViewPrivate : public MButtonViewPrivate
+{
+ Q_DECLARE_PUBLIC(MButtonTabView)
+};
+
+#endif
diff --git a/src/views/views.pri b/src/views/views.pri
index 4c681e0c..587aa556 100644
--- a/src/views/views.pri
+++ b/src/views/views.pri
@@ -40,6 +40,7 @@ PUBLIC_HEADERS += \
mimagewidgetview.h \
mbuttoniconview.h \
mbuttonswitchview.h \
+ mbuttontabview.h \
mcheckboxview.h \
mcontainerview.h \
mcontentitemview.h \
@@ -122,6 +123,7 @@ SOURCES += \
mpositionindicatorview.cpp \
mapplicationmenubuttonview.cpp \
mbuttonview.cpp \
+ mbuttontabview.cpp \
mimagewidgetview.cpp \
mbuttoniconview.cpp \
mbuttonswitchview.cpp \