13#include <QQuickWindow>
14#include <QSGImageNode>
15#include <QStandardPaths>
24 , m_sourceSize(QSize())
26 setFlag(ItemHasContents);
40void WindowThumbnailItem::findImage()
45 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kwin/kcm_kwintabbox/falkon.png");
48 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kwin/kcm_kwintabbox/systemsettings.png");
51 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kwin/kcm_kwintabbox/kmail.png");
54 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kwin/kcm_kwintabbox/dolphin.png");
57 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"wallpapers/Next/contents/images/1280x800.png");
58 if (imagePath.isNull()) {
59 imagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
"kwin/kcm_kwintabbox/desktop.png");
66 if (imagePath.isNull()) {
69 m_image = QImage(imagePath);
72 setImplicitSize(m_image.width(), m_image.height());
77 auto *node =
static_cast<QSGImageNode *
>(oldNode);
79 node = window()->createImageNode();
80 node->setOwnsTexture(
true);
81 qsgnode_set_description(node, QStringLiteral(
"windowthumbnail"));
82 node->setFiltering(QSGTexture::Linear);
85 node->setTexture(window()->createTextureFromImage(m_image));
87 const QSize size(m_image.size().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio));
88 const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2;
89 const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2;
91 node->setRect(QRectF(QPointF(x, y), size));
103 if (m_sourceSize == size) {
113#include "moc_thumbnailitem.cpp"
void setWId(qulonglong wId)
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override
~WindowThumbnailItem() override
void setSourceSize(const QSize &size)
WindowThumbnailItem(QQuickItem *parent=nullptr)