2024-01-15 07:16:59 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2024, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
* Authors: hxf <hewenfei@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2024-01-24 10:16:54 +08:00
|
|
|
import QtQuick 2.15
|
2024-01-15 07:16:59 +08:00
|
|
|
import QtQml.Models 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
import org.ukui.menu.core 1.0
|
2024-01-24 10:16:54 +08:00
|
|
|
import org.ukui.menu.extension 1.0
|
2024-02-01 18:55:21 +08:00
|
|
|
import "../extensions" as Extension
|
2024-01-15 07:16:59 +08:00
|
|
|
import AppControls2 1.0 as AppControls2
|
|
|
|
|
|
|
|
import org.ukui.quick.items 1.0 as UkuiItems
|
|
|
|
import org.ukui.quick.platform 1.0 as Platform
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: root
|
2024-02-01 18:55:21 +08:00
|
|
|
signal openFolderSignal(string folderId, string folderName, int x, int y)
|
|
|
|
signal contentShowFinished()
|
|
|
|
property bool isContentShow
|
|
|
|
|
2024-01-15 07:16:59 +08:00
|
|
|
property int itemHeight: 40
|
|
|
|
property alias sourceModel: appGroupModel.sourceModel
|
2024-02-01 18:55:21 +08:00
|
|
|
// TODO: 动态计算尺寸
|
|
|
|
property int column: 10
|
2024-01-15 07:16:59 +08:00
|
|
|
|
|
|
|
spacing: 5
|
|
|
|
clip: true
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
|
|
|
|
model: AppGroupModel {
|
|
|
|
id: appGroupModel
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
width: ListView.view.width
|
|
|
|
height: childrenRect.height
|
|
|
|
|
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
AppControls2.LabelItem {
|
|
|
|
width: parent.width
|
|
|
|
height: root.itemHeight
|
|
|
|
displayName: model.name
|
2024-01-24 10:16:54 +08:00
|
|
|
visible: displayName !== ""
|
2024-01-15 07:16:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2024-02-01 18:55:21 +08:00
|
|
|
cellWidth: width / root.column
|
2024-01-15 07:16:59 +08:00
|
|
|
cellHeight: cellWidth
|
|
|
|
interactive: false
|
|
|
|
|
|
|
|
model: DelegateModel {
|
|
|
|
model: appGroupModel
|
|
|
|
rootIndex: modelIndex(index)
|
|
|
|
delegate: Item {
|
|
|
|
width: GridView.view.cellWidth
|
|
|
|
height: GridView.view.cellHeight
|
|
|
|
|
|
|
|
FullScreenAppItem {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
|
|
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
|
|
|
text.text: model.name
|
|
|
|
icon.source: model.icon
|
|
|
|
|
|
|
|
onClicked: (event) => {
|
|
|
|
if (event.button === Qt.LeftButton) {
|
|
|
|
// openApplication
|
|
|
|
appManager.launchApp(id);
|
2024-02-04 11:46:11 +08:00
|
|
|
} else if (event.button === Qt.RightButton) {
|
|
|
|
menuManager.showMenu(model.id, MenuInfo.FullScreen);
|
2024-01-15 07:16:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-24 10:16:54 +08:00
|
|
|
|
|
|
|
header: Item {
|
2024-02-01 18:55:21 +08:00
|
|
|
width: root.width
|
|
|
|
height: childrenRect.height
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
property var widgets: []
|
|
|
|
property var widgetInfos: []
|
|
|
|
property int widgetCount: 1
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
Component.onCompleted: {
|
|
|
|
widgetInfos.push({label: "favorite", display: "non-starred-symbolic", type: WidgetMetadata.Widget});
|
|
|
|
widgets.push("favorite");
|
|
|
|
}
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
Column {
|
2024-01-24 10:16:54 +08:00
|
|
|
width: parent.width
|
2024-02-01 18:55:21 +08:00
|
|
|
height: childrenRect.height + spacing
|
|
|
|
spacing: root.spacing
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
AppControls2.LabelItem {
|
|
|
|
width: parent.width
|
|
|
|
height: root.itemHeight
|
|
|
|
displayName: qsTr("Favorite")
|
2024-01-24 10:16:54 +08:00
|
|
|
}
|
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
GridView {
|
|
|
|
id: favoriteView
|
|
|
|
width: parent.width
|
|
|
|
height: contentHeight
|
|
|
|
property string mergeToAppId: ""
|
|
|
|
property bool isMergeToFolder: false
|
|
|
|
property bool dragTypeIsMerge: false
|
|
|
|
property int exchangedStartIndex: 0
|
|
|
|
property alias viewModel: visualModel
|
|
|
|
|
|
|
|
cellWidth: width / root.column
|
|
|
|
cellHeight: cellWidth
|
|
|
|
model: DelegateModel {
|
|
|
|
id: visualModel
|
|
|
|
model: favoriteModel
|
|
|
|
delegate: Item {
|
|
|
|
id: container
|
|
|
|
width: favoriteView.cellWidth
|
|
|
|
height: favoriteView.cellHeight
|
|
|
|
Extension.FavoriteDelegate {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
visualIndex: container.DelegateModel.itemsIndex
|
|
|
|
delegateLayout.anchors.topMargin: 16
|
|
|
|
delegateLayout.anchors.bottomMargin: 16
|
|
|
|
delegateLayout.spacing: 8
|
|
|
|
mergePrompt.anchors.topMargin: 10
|
|
|
|
mergePrompt.width: width*0.67
|
|
|
|
mergePrompt.radius: 32
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
Component.onCompleted: contentShowFinished.connect(resetOpacity)
|
|
|
|
Component.onDestruction: contentShowFinished.disconnect(resetOpacity)
|
2024-01-24 10:16:54 +08:00
|
|
|
}
|
|
|
|
}
|
2024-02-01 18:55:21 +08:00
|
|
|
}
|
2024-01-24 10:16:54 +08:00
|
|
|
|
2024-02-01 18:55:21 +08:00
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad; duration: 200 }
|
2024-01-24 10:16:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-15 07:16:59 +08:00
|
|
|
}
|