Add paintedWidth and paintedHeight properties to WindowThumbnail
REVIEW: 118886
This commit is contained in:
parent
ce5d182510
commit
347e073df3
@ -64,6 +64,7 @@ WindowThumbnail::WindowThumbnail(QQuickItem *parent)
|
||||
, QAbstractNativeEventFilter()
|
||||
, m_xcb(false)
|
||||
, m_winId(0)
|
||||
, m_paintedSize(QSizeF())
|
||||
, m_damaged(false)
|
||||
, m_depth(0)
|
||||
#if HAVE_XCB_COMPOSITE
|
||||
@ -140,6 +141,16 @@ void WindowThumbnail::setWinId(uint32_t winId)
|
||||
emit winIdChanged();
|
||||
}
|
||||
|
||||
qreal WindowThumbnail::paintedWidth() const
|
||||
{
|
||||
return m_paintedSize.width();
|
||||
}
|
||||
|
||||
qreal WindowThumbnail::paintedHeight() const
|
||||
{
|
||||
return m_paintedSize.height();
|
||||
}
|
||||
|
||||
QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
|
||||
{
|
||||
Q_UNUSED(updatePaintNodeData)
|
||||
@ -154,7 +165,11 @@ QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
|
||||
windowToTexture(node);
|
||||
}
|
||||
node->setRect(boundingRect());
|
||||
const QSize size(node->texture()->textureSize().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio));
|
||||
const QSizeF size(node->texture()->textureSize().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio));
|
||||
if (size != m_paintedSize) {
|
||||
m_paintedSize = size;
|
||||
emit paintedSizeChanged();
|
||||
}
|
||||
const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2;
|
||||
const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2;
|
||||
node->setRect(QRectF(QPointF(x, y), size));
|
||||
|
@ -73,6 +73,9 @@ class WindowThumbnail : public QQuickItem, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(uint winId READ winId WRITE setWinId NOTIFY winIdChanged)
|
||||
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
|
||||
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
|
||||
|
||||
public:
|
||||
WindowThumbnail(QQuickItem *parent = 0);
|
||||
virtual ~WindowThumbnail();
|
||||
@ -82,8 +85,12 @@ public:
|
||||
uint32_t winId() const;
|
||||
void setWinId(uint32_t winId);
|
||||
|
||||
qreal paintedWidth() const;
|
||||
qreal paintedHeight() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void winIdChanged();
|
||||
void paintedSizeChanged();
|
||||
|
||||
private:
|
||||
void iconToTexture(WindowTextureNode *textureNode);
|
||||
@ -94,6 +101,7 @@ private:
|
||||
void discardPixmap();
|
||||
bool m_xcb;
|
||||
uint32_t m_winId;
|
||||
QSizeF m_paintedSize;
|
||||
bool m_damaged;
|
||||
int m_depth;
|
||||
#if HAVE_XCB_COMPOSITE
|
||||
|
Loading…
Reference in New Issue
Block a user