homescreens/halcyon: Ensure gridview header is draggable, and add scrollbar

This commit is contained in:
Devin Lin 2022-06-24 15:31:46 -04:00
parent 13f2a10579
commit 4f5427cd3e
3 changed files with 29 additions and 10 deletions

View file

@ -166,11 +166,12 @@ MobileShell.ExtendedAbstractButton {
visible: text.length > 0 visible: text.length > 0
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: PlasmaCore.Units.smallSpacing
Layout.preferredHeight: delegate.reservedSpaceForLabel Layout.preferredHeight: delegate.reservedSpaceForLabel
wrapMode: Text.WordWrap Layout.topMargin: PlasmaCore.Units.smallSpacing
Layout.leftMargin: -parent.anchors.leftMargin + PlasmaCore.Units.smallSpacing Layout.leftMargin: -parent.anchors.leftMargin + PlasmaCore.Units.smallSpacing
Layout.rightMargin: -parent.anchors.rightMargin + PlasmaCore.Units.smallSpacing Layout.rightMargin: -parent.anchors.rightMargin + PlasmaCore.Units.smallSpacing
wrapMode: Text.WordWrap
maximumLineCount: 2 maximumLineCount: 2
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop

View file

@ -22,20 +22,21 @@ GridView {
clip: true clip: true
readonly property int reservedSpaceForLabel: metrics.height readonly property int reservedSpaceForLabel: metrics.height
readonly property real effectiveContentWidth: width - leftMargin - rightMargin
cellWidth: width / Math.min(Math.floor(width / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8) cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
cellHeight: cellWidth + reservedSpaceForLabel cellHeight: cellWidth + reservedSpaceForLabel
property int columns: Math.floor(width / cellWidth) property int columns: Math.floor(effectiveContentWidth / cellWidth)
property int rows: Math.ceil(Halcyon.ApplicationListModel.count / columns) property int rows: Math.ceil(Halcyon.ApplicationListModel.count / columns)
cacheBuffer: Math.max(0, rows * cellHeight) cacheBuffer: Math.max(0, rows * cellHeight)
model: Halcyon.ApplicationListModel model: Halcyon.ApplicationListModel
header: Controls.Control { header: MobileShell.BaseItem {
implicitWidth: gridView.width implicitWidth: gridView.effectiveContentWidth
topPadding: PlasmaCore.Units.largeSpacing + Math.round(gridView.height * 0.25) topPadding: PlasmaCore.Units.largeSpacing + Math.round(gridView.height * 0.2)
bottomPadding: PlasmaCore.Units.largeSpacing bottomPadding: PlasmaCore.Units.largeSpacing
leftPadding: PlasmaCore.Units.smallSpacing leftPadding: PlasmaCore.Units.smallSpacing
@ -78,4 +79,21 @@ GridView {
application.runApplication(); application.runApplication();
} }
} }
PC3.ScrollBar.vertical: PC3.ScrollBar {
id: scrollBar
interactive: true
enabled: true
Behavior on opacity {
OpacityAnimator {
duration: PlasmaCore.Units.longDuration * 2
easing.type: Easing.InOutQuad
}
}
implicitWidth: PlasmaCore.Units.smallSpacing
contentItem: Rectangle {
radius: width/2
color: Qt.rgba(1, 1, 1, 0.3)
}
}
} }

View file

@ -158,12 +158,12 @@ Item {
height: swipeView.height height: swipeView.height
width: swipeView.width width: swipeView.width
property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, column.width * 0.1 / 2) property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, root.width * 0.1 / 2)
GridAppList { GridAppList {
interactive: root.interactive interactive: root.interactive
Layout.leftMargin: column.horizontalMargin leftMargin: column.horizontalMargin
Layout.rightMargin: column.horizontalMargin rightMargin: column.horizontalMargin
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
} }