summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriano Rezende <adriano.1.rezende@nokia.com>2012-07-03 12:40:41 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-07-03 18:00:08 +0200
commitbd9cc5c12c022c6c368b51eb0d28bd6b8f8ef0ee (patch)
tree8983a30ee8e3694deae52f3d4cc6c43fbe7c87a0 /src
parent71f785fd200e504dd77e179fdf51d1e69aa5d128 (diff)
downloadqtquickcontrols-bd9cc5c12c022c6c368b51eb0d28bd6b8f8ef0ee.tar.gz
Fix ToolTip and improve ButtonBehavior
Change-Id: I099aa93a8ee28c5e7e76ef8e316449266acbadd2 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qquickcomponentsprivate.cpp (renamed from src/qtooltiparea.cpp)50
-rw-r--r--src/qquickcomponentsprivate.h (renamed from src/qtooltiparea.h)35
-rw-r--r--src/qstyleplugin.cpp12
-rw-r--r--src/src.pro4
4 files changed, 31 insertions, 70 deletions
diff --git a/src/qtooltiparea.cpp b/src/qquickcomponentsprivate.cpp
index 9b97d8fe..2f424ca3 100644
--- a/src/qtooltiparea.cpp
+++ b/src/qquickcomponentsprivate.cpp
@@ -38,54 +38,26 @@
**
****************************************************************************/
-#include "qtooltiparea.h"
-#include <QtWidgets/QToolTip>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QGraphicsSceneEvent>
+#include "qquickcomponentsprivate.h"
+#include <QToolTip>
+#include <QQuickCanvas>
-QTooltipArea::QTooltipArea(QQuickItem *parent) :
- QQuickItem(parent),
- m_containsMouse(false)
-{
- setAcceptHoverEvents(true);
- connect(&m_tiptimer, SIGNAL(timeout()), this, SLOT(timeout()));
-}
-void QTooltipArea::setText(const QString &t)
+QQuickComponentsPrivate::QQuickComponentsPrivate(QObject *parent)
+ : QObject(parent)
{
- if (t != m_text) {
- m_text = t;
- emit textChanged();
- }
-}
-void QTooltipArea::showToolTip(const QString &str) const
-{
- Q_UNUSED(str);
- //QToolTip::showText(cursor().pos(), str);
}
-void QTooltipArea::hoverEnterEvent(QHoverEvent *event)
-
+void QQuickComponentsPrivate::showToolTip(QQuickItem *item, const QPointF &pos, const QString &str)
{
- Q_UNUSED(event);
- m_tiptimer.start(1000);
-
- m_containsMouse = true;
- emit containsMouseChanged();
- //QQuickItem::hoverEnterEvent(event);
-}
+ if (!item || !item->canvas())
+ return;
-void QTooltipArea::hoverLeaveEvent(QHoverEvent *event)
-{
- Q_UNUSED(event);
- m_tiptimer.stop();
- m_containsMouse = false;
- emit containsMouseChanged();
- //QQuickItem::hoverLeaveEvent(event);
+ QToolTip::showText(item->canvas()->mapToGlobal(item->mapToScene(pos).toPoint()), str);
}
-void QTooltipArea::timeout()
+void QQuickComponentsPrivate::hideToolTip()
{
- showToolTip(m_text);
+ QToolTip::hideText();
}
diff --git a/src/qtooltiparea.h b/src/qquickcomponentsprivate.h
index 5352ab94..2f9c9ecf 100644
--- a/src/qtooltiparea.h
+++ b/src/qquickcomponentsprivate.h
@@ -38,40 +38,21 @@
**
****************************************************************************/
-#ifndef QTOOLTIPAREA_H
-#define QTOOLTIPAREA_H
+#ifndef QQUICKCOMPONENTSPRIVATE_H
+#define QQUICKCOMPONENTSPRIVATE_H
+#include <QObject>
#include <QQuickItem>
-#include <QTimer>
-#include <QtWidgets/QGraphicsSceneHoverEvent>
-class QTooltipArea : public QQuickItem
+class QQuickComponentsPrivate : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
public:
- QTooltipArea(QQuickItem *parent = 0);
- void setText(const QString &t);
- QString text() const {return m_text;}
- bool containsMouse() const {return m_containsMouse;}
- void showToolTip(const QString &str) const;
- void hoverEnterEvent(QHoverEvent *event);
- void hoverLeaveEvent(QHoverEvent *event);
+ QQuickComponentsPrivate(QObject *parent = 0);
-public slots:
- void timeout();
-
-signals:
- void textChanged();
- void containsMouseChanged();
-
-private:
-
- QTimer m_tiptimer;
- QString m_text;
- bool m_containsMouse;
+ Q_INVOKABLE void showToolTip(QQuickItem *item, const QPointF &pos, const QString &text);
+ Q_INVOKABLE void hideToolTip();
};
-#endif // QTOOLTIPAREA_H
+#endif
diff --git a/src/qstyleplugin.cpp b/src/qstyleplugin.cpp
index e375d253..4cf7a825 100644
--- a/src/qstyleplugin.cpp
+++ b/src/qstyleplugin.cpp
@@ -49,9 +49,9 @@
#include "qdesktopitem.h"
#include "qwheelarea.h"
#include "qcursorarea.h"
-#include "qtooltiparea.h"
#include "qtsplitterbase.h"
#include "qquicklinearlayout.h"
+#include "qquickcomponentsprivate.h"
#include <qqmlextensionplugin.h>
#include <qqmlengine.h>
@@ -79,12 +79,20 @@ public:
}
};
+QObject *registerPrivateModule(QQmlEngine *engine, QJSEngine *jsEngine)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(jsEngine);
+ return new QQuickComponentsPrivate();
+}
void StylePlugin::registerTypes(const char *uri)
{
+ qmlRegisterModuleApi<QQuickComponentsPrivate>(QByteArray(uri) + ".Internal",
+ 0, 2, registerPrivateModule);
+
qmlRegisterType<QStyleItem>(uri, 0, 2, "StyleItem");
qmlRegisterType<QCursorArea>(uri, 0, 2, "CursorArea");
- qmlRegisterType<QTooltipArea>(uri, 0, 2, "TooltipArea");
qmlRegisterType<QRangeModel>(uri, 0, 2, "RangeModel");
qmlRegisterType<QWheelArea>(uri, 0, 2, "WheelArea");
diff --git a/src/src.pro b/src/src.pro
index 353ab5cc..54fe2cc3 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -25,7 +25,7 @@ HEADERS += qtmenu.h \
qquicklayoutengine_p.h \
qquicklayout.h \
qquicklinearlayout.h \
- qtooltiparea.h \
+ qquickcomponentsprivate.h \
qtsplitterbase.h
SOURCES += qtmenu.cpp \
@@ -39,10 +39,10 @@ SOURCES += qtmenu.cpp \
qdesktopitem.cpp \
qtoplevelwindow.cpp \
qcursorarea.cpp \
- qtooltiparea.cpp \
qquicklayout.cpp \
qquicklayoutengine.cpp \
qquicklinearlayout.cpp \
+ qquickcomponentsprivate.cpp \
qtsplitterbase.cpp
TARGETPATH = QtDesktop/plugin