2023-02-14 09:34:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023, 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQml 2.12
|
2023-02-20 17:23:08 +08:00
|
|
|
import QtQuick.Controls 2.5
|
|
|
|
import QtQuick.Layouts 1.12
|
2023-02-14 09:34:15 +08:00
|
|
|
import AppControls2 1.0 as AppControls2
|
|
|
|
import org.ukui.menu.core 1.0
|
|
|
|
|
2023-02-20 17:23:08 +08:00
|
|
|
Item {
|
2023-02-14 09:34:15 +08:00
|
|
|
property string title: ""
|
2023-03-31 16:08:10 +08:00
|
|
|
signal labelItemClicked()
|
|
|
|
signal openFolderPageSignal(string folderId, string folderName);
|
2023-02-20 17:23:08 +08:00
|
|
|
|
2023-03-06 09:37:06 +08:00
|
|
|
function labelSelection(labelId) {
|
2023-03-31 16:08:10 +08:00
|
|
|
appListView.view.positionViewAtIndex(appListView.model.getLabelIndex(labelId), ListView.Beginning)
|
2023-03-06 09:37:06 +08:00
|
|
|
}
|
|
|
|
|
2023-03-31 16:08:10 +08:00
|
|
|
AppListView {
|
|
|
|
id: appListView
|
2023-02-20 17:23:08 +08:00
|
|
|
anchors.fill: parent
|
2023-03-31 16:08:10 +08:00
|
|
|
model: modelManager.getAppModel()
|
|
|
|
delegate: Component {
|
|
|
|
Loader {
|
|
|
|
width: ListView.view ? ListView.view.width : 0
|
|
|
|
height: 40
|
|
|
|
property int index: model.index
|
|
|
|
property int type: model.type
|
|
|
|
property string id: model.id
|
|
|
|
property string name: model.name
|
|
|
|
property string icon: model.icon
|
2023-04-12 17:13:28 +08:00
|
|
|
property int toTop: model.top
|
2023-04-17 17:23:08 +08:00
|
|
|
property bool recentInstall: model.recentInstall
|
2023-03-31 16:08:10 +08:00
|
|
|
sourceComponent: {
|
|
|
|
if (type === DataType.Normal) {
|
|
|
|
return appItem;
|
|
|
|
}
|
|
|
|
if (type === DataType.Folder) {
|
|
|
|
return folderItem;
|
|
|
|
}
|
|
|
|
if (type === DataType.Label) {
|
|
|
|
return labelItem;
|
2023-02-20 17:23:08 +08:00
|
|
|
}
|
2023-02-14 09:34:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: appItem
|
2023-03-31 16:08:10 +08:00
|
|
|
AppControls2.AppItem {
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
appListView.model.openMenu(index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mouse.button === Qt.LeftButton) {
|
|
|
|
appManager.launchApp(id);
|
2023-04-17 17:23:08 +08:00
|
|
|
if (recentInstall) {
|
|
|
|
appManager.appLaunched(id);
|
|
|
|
}
|
2023-03-31 16:08:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-14 09:34:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: labelItem
|
2023-03-31 16:08:10 +08:00
|
|
|
AppControls2.LabelItem {
|
|
|
|
onClicked: labelItemClicked();
|
|
|
|
}
|
2023-02-14 09:34:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: folderItem
|
2023-03-31 16:08:10 +08:00
|
|
|
AppControls2.FolderItem {
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
appListView.model.openMenu(index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mouse.button === Qt.LeftButton) {
|
|
|
|
openFolderPageSignal(id, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-04-07 10:00:56 +08:00
|
|
|
Component.onCompleted: {
|
|
|
|
appListView.model.renameText.connect(toEditText);
|
|
|
|
}
|
|
|
|
Component.onDestruction: {
|
|
|
|
appListView.model.renameText.disconnect(toEditText);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toEditText(idOfIndex){
|
|
|
|
if (id === idOfIndex) {
|
|
|
|
editStatus = true;
|
|
|
|
}
|
|
|
|
}
|
2023-03-31 16:08:10 +08:00
|
|
|
}
|
2023-02-14 09:34:15 +08:00
|
|
|
}
|
|
|
|
}
|