From 2609450d9844fa8a209da80f4107f4e20f5f140f Mon Sep 17 00:00:00 2001 From: cutefishd Date: Sat, 20 Mar 2021 11:37:11 +0800 Subject: [PATCH] Adjust size --- qml/LauncherGridView.qml | 26 ++++++-------------------- qml/main.qml | 13 ++++++++----- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/qml/LauncherGridView.qml b/qml/LauncherGridView.qml index 9840835..e8ad134 100644 --- a/qml/LauncherGridView.qml +++ b/qml/LauncherGridView.qml @@ -5,7 +5,8 @@ import Cutefish.Launcher 1.0 PageView { id: gridView - property int iconSize: gridView.width * 0.1 + Meui.Units.largeSpacing * 2 + property int iconSize: Math.max(64 + root.horizontalSpacing, + gridView.width * 0.1 + root.horizontalSpacing) property int cellWidth: { var extraWidth = calcExtraSpacing(iconSize, gridView.width) @@ -29,18 +30,13 @@ PageView { LauncherGridDelegate { id: delegate anchors.fill: parent - anchors.margins: Meui.Units.smallSpacing + anchors.leftMargin: root.horizontalSpacing + anchors.rightMargin: root.horizontalSpacing + anchors.topMargin: root.verticalSpacing + anchors.bottomMargin: root.verticalSpacing } } - onWidthChanged: { - // gridView.adaptGrid() - } - - onHeightChanged: { - // gridView.adaptGrid() - } - function calcExtraSpacing(cellSize, containerSize) { var availableColumns = Math.floor(containerSize / cellSize); var extraSpacing = 0; @@ -51,14 +47,4 @@ PageView { } return Math.floor(extraSpacing); } - - function adaptGrid() { - var fullWidth = gridView.width - var fullHeight = gridView.height - - var cellSize = Math.max(144, gridView.height * 0.18) - - gridView.cellWidth = cellSize + calcExtraSpacing(cellSize, fullWidth) - gridView.cellHeight = cellSize + calcExtraSpacing(cellSize, fullHeight) - } } diff --git a/qml/main.qml b/qml/main.qml index 61887e2..5e2aa55 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -10,6 +10,9 @@ import MeuiKit 1.0 as Meui Item { id: root + property real horizontalSpacing: root.width * 0.01 + property real verticalSpacing: root.height * 0.01 + Wallpaper { id: backend } @@ -55,16 +58,16 @@ Item { id: mainLayout anchors.fill: parent anchors.leftMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.x : 0 - anchors.topMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.y + Meui.Units.largeSpacing * 4: 0 + anchors.topMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.y + root.verticalSpacing * 3: 0 anchors.rightMargin: launcher.screenRect.width - (launcher.screenAvailableRect.x + launcher.screenAvailableRect.width) - anchors.bottomMargin: launcher.screenRect.height - (launcher.screenAvailableRect.y + launcher.screenAvailableRect.height - Meui.Units.largeSpacing * 2) + anchors.bottomMargin: launcher.screenRect.height - (launcher.screenAvailableRect.y + launcher.screenAvailableRect.height - root.verticalSpacing) - spacing: Meui.Units.largeSpacing * 2 + spacing: root.verticalSpacing * 2 Item { id: searchItem Layout.fillWidth: true - height: fontMetrics.height + Meui.Units.largeSpacing * 2 + height: fontMetrics.height + Meui.Units.largeSpacing TextMetrics { id: fontMetrics @@ -163,7 +166,7 @@ Item { currentIndex: grid.currentPage onCurrentIndexChanged: grid.currentPage = currentIndex interactive: true - spacing: Meui.Units.largeSpacing + spacing: root.horizontalSpacing / 2 Layout.alignment: Qt.AlignHCenter delegate: Rectangle {