ukui-menu/qml/AppUI/AppPageContent.qml

158 lines
5.0 KiB
QML
Raw Normal View History

2023-03-20 15:33:32 +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/>.
*
*/
2023-04-04 09:33:06 +08:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5
import AppControls2 1.0 as AppControls2
import org.ukui.menu.core 1.0
SwipeView {
id: root
interactive: false
2023-04-03 15:58:05 +08:00
// 5.15
// required property AppPageHeader appPageHeader
// 5.12
property AppPageHeader appPageHeader: null
property bool isAppListShow: appList.visible
function resetFocus() {
if (appList.visible) {
appList.resetListFocus();
} else {
selectionPage.viewFocusEnable();
}
}
Item {
id: appListBase
AppControls2.StyleBackground {
anchors.top: parent.top
width: parent.width
height: 1
useStyleTransparent: false
alpha: 0.15
paletteRole: Palette.Text
visible: appList.viewContentY > 0 && appList.visible
}
AppList {
id: appList
anchors.fill: parent
anchors.leftMargin: 4
onLabelItemClicked: {
appList.visible = false;
selectionPage.viewShowStart();
}
2023-05-17 14:03:33 +08:00
onTitleChanged: {
appPageHeader.title = title;
}
}
SelectionPage {
id: selectionPage
anchors.fill: parent
anchors.bottomMargin: 54
visible: !appList.visible
onViewHideFinished: appList.visible = true
onLabelSelected: appList.labelSelection(labelId)
}
}
Loader {
id: folderPageLoader
active: false
sourceComponent: Component {
AppListView {
model: modelManager.getFolderModel()
delegate: Component {
Loader {
width: ListView.view ? ListView.view.width : 0; height: 40
property string id: model.id
property string name: model.name
property string icon: model.icon
sourceComponent: AppControls2.AppItem {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
2023-05-06 09:20:34 +08:00
menuManager.showMenu(id, MenuInfo.FolderPage);
return;
}
if (mouse.button === Qt.LeftButton) {
appManager.launchApp(id);
return;
}
}
}
}
}
}
}
function showFolderPage(folderId, folderName) {
active = true;
item.model.setFolderId(folderId);
appPageHeader.title = folderName;
appPageHeader.content = folderPageHeader;
root.currentIndex = SwipeView.index;
EventTrack.sendClickEvent("enter_folder_page", "AppView");
}
function hideFolderPage() {
root.currentIndex = appListBase.SwipeView.index;
appPageHeader.title = appList.title;
appPageHeader.content = null;
//active = false;
EventTrack.sendClickEvent("exit_folder_page", "AppView");
}
Component.onCompleted: {
appList.openFolderPageSignal.connect(showFolderPage);
}
}
Component {
id: folderPageHeader
Item {
RowLayout {
anchors.fill: parent
anchors.leftMargin: 12
2023-04-04 09:33:06 +08:00
anchors.rightMargin: 30
spacing: 2
2023-04-04 09:33:06 +08:00
ThemeIcon {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: 16
Layout.maximumHeight: 16
Layout.alignment: Qt.AlignVCenter
source: "image://appicon/ukui-start-symbolic"
MouseArea {
anchors.fill: parent
onClicked: folderPageLoader.hideFolderPage();
}
}
2023-04-04 09:33:06 +08:00
2023-04-08 14:12:11 +08:00
EditText {
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}
}