[WindowThumbnailItem] Expose the client's frameGeometry as implicit size

Set the implicit size of the item to the client frameGeometry size.

This is also more convenient for tabbox usage than accessing it through the
client's property, had a proper notify signal and abstracts it from the
implementation.

It also can be mimicked by the preview ThumbnailItem used in the tabbox KCM,
which has no client property.
master
Ismael Asensio 3 years ago
parent 08f6e28a1d
commit 9b3dfe2158

@ -150,6 +150,8 @@ void WindowThumbnailItem::findImage()
} else {
m_image = QImage(imagePath);
}
setImplicitSize(m_image.width(), m_image.height());
}
QSGNode *WindowThumbnailItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)

@ -281,6 +281,7 @@ void WindowThumbnailItem::setWId(const QUuid &wId)
setClient(workspace()->findAbstractClient(wId));
} else if (m_client) {
m_client = nullptr;
updateImplicitSize();
Q_EMIT clientChanged();
}
Q_EMIT wIdChanged();
@ -301,6 +302,8 @@ void WindowThumbnailItem::setClient(AbstractClient *client)
this, &WindowThumbnailItem::invalidateOffscreenTexture);
disconnect(m_client, &AbstractClient::damaged,
this, &WindowThumbnailItem::invalidateOffscreenTexture);
disconnect(m_client, &AbstractClient::frameGeometryChanged,
this, &WindowThumbnailItem::updateImplicitSize);
}
m_client = client;
if (m_client) {
@ -308,14 +311,26 @@ void WindowThumbnailItem::setClient(AbstractClient *client)
this, &WindowThumbnailItem::invalidateOffscreenTexture);
connect(m_client, &AbstractClient::damaged,
this, &WindowThumbnailItem::invalidateOffscreenTexture);
connect(m_client, &AbstractClient::frameGeometryChanged,
this, &WindowThumbnailItem::updateImplicitSize);
setWId(m_client->internalId());
} else {
setWId(QUuid());
}
invalidateOffscreenTexture();
updateImplicitSize();
Q_EMIT clientChanged();
}
void WindowThumbnailItem::updateImplicitSize()
{
QSize frameSize;
if (m_client) {
frameSize = m_client->frameGeometry().size();
}
setImplicitSize(frameSize.width(), frameSize.height());
}
QImage WindowThumbnailItem::fallbackImage() const
{
if (m_client) {

@ -111,6 +111,7 @@ protected:
QRectF paintedRect() const override;
void invalidateOffscreenTexture() override;
void updateOffscreenTexture() override;
void updateImplicitSize();
private:
QUuid m_wId;

Loading…
Cancel
Save