homescreens/default: Use external margins on grid view and adjust spacing

This commit is contained in:
Devin Lin 2022-06-24 15:27:28 -04:00
parent d0291cb211
commit 13f2a10579
2 changed files with 20 additions and 13 deletions

View file

@ -25,6 +25,8 @@ MouseArea {
property int reservedSpaceForLabel property int reservedSpaceForLabel
property alias iconItem: icon property alias iconItem: icon
readonly property real margins: Math.floor(width * 0.2)
signal launch(int x, int y, var source, string title, string storageId) signal launch(int x, int y, var source, string title, string storageId)
signal dragStarted(string imageSource, int x, int y, string mimeData) signal dragStarted(string imageSource, int x, int y, string mimeData)
@ -97,10 +99,10 @@ MouseArea {
ColumnLayout { ColumnLayout {
anchors { anchors {
fill: parent fill: parent
leftMargin: PlasmaCore.Units.smallSpacing * 2 leftMargin: margins
topMargin: PlasmaCore.Units.smallSpacing * 2 topMargin: margins
rightMargin: PlasmaCore.Units.smallSpacing * 2 rightMargin: margins
bottomMargin: PlasmaCore.Units.smallSpacing * 2 bottomMargin: margins
} }
spacing: 0 spacing: 0
@ -109,7 +111,7 @@ MouseArea {
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: parent.height - delegate.reservedSpaceForLabel Layout.minimumHeight: Math.floor(parent.height - delegate.reservedSpaceForLabel)
Layout.preferredHeight: Layout.minimumHeight Layout.preferredHeight: Layout.minimumHeight
usesPlasmaTheme: false usesPlasmaTheme: false
@ -143,8 +145,8 @@ MouseArea {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: delegate.reservedSpaceForLabel Layout.preferredHeight: delegate.reservedSpaceForLabel
Layout.topMargin: PlasmaCore.Units.smallSpacing Layout.topMargin: PlasmaCore.Units.smallSpacing
Layout.leftMargin: -parent.anchors.leftMargin + PlasmaCore.Units.smallSpacing * 2 Layout.leftMargin: -parent.anchors.leftMargin + PlasmaCore.Units.smallSpacing
Layout.rightMargin: -parent.anchors.rightMargin + PlasmaCore.Units.smallSpacing * 2 Layout.rightMargin: -parent.anchors.rightMargin + PlasmaCore.Units.smallSpacing
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
maximumLineCount: 2 maximumLineCount: 2

View file

@ -34,11 +34,16 @@ AbstractAppDrawer {
*/ */
interactive: contentHeight <= height ? true : root.homeScreenState.appDrawerInteractive interactive: contentHeight <= height ? true : root.homeScreenState.appDrawerInteractive
cellWidth: root.contentWidth / Math.floor(root.contentWidth / ((root.availableCellHeight - root.reservedSpaceForLabel) + PlasmaCore.Units.smallSpacing*4)) readonly property real effectiveContentWidth: root.contentWidth - 2 * horizontalMargin
cellHeight: root.availableCellHeight readonly property real horizontalMargin: root.width * 0.1 / 2
leftMargin: horizontalMargin
rightMargin: horizontalMargin
property int columns: Math.floor(root.contentWidth / cellWidth) cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
property int rows: Math.ceil(gridView.count / columns) cellHeight: cellWidth + root.reservedSpaceForLabel
readonly property int columns: Math.floor(effectiveContentWidth / cellWidth)
readonly property int rows: Math.ceil(gridView.count / columns)
cacheBuffer: Math.max(0, rows * cellHeight) cacheBuffer: Math.max(0, rows * cellHeight)