From 78a34cbf35d7cd612b1a3b4b0f857d096545a88c Mon Sep 17 00:00:00 2001 From: revenmartin Date: Mon, 24 May 2021 23:31:42 +0800 Subject: [PATCH] Adjust icon size --- qml/LauncherGridDelegate.qml | 28 +++++++++++++++++++----- qml/LauncherGridView.qml | 41 ++++++++++++++++++++++++++---------- qml/PageView.qml | 19 +++++++++++++++++ qml/main.qml | 24 +++++++++++++++++++-- src/wallpaper.cpp | 19 +++++++++++++++++ src/wallpaper.h | 19 +++++++++++++++++ 6 files changed, 132 insertions(+), 18 deletions(-) diff --git a/qml/LauncherGridDelegate.qml b/qml/LauncherGridDelegate.qml index 2cd4d43..575606c 100755 --- a/qml/LauncherGridDelegate.qml +++ b/qml/LauncherGridDelegate.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.9 import QtQuick.Controls 2.1 import QtGraphicalEffects 1.0 @@ -48,11 +67,10 @@ Item { horizontalCenter: parent.horizontalCenter top: parent.top bottom: label.top - // margins: FishUI.Units.largeSpacing * 2 - leftMargin: Math.min(FishUI.Units.largeSpacing * 2, root.horizontalSpacing) - rightMargin: Math.min(FishUI.Units.largeSpacing * 2, root.horizontalSpacing) - topMargin: Math.min(FishUI.Units.largeSpacing * 2, root.verticalSpacing) - bottomMargin: Math.min(FishUI.Units.largeSpacing * 2, root.verticalSpacing) + leftMargin: Math.min(FishUI.Units.largeSpacing * 2, root.maxSpacing) + rightMargin: Math.min(FishUI.Units.largeSpacing * 2, root.maxSpacing) + topMargin: Math.min(FishUI.Units.largeSpacing * 2, root.maxSpacing) + bottomMargin: Math.min(FishUI.Units.largeSpacing * 2, root.maxSpacing) } property real size: height diff --git a/qml/LauncherGridView.qml b/qml/LauncherGridView.qml index 01a10b6..9dc60f9 100644 --- a/qml/LauncherGridView.qml +++ b/qml/LauncherGridView.qml @@ -1,26 +1,45 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.12 import QtQuick.Window 2.12 import FishUI 1.0 as FishUI import Cutefish.Launcher 1.0 PageView { - id: gridView + id: control - property int iconSize: gridView.width > gridView.height ? gridView.width * 0.09 + root.horizontalSpacing * 2 - : gridView.height * 0.09 + root.verticalSpacing * 2 + property int iconSize: control.width > control.height ? control.width * 0.09 + root.horizontalSpacing * 2 + root.maxSpacing + : control.height * 0.09 + root.verticalSpacing * 2 + root.maxSpacing property int cellWidth: { - var extraWidth = calcExtraSpacing(iconSize, gridView.width) + var extraWidth = calcExtraSpacing(iconSize, control.width) return iconSize + extraWidth } property int cellHeight: { - var extraHeight = calcExtraSpacing(iconSize, gridView.height) + var extraHeight = calcExtraSpacing(iconSize, control.height) return iconSize + extraHeight } - columns: gridView.width / cellWidth - rows: gridView.height / cellHeight + columns: control.width / cellWidth + rows: control.height / cellHeight model: launcherModel @@ -31,10 +50,10 @@ PageView { LauncherGridDelegate { id: delegate anchors.fill: parent - anchors.leftMargin: root.horizontalSpacing * 1.5 - anchors.rightMargin: root.horizontalSpacing * 1.5 - anchors.topMargin: root.verticalSpacing * 1.5 - anchors.bottomMargin: root.verticalSpacing * 1.5 + anchors.leftMargin: root.maxSpacing + anchors.rightMargin: root.maxSpacing + anchors.topMargin: root.maxSpacing + anchors.bottomMargin: root.maxSpacing } } diff --git a/qml/PageView.qml b/qml/PageView.qml index 6b400ab..71e83cc 100644 --- a/qml/PageView.qml +++ b/qml/PageView.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.0 import Cutefish.Launcher 1.0 diff --git a/qml/main.qml b/qml/main.qml index 07a5fc9..3ca4ab8 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.9 import QtQuick.Window 2.3 import QtQuick.Controls 2.5 @@ -15,6 +34,7 @@ Item { property real horizontalSpacing: launcher.screenRect.width * 0.01 * Screen.devicePixelRatio property real verticalSpacing: launcher.screenRect.height * 0.01 * Screen.devicePixelRatio + property real maxSpacing: horizontalSpacing > verticalSpacing ? horizontalSpacing : verticalSpacing Wallpaper { id: backend @@ -63,11 +83,11 @@ Item { id: mainLayout anchors.fill: parent anchors.leftMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.x : 0 - anchors.topMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.y + root.verticalSpacing * 2 * Screen.devicePixelRatio : 0 + anchors.topMargin: launcher.screenAvailableRect ? launcher.screenAvailableRect.y + root.verticalSpacing * 2 : 0 anchors.rightMargin: launcher.screenRect.width - (launcher.screenAvailableRect.x + launcher.screenAvailableRect.width) anchors.bottomMargin: launcher.screenRect.height - (launcher.screenAvailableRect.y + launcher.screenAvailableRect.height - root.verticalSpacing) - spacing: root.verticalSpacing * Screen.devicePixelRatio + spacing: root.verticalSpacing Item { id: searchItem diff --git a/src/wallpaper.cpp b/src/wallpaper.cpp index cb391af..9d35558 100644 --- a/src/wallpaper.cpp +++ b/src/wallpaper.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "wallpaper.h" Wallpaper::Wallpaper(QObject *parent) diff --git a/src/wallpaper.h b/src/wallpaper.h index 7d316ab..de96227 100644 --- a/src/wallpaper.h +++ b/src/wallpaper.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS. + * + * Author: revenmartin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef WALLPAPER_H #define WALLPAPER_H