From 95dddcea35123c6824b64e7bff7a8d9de38ee214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 4 Apr 2013 22:14:56 +0200 Subject: [PATCH] split tooltip and tooltipwindow --- src/declarativeimports/core/CMakeLists.txt | 1 + .../core/corebindingsplugin.cpp | 2 +- src/declarativeimports/core/tooltip.cpp | 210 ++----------- src/declarativeimports/core/tooltip.h | 45 +-- src/declarativeimports/core/tooltipwindow.cpp | 282 ++++++++++++++++++ src/declarativeimports/core/tooltipwindow.h | 130 ++++++++ 6 files changed, 445 insertions(+), 225 deletions(-) create mode 100644 src/declarativeimports/core/tooltipwindow.cpp create mode 100644 src/declarativeimports/core/tooltipwindow.h diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index ea30753f3..3403507ba 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -19,6 +19,7 @@ set(corebindings_SRCS framesvgitem.cpp dialog.cpp tooltip.cpp + tooltipwindow.cpp dataenginebindings.cpp iconitem.cpp plasmanamespace.cpp diff --git a/src/declarativeimports/core/corebindingsplugin.cpp b/src/declarativeimports/core/corebindingsplugin.cpp index 103645adf..9aa06050d 100644 --- a/src/declarativeimports/core/corebindingsplugin.cpp +++ b/src/declarativeimports/core/corebindingsplugin.cpp @@ -40,7 +40,7 @@ #include "theme.h" #include "dialog.h" #include "iconitem.h" -#include "tooltip.h" +#include "tooltipwindow.h" // #include "dataenginebindings_p.h" #include "plasmanamespace.h" diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 08e7cea67..f7b3eda24 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -28,178 +28,53 @@ #include "framesvgitem.h" #include -ToolTipWindow::ToolTipWindow(QWindow *parent) - : QQuickWindow(parent), m_mainText(""), m_subText(""), m_widget(0) -{ - QSurfaceFormat format; - format.setAlphaBufferSize(8); - setFormat(format); - setClearBeforeRendering(true); - setColor(QColor(Qt::transparent)); - setFlags(Qt::ToolTip); - - m_syncTimer = new QTimer(this); - m_syncTimer->setSingleShot(true); - m_syncTimer->setInterval(250); - connect(m_syncTimer, &QTimer::timeout, this, &ToolTipWindow::syncGeometry); - - connect(this, SIGNAL(targetChanged()), this, SLOT(updateToolTip())); - connect(this, SIGNAL(mainTextChanged()), this, SLOT(updateToolTip())); - connect(this, SIGNAL(subTextChanged()), this, SLOT(updateToolTip())); - connect(this, SIGNAL(imageChanged()), this, SLOT(updateToolTip())); -} - -ToolTipWindow::~ToolTipWindow() +ToolTip::ToolTip(QObject *parent) + : QObject(parent) { } -QQuickItem *ToolTipWindow::target() const +ToolTip::~ToolTip() +{ +} + +QQuickItem *ToolTip::target() const { return m_target.data(); } -void ToolTipWindow::setTarget(QQuickItem *target) +void ToolTip::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 ToolTipWindow::syncGeometry() -{ - qDebug() << " XXX synching geometry"; - qDebug() << "XXXX mainitem : " << mainItem()->width() << mainItem()->height(); - resize(mainItem()->width(), mainItem()->height()); - setPosition(popupPosition(visualParent())); - - Plasma::FrameSvgItem *frameSvg = qobject_cast(mainItem()); - if (frameSvg) { - KWindowEffects::enableBlurBehind(winId(), true, frameSvg->frameSvg()->mask()); - } -} - -QString ToolTipWindow::mainText() const -{ - return m_mainText; -} - -void ToolTipWindow::setMainText(const QString &text) -{ - if (text == m_mainText) { - return; - } - - m_mainText = text; - emit mainTextChanged(); -} - -QString ToolTipWindow::subText() const -{ - return m_subText; -} - -void ToolTipWindow::setSubText(const QString &text) -{ - if (text == m_subText) { - return; - } - - m_subText = text; - emit subTextChanged(); -} - -QVariant ToolTipWindow::image() const -{ - return m_image; -} - -void ToolTipWindow::setImage(QVariant name) -{ - if (name == m_image) { - return; - } - - m_image = name; - emit imageChanged(); -} - -void ToolTipWindow::updateToolTip() -{ - if (!m_widget) { - return; - } - -// 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()) { - QIcon icon = QIcon::fromTheme(name); - if (!icon.isNull()) { -// data.setImage(icon.pixmap(IconSize(KIconLoader::Desktop))); - } - } - break; - } - - case QVariant::Icon: { - QIcon icon = m_image.value(); -// data.setImage(icon); - break; - } - - case QVariant::Pixmap: { - QPixmap pixmap = m_image.value(); -// data.setImage(pixmap); - break; - } - - default: - break; - } - //Plasma::ToolTipManager::self()->setContent(m_widget, data); -} - -QQuickItem *ToolTipWindow::mainItem() const +QQuickItem *ToolTip::mainItem() const { return m_mainItem.data(); } -void ToolTipWindow::setMainItem(QQuickItem *mainItem) +void ToolTip::setMainItem(QQuickItem *mainItem) { qDebug() << "XXXX mainitem changed: " << mainItem->width() << mainItem->height(); -// resize(400, 200); if (m_mainItem.data() != mainItem) { qDebug() << " XXX new mainItem"; - disconnect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTipWindow::syncGeometry); - disconnect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTipWindow::syncGeometry); +// disconnect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTip::syncGeometry); +// disconnect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTip::syncGeometry); if (m_mainItem) { m_mainItem.data()->setParent(parent()); } m_mainItem = mainItem; - if (mainItem) { //mainItem->setParentItem(0); - connect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTipWindow::syncGeometry); - connect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTipWindow::syncGeometry); +// connect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTip::syncGeometry); +// connect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTip::syncGeometry); qDebug() << "XXX new mainITem connected"; - mainItem->setParent(contentItem()); - mainItem->setProperty("parent", QVariant::fromValue(contentItem())); + //mainItem->setParent(contentItem()); + //mainItem->setProperty("parent", QVariant::fromValue(contentItem())); if (mainItem->metaObject()->indexOfSignal("widthChanged")) { connect(mainItem, SIGNAL(widthChanged()), m_syncTimer, SIGNAL(start())); @@ -214,70 +89,37 @@ void ToolTipWindow::setMainItem(QQuickItem *mainItem) } } -QQuickItem *ToolTipWindow::visualParent() const +QQuickItem *ToolTip::visualParent() const { return m_visualParent.data(); } -void ToolTipWindow::setVisualParent(QQuickItem *visualParent) +void ToolTip::setVisualParent(QQuickItem *visualParent) { if (m_visualParent.data() == visualParent) { return; } if (visualParent) { - setPosition(popupPosition(visualParent, Qt::AlignCenter)); + //setPosition(popupPosition(visualParent, Qt::AlignCenter)); } - disconnect(m_visualParent.data(), &QQuickItem::xChanged, this, &ToolTipWindow::syncGeometry); - disconnect(m_visualParent.data(), &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); - //disconnect(visualParent, &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); - - m_visualParent = visualParent; - connect(m_visualParent.data(), &QQuickItem::xChanged, this, &ToolTipWindow::syncGeometry); - connect(m_visualParent.data(), &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); emit visualParentChanged(); } - -bool ToolTipWindow::isVisible() const +bool ToolTip::isVisible() const { - return QQuickWindow::isVisible(); - + //return QQuickWindow::isVisible(); + return true; } -void ToolTipWindow::setVisible(const bool visible) +void ToolTip::setVisible(const bool visible) { qDebug() << visible; if (visible) { //setPosition(popupPosition()); - syncGeometry(); - raise(); +// syncGeometry(); +// raise(); } - QQuickWindow::setVisible(visible); + //QQuickWindow::setVisible(visible); } -QPoint ToolTipWindow::popupPosition(QQuickItem *item, Qt::AlignmentFlag alignment) -{ - // FIXME :: Item - if (!item) { - item = qobject_cast(visualParent()); - } - if (item && item->window()) { - QPointF itemScreenPos; - - QPointF pos = item->mapToScene(QPointF(0, 0)); - //qDebug() << "I've an Item at " << pos; - if (item->window() && item->window()->screen()) { - pos = item->window()->mapToGlobal(pos.toPoint()); - } else { - } - itemScreenPos = QPoint(pos.x() + (item->width() - mainItem()->width())/2, pos.y()-mainItem()->height()); - qDebug() << "XXX Centering at visualParent" << itemScreenPos; - return itemScreenPos.toPoint(); - } else { - qDebug() << "XXX No QQuickItem visualParent found"; - return QPoint(100, 100); - } -} -//#include "tooltip.moc" - diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index c55cbf7e9..6da01aa65 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -19,8 +19,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -#ifndef TOOLTIP_WINDOW_P -#define TOOLTIP_WINDOW_P +#ifndef TOOLTIPOBJECT_H +#define TOOLTIPOBJECT_H #include #include @@ -35,7 +35,7 @@ class QGraphicsWidget; * * Exposed as `ToolTip` in QML. */ -class ToolTipWindow : public QQuickWindow +class ToolTip : public QObject { Q_OBJECT @@ -44,21 +44,6 @@ class ToolTipWindow : public QQuickWindow */ Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged) - /** - * The title of the tooltip, not more that 2-3 words - */ - Q_PROPERTY(QString mainText READ mainText WRITE setMainText NOTIFY mainTextChanged) - - /** - * subtitle of the tooltip. needed if a longer description is needed - */ - Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged) - - /** - * Image to display in the tooltip, can be an image full path or a Freedesktop icon name or QIcon or QPixmap - */ - Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) - /** * The main QML item that will be displayed in the Dialog */ @@ -76,21 +61,12 @@ class ToolTipWindow : public QQuickWindow public: - ToolTipWindow(QWindow *parent = 0); - ~ToolTipWindow(); + ToolTip(QObject *parent = 0); + ~ToolTip(); QQuickItem *target() const; void setTarget(QQuickItem *target); - QString mainText() const; - void setMainText(const QString &text); - - QString subText() const; - void setSubText(const QString &text); - - QVariant image() const; - void setImage(QVariant name); - QQuickItem *mainItem() const; void setMainItem(QQuickItem *mainItem); @@ -104,23 +80,12 @@ public: Q_SIGNALS: void targetChanged(); - void mainTextChanged(); - void subTextChanged(); - void imageChanged(); void mainItemChanged(); void visualParentChanged(); void visibleChanged(); -protected Q_SLOTS: - void syncGeometry(); - void updateToolTip(); - private: QTimer *m_syncTimer; - QString m_mainText; - QString m_subText; - QVariant m_image; - QGraphicsWidget *m_widget; QWeakPointer m_mainItem; QWeakPointer m_visualParent; QWeakPointer m_declarativeItemContainer; diff --git a/src/declarativeimports/core/tooltipwindow.cpp b/src/declarativeimports/core/tooltipwindow.cpp new file mode 100644 index 000000000..31b617a1a --- /dev/null +++ b/src/declarativeimports/core/tooltipwindow.cpp @@ -0,0 +1,282 @@ +/*************************************************************************** + * Copyright 2011 Marco Martin * + * Copyright 2011 Artur Duque de Souza * + * Copyright 2013 Sebastian Kügler * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +#include "tooltipwindow.h" + +#include +#include +#include + +#include "framesvgitem.h" +#include + +ToolTipWindow::ToolTipWindow(QWindow *parent) + : QQuickWindow(parent), m_mainText(""), m_subText(""), m_widget(0) +{ + QSurfaceFormat format; + format.setAlphaBufferSize(8); + setFormat(format); + setClearBeforeRendering(true); + setColor(QColor(Qt::transparent)); + setFlags(Qt::ToolTip); + + m_syncTimer = new QTimer(this); + m_syncTimer->setSingleShot(true); + m_syncTimer->setInterval(250); + connect(m_syncTimer, &QTimer::timeout, this, &ToolTipWindow::syncGeometry); + + connect(this, SIGNAL(targetChanged()), this, SLOT(updateToolTip())); + connect(this, SIGNAL(mainTextChanged()), this, SLOT(updateToolTip())); + connect(this, SIGNAL(subTextChanged()), this, SLOT(updateToolTip())); + connect(this, SIGNAL(imageChanged()), this, SLOT(updateToolTip())); +} + +ToolTipWindow::~ToolTipWindow() +{ +} + +QQuickItem *ToolTipWindow::target() const +{ + return m_target.data(); +} + +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 ToolTipWindow::syncGeometry() +{ + qDebug() << " XXX synching geometry"; + qDebug() << "XXXX mainitem : " << mainItem()->width() << mainItem()->height(); + resize(mainItem()->width(), mainItem()->height()); + setPosition(popupPosition(visualParent())); + + Plasma::FrameSvgItem *frameSvg = qobject_cast(mainItem()); + if (frameSvg) { + KWindowEffects::enableBlurBehind(winId(), true, frameSvg->frameSvg()->mask()); + } +} + +QString ToolTipWindow::mainText() const +{ + return m_mainText; +} + +void ToolTipWindow::setMainText(const QString &text) +{ + if (text == m_mainText) { + return; + } + + m_mainText = text; + emit mainTextChanged(); +} + +QString ToolTipWindow::subText() const +{ + return m_subText; +} + +void ToolTipWindow::setSubText(const QString &text) +{ + if (text == m_subText) { + return; + } + + m_subText = text; + emit subTextChanged(); +} + +QVariant ToolTipWindow::image() const +{ + return m_image; +} + +void ToolTipWindow::setImage(QVariant name) +{ + if (name == m_image) { + return; + } + + m_image = name; + emit imageChanged(); +} + +void ToolTipWindow::updateToolTip() +{ + if (!m_widget) { + return; + } + +// 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()) { + QIcon icon = QIcon::fromTheme(name); + if (!icon.isNull()) { +// data.setImage(icon.pixmap(IconSize(KIconLoader::Desktop))); + } + } + break; + } + + case QVariant::Icon: { + QIcon icon = m_image.value(); +// data.setImage(icon); + break; + } + + case QVariant::Pixmap: { + QPixmap pixmap = m_image.value(); +// data.setImage(pixmap); + break; + } + + default: + break; + } + //Plasma::ToolTipManager::self()->setContent(m_widget, data); +} + +QQuickItem *ToolTipWindow::mainItem() const +{ + return m_mainItem.data(); +} + +void ToolTipWindow::setMainItem(QQuickItem *mainItem) +{ + qDebug() << "XXXX mainitem changed: " << mainItem->width() << mainItem->height(); + +// resize(400, 200); + if (m_mainItem.data() != mainItem) { + qDebug() << " XXX new mainItem"; + disconnect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTipWindow::syncGeometry); + disconnect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTipWindow::syncGeometry); + if (m_mainItem) { + m_mainItem.data()->setParent(parent()); + } + m_mainItem = mainItem; + + + if (mainItem) { + //mainItem->setParentItem(0); + connect(m_mainItem.data(), &QQuickItem::widthChanged, this, &ToolTipWindow::syncGeometry); + connect(m_mainItem.data(), &QQuickItem::heightChanged, this, &ToolTipWindow::syncGeometry); + qDebug() << "XXX new mainITem connected"; + mainItem->setParent(contentItem()); + mainItem->setProperty("parent", QVariant::fromValue(contentItem())); + + if (mainItem->metaObject()->indexOfSignal("widthChanged")) { + connect(mainItem, SIGNAL(widthChanged()), m_syncTimer, SIGNAL(start())); + } + if (mainItem->metaObject()->indexOfSignal("heightChanged")) { + connect(mainItem, SIGNAL(heightChanged()), m_syncTimer, SIGNAL(start())); + } + } + + //if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene + emit mainItemChanged(); + } +} + +QQuickItem *ToolTipWindow::visualParent() const +{ + return m_visualParent.data(); +} + +void ToolTipWindow::setVisualParent(QQuickItem *visualParent) +{ + if (m_visualParent.data() == visualParent) { + return; + } + + if (visualParent) { + setPosition(popupPosition(visualParent, Qt::AlignCenter)); + } + disconnect(m_visualParent.data(), &QQuickItem::xChanged, this, &ToolTipWindow::syncGeometry); + disconnect(m_visualParent.data(), &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); + //disconnect(visualParent, &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); + + m_visualParent = visualParent; + connect(m_visualParent.data(), &QQuickItem::xChanged, this, &ToolTipWindow::syncGeometry); + connect(m_visualParent.data(), &QQuickItem::yChanged, this, &ToolTipWindow::syncGeometry); + emit visualParentChanged(); +} + + +bool ToolTipWindow::isVisible() const +{ + return QQuickWindow::isVisible(); + +} + +void ToolTipWindow::setVisible(const bool visible) +{ + qDebug() << visible; + if (visible) { + //setPosition(popupPosition()); + syncGeometry(); + raise(); + } + QQuickWindow::setVisible(visible); +} + +QPoint ToolTipWindow::popupPosition(QQuickItem *item, Qt::AlignmentFlag alignment) +{ + // FIXME :: Item + if (!item) { + item = qobject_cast(visualParent()); + } + if (item && item->window()) { + QPointF itemScreenPos; + + QPointF pos = item->mapToScene(QPointF(0, 0)); + //qDebug() << "I've an Item at " << pos; + if (item->window() && item->window()->screen()) { + pos = item->window()->mapToGlobal(pos.toPoint()); + } else { + } + itemScreenPos = QPoint(pos.x() + (item->width() - mainItem()->width())/2, pos.y()-mainItem()->height()); + qDebug() << "XXX Centering at visualParent" << itemScreenPos; + return itemScreenPos.toPoint(); + } else { + qDebug() << "XXX No QQuickItem visualParent found"; + return QPoint(100, 100); + } +} + diff --git a/src/declarativeimports/core/tooltipwindow.h b/src/declarativeimports/core/tooltipwindow.h new file mode 100644 index 000000000..c55cbf7e9 --- /dev/null +++ b/src/declarativeimports/core/tooltipwindow.h @@ -0,0 +1,130 @@ +/*************************************************************************** + * Copyright 2011 Marco Martin * + * Copyright 2011 Artur Duque de Souza * + * Copyright 2013 Sebastian Kügler * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +#ifndef TOOLTIP_WINDOW_P +#define TOOLTIP_WINDOW_P + +#include +#include +#include +#include + +class QQuickItem; +class QGraphicsWidget; + +/** + * QML wrapper for kdelibs Plasma::ToolTip + * + * Exposed as `ToolTip` in QML. + */ +class ToolTipWindow : public QQuickWindow +{ + Q_OBJECT + + /** + * The item that will display this tooltip on mouse over + */ + Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged) + + /** + * The title of the tooltip, not more that 2-3 words + */ + Q_PROPERTY(QString mainText READ mainText WRITE setMainText NOTIFY mainTextChanged) + + /** + * subtitle of the tooltip. needed if a longer description is needed + */ + Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged) + + /** + * Image to display in the tooltip, can be an image full path or a Freedesktop icon name or QIcon or QPixmap + */ + Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) + + /** + * The main QML item that will be displayed in the Dialog + */ + Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged) + + /** + * The main QML item that will be displayed in the Dialog + */ + Q_PROPERTY(QQuickItem *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged) + + /** + * Visibility of the Dialog window. Doesn't have anything to do with the visibility of the mainItem. + */ + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + + +public: + ToolTipWindow(QWindow *parent = 0); + ~ToolTipWindow(); + + QQuickItem *target() const; + void setTarget(QQuickItem *target); + + QString mainText() const; + void setMainText(const QString &text); + + QString subText() const; + void setSubText(const QString &text); + + QVariant image() const; + void setImage(QVariant name); + + QQuickItem *mainItem() const; + void setMainItem(QQuickItem *mainItem); + + QQuickItem *visualParent() const; + void setVisualParent(QQuickItem *visualParent); + + bool isVisible() const; + void setVisible(const bool visible); + + QPoint popupPosition(QQuickItem *item = 0, Qt::AlignmentFlag alignment=Qt::AlignCenter) ; + +Q_SIGNALS: + void targetChanged(); + void mainTextChanged(); + void subTextChanged(); + void imageChanged(); + void mainItemChanged(); + void visualParentChanged(); + void visibleChanged(); + +protected Q_SLOTS: + void syncGeometry(); + void updateToolTip(); + +private: + QTimer *m_syncTimer; + QString m_mainText; + QString m_subText; + QVariant m_image; + QGraphicsWidget *m_widget; + QWeakPointer m_mainItem; + QWeakPointer m_visualParent; + QWeakPointer m_declarativeItemContainer; + QWeakPointer m_target; +}; + +#endif