QmlDesigner: Fix StatesEditor scroll bar

Change-Id: I241a33906d06c6011cb618b96c039dfe91323809
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2022-09-20 11:46:17 +02:00
committed by Henning Gründl
parent 7fc3bac762
commit 533090fb5e
3 changed files with 27 additions and 16 deletions

View File

@@ -507,7 +507,6 @@ Rectangle {
x: scrollView.leftPadding x: scrollView.leftPadding
y: scrollView.height - height y: scrollView.height - height
width: scrollView.availableWidth width: scrollView.availableWidth
active: scrollView.ScrollBar.vertical.active
orientation: Qt.Horizontal orientation: Qt.Horizontal
} }
@@ -516,20 +515,9 @@ Rectangle {
x: scrollView.mirrored ? 0 : scrollView.width - width x: scrollView.mirrored ? 0 : scrollView.width - width
y: scrollView.topPadding y: scrollView.topPadding
height: scrollView.availableHeight height: scrollView.availableHeight
active: scrollView.ScrollBar.horizontal.active
orientation: Qt.Vertical orientation: Qt.Vertical
} }
flickableDirection: {
if (frame.contentHeight <= scrollView.height)
return Flickable.HorizontalFlick
if (frame.contentWidth <= scrollView.width)
return Flickable.VerticalFlick
return Flickable.HorizontalAndVerticalFlick
}
Flickable { Flickable {
id: frame id: frame
boundsMovement: Flickable.StopAtBounds boundsMovement: Flickable.StopAtBounds
@@ -543,6 +531,15 @@ Rectangle {
let ext = root.showExtendGroups ? (2 * root.extend) : 0 let ext = root.showExtendGroups ? (2 * root.extend) : 0
return innerGrid.height + ext return innerGrid.height + ext
} }
flickableDirection: {
if (frame.contentHeight <= scrollView.height)
return Flickable.HorizontalFlick
if (frame.contentWidth <= scrollView.width)
return Flickable.VerticalFlick
return Flickable.HorizontalAndVerticalFlick
}
Behavior on contentY { Behavior on contentY {
NumberAnimation { NumberAnimation {

View File

@@ -24,12 +24,17 @@
****************************************************************************/ ****************************************************************************/
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Templates as T
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
ScrollBar { T.ScrollBar {
id: scrollBar id: scrollBar
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
contentItem: Rectangle { contentItem: Rectangle {
implicitWidth: scrollBar.interactive ? 6 : 2 implicitWidth: scrollBar.interactive ? 6 : 2
implicitHeight: scrollBar.interactive ? 6 : 2 implicitHeight: scrollBar.interactive ? 6 : 2
@@ -40,8 +45,7 @@ ScrollBar {
states: State { states: State {
name: "active" name: "active"
when: scrollBar.policy === ScrollBar.AlwaysOn when: scrollBar.active && scrollBar.size < 1.0
|| (scrollBar.active && scrollBar.size < 1.0)
PropertyChanges { PropertyChanges {
target: scrollBar.contentItem target: scrollBar.contentItem
opacity: 0.75 opacity: 0.75

View File

@@ -286,11 +286,21 @@ Item {
} }
Flickable { Flickable {
id: frame
boundsMovement: Flickable.StopAtBounds boundsMovement: Flickable.StopAtBounds
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
interactive: true interactive: true
contentWidth: column.width contentWidth: column.width
contentHeight: column.height contentHeight: column.height
flickableDirection: {
if (frame.contentHeight <= scrollView.height)
return Flickable.HorizontalFlick
if (frame.contentWidth <= scrollView.width)
return Flickable.VerticalFlick
return Flickable.HorizontalAndVerticalFlick
}
// ScrollView needs an extra TapHandler on top in order to receive click // ScrollView needs an extra TapHandler on top in order to receive click
// events. MouseAreas below ScrollView do not let clicks through. // events. MouseAreas below ScrollView do not let clicks through.