2024-01-30 16:16:09 +08:00
|
|
|
/*
|
2024-02-01 18:55:21 +08:00
|
|
|
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
2024-01-30 16:16:09 +08:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQml.Models 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls 2.5
|
|
|
|
import org.ukui.menu.core 1.0
|
|
|
|
import org.ukui.quick.platform 1.0 as Platform
|
|
|
|
import org.ukui.quick.items 1.0 as UkuiItems
|
2024-02-01 18:55:21 +08:00
|
|
|
import AppUI 1.0 as AppUI
|
2024-01-30 16:16:09 +08:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: root
|
|
|
|
active: false
|
|
|
|
property var folderModel
|
|
|
|
property string folderName: ""
|
|
|
|
property int folderX: 0
|
|
|
|
property int folderY: 0
|
|
|
|
property int viewMaxRow: 0
|
|
|
|
property bool isFolderOpened: false
|
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
property int margins: 20
|
2024-01-30 16:16:09 +08:00
|
|
|
property int animationDuration: 300
|
|
|
|
signal turnPageFinished()
|
|
|
|
|
|
|
|
function initFolder(id, name, x, y) {
|
2024-02-01 18:55:21 +08:00
|
|
|
FolderModel.setFolderId(id);
|
2024-01-30 16:16:09 +08:00
|
|
|
folderName = name;
|
|
|
|
folderX = x;
|
|
|
|
folderY = y;
|
|
|
|
viewMaxRow = Math.ceil(folderModel.count / 4) > 4 ? 4 : Math.ceil(folderModel.count / 4);
|
|
|
|
active = true;
|
|
|
|
isFolderOpened = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceComponent: folderComponent
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: folderComponent
|
|
|
|
Item {
|
|
|
|
UkuiItems.StyleBackground {
|
|
|
|
id: folderIconBase
|
|
|
|
paletteRole: Platform.Theme.Text
|
|
|
|
useStyleTransparency: false
|
2024-02-01 18:55:21 +08:00
|
|
|
alpha: 0.1
|
|
|
|
|
2024-01-30 16:16:09 +08:00
|
|
|
property int folderIconSize: 0
|
|
|
|
property int iconSpacing: 0
|
|
|
|
property int imageX: 0
|
|
|
|
property int imageY: 0
|
|
|
|
property int gridViewMargin: 8
|
|
|
|
|
|
|
|
state: isFolderOpened ? "folderOpened" : "folderHidden"
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "folderOpened"
|
|
|
|
PropertyChanges {
|
|
|
|
target: folderIconBase
|
2024-02-01 18:55:21 +08:00
|
|
|
width: 720 // margins: 16
|
|
|
|
height: viewMaxRow*176 + content.contentMargins*2 // itemHeight: 160 + spacing: 16 + margins: 24
|
|
|
|
radius: Platform.Theme.maxRadius //? 32
|
|
|
|
x: (parent.width - width) / 2
|
|
|
|
y: (parent.height - height) / 2
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: content
|
|
|
|
contentMargins: 8
|
|
|
|
labelSpacing: 8
|
|
|
|
labelMagrins: 8
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
PropertyChanges { target: folderNameText; opacity: 1 }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "folderHidden"
|
|
|
|
PropertyChanges {
|
|
|
|
target: folderIconBase
|
2024-02-01 18:55:21 +08:00
|
|
|
width: 84
|
|
|
|
height: 84
|
2024-01-30 16:16:09 +08:00
|
|
|
radius: Platform.Theme.maxRadius
|
|
|
|
x: root.mapFromGlobal(folderX, 0).x
|
|
|
|
y: root.mapFromGlobal(0, folderY).y
|
2024-02-01 18:55:21 +08:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: content
|
2024-02-27 17:58:23 +08:00
|
|
|
contentMargins: 8
|
2024-02-01 18:55:21 +08:00
|
|
|
labelSpacing: 0
|
|
|
|
labelMagrins: 0
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
PropertyChanges { target: folderNameText; opacity: 0 }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
to: "folderHidden"
|
|
|
|
SequentialAnimation {
|
|
|
|
ScriptAction { script: content.mouseEnable = false }
|
|
|
|
ParallelAnimation {
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.InOutCubic
|
2024-02-01 18:55:21 +08:00
|
|
|
properties: "x, y, width, height, radius, alpha"
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.OutQuint
|
|
|
|
properties: "opacity"
|
|
|
|
}
|
2024-02-01 18:55:21 +08:00
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.OutQuint
|
2024-02-06 09:54:18 +08:00
|
|
|
properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins"
|
2024-02-01 18:55:21 +08:00
|
|
|
}
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
2024-02-27 15:10:32 +08:00
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
// 点击空白区域实现重命名并收起应用组
|
|
|
|
if (folderNameText.text !== folderNameText.textEdited) {
|
|
|
|
folderModel.renameFolder(folderNameText.text);
|
|
|
|
}
|
|
|
|
content.folderSwipeView.hideFolder()
|
|
|
|
}}
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
to: "folderOpened"
|
|
|
|
SequentialAnimation {
|
|
|
|
ParallelAnimation {
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.InOutCubic
|
2024-02-01 18:55:21 +08:00
|
|
|
properties: "x, y, width, height, radius, alpha"
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.InQuint
|
|
|
|
properties: "opacity"
|
|
|
|
}
|
2024-02-01 18:55:21 +08:00
|
|
|
PropertyAnimation {
|
|
|
|
duration: animationDuration; easing.type: Easing.OutQuint
|
2024-02-06 09:54:18 +08:00
|
|
|
properties: "contentMargins, labelMagrins, labelSpacing, labelMagrins"
|
2024-02-01 18:55:21 +08:00
|
|
|
}
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
content.folderSwipeView.contentItem.highlightMoveDuration = 0;
|
|
|
|
content.mouseEnable = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
FolderContent {
|
|
|
|
id: content
|
|
|
|
anchors.fill: parent
|
|
|
|
folderContentModel: folderModel
|
2024-02-01 18:55:21 +08:00
|
|
|
isFullScreen: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PageIndicator {
|
|
|
|
id: pageIndicator
|
|
|
|
interactive: true
|
|
|
|
count: content.count
|
|
|
|
visible: count > 1
|
|
|
|
currentIndex: content.currentIndex
|
|
|
|
anchors.bottom: folderIconBase.bottom
|
|
|
|
anchors.horizontalCenter: folderIconBase.horizontalCenter
|
|
|
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
color: "black"
|
|
|
|
width: 6; height: width;
|
|
|
|
radius: width / 2
|
|
|
|
opacity: (index === content.currentIndex )? 0.9 : 0.3
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
AppUI.EditText {
|
2024-01-30 16:16:09 +08:00
|
|
|
id: folderNameText
|
|
|
|
anchors.bottom: folderIconBase.top
|
2024-07-08 10:42:12 +08:00
|
|
|
anchors.bottomMargin: 12
|
2024-01-30 16:16:09 +08:00
|
|
|
anchors.horizontalCenter: folderIconBase.horizontalCenter
|
2024-02-01 18:55:21 +08:00
|
|
|
|
2024-07-08 10:42:12 +08:00
|
|
|
height: 72; width: folderIconBase.width
|
2024-01-30 16:16:09 +08:00
|
|
|
textEdited: folderName
|
|
|
|
textCenterIn: true
|
2024-02-01 18:55:21 +08:00
|
|
|
textSize: 32
|
|
|
|
|
|
|
|
onTextEditingFinished: text=> {
|
|
|
|
folderModel.renameFolder(text);
|
|
|
|
}
|
2024-01-30 16:16:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|