2015-02-25 18:26:04 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@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
|
|
|
*/
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
import QtQuick 2.12
|
2020-07-22 15:17:10 +00:00
|
|
|
import QtQuick.Window 2.12
|
2015-02-25 18:38:34 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2019-09-04 16:39:31 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
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
|
|
|
|
|
import org.kde.draganddrop 2.0 as DragDrop
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents
|
2019-09-04 16:39:31 +00:00
|
|
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
|
|
|
|
|
2020-07-22 15:17:10 +00:00
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
|
|
|
|
|
2021-03-18 17:34:37 +00:00
|
|
|
FocusScope {
|
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
|
|
|
|
|
|
|
|
property Item toolBox
|
|
|
|
|
|
2015-06-20 23:08:46 +00:00
|
|
|
//BEGIN functions
|
2015-07-09 11:29:26 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
function recalculateMaxFavoriteCount() {
|
|
|
|
|
if (!componentComplete) {
|
|
|
|
|
return;
|
2015-10-15 13:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
HomeScreenComponents.ApplicationListModel.maxFavoriteCount = Math.max(4, Math.floor(Math.min(width, height) / homeScreenContents.appletsLayout.cellWidth));
|
2015-06-20 23:08:46 +00:00
|
|
|
}
|
2021-02-15 10:44:48 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
//END functions
|
2015-06-20 23:08:46 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
property bool componentComplete: false
|
|
|
|
|
onWidthChanged: recalculateMaxFavoriteCount()
|
|
|
|
|
onHeightChanged:recalculateMaxFavoriteCount()
|
|
|
|
|
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
|
|
|
|
|
HomeScreenComponents.ApplicationListModel.loadApplications();
|
|
|
|
|
HomeScreenComponents.FavoritesModel.applet = plasmoid;
|
|
|
|
|
HomeScreenComponents.FavoritesModel.loadApplications();
|
|
|
|
|
|
2020-07-22 15:17:10 +00:00
|
|
|
if (plasmoid.screen == 0) {
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreen = root
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window
|
|
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
componentComplete = true;
|
|
|
|
|
recalculateMaxFavoriteCount()
|
2015-03-05 12:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-22 15:17:10 +00:00
|
|
|
Plasmoid.onScreenChanged: {
|
|
|
|
|
if (plasmoid.screen == 0) {
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreen = root
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Window.onWindowChanged: {
|
|
|
|
|
if (plasmoid.screen == 0) {
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
2021-02-15 10:44:48 +00:00
|
|
|
property real lastRequestedPosition: 0
|
2020-07-22 15:17:10 +00:00
|
|
|
target: MobileShell.HomeScreenControls
|
|
|
|
|
function onResetHomeScreenPosition() {
|
2021-04-01 15:43:26 +00:00
|
|
|
mainFlickable.scrollToPage(0);
|
2021-02-15 10:44:48 +00:00
|
|
|
appDrawer.close();
|
2020-07-22 15:17:10 +00:00
|
|
|
}
|
2020-07-23 15:09:37 +00:00
|
|
|
function onSnapHomeScreenPosition() {
|
2021-04-13 12:03:05 +00:00
|
|
|
if (lastRequestedPosition < 0) {
|
2021-02-15 10:44:48 +00:00
|
|
|
appDrawer.open();
|
|
|
|
|
} else {
|
|
|
|
|
appDrawer.close();
|
|
|
|
|
}
|
2020-07-23 15:09:37 +00:00
|
|
|
}
|
2021-04-13 12:03:05 +00:00
|
|
|
function onRequestRelativeScroll(pos) {
|
|
|
|
|
appDrawer.offset -= pos.y;
|
|
|
|
|
lastRequestedPosition = pos.y;
|
2020-07-23 15:09:37 +00:00
|
|
|
}
|
2020-07-22 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
HomeScreenComponents.FlickablePages {
|
2019-09-04 16:39:31 +00:00
|
|
|
id: mainFlickable
|
2021-02-15 10:44:48 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
2021-02-15 10:44:48 +00:00
|
|
|
topMargin: plasmoid.availableScreenRect.y
|
2021-04-12 13:38:11 +00:00
|
|
|
bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
2015-03-18 14:45:48 +00:00
|
|
|
}
|
2020-08-13 09:17:06 +00:00
|
|
|
|
2021-04-08 16:57:20 +00:00
|
|
|
//TODO: favorite strip disappearing with everything else
|
2021-04-12 09:30:43 +00:00
|
|
|
footer: favoriteStrip
|
2021-03-26 16:21:30 +00:00
|
|
|
appletsLayout: homeScreenContents.appletsLayout
|
|
|
|
|
|
2021-03-24 13:48:56 +00:00
|
|
|
appDrawer: appDrawer
|
2021-03-18 14:07:33 +00:00
|
|
|
contentWidth: Math.max(width, width * Math.ceil(homeScreenContents.itemsBoundingRect.width/width)) + (homeScreenContents.launcherDragManager.active ? width : 0)
|
|
|
|
|
showAddPageIndicator: homeScreenContents.launcherDragManager.active
|
|
|
|
|
|
|
|
|
|
dragGestureEnabled: root.focus && appDrawer.status !== HomeScreenComponents.AppDrawer.Status.Open && !appletsLayout.editMode && !plasmoid.editMode && !homeScreenContents.launcherDragManager.active
|
2021-03-24 13:48:56 +00:00
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
HomeScreenComponents.HomeScreenContents {
|
2021-03-26 16:21:30 +00:00
|
|
|
id: homeScreenContents
|
2021-03-24 17:01:58 +00:00
|
|
|
width: mainFlickable.width * 100
|
2021-04-01 14:56:29 +00:00
|
|
|
favoriteStrip: favoriteStrip
|
2015-03-05 16:28:24 +00:00
|
|
|
}
|
2015-02-25 18:26:04 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
2021-10-16 03:17:32 +00:00
|
|
|
Plasmoid.onActivated: {
|
|
|
|
|
console.log("Triggered!", plasmoid.nativeInterface.showingDesktop)
|
|
|
|
|
|
|
|
|
|
// there's a couple of steps:
|
|
|
|
|
// - minimize windows
|
|
|
|
|
// - open app drawer
|
|
|
|
|
// - restore windows
|
|
|
|
|
if (!plasmoid.nativeInterface.showingDesktop) {
|
|
|
|
|
plasmoid.nativeInterface.showingDesktop = true
|
|
|
|
|
} else if (appDrawer.status !== HomeScreenComponents.AppDrawer.Status.Open) {
|
|
|
|
|
mainFlickable.currentIndex = 0
|
|
|
|
|
appDrawer.open()
|
|
|
|
|
} else {
|
|
|
|
|
plasmoid.nativeInterface.showingDesktop = false
|
|
|
|
|
appDrawer.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-18 14:07:33 +00:00
|
|
|
HomeScreenComponents.AppDrawer {
|
2021-02-15 10:44:48 +00:00
|
|
|
id: appDrawer
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
topPadding: plasmoid.availableScreenRect.y
|
2021-04-12 13:38:11 +00:00
|
|
|
bottomPadding: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
2021-08-30 00:12:19 +00:00
|
|
|
rightPadding: plasmoid.screenGeometry.width - plasmoid.availableScreenRect.width - plasmoid.availableScreenRect.x
|
2021-04-12 09:30:43 +00:00
|
|
|
closedPositionOffset: favoriteStrip.height
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2021-02-15 10:44:48 +00:00
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
HomeScreenComponents.FavoriteStrip {
|
2019-09-04 16:39:31 +00:00
|
|
|
id: favoriteStrip
|
2021-04-12 13:16:41 +00:00
|
|
|
|
2021-03-26 16:21:30 +00:00
|
|
|
appletsLayout: homeScreenContents.appletsLayout
|
|
|
|
|
|
2021-03-18 14:07:33 +00:00
|
|
|
visible: flow.children.length > 0 || homeScreenContents.launcherDragManager.active || homeScreenContents.containsDrag
|
|
|
|
|
|
|
|
|
|
opacity: homeScreenContents.launcherDragManager.active && HomeScreenComponents.ApplicationListModel.favoriteCount >= HomeScreenComponents.ApplicationListModel.maxFavoriteCount ? 0.3 : 1
|
2021-02-15 10:44:48 +00:00
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
|
target: favoriteStrip
|
|
|
|
|
onTapped: {
|
|
|
|
|
//Hides icons close button
|
2021-03-26 16:21:30 +00:00
|
|
|
homeScreenContents.appletsLayout.appletsLayoutInteracted();
|
|
|
|
|
homeScreenContents.appletsLayout.editMode = false;
|
2021-02-15 10:44:48 +00:00
|
|
|
}
|
2021-03-26 16:21:30 +00:00
|
|
|
onLongPressed: homeScreenContents.appletsLayout.editMode = true;
|
2021-02-22 13:59:15 +00:00
|
|
|
onPressedChanged: root.focus = true;
|
2021-02-15 10:44:48 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
}
|
2015-06-20 21:45:19 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|