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-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
|
|
|
|
|
|
|
|
|
|
function recalculateMaxFavoriteCount() {
|
|
|
|
|
if (!componentComplete) {
|
|
|
|
|
return;
|
2021-12-25 01:17:08 +00:00
|
|
|
}
|
2022-04-06 02:06:05 +00:00
|
|
|
MobileShell.ApplicationListModel.maxFavoriteCount = Math.max(4, Math.floor(Math.min(width, height) / homescreen.homeScreenContents.favoriteStrip.cellWidth));
|
2021-12-25 01:17:08 +00:00
|
|
|
}
|
2021-10-18 03:50:59 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
onWidthChanged: recalculateMaxFavoriteCount()
|
2021-12-25 01:17:08 +00:00
|
|
|
onHeightChanged: recalculateMaxFavoriteCount()
|
2021-10-29 00:11:01 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Component.onCompleted: {
|
2021-03-18 14:07:33 +00:00
|
|
|
// ApplicationListModel doesn't have a plasmoid as is not the one that should be doing writing
|
2022-04-06 02:06:05 +00:00
|
|
|
MobileShell.ApplicationListModel.loadApplications();
|
|
|
|
|
MobileShell.FavoritesModel.applet = plasmoid;
|
|
|
|
|
MobileShell.FavoritesModel.loadApplications();
|
2021-03-18 14:07:33 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
componentComplete = true;
|
|
|
|
|
recalculateMaxFavoriteCount()
|
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
|
|
|
|
2021-10-16 03:17:32 +00:00
|
|
|
Plasmoid.onActivated: {
|
|
|
|
|
console.log("Triggered!", plasmoid.nativeInterface.showingDesktop)
|
2021-12-31 00:49:08 +00:00
|
|
|
|
|
|
|
|
// there's a couple of steps:
|
|
|
|
|
// - minimize windows
|
|
|
|
|
// - open app drawer
|
|
|
|
|
// - restore windows
|
|
|
|
|
if (!plasmoid.nativeInterface.showingDesktop) {
|
|
|
|
|
plasmoid.nativeInterface.showingDesktop = true;
|
|
|
|
|
} else if (homescreen.homeScreenState.currentView === MobileShell.HomeScreenState.PageView) {
|
|
|
|
|
homescreen.homeScreenState.openAppDrawer()
|
|
|
|
|
} else {
|
|
|
|
|
plasmoid.nativeInterface.showingDesktop = false
|
|
|
|
|
homescreen.homeScreenState.closeAppDrawer()
|
|
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2021-10-18 18:56:37 +00:00
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
// homescreen component
|
2022-04-06 02:06:05 +00:00
|
|
|
HomeScreen {
|
2021-12-25 01:17:08 +00:00
|
|
|
id: homescreen
|
2021-10-18 18:56:37 +00:00
|
|
|
anchors.fill: parent
|
2022-01-03 05:25:33 +00:00
|
|
|
opacity: root.homeScreenOpacity * (1 - searchWidget.openFactor)
|
2021-12-31 00:49:08 +00:00
|
|
|
|
|
|
|
|
// make the homescreen not interactable when task switcher or startup feedback is on
|
2022-04-06 02:06:05 +00:00
|
|
|
interactive: !root.overlayShown
|
2022-01-03 05:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// search component
|
|
|
|
|
MobileShell.KRunnerWidget {
|
|
|
|
|
id: searchWidget
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
opacity: root.homeScreenOpacity
|
|
|
|
|
visible: openFactor > 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2015-06-20 21:45:19 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|