2022-06-08 22:09:35 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Window 2.15
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
2022-11-11 16:21:12 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
|
2022-06-18 19:42:29 +00:00
|
|
|
import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
|
2022-06-08 22:09:35 +00:00
|
|
|
|
|
|
|
|
MobileShell.HomeScreen {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
onResetHomeScreenPosition: {
|
|
|
|
|
homescreen.triggerHomescreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onHomeTriggered: {
|
|
|
|
|
search.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2022-06-18 19:42:29 +00:00
|
|
|
Halcyon.ApplicationListModel.loadApplications();
|
2022-06-22 14:50:06 +00:00
|
|
|
Halcyon.PinnedModel.load();
|
2022-06-08 22:09:35 +00:00
|
|
|
forceActiveFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: darkenBackground
|
2022-06-21 03:23:11 +00:00
|
|
|
color: root.overlayShown ? 'transparent' : (homescreen.page == 1 ? Qt.rgba(0, 0, 0, 0.7) : Qt.rgba(0, 0, 0, 0.2))
|
2022-06-08 22:09:35 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
z: -1
|
|
|
|
|
Behavior on color {
|
|
|
|
|
ColorAnimation { duration: PlasmaCore.Units.longDuration }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-27 15:25:43 +00:00
|
|
|
Plasmoid.onActivated: {
|
2022-09-24 18:19:02 +00:00
|
|
|
// there's a couple of steps:
|
|
|
|
|
// - minimize windows (only if we are in an app)
|
|
|
|
|
// - open app drawer
|
|
|
|
|
// - close app drawer and, if necessary, restore windows
|
2022-11-11 16:21:12 +00:00
|
|
|
if (!plasmoid.nativeInterface.showingDesktop && !MobileShellState.Shell.homeScreenVisible
|
|
|
|
|
|| MobileShellState.Shell.actionDrawerVisible
|
2022-09-27 15:25:43 +00:00
|
|
|
|| search.isOpen
|
|
|
|
|
) {
|
|
|
|
|
// Always close action drawer
|
2022-11-11 16:21:12 +00:00
|
|
|
if (MobileShellState.Shell.actionDrawerVisible) {
|
|
|
|
|
MobileShellState.Shell.closeActionDrawer();
|
2022-09-27 15:25:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Always close the search widget as well
|
|
|
|
|
if (search.isOpen) {
|
|
|
|
|
search.close();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 18:19:02 +00:00
|
|
|
plasmoid.nativeInterface.showingDesktop = true;
|
|
|
|
|
} else if (homescreen.page == 0) {
|
|
|
|
|
homescreen.page = 1;
|
|
|
|
|
} else {
|
|
|
|
|
plasmoid.nativeInterface.showingDesktop = false;
|
|
|
|
|
homescreen.page = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 22:09:35 +00:00
|
|
|
// homescreen component
|
|
|
|
|
contentItem: Item {
|
|
|
|
|
HomeScreen {
|
|
|
|
|
id: homescreen
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
// make the homescreen not interactable when task switcher or startup feedback is on
|
|
|
|
|
interactive: !root.overlayShown
|
|
|
|
|
searchWidget: search
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// search component
|
|
|
|
|
MobileShell.KRunnerWidget {
|
|
|
|
|
id: search
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
visible: openFactor > 0
|
|
|
|
|
|
|
|
|
|
// close search component when task switcher is shown or hidden
|
|
|
|
|
Connections {
|
2022-11-11 16:21:12 +00:00
|
|
|
target: MobileShellState.HomeScreenControls.taskSwitcher
|
2022-06-08 22:09:35 +00:00
|
|
|
function onVisibleChanged() {
|
2022-06-18 19:42:29 +00:00
|
|
|
search.close();
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|