From 483ad7db66902a58fe9e6ef0b83841ada760b169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 24 Mar 2012 08:12:29 +0100 Subject: [PATCH] Support specifying the parent window on which the thumbnail is shown ThumbnailItem tries to find the window where it is embedded in through a context propery containing the window id of the declarative view. This works fine for e.g. TabBox but not for Plasma.Dialog as that opens a new window. REVIEW: 104394 --- thumbnailitem.cpp | 17 +++++++++++++++++ thumbnailitem.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/thumbnailitem.cpp b/thumbnailitem.cpp index b402b3244b..b2685be71e 100644 --- a/thumbnailitem.cpp +++ b/thumbnailitem.cpp @@ -37,6 +37,7 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent) , m_wId(0) , m_clip(true) , m_parent(QWeakPointer()) + , m_parentWindow(0) { setFlags(flags() & ~QGraphicsItem::ItemHasNoContents); if (effects) { @@ -58,9 +59,24 @@ void ThumbnailItem::init() } } +void ThumbnailItem::setParentWindow(qulonglong parentWindow) +{ + m_parentWindow = parentWindow; + findParentEffectWindow(); + if (!m_parent.isNull()) { + m_parent.data()->registerThumbnail(this); + } +} + void ThumbnailItem::findParentEffectWindow() { if (effects) { + if (m_parentWindow) { + if (EffectWindowImpl *w = static_cast(effects->findWindow(m_parentWindow))) { + m_parent = QWeakPointer(w); + return; + } + } QDeclarativeContext *ctx = QDeclarativeEngine::contextForObject(this); if (!ctx) { kDebug(1212) << "No Context"; @@ -73,6 +89,7 @@ void ThumbnailItem::findParentEffectWindow() } if (EffectWindowImpl *w = static_cast(effects->findWindow(variant.value()))) { m_parent = QWeakPointer(w); + m_parentWindow = variant.value(); } } } diff --git a/thumbnailitem.h b/thumbnailitem.h index e50c973539..a219a33d13 100644 --- a/thumbnailitem.h +++ b/thumbnailitem.h @@ -35,6 +35,7 @@ class ThumbnailItem : public QDeclarativeItem Q_OBJECT Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true) Q_PROPERTY(bool clip READ isClip WRITE setClip NOTIFY clipChanged SCRIPTABLE true) + Q_PROPERTY(qulonglong parentWindow READ parentWindow WRITE setParentWindow) public: ThumbnailItem(QDeclarativeItem *parent = 0); virtual ~ThumbnailItem(); @@ -48,6 +49,10 @@ public: } void setClip(bool clip); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + qulonglong parentWindow() const { + return m_parentWindow; + } + void setParentWindow(qulonglong parentWindow); Q_SIGNALS: void wIdChanged(qulonglong wid); void clipChanged(bool clipped); @@ -60,6 +65,7 @@ private: qulonglong m_wId; bool m_clip; QWeakPointer m_parent; + qulonglong m_parentWindow; }; } // KWin