ukui-menu/qml/AppUI/FullScreenAppList.qml

98 lines
3.0 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.12
import QtQml.Models 2.12
import QtQuick.Layouts 1.12
import org.ukui.menu.core 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
}
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);
}
}
}
}
}
}
}
}
}