From 2bb585b4ab3f0c410a56d7cc16999cb3e0d3a358 Mon Sep 17 00:00:00 2001 From: qiqi49 Date: Tue, 6 Feb 2024 09:54:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(qml):=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=8F?= =?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/AppUI/FullScreenAppList.qml | 52 +++++++++++++++++++++++++++-- qml/AppUI/FullScreenUI.qml | 14 +++++--- qml/extensions/EditModeFlag.qml | 29 ++++++++++++++++ qml/extensions/FavoriteDelegate.qml | 2 +- qml/extensions/FavoriteGridView.qml | 27 +++------------ qml/extensions/FolderContent.qml | 10 +++--- qml/extensions/FolderGridView.qml | 8 ++--- qml/extensions/FullScreenFolder.qml | 4 +-- qml/qml.qrc | 1 + 9 files changed, 106 insertions(+), 41 deletions(-) create mode 100644 qml/extensions/EditModeFlag.qml diff --git a/qml/AppUI/FullScreenAppList.qml b/qml/AppUI/FullScreenAppList.qml index a0ee456..705005f 100644 --- a/qml/AppUI/FullScreenAppList.qml +++ b/qml/AppUI/FullScreenAppList.qml @@ -103,9 +103,10 @@ ListView { } } - header: Item { + header: MouseArea { width: root.width height: childrenRect.height + acceptedButtons: Qt.RightButton property var widgets: [] property var widgetInfos: [] @@ -116,6 +117,40 @@ ListView { widgets.push("favorite"); } + onClicked: { + if (mouse.button === Qt.RightButton) { + menu.open(); + } + } + + UkuiItems.Menu { + id: menu + content: [ + UkuiItems.MenuItem { + text: qsTr("Enable editing mode") + onClicked: mainWindow.editMode = true; + }, + UkuiItems.MenuItem { + text: qsTr("Remove all favorite apps") + onClicked: extensionData.favoriteAppsModel.clearFavorites(); + } + ] + } + + // 拖动到文件到空白区域 添加到收藏 + DropArea { + width: parent.width + height: favoriteView.contentHeight + onEntered: { + if (drag.source.isFavorite) { + favoriteView.dragTypeIsMerge = false; + } else { + var id = drag.source.id; + extensionData.favoriteAppsModel.addAppToFavorites(id); + } + } + } + Column { width: parent.width height: childrenRect.height + spacing @@ -155,12 +190,25 @@ ListView { delegateLayout.anchors.bottomMargin: 16 delegateLayout.spacing: 8 mergePrompt.anchors.topMargin: 10 - mergePrompt.width: width*0.67 + mergePrompt.width: width*0.675 +// mergePrompt.width: 108 mergePrompt.radius: 32 Component.onCompleted: contentShowFinished.connect(resetOpacity) Component.onDestruction: contentShowFinished.disconnect(resetOpacity) } + + //编辑模式标志 + Extension.EditModeFlag { + id: tag + anchors.top: parent.top + anchors.topMargin: 10 + anchors.right: parent.right + anchors.rightMargin: 28 + onClicked: { + visualModel.model.removeAppFromFavorites(id); + } + } } } diff --git a/qml/AppUI/FullScreenUI.qml b/qml/AppUI/FullScreenUI.qml index 01cbe07..7cc1fa3 100644 --- a/qml/AppUI/FullScreenUI.qml +++ b/qml/AppUI/FullScreenUI.qml @@ -15,12 +15,16 @@ UkuiItems.StyleBackground { MouseArea { anchors.fill: parent onClicked: { - if (mainContainer.visible) { - //执行全屏退出操作 - forceActiveFocus(); - mainWindow.hide(); + if (mainWindow.editMode) { + mainWindow.editMode = false; } else { - folderLoader.isFolderOpened = false; + if (mainContainer.visible) { + //执行全屏退出操作 + forceActiveFocus(); + mainWindow.hide(); + } else { + folderLoader.isFolderOpened = false; + } } } } diff --git a/qml/extensions/EditModeFlag.qml b/qml/extensions/EditModeFlag.qml new file mode 100644 index 0000000..1afc7a4 --- /dev/null +++ b/qml/extensions/EditModeFlag.qml @@ -0,0 +1,29 @@ +import QtQuick 2.15 +import org.ukui.menu.core 1.0 +import org.ukui.quick.items 1.0 as UkuiItems +import org.ukui.quick.platform 1.0 as Platform + +Loader { + id: tag + signal clicked() + + 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: tag.clicked() + + background.radius: width / 2 + icon.source: "ukui-cancel-star-symbolic" + } + } + + sourceComponent: mainWindow.editMode && (type === DataType.Normal) ? editImage : null +} diff --git a/qml/extensions/FavoriteDelegate.qml b/qml/extensions/FavoriteDelegate.qml index d72b388..c80a77e 100644 --- a/qml/extensions/FavoriteDelegate.qml +++ b/qml/extensions/FavoriteDelegate.qml @@ -104,7 +104,7 @@ UkuiItems.StyleBackground { anchors.fill: parent anchors.topMargin: 8 anchors.bottomMargin: 14 - spacing: 6 + spacing: 4 ToolTip.visible: iconText.truncated && control.containsMouse ToolTip.text: model.name diff --git a/qml/extensions/FavoriteGridView.qml b/qml/extensions/FavoriteGridView.qml index fdf2146..7cb7227 100644 --- a/qml/extensions/FavoriteGridView.qml +++ b/qml/extensions/FavoriteGridView.qml @@ -135,39 +135,22 @@ GridView { mergePrompt.anchors.topMargin: 6 mergePrompt.width: 52 mergePrompt.radius: 14 + delegateLayout.anchors.leftMargin: 2 + delegateLayout.anchors.rightMargin: 2 Component.onCompleted: favoriteView.contentShowFinished.connect(resetOpacity) Component.onDestruction: favoriteView.contentShowFinished.disconnect(resetOpacity) } - //编辑模式标志 - Loader { + EditModeFlag { id: tag anchors.top: parent.top anchors.right: parent.right anchors.rightMargin: 10 - 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: { - visualModel.model.removeAppFromFavorites(id); - } - - background.radius: width / 2 - icon.source: "ukui-cancel-star-symbolic" - } + onClicked: { + visualModel.model.removeAppFromFavorites(id); } - - sourceComponent: mainWindow.editMode && (type === DataType.Normal) ? editImage : null } } } diff --git a/qml/extensions/FolderContent.qml b/qml/extensions/FolderContent.qml index 55b1858..c0772df 100644 --- a/qml/extensions/FolderContent.qml +++ b/qml/extensions/FolderContent.qml @@ -35,9 +35,9 @@ SwipeView { property var folderContentModel property alias folderSwipeView: folderSwipeView property bool mouseEnable: false - property int contentMargins - property int labelMagrins - property int labelSpacing + property real contentMargins + property real labelMagrins + property real labelSpacing property bool isFullScreen: false function hideFolder() { @@ -135,8 +135,8 @@ SwipeView { ColumnLayout { anchors.fill: parent - anchors.margins: labelSpacing - spacing: (parent.width > 40) ? 4 : 0 + anchors.margins: labelMagrins + spacing: labelSpacing UkuiItems.Icon { id: iconImage source: icon diff --git a/qml/extensions/FolderGridView.qml b/qml/extensions/FolderGridView.qml index a666390..3ebcfc9 100644 --- a/qml/extensions/FolderGridView.qml +++ b/qml/extensions/FolderGridView.qml @@ -81,8 +81,8 @@ Loader { PropertyChanges { target: content contentMargins: 0 - labelSpacing: 8 - labelMagrins: 2 + labelSpacing: 2 + labelMagrins: 4 } PropertyChanges { target: folderNameText; opacity: 1 } }, @@ -122,7 +122,7 @@ Loader { } PropertyAnimation { duration: animationDuration; easing.type: Easing.OutQuint - properties: "contentMargins, labelMagrins, labelSpacing" + properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins" } } ScriptAction { script: content.folderSwipeView.hideFolder() } @@ -142,7 +142,7 @@ Loader { } PropertyAnimation { duration: animationDuration; easing.type: Easing.OutQuint - properties: "contentMargins, labelMagrins, labelSpacing" + properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins" } } ScriptAction { diff --git a/qml/extensions/FullScreenFolder.qml b/qml/extensions/FullScreenFolder.qml index f059a36..37a47fc 100644 --- a/qml/extensions/FullScreenFolder.qml +++ b/qml/extensions/FullScreenFolder.qml @@ -121,7 +121,7 @@ Loader { } PropertyAnimation { duration: animationDuration; easing.type: Easing.OutQuint - properties: "contentMargins, labelMagrins, labelSpacing" + properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins" } } ScriptAction { script: content.folderSwipeView.hideFolder() } @@ -141,7 +141,7 @@ Loader { } PropertyAnimation { duration: animationDuration; easing.type: Easing.OutQuint - properties: "contentMargins, labelMagrins, labelSpacing" + properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins" } } ScriptAction { diff --git a/qml/qml.qrc b/qml/qml.qrc index fd2eff0..039d5bc 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -39,5 +39,6 @@ AppUI/FullScreenAppList.qml AppUI/FullScreenAppItem.qml AppUI/AppLabelPage.qml + extensions/EditModeFlag.qml