feat(qml):添加全屏编辑模式

This commit is contained in:
qiqi49 2024-02-06 09:54:18 +08:00 committed by He Sir
parent f36b16229e
commit 2bb585b4ab
9 changed files with 106 additions and 41 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 {

View File

@ -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 {

View File

@ -39,5 +39,6 @@
<file>AppUI/FullScreenAppList.qml</file>
<file>AppUI/FullScreenAppItem.qml</file>
<file>AppUI/AppLabelPage.qml</file>
<file>extensions/EditModeFlag.qml</file>
</qresource>
</RCC>