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

@ -21,9 +21,11 @@ MouseArea {
id: delegate id: delegate
width: GridView.view.cellWidth width: GridView.view.cellWidth
height: GridView.view.cellHeight height: GridView.view.cellHeight
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
@ -152,7 +154,7 @@ MouseArea {
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
elide: Text.ElideRight elide: Text.ElideRight
text: model.applicationName text: model.applicationName
font.pointSize: theme.defaultFont.pointSize * 0.8 font.pointSize: theme.defaultFont.pointSize * 0.8
font.weight: Font.Bold font.weight: Font.Bold

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
cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
cellHeight: cellWidth + root.reservedSpaceForLabel
property int columns: Math.floor(root.contentWidth / cellWidth) readonly property int columns: Math.floor(effectiveContentWidth / cellWidth)
property int rows: Math.ceil(gridView.count / columns) readonly property int rows: Math.ceil(gridView.count / columns)
cacheBuffer: Math.max(0, rows * cellHeight) cacheBuffer: Math.max(0, rows * cellHeight)