From 5ee1832c710b74f7739bc07ad07ddd8e162b15e5 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Tue, 3 Sep 2024 18:20:10 +0330 Subject: [PATCH] Scroll bar when content height is > height. --- src/qml/PositioningInformationView.qml | 97 ++++++++++++++------------ 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index cc2f4b7871..d69454f7ae 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -16,63 +16,74 @@ Rectangle { property color textColor: positionSource.currentness ? Theme.mainTextColor : Theme.secondaryTextColor property double cellHeight: 26 property double cellPadding: 6 - property real contentHeight: grid.count / grid.numberOfColumns * cellHeight + property real contentHeight: grid.numberOfRows * cellHeight color: Theme.mainBackgroundColorSemiOpaque anchors.margins: 20 width: parent.width + clip: true - GridView { - id: grid - - readonly property real numberOfColumns: parent.width > 1000 ? 6 : parent.width > 620 ? 3 : 2 - - flow: GridView.FlowTopToBottom - model: PositioningInformationModel { - id: positioningInformationModel - distanceUnits: projectInfo.distanceUnits - coordinateDisplayCrs: projectInfo.coordinateDisplayCrs - } - anchors.fill: parent - cellHeight: positioningInformationView.cellHeight - cellWidth: parent.width / numberOfColumns - clip: true + Flickable { + width: parent.width + height: positioningInformationView.height + contentHeight: grid.height boundsBehavior: Flickable.StopAtBounds ScrollBar.vertical: QfScrollBar { } - delegate: Rectangle { - readonly property real currentColumn: parseInt(index / (grid.count / grid.numberOfColumns)) - readonly property real currentRow: index % (grid.count / grid.numberOfColumns) - width: grid.cellWidth - height: grid.cellHeight - color: { - if (currentColumn % 2 == 0) { - return currentRow % 2 == 0 ? alternateBackgroundColor : backgroundColor; - } else { - return currentRow % 2 == 0 ? backgroundColor : alternateBackgroundColor; - } + GridView { + id: grid + + readonly property real numberOfColumns: parent.width > 1000 ? 6 : parent.width > 620 ? 3 : 2 + readonly property real numberOfRows: grid.count / numberOfColumns + + flow: GridView.FlowTopToBottom + boundsBehavior: Flickable.StopAtBounds + model: PositioningInformationModel { + id: positioningInformationModel + distanceUnits: projectInfo.distanceUnits + coordinateDisplayCrs: projectInfo.coordinateDisplayCrs } + height: numberOfRows * cellHeight + width: parent.width + cellHeight: positioningInformationView.cellHeight + cellWidth: parent.width / numberOfColumns + clip: true - RowLayout { - anchors.margins: cellPadding - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: parent.right + delegate: Rectangle { + readonly property real currentColumn: parseInt(index / (grid.count / grid.numberOfColumns)) + readonly property real currentRow: index % (grid.count / grid.numberOfColumns) - Text { - font: Theme.tipFont - color: Theme.secondaryTextColor - text: Name + width: grid.cellWidth + height: grid.cellHeight + color: { + if (currentColumn % 2 == 0) { + return currentRow % 2 == 0 ? alternateBackgroundColor : backgroundColor; + } else { + return currentRow % 2 == 0 ? backgroundColor : alternateBackgroundColor; + } } - Text { - Layout.fillWidth: true - font: Theme.tipFont - color: positioningInformationView.textColor - text: Value ? Value : qsTr("N/A") - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight + RowLayout { + anchors.margins: cellPadding + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.right: parent.right + + Text { + font: Theme.tipFont + color: Theme.secondaryTextColor + text: Name + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: positioningInformationView.textColor + text: Value ? Value : qsTr("N/A") + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } } } }