From 67d9b21beb499e6b1350a9bdfe3f50b69a6abde0 Mon Sep 17 00:00:00 2001 From: qiqi49 Date: Mon, 26 Feb 2024 18:02:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(qml):=E6=B7=BB=E5=8A=A0=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=BB=84=E5=B1=95=E5=BC=80=E7=8A=B6=E6=80=81=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppControls2/AppItem.qml | 27 +++++---------------------- qml/AppUI/FullScreenAppList.qml | 27 +++++---------------------- qml/extensions/EditModeFlag.qml | 3 ++- qml/extensions/FavoriteExtension.qml | 4 ++-- qml/extensions/FavoriteGridView.qml | 2 +- qml/extensions/FolderContent.qml | 10 ++++++++++ 6 files changed, 25 insertions(+), 48 deletions(-) diff --git a/qml/AppControls2/AppItem.qml b/qml/AppControls2/AppItem.qml index ad441a8..49204e7 100644 --- a/qml/AppControls2/AppItem.qml +++ b/qml/AppControls2/AppItem.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.5 import org.ukui.menu.core 1.0 +import "../extensions" as Extension import org.ukui.quick.platform 1.0 as Platform import org.ukui.quick.items 1.0 as UkuiItems @@ -44,9 +45,7 @@ MouseArea { spacing: 12 } - Loader { - id: tag - visible: mainWindow.editMode + Extension.EditModeFlag { Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.fillWidth: true Layout.fillHeight: true @@ -54,26 +53,10 @@ MouseArea { Layout.maximumHeight: width Layout.rightMargin: visible ? 4 : 0 - Component { - id: editImage - UkuiItems.Button { - width: 28 - height: 28 - icon.width: 16 - icon.height: 16 - background.paletteRole: Platform.Theme.Light - background.alpha: 1 - activeFocusOnTab: false - - onClicked: { - appManager.changeFavoriteState(id, favorite); - } - - background.radius: width / 2 - icon.source: favorite ? "ukui-cancel-star-symbolic" : "non-starred-symbolic" - } + isFavorited: favorite + onClicked: { + appManager.changeFavoriteState(id, !isFavorited); } - sourceComponent: mainWindow.editMode ? editImage : null } } } diff --git a/qml/AppUI/FullScreenAppList.qml b/qml/AppUI/FullScreenAppList.qml index db056e2..084a034 100644 --- a/qml/AppUI/FullScreenAppList.qml +++ b/qml/AppUI/FullScreenAppList.qml @@ -114,32 +114,14 @@ ListView { } // 收藏按钮 - Loader { - property bool isFavorited: model.favorite > 0 + Extension.EditModeFlag { + isFavorited: model.favorite > 0 anchors.top: parent.top anchors.topMargin: 10 anchors.right: parent.right anchors.rightMargin: 28 - - width: 28 - height: 28 - - active: mainWindow.editMode - sourceComponent: Component { - UkuiItems.Button { - icon.width: 16 - icon.height: 16 - background.paletteRole: Platform.Theme.Light - background.alpha: 1 - activeFocusOnTab: false - - onClicked: { - appManager.changeFavoriteState(id, !isFavorited); - } - - background.radius: width / 2 - icon.source: isFavorited ? "ukui-cancel-star-symbolic" : "non-starred-symbolic" - } + onClicked: { + appManager.changeFavoriteState(id, !isFavorited); } } } @@ -305,6 +287,7 @@ ListView { //编辑模式标志 Extension.EditModeFlag { id: tag + isFavorited: true anchors.top: parent.top anchors.topMargin: 10 anchors.right: parent.right diff --git a/qml/extensions/EditModeFlag.qml b/qml/extensions/EditModeFlag.qml index 1afc7a4..79d14e0 100644 --- a/qml/extensions/EditModeFlag.qml +++ b/qml/extensions/EditModeFlag.qml @@ -5,6 +5,7 @@ import org.ukui.quick.platform 1.0 as Platform Loader { id: tag + property bool isFavorited signal clicked() Component { @@ -21,7 +22,7 @@ Loader { onClicked: tag.clicked() background.radius: width / 2 - icon.source: "ukui-cancel-star-symbolic" + icon.source: isFavorited ? "ukui-cancel-star-symbolic" : "non-starred-symbolic" } } diff --git a/qml/extensions/FavoriteExtension.qml b/qml/extensions/FavoriteExtension.qml index 4d1bb43..b30dccf 100644 --- a/qml/extensions/FavoriteExtension.qml +++ b/qml/extensions/FavoriteExtension.qml @@ -40,9 +40,9 @@ UkuiMenuExtension { } else { if (mainWindow.editMode) { mainWindow.editMode = false; + } else { + folderLoader.isFolderOpened = false; } - - folderLoader.isFolderOpened = false; } } diff --git a/qml/extensions/FavoriteGridView.qml b/qml/extensions/FavoriteGridView.qml index 8584edf..5172197 100644 --- a/qml/extensions/FavoriteGridView.qml +++ b/qml/extensions/FavoriteGridView.qml @@ -156,7 +156,7 @@ GridView { //编辑模式标志 EditModeFlag { - id: tag + isFavorited: true anchors.top: parent.top anchors.right: parent.right anchors.rightMargin: 10 diff --git a/qml/extensions/FolderContent.qml b/qml/extensions/FolderContent.qml index c0772df..6b388f9 100644 --- a/qml/extensions/FolderContent.qml +++ b/qml/extensions/FolderContent.qml @@ -172,6 +172,16 @@ SwipeView { } } } + + EditModeFlag { + isFavorited: true + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: 10 + onClicked: { + extensionData.favoriteAppsModel.removeAppFromFavorites(id); + } + } } } }