2015-02-25 18:26:04 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
|
2021-12-25 01:17:08 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
2015-02-25 18:26:04 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
2015-02-25 18:26:04 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-12-25 01:17:08 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Window 2.15
|
2015-02-25 18:38:34 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2015-02-25 18:26:04 +00:00
|
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2019-09-04 16:39:31 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2020-07-22 15:17:10 +00:00
|
|
|
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
|
2023-03-05 17:39:03 +00:00
|
|
|
import org.kde.private.plasma.mobile.homescreen.folio 1.0 as Folio
|
2020-07-22 15:17:10 +00:00
|
|
|
|
2022-04-06 02:06:05 +00:00
|
|
|
MobileShell.HomeScreen {
|
2015-02-25 18:26:04 +00:00
|
|
|
id: root
|
2019-09-04 16:39:31 +00:00
|
|
|
width: 640
|
|
|
|
|
height: 480
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2022-04-06 02:06:05 +00:00
|
|
|
onResetHomeScreenPosition: {
|
|
|
|
|
homescreen.homeScreenState.animateGoToPageIndex(0, PlasmaCore.Units.longDuration);
|
|
|
|
|
homescreen.homeScreenState.closeAppDrawer();
|
2015-06-20 23:08:46 +00:00
|
|
|
}
|
2021-12-25 03:31:33 +00:00
|
|
|
|
2022-04-06 02:06:05 +00:00
|
|
|
onHomeTriggered: {
|
2022-01-03 05:25:33 +00:00
|
|
|
searchWidget.close();
|
2021-10-18 03:50:59 +00:00
|
|
|
}
|
2021-12-25 01:17:08 +00:00
|
|
|
|
2022-04-06 02:06:05 +00:00
|
|
|
property bool componentComplete: false
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Component.onCompleted: {
|
2021-10-18 18:56:37 +00:00
|
|
|
// ensure the gestures work immediately on load
|
|
|
|
|
forceActiveFocus();
|
2015-03-05 12:37:39 +00:00
|
|
|
}
|
2021-10-18 18:56:37 +00:00
|
|
|
|
2022-09-27 15:25:43 +00:00
|
|
|
Plasmoid.onActivated: {
|
2021-12-31 00:49:08 +00:00
|
|
|
// there's a couple of steps:
|
2022-09-23 18:36:34 +00:00
|
|
|
// - minimize windows (only if we are in an app)
|
2021-12-31 00:49:08 +00:00
|
|
|
// - open app drawer
|
2022-09-23 18:36:34 +00:00
|
|
|
// - 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
|
|
|
|| searchWidget.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 (searchWidget.isOpen) {
|
|
|
|
|
searchWidget.close();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 00:49:08 +00:00
|
|
|
plasmoid.nativeInterface.showingDesktop = true;
|
2022-09-23 18:36:34 +00:00
|
|
|
} else if (homescreen.homeScreenState.currentView === HomeScreenState.PageView) {
|
|
|
|
|
homescreen.homeScreenState.openAppDrawer();
|
2021-12-31 00:49:08 +00:00
|
|
|
} else {
|
2022-09-23 18:36:34 +00:00
|
|
|
plasmoid.nativeInterface.showingDesktop = false;
|
|
|
|
|
homescreen.homeScreenState.closeAppDrawer();
|
2021-12-31 00:49:08 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2021-10-18 18:56:37 +00:00
|
|
|
|
2022-04-06 21:59:36 +00:00
|
|
|
contentItem: Item {
|
|
|
|
|
// homescreen component
|
|
|
|
|
HomeScreen {
|
|
|
|
|
id: homescreen
|
|
|
|
|
anchors.fill: parent
|
2022-12-11 02:05:13 +00:00
|
|
|
|
|
|
|
|
topMargin: root.topMargin
|
|
|
|
|
bottomMargin: root.bottomMargin
|
|
|
|
|
leftMargin: root.leftMargin
|
|
|
|
|
rightMargin: root.rightMargin
|
|
|
|
|
|
2022-04-06 21:59:36 +00:00
|
|
|
opacity: (1 - searchWidget.openFactor)
|
2022-12-11 02:05:13 +00:00
|
|
|
|
2022-04-06 21:59:36 +00:00
|
|
|
// make the homescreen not interactable when task switcher or startup feedback is on
|
|
|
|
|
interactive: !root.overlayShown
|
|
|
|
|
}
|
2022-01-03 05:25:33 +00:00
|
|
|
|
2022-04-06 21:59:36 +00:00
|
|
|
// search component
|
|
|
|
|
MobileShell.KRunnerWidget {
|
|
|
|
|
id: searchWidget
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
visible: openFactor > 0
|
2022-12-11 02:05:13 +00:00
|
|
|
|
|
|
|
|
topMargin: root.topMargin
|
|
|
|
|
bottomMargin: root.bottomMargin
|
|
|
|
|
leftMargin: root.leftMargin
|
|
|
|
|
rightMargin: root.rightMargin
|
2022-04-06 21:59:36 +00:00
|
|
|
|
|
|
|
|
// close search component when task switcher is shown or hidden
|
|
|
|
|
Connections {
|
2022-11-11 16:21:12 +00:00
|
|
|
target: MobileShellState.HomeScreenControls.taskSwitcher
|
2022-04-06 21:59:36 +00:00
|
|
|
function onVisibleChanged() {
|
|
|
|
|
searchWidget.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-03 05:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: homescreen.homeScreenState
|
|
|
|
|
|
|
|
|
|
function onSwipeDownGestureBegin() {
|
|
|
|
|
searchWidget.startGesture();
|
|
|
|
|
}
|
|
|
|
|
function onSwipeDownGestureEnd() {
|
|
|
|
|
searchWidget.endGesture();
|
|
|
|
|
}
|
|
|
|
|
function onSwipeDownGestureOffset(offset) {
|
|
|
|
|
searchWidget.updateGestureOffset(-offset);
|
2021-12-25 01:17:08 +00:00
|
|
|
}
|
2021-10-18 18:56:37 +00:00
|
|
|
}
|
2022-04-06 16:04:57 +00:00
|
|
|
|
|
|
|
|
// listen to app launch errors
|
|
|
|
|
Connections {
|
2023-03-05 17:39:03 +00:00
|
|
|
target: Folio.ApplicationListModel
|
2022-04-06 16:04:57 +00:00
|
|
|
function onLaunchError(msg) {
|
2022-11-11 16:21:12 +00:00
|
|
|
MobileShellState.Shell.closeAppLaunchAnimation()
|
2022-04-06 16:04:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-06-20 21:45:19 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|