fix(qml):添加应用组展开状态下的编辑模式

This commit is contained in:
qiqi49 2024-02-26 18:02:03 +08:00 committed by iaom
parent 37a1773519
commit 67d9b21beb
6 changed files with 25 additions and 48 deletions

View File

@ -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
isFavorited: favorite
onClicked: {
appManager.changeFavoriteState(id, favorite);
}
background.radius: width / 2
icon.source: favorite ? "ukui-cancel-star-symbolic" : "non-starred-symbolic"
}
}
sourceComponent: mainWindow.editMode ? editImage : null
appManager.changeFavoriteState(id, !isFavorited);
}
}
}
}

View File

@ -114,33 +114,15 @@ 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"
}
}
}
}
}
@ -305,6 +287,7 @@ ListView {
//
Extension.EditModeFlag {
id: tag
isFavorited: true
anchors.top: parent.top
anchors.topMargin: 10
anchors.right: parent.right

View File

@ -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"
}
}

View File

@ -40,11 +40,11 @@ UkuiMenuExtension {
} else {
if (mainWindow.editMode) {
mainWindow.editMode = false;
}
} else {
folderLoader.isFolderOpened = false;
}
}
}
UkuiItems.Menu {
id: menu

View File

@ -156,7 +156,7 @@ GridView {
//
EditModeFlag {
id: tag
isFavorited: true
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 10

View File

@ -172,6 +172,16 @@ SwipeView {
}
}
}
EditModeFlag {
isFavorited: true
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 10
onClicked: {
extensionData.favoriteAppsModel.removeAppFromFavorites(id);
}
}
}
}
}