aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Rahn <Torsten.Rahn@basyskom.de>2010-08-06 14:54:33 +0200
committerTorsten Rahn <Torsten.Rahn@basyskom.de>2010-08-06 15:07:49 +0200
commit122f19c4d584dfb9109fab8a38328a183c7af073 (patch)
treecfd4e0e918c989926f8884274c4f8f35db41cb28
parentd8530644426eefc5011f9c18df5817884b02e3c2 (diff)
Fixes: NB#182543 - plainQt - Weird haptic feedback
RevBy: Bernd Lamecker
-rw-r--r--plainqt/style/qtmaemo6style.cpp42
-rw-r--r--plainqt/style/qtmaemo6style.h12
-rw-r--r--plainqt/style/qtmaemo6styleeventfilter.cpp15
3 files changed, 57 insertions, 12 deletions
diff --git a/plainqt/style/qtmaemo6style.cpp b/plainqt/style/qtmaemo6style.cpp
index 0bf3eb85..20b6bae3 100644
--- a/plainqt/style/qtmaemo6style.cpp
+++ b/plainqt/style/qtmaemo6style.cpp
@@ -55,6 +55,7 @@
#include <QHeaderView>
#include <MComponentData>
+#include <MFeedback>
#include <MTheme>
#include <MScalableImage>
#include <MLabel>
@@ -2267,6 +2268,47 @@ QRect QtMaemo6Style::subElementRect(SubElement element,
}
+const MFeedback * QtMaemo6Style::feedback(const QString& feedbackName, const QWidget *widget)
+{
+ if ( widget ) {
+
+ // First check for dynamic properties
+ if ( widget->dynamicPropertyNames().contains("NoMFeedback") )
+ return 0;
+
+ // Then check for the class type
+
+ QString meegoClassString;
+
+ if(qobject_cast<const QWidget*>(widget))
+ meegoClassString = "MWidgetStyle";
+
+ if(qobject_cast<const QPushButton*>(widget))
+ meegoClassString = "MButtonIconStyle";
+
+ if(qobject_cast<const QComboBox*>(widget))
+ meegoClassString = "MComboBoxStyle";
+
+ if ( meegoClassString.isEmpty() )
+ return 0;
+
+ QStyleOption opt;
+ opt.initFrom(widget);
+
+ const MWidgetStyle *style = static_cast<const MWidgetStyle *>(
+ QtMaemo6StylePrivate::mStyle(opt.state, meegoClassString, ""));
+
+ if ( feedbackName == MFeedbackPlayer::Press )
+ return &(style->pressFeedback());
+ if ( feedbackName == MFeedbackPlayer::Release )
+ return &(style->releaseFeedback());
+ if ( feedbackName == MFeedbackPlayer::Cancel )
+ return &(style->cancelFeedback());
+ }
+
+ return 0;
+}
+
QSize QtMaemo6Style::sizeFromContents(ContentsType type,
const QStyleOption *option,
const QSize &contentsSize,
diff --git a/plainqt/style/qtmaemo6style.h b/plainqt/style/qtmaemo6style.h
index 024644cf..27021437 100644
--- a/plainqt/style/qtmaemo6style.h
+++ b/plainqt/style/qtmaemo6style.h
@@ -31,6 +31,7 @@
class MComponentData;
class MStyle;
class MButtonStyle;
+class MFeedback;
class MWidgetStyle;
class MScalableImage;
class MSliderStyle;
@@ -105,10 +106,13 @@ public:
const QStyleOptionComplex *option,
SubControl subControl,
const QWidget *widget = 0) const;
-
- virtual QRect subElementRect(SubElement element,
- const QStyleOption* option,
- const QWidget* widget = 0 ) const;
+
+ virtual QRect subElementRect(SubElement element,
+ const QStyleOption* option,
+ const QWidget* widget = 0 ) const;
+
+ const MFeedback * feedback(const QString &feedbackName, const QWidget *widget = 0);
+
/*! \reimp_end */
/*!
diff --git a/plainqt/style/qtmaemo6styleeventfilter.cpp b/plainqt/style/qtmaemo6styleeventfilter.cpp
index c0556dba..746f2bc8 100644
--- a/plainqt/style/qtmaemo6styleeventfilter.cpp
+++ b/plainqt/style/qtmaemo6styleeventfilter.cpp
@@ -160,11 +160,11 @@ bool QtMaemo6StyleEventFilter::eventFilter(QObject *obj, QEvent *event)
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress: {
// now send press feedback
- MFeedbackPlayer *feedbackPlayer = MComponentData::feedbackPlayer();
-
- if (feedbackPlayer) {
- feedbackPlayer->play(MFeedbackPlayer::Press);
+ if(QtMaemo6Style* style = qobject_cast<QtMaemo6Style*>(widget->style())) {
+ const MFeedback * feedback = style->feedback(MFeedbackPlayer::Press, widget);
+ if ( feedback ) feedback->play();
}
+
if(QComboBox* comboBox = qobject_cast<QComboBox*>(widget)) {
//done in mousePress, because in this way the original popup is completely suppressed
QtMaemo6ComboBoxPopup *comboBoxPopup = new QtMaemo6ComboBoxPopup(comboBox, NULL);
@@ -179,10 +179,9 @@ bool QtMaemo6StyleEventFilter::eventFilter(QObject *obj, QEvent *event)
//qCritical( "eventFilter got mouseRelease" );
// now send release feedback
- MFeedbackPlayer *feedbackPlayer = MComponentData::feedbackPlayer();
-
- if (feedbackPlayer) {
- feedbackPlayer->play(MFeedbackPlayer::Release);
+ if(QtMaemo6Style* style = qobject_cast<QtMaemo6Style*>(widget->style())) {
+ const MFeedback * feedback = style->feedback(MFeedbackPlayer::Release, widget);
+ if ( feedback ) feedback->play();
}
}
break;