diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-10-02 21:09:09 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-10-06 14:31:09 +0200 |
commit | 5ca072446a89d89e4017b6a04cc1ea14853a9f65 (patch) | |
tree | 4ded81113fd39bcd45b2b404b51a3f7671d7534d /src/imports/nativestyle/items/qquickstyleitem.cpp | |
parent | b68a83595d77d9967b5296858865c6a11d1022de (diff) |
Native style, StyleItem: add property 'minimumSize'
Some items, like the scrollbar handle, can scale
the handle down to 0 if no minimumSize is set. This
will truncate the image drawn by QStyle.
This patch will expose the minimum size read from
QStyle to the QML control. We can then set
ScrollBar.minimumSize to the correct value.
Change-Id: Ib87e3ca7ea661bf41ab8057941fec7364b606177
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports/nativestyle/items/qquickstyleitem.cpp')
-rw-r--r-- | src/imports/nativestyle/items/qquickstyleitem.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp index 4c84bf9a..643b190e 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.cpp +++ b/src/imports/nativestyle/items/qquickstyleitem.cpp @@ -226,6 +226,7 @@ void QQuickStyleItem::updateGeometry() const QQuickStyleMargins oldContentPadding = contentPadding(); const QQuickStyleMargins oldLayoutMargins = layoutMargins(); + const QSize oldMinimumSize = minimumSize(); m_styleItemGeometry = calculateGeometry(); @@ -245,6 +246,8 @@ void QQuickStyleItem::updateGeometry() emit contentPaddingChanged(); if (layoutMargins() != oldLayoutMargins) emit layoutMarginsChanged(); + if (minimumSize() != oldMinimumSize) + emit minimumSizeChanged(); setImplicitSize(m_styleItemGeometry.implicitSize.width(), m_styleItemGeometry.implicitSize.height()); @@ -437,6 +440,13 @@ QQuickStyleMargins QQuickStyleItem::layoutMargins() const return QQuickStyleMargins(outerRect, m_styleItemGeometry.layoutRect); } +QSize QQuickStyleItem::minimumSize() +{ + // The style item should not be scaled below this size. + // Otherwise the image will be truncated. + return m_styleItemGeometry.minimumSize; +} + qreal QQuickStyleItem::focusFrameRadius() const { return m_styleItemGeometry.focusFrameRadius; |