From 0bac65e37498e99afc3405f38817a5f7b9952ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 3 Apr 2013 00:50:00 +0200 Subject: [PATCH] Strip down tooltip so it builds --- src/declarativeimports/core/CMakeLists.txt | 2 +- src/declarativeimports/core/tooltip.cpp | 68 +++++++++++----------- src/declarativeimports/core/tooltip.h | 25 ++++---- 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index ca93e9110..ac7ff4abd 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -18,7 +18,7 @@ set(corebindings_SRCS svgitem.cpp framesvgitem.cpp dialog.cpp -# tooltip.cpp + tooltip.cpp dataenginebindings.cpp iconitem.cpp plasmanamespace.cpp diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 4dba47639..f9fe6e4cf 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -19,23 +19,21 @@ ***************************************************************************/ #include "tooltip.h" -#include "declarativeitemcontainer_p.h" #include -#include -#include -#include +// #include +// #include #include #include -#include -#include -#include -#include +//#include +// #include +// #include +// #include -ToolTipProxy::ToolTipProxy(QObject *parent) - : QObject(parent), m_mainText(""), m_subText(""), m_widget(0) +ToolTipWindow::ToolTipWindow(QWindow *parent) + : QQuickWindow(parent), m_mainText(""), m_subText(""), m_widget(0) { connect(this, SIGNAL(targetChanged()), this, SLOT(updateToolTip())); connect(this, SIGNAL(mainTextChanged()), this, SLOT(updateToolTip())); @@ -43,33 +41,34 @@ ToolTipProxy::ToolTipProxy(QObject *parent) connect(this, SIGNAL(imageChanged()), this, SLOT(updateToolTip())); } -ToolTipProxy::~ToolTipProxy() +ToolTipWindow::~ToolTipWindow() { } -QGraphicsObject *ToolTipProxy::target() const +QQuickItem *ToolTipWindow::target() const { return m_target.data(); } -void ToolTipProxy::setTarget(QGraphicsObject *target) +void ToolTipWindow::setTarget(QQuickItem *target) { if (m_target.data() != target) { m_target = target; - +/* m_widget = qobject_cast(m_target.data()); if (!m_widget) { // if this is called in Compenent.onCompleted we have to // wait a loop for the item to be added to a scene QTimer::singleShot(0, this, SLOT(syncTarget())); return; - } + }*/ emit targetChanged(); } } -void ToolTipProxy::syncTarget() +void ToolTipWindow::syncTarget() { + /* if (!m_target) { return; } @@ -78,7 +77,7 @@ void ToolTipProxy::syncTarget() if (!scene) { QObject *parent = m_target.data(); while ((parent = parent->parent())) { - QGraphicsObject *qo = qobject_cast(parent); + QQuickItem *qo = qobject_cast(parent); if (qo && qo->scene()) { scene = qo->scene(); scene->addItem(m_target.data()); @@ -93,7 +92,7 @@ void ToolTipProxy::syncTarget() } if (!m_declarativeItemContainer && scene) { - m_declarativeItemContainer = QWeakPointer(new DeclarativeItemContainer()); + m_declarativeItemContainer = QWeakPointer(new QQuickItem()); m_declarativeItemContainer.data()->setObjectName("DIContainer"); scene->addItem(m_declarativeItemContainer.data()); } @@ -106,14 +105,15 @@ void ToolTipProxy::syncTarget() m_widget = m_declarativeItemContainer.data(); emit targetChanged(); } + */ } -QString ToolTipProxy::mainText() const +QString ToolTipWindow::mainText() const { return m_mainText; } -void ToolTipProxy::setMainText(const QString &text) +void ToolTipWindow::setMainText(const QString &text) { if (text == m_mainText) { return; @@ -123,12 +123,12 @@ void ToolTipProxy::setMainText(const QString &text) emit mainTextChanged(); } -QString ToolTipProxy::subText() const +QString ToolTipWindow::subText() const { return m_subText; } -void ToolTipProxy::setSubText(const QString &text) +void ToolTipWindow::setSubText(const QString &text) { if (text == m_subText) { return; @@ -138,12 +138,12 @@ void ToolTipProxy::setSubText(const QString &text) emit subTextChanged(); } -QVariant ToolTipProxy::image() const +QVariant ToolTipWindow::image() const { return m_image; } -void ToolTipProxy::setImage(QVariant name) +void ToolTipWindow::setImage(QVariant name) { if (name == m_image) { return; @@ -153,24 +153,24 @@ void ToolTipProxy::setImage(QVariant name) emit imageChanged(); } -void ToolTipProxy::updateToolTip() +void ToolTipWindow::updateToolTip() { if (!m_widget) { return; } - Plasma::ToolTipContent data; - data.setMainText(m_mainText); - data.setSubText(m_subText); +// Plasma::ToolTipContent data; +// data.setMainText(m_mainText); +// data.setSubText(m_subText); // set image switch (m_image.type()) { case QVariant::String: { QString name = m_image.toString(); if (!name.isEmpty()) { - KIcon icon(name); + QIcon icon = QIcon::fromTheme(name); if (!icon.isNull()) { - data.setImage(icon.pixmap(IconSize(KIconLoader::Desktop))); +// data.setImage(icon.pixmap(IconSize(KIconLoader::Desktop))); } } break; @@ -178,21 +178,21 @@ void ToolTipProxy::updateToolTip() case QVariant::Icon: { QIcon icon = m_image.value(); - data.setImage(icon); +// data.setImage(icon); break; } case QVariant::Pixmap: { QPixmap pixmap = m_image.value(); - data.setImage(pixmap); +// data.setImage(pixmap); break; } default: break; } - Plasma::ToolTipManager::self()->setContent(m_widget, data); + //Plasma::ToolTipManager::self()->setContent(m_widget, data); } -#include "tooltip.moc" +//#include "tooltip.moc" diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index 9384f485f..c42c6d226 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -18,30 +18,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -#ifndef TOOLTIP_PROXY_P -#define TOOLTIP_PROXY_P +#ifndef TOOLTIP_WINDOW_P +#define TOOLTIP_WINDOW_P -#include +#include #include #include -class QGraphicsObject; +class QQuickItem; class QGraphicsWidget; -class DeclarativeItemContainer; /** * QML wrapper for kdelibs Plasma::ToolTip * * Exposed as `ToolTip` in QML. */ -class ToolTipProxy : public QObject +class ToolTipWindow : public QQuickWindow { Q_OBJECT /** * The item that will display this tooltip on mouse over */ - Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged) /** * The title of the tooltip, not more that 2-3 words @@ -59,11 +58,11 @@ class ToolTipProxy : public QObject Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) public: - ToolTipProxy(QObject *parent = 0); - ~ToolTipProxy(); + ToolTipWindow(QWindow *parent = 0); + ~ToolTipWindow(); - QGraphicsObject *target() const; - void setTarget(QGraphicsObject *target); + QQuickItem *target() const; + void setTarget(QQuickItem *target); QString mainText() const; void setMainText(const QString &text); @@ -89,8 +88,8 @@ private: QString m_subText; QVariant m_image; QGraphicsWidget *m_widget; - QWeakPointer m_declarativeItemContainer; - QWeakPointer m_target; + QWeakPointer m_declarativeItemContainer; + QWeakPointer m_target; }; #endif