2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2023-11-16 04:24:44 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Effects
|
2024-03-06 18:04:25 +00:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
|
|
2015-02-25 18:26:04 +00:00
|
|
|
import org.kde.plasma.plasmoid 2.0
|
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
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
|
|
|
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
2023-03-06 19:13:48 +00:00
|
|
|
import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
2023-03-16 07:21:01 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
2024-03-08 15:38:59 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
2020-07-22 15:17:10 +00:00
|
|
|
|
2023-06-12 23:58:17 +00:00
|
|
|
ContainmentItem {
|
2015-02-25 18:26:04 +00:00
|
|
|
id: root
|
2024-06-21 04:42:14 +00:00
|
|
|
property Folio.HomeScreen folio: root.plasmoid
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Component.onCompleted: {
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.FolioSettings.load();
|
|
|
|
|
folio.FavouritesModel.load();
|
|
|
|
|
folio.PageListModel.load();
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2021-10-18 18:56:37 +00:00
|
|
|
// ensure the gestures work immediately on load
|
|
|
|
|
forceActiveFocus();
|
2015-03-05 12:37:39 +00:00
|
|
|
}
|
2023-06-12 23:58:17 +00:00
|
|
|
|
2024-02-08 17:10:55 +00:00
|
|
|
Loader {
|
|
|
|
|
id: wallpaperBlurLoader
|
2024-06-21 04:42:14 +00:00
|
|
|
active: folio.FolioSettings.showWallpaperBlur
|
2023-11-17 06:40:07 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2024-02-08 17:10:55 +00:00
|
|
|
sourceComponent: Item {
|
2024-03-06 18:04:25 +00:00
|
|
|
id: wallpaper
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
// only take samples from wallpaper when we need the blur for performance
|
|
|
|
|
ShaderEffectSource {
|
|
|
|
|
id: controlledWallpaperSource
|
2024-02-08 17:10:55 +00:00
|
|
|
anchors.fill: parent
|
2024-03-06 18:04:25 +00:00
|
|
|
|
|
|
|
|
sourceItem: Plasmoid.wallpaperGraphicsObject
|
|
|
|
|
live: blur.visible
|
|
|
|
|
hideSource: false
|
|
|
|
|
visible: false
|
2024-02-08 17:10:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wallpaper blur
|
2024-03-06 18:04:25 +00:00
|
|
|
// we attempted to use MultiEffect in the past, but it had very poor performance on the PinePhone
|
|
|
|
|
FastBlur {
|
|
|
|
|
id: blur
|
|
|
|
|
radius: 50
|
|
|
|
|
cached: true
|
|
|
|
|
source: controlledWallpaperSource
|
2024-02-08 17:10:55 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
visible: opacity > 0
|
2024-06-21 04:42:14 +00:00
|
|
|
opacity: Math.min(1,
|
2024-02-08 17:10:55 +00:00
|
|
|
Math.max(
|
|
|
|
|
1 - homeScreen.contentOpacity,
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.appDrawerOpenProgress * 2, // blur faster during swipe
|
|
|
|
|
folio.HomeScreenState.searchWidgetOpenProgress * 1.5, // blur faster during swipe
|
|
|
|
|
folio.HomeScreenState.folderOpenProgress
|
2024-02-08 17:10:55 +00:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-15 16:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-23 22:47:24 +00:00
|
|
|
WindowPlugin.WindowMaximizedTracker {
|
|
|
|
|
id: windowMaximizedTracker
|
|
|
|
|
screenGeometry: Plasmoid.containment.screenGeometry
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
function homeAction() {
|
2024-06-23 22:47:24 +00:00
|
|
|
const isInWindow = (!WindowPlugin.WindowUtil.isShowingDesktop && windowMaximizedTracker.showingWindow);
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2024-03-08 15:38:59 +00:00
|
|
|
// Always close action drawer
|
|
|
|
|
if (MobileShellState.ShellDBusClient.isActionDrawerOpen) {
|
|
|
|
|
MobileShellState.ShellDBusClient.closeActionDrawer();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
if (isInWindow) {
|
2024-07-08 04:08:53 +00:00
|
|
|
// Only minimize windows and go to homescreen when not in docked mode
|
2024-03-08 15:38:59 +00:00
|
|
|
if (!ShellSettings.Settings.convergenceModeEnabled) {
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.closeFolder();
|
|
|
|
|
folio.HomeScreenState.closeSearchWidget();
|
|
|
|
|
folio.HomeScreenState.closeAppDrawer();
|
|
|
|
|
folio.HomeScreenState.goToPage(0);
|
2024-03-08 15:38:59 +00:00
|
|
|
|
2024-03-16 04:06:42 +00:00
|
|
|
WindowPlugin.WindowUtil.minimizeAll();
|
2024-03-08 15:38:59 +00:00
|
|
|
}
|
2024-07-08 04:08:53 +00:00
|
|
|
|
|
|
|
|
// Always ensure settings view is closed
|
|
|
|
|
if (folio.HomeScreenState.viewState == Folio.HomeScreenState.SettingsView) {
|
|
|
|
|
folio.HomeScreenState.closeSettingsView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else { // If we are already on the homescreen
|
2024-06-21 04:42:14 +00:00
|
|
|
switch (folio.HomeScreenState.viewState) {
|
2023-10-22 03:59:27 +00:00
|
|
|
case Folio.HomeScreenState.PageView:
|
2024-06-21 04:42:14 +00:00
|
|
|
if (folio.HomeScreenState.currentPage === 0) {
|
|
|
|
|
folio.HomeScreenState.openAppDrawer();
|
2023-10-22 03:59:27 +00:00
|
|
|
} else {
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.goToPage(0);
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Folio.HomeScreenState.AppDrawerView:
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.closeAppDrawer();
|
2023-10-22 03:59:27 +00:00
|
|
|
break;
|
|
|
|
|
case Folio.HomeScreenState.SearchWidgetView:
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.closeSearchWidget();
|
2023-10-22 03:59:27 +00:00
|
|
|
break;
|
|
|
|
|
case Folio.HomeScreenState.FolderView:
|
2024-06-21 04:42:14 +00:00
|
|
|
folio.HomeScreenState.closeFolder();
|
2023-10-22 03:59:27 +00:00
|
|
|
break;
|
2024-07-08 04:08:53 +00:00
|
|
|
case Folio.HomeScreenState.SettingsView:
|
|
|
|
|
folio.HomeScreenState.closeSettingsView();
|
|
|
|
|
break;
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
2023-03-20 01:32:19 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
Plasmoid.onActivated: homeAction()
|
2023-06-12 23:58:17 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
Rectangle {
|
|
|
|
|
id: appDrawerBackground
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: Qt.rgba(0, 0, 0, 0.6)
|
2023-06-12 23:58:17 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
opacity: folio.HomeScreenState.appDrawerOpenProgress
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: searchWidgetBackground
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: Qt.rgba(0, 0, 0, 0.3)
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
opacity: folio.HomeScreenState.searchWidgetOpenProgress
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: settingsViewBackground
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: Qt.rgba(0, 0, 0, 0.3)
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
opacity: folio.HomeScreenState.settingsOpenProgress
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2023-06-12 23:58:17 +00:00
|
|
|
|
|
|
|
|
MobileShell.HomeScreen {
|
|
|
|
|
id: homeScreen
|
2023-10-22 03:59:27 +00:00
|
|
|
anchors.fill: parent
|
2023-06-12 23:58:17 +00:00
|
|
|
|
2023-09-20 12:41:40 +00:00
|
|
|
plasmoidItem: root
|
2023-06-12 23:58:17 +00:00
|
|
|
onResetHomeScreenPosition: {
|
2023-10-22 03:59:27 +00:00
|
|
|
// NOTE: empty, because this is handled by homeAction()
|
2022-04-06 21:59:36 +00:00
|
|
|
}
|
2023-06-12 23:58:17 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
onHomeTriggered: root.homeAction()
|
2023-06-12 23:58:17 +00:00
|
|
|
|
|
|
|
|
contentItem: Item {
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-06-12 23:58:17 +00:00
|
|
|
// homescreen component
|
|
|
|
|
HomeScreen {
|
|
|
|
|
id: folioHomeScreen
|
2024-06-21 04:42:14 +00:00
|
|
|
folio: root.folio
|
2023-06-12 23:58:17 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
topMargin: homeScreen.topMargin
|
|
|
|
|
bottomMargin: homeScreen.bottomMargin
|
|
|
|
|
leftMargin: homeScreen.leftMargin
|
|
|
|
|
rightMargin: homeScreen.rightMargin
|
|
|
|
|
}
|
2022-04-06 16:04:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-06-20 21:45:19 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|