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
|
2023-03-06 09:37:06 +08:00
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls 2.5
|
|
|
|
import AppControls2 1.0 as AppControls2
|
|
|
|
import org.ukui.menu.core 1.0
|
|
|
|
|
2024-01-09 10:08:53 +08:00
|
|
|
Item {
|
2023-08-14 11:15:54 +08:00
|
|
|
property bool isAppListShow: appList.visible
|
2023-03-31 16:20:05 +08:00
|
|
|
|
2023-04-26 17:04:22 +08:00
|
|
|
function resetFocus() {
|
2023-08-14 11:15:54 +08:00
|
|
|
if (appList.visible) {
|
|
|
|
appList.resetListFocus();
|
|
|
|
} else {
|
2024-01-22 16:03:53 +08:00
|
|
|
selectionPage.focus = true;
|
|
|
|
labelPage.focus = true;
|
2023-08-14 11:15:54 +08:00
|
|
|
}
|
2023-04-26 17:04:22 +08:00
|
|
|
}
|
|
|
|
|
2024-01-09 10:08:53 +08:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 5
|
2023-03-31 16:20:05 +08:00
|
|
|
|
2024-01-09 10:08:53 +08:00
|
|
|
AppListHeader {
|
|
|
|
id: appListHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 48
|
2024-01-18 03:24:01 +08:00
|
|
|
header: AppPageBackend.appModel.header
|
2023-03-31 16:20:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
2024-01-09 10:08:53 +08:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
AppList {
|
|
|
|
id: appList
|
2023-03-31 16:20:05 +08:00
|
|
|
anchors.fill: parent
|
2024-01-22 16:03:53 +08:00
|
|
|
visible: !selectionPage.visible
|
2024-01-18 03:24:01 +08:00
|
|
|
model: AppPageBackend.appModel
|
2023-03-31 16:20:05 +08:00
|
|
|
|
2024-01-09 10:08:53 +08:00
|
|
|
view.onContentYChanged: {
|
|
|
|
if (view.contentY <= 0) {
|
|
|
|
appListHeader.title = "";
|
|
|
|
} else {
|
|
|
|
appListHeader.title = view.currentSection;
|
2023-03-31 16:20:05 +08:00
|
|
|
}
|
|
|
|
}
|
2024-01-22 16:03:53 +08:00
|
|
|
|
|
|
|
function positionLabel(label) {
|
|
|
|
let index = model.findLabelIndex(label);
|
|
|
|
if (index >= 0) {
|
|
|
|
view.positionViewAtIndex(index, ListView.Beginning)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLabelItemClicked: {
|
|
|
|
labelPage.labelBottle = AppPageBackend.appModel.labelBottle;
|
|
|
|
labelPage.currentIndex = 0;
|
|
|
|
selectionPage.state = "viewShowed";
|
|
|
|
}
|
2024-01-09 10:08:53 +08:00
|
|
|
}
|
2023-04-04 09:33:06 +08:00
|
|
|
|
2024-01-22 16:03:53 +08:00
|
|
|
MouseArea {
|
2024-01-09 10:08:53 +08:00
|
|
|
id: selectionPage
|
|
|
|
anchors.fill: parent
|
2024-01-22 16:03:53 +08:00
|
|
|
visible: false
|
|
|
|
|
|
|
|
onClicked: state = "viewHid";
|
|
|
|
|
|
|
|
state: "viewHid"
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "viewShowed"
|
|
|
|
changes: [
|
|
|
|
PropertyChanges {target: selectionPage; scale: 1; opacity: 1; focus: true }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "viewHid"
|
|
|
|
changes: [
|
|
|
|
PropertyChanges {target: selectionPage; scale: 1.5; opacity: 0; focus: false }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "*"; to: "viewShowed"
|
|
|
|
SequentialAnimation {
|
|
|
|
ScriptAction { script: selectionPage.visible = true; }
|
|
|
|
NumberAnimation { properties: "scale,opacity"; easing.type: Easing.InOutCubic; duration: 300}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "*"; to: "viewHid"
|
|
|
|
SequentialAnimation {
|
|
|
|
NumberAnimation { properties: "scale,opacity"; easing.type: Easing.InOutCubic; duration: 300}
|
|
|
|
ScriptAction {
|
|
|
|
script: {
|
|
|
|
selectionPage.visible = false;
|
|
|
|
labelPage.labelBottle = null;
|
|
|
|
labelPage.focus = false;
|
|
|
|
appList.focus = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
AppLabelPage {
|
|
|
|
id: labelPage
|
|
|
|
anchors.centerIn: parent
|
|
|
|
interactive: height > parent.height
|
|
|
|
|
|
|
|
onLabelSelected: (label) => {
|
|
|
|
appList.positionLabel(label);
|
|
|
|
selectionPage.state = "viewHid";
|
|
|
|
}
|
|
|
|
|
|
|
|
onModelChanged: {
|
|
|
|
currentIndex = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function hidePage() {
|
|
|
|
state = "viewHid";
|
|
|
|
visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
mainWindow.visibleChanged.connect(hidePage)
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onDestruction: {
|
|
|
|
mainWindow.visibleChanged.disconnect(hidePage)
|
|
|
|
}
|
2023-03-31 16:20:05 +08:00
|
|
|
}
|
|
|
|
}
|
2023-03-06 09:37:06 +08:00
|
|
|
}
|
|
|
|
}
|