homescreens/halcyon: Fix app list margins resizing not working during screen rotation

This commit is contained in:
Devin Lin 2022-09-05 16:09:50 -04:00
parent 79e1169815
commit 2de1a7a0e4
2 changed files with 6 additions and 11 deletions

View file

@ -22,18 +22,14 @@ MobileShell.GridView {
layer.enabled: true layer.enabled: true
readonly property int reservedSpaceForLabel: metrics.height readonly property int reservedSpaceForLabel: metrics.height
required property real effectiveContentWidth readonly property real effectiveContentWidth: width - leftMargin - rightMargin
cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8) cellWidth: gridView.effectiveContentWidth / Math.min(Math.floor(gridView.effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
cellHeight: cellWidth + reservedSpaceForLabel cellHeight: cellWidth + reservedSpaceForLabel
property int columns: Math.floor(effectiveContentWidth / cellWidth) property int columns: Math.floor(gridView.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)
onWidthChanged: gridView.forceLayout()
function goToBeginning() { function goToBeginning() {
goToBeginningAnim.restart(); goToBeginningAnim.restart();
} }

View file

@ -4,6 +4,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.15 as QQC2 import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.15
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
@ -65,16 +66,14 @@ Item {
} }
QQC2.ScrollView { QQC2.ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
width: swipeView.width width: swipeView.width
height: swipeView.height height: swipeView.height
GridAppList { GridAppList {
id: gridAppList id: gridAppList
property real horizontalMargin: Math.max(Kirigami.Units.largeSpacing, swipeView.width * 0.1 / 2)
property int horizontalMargin: Math.round(swipeView.width * 0.05)
interactive: root.interactive interactive: root.interactive
effectiveContentWidth: swipeView.width - leftMargin - rightMargin
leftMargin: horizontalMargin leftMargin: horizontalMargin
rightMargin: horizontalMargin rightMargin: horizontalMargin
} }