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
This commit is contained in:
parent
6fa9d35322
commit
483ad7db66
2 changed files with 23 additions and 0 deletions
|
@ -37,6 +37,7 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
|
|||
, m_wId(0)
|
||||
, m_clip(true)
|
||||
, m_parent(QWeakPointer<EffectWindowImpl>())
|
||||
, 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<EffectWindowImpl*>(effects->findWindow(m_parentWindow))) {
|
||||
m_parent = QWeakPointer<EffectWindowImpl>(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<EffectWindowImpl*>(effects->findWindow(variant.value<qulonglong>()))) {
|
||||
m_parent = QWeakPointer<EffectWindowImpl>(w);
|
||||
m_parentWindow = variant.value<qulonglong>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<EffectWindowImpl> m_parent;
|
||||
qulonglong m_parentWindow;
|
||||
};
|
||||
|
||||
} // KWin
|
||||
|
|
Loading…
Reference in a new issue