167 lines
5.2 KiB
QML
167 lines
5.2 KiB
QML
/*
|
|
* 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>
|
|
*
|
|
*/
|
|
|
|
import QtQuick 2.15
|
|
import QtQml.Models 2.12
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import org.ukui.menu.core 1.0
|
|
import org.ukui.menu.extension 1.0
|
|
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
|
|
property int itemHeight: 40
|
|
property alias sourceModel: appGroupModel.sourceModel
|
|
|
|
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
|
|
visible: displayName !== ""
|
|
}
|
|
|
|
GridView {
|
|
width: parent.width
|
|
height: childrenRect.height
|
|
// TODO: 动态计算尺寸
|
|
cellWidth: width / 8
|
|
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);
|
|
} else if (mouse.button === Qt.RightButton) {
|
|
// appListView.model.openMenu(index, MenuInfo.FullScreen);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
header: Item {
|
|
width: ListView.view.width
|
|
height: childrenRect.height + ListView.view.spacing
|
|
|
|
property alias widgets: widgetView.widgets
|
|
property alias widgetCount: widgetView.count
|
|
property alias widgetInfos: widgetView.widgetInfos
|
|
|
|
ListView {
|
|
id: widgetView
|
|
|
|
property var widgets: []
|
|
property var widgetInfos: []
|
|
|
|
anchors.top: parent.top
|
|
width: parent.width
|
|
height: childrenRect.height
|
|
interactive: false
|
|
spacing: parent.ListView.view.spacing
|
|
|
|
onCountChanged: {
|
|
widgets = [];
|
|
widgetInfos = [];
|
|
for (let i = 0; i < count; ++i) {
|
|
let item = itemAtIndex(i);
|
|
widgetInfos.push({label: item.widgetId, display: item.icon, type: LabelItem.Icon});
|
|
widgets.push(item.widgetId);
|
|
}
|
|
}
|
|
|
|
model: WidgetModel {
|
|
flags: WidgetMetadata.OnlyFullScreen
|
|
}
|
|
delegate: Column {
|
|
property string icon: model.icon
|
|
property string widgetId: model.id
|
|
|
|
width: ListView.view.width
|
|
height: childrenRect.height
|
|
spacing: ListView.view.spacing
|
|
|
|
AppControls2.LabelItem {
|
|
width: parent.width
|
|
height: root.itemHeight
|
|
displayName: model.name
|
|
}
|
|
|
|
Loader {
|
|
width: parent.width
|
|
// height: item === null ? 0 : item.height
|
|
height: item === null ? 0 : 200
|
|
|
|
property var extensionData: model.data
|
|
onExtensionDataChanged: {
|
|
if (item !== null) {
|
|
item.extensionData = extensionData;
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
setSource(model.main, {extensionData: extensionData});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|