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); + } + } } } }