homescreens: Update API usage to match changes for Plasmoid & Containment

This commit is contained in:
Devin Lin 2023-06-12 19:58:17 -04:00
parent 2b613a1c89
commit 8a577f9a57
3 changed files with 152 additions and 146 deletions

View file

@ -1,7 +1,5 @@
/* // SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org> // SPDX-License-Identifier: LGPL-2.0-or-later
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick import QtQuick
import QtQuick.Window import QtQuick.Window
@ -20,6 +18,7 @@ import "../components" as Components
* The base homescreen component, implementing features that simplify * The base homescreen component, implementing features that simplify
* homescreen implementation. * homescreen implementation.
*/ */
Item { Item {
id: root id: root
@ -58,15 +57,15 @@ Item {
property real rightMargin property real rightMargin
function evaluateMargins() { function evaluateMargins() {
topMargin = plasmoid.availableScreenRect.y topMargin = Plasmoid.availableScreenRect.y
// add a specific check for the nav panel for now, since the gesture mode still technically has height // add a specific check for the nav panel for now, since the gesture mode still technically has height
bottomMargin = ShellSettings.Settings.navigationPanelEnabled ? root.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) : 0; bottomMargin = ShellSettings.Settings.navigationPanelEnabled ? root.height - (Plasmoid.availableScreenRect.y + Plasmoid.availableScreenRect.height) : 0;
leftMargin = plasmoid.availableScreenRect.x leftMargin = Plasmoid.availableScreenRect.x
rightMargin = root.width - (plasmoid.availableScreenRect.x + plasmoid.availableScreenRect.width) rightMargin = root.width - (Plasmoid.availableScreenRect.x + Plasmoid.availableScreenRect.width)
} }
Connections { Connections {
target: plasmoid target: Plasmoid
// avoid binding loops with root.height and root.width changing along with the availableScreenRect // avoid binding loops with root.height and root.width changing along with the availableScreenRect
function onAvailableScreenRectChanged() { function onAvailableScreenRectChanged() {

View file

@ -18,21 +18,9 @@ import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
import org.kde.private.mobile.homescreen.folio 1.0 as Folio import org.kde.private.mobile.homescreen.folio 1.0 as Folio
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
MobileShell.HomeScreen {
ContainmentItem {
id: root id: root
width: 640
height: 480
onResetHomeScreenPosition: {
homescreen.homeScreenState.animateGoToPageIndex(0, PlasmaCore.Units.longDuration);
homescreen.homeScreenState.closeAppDrawer();
}
onHomeTriggered: {
searchWidget.close();
}
property bool componentComplete: false
Component.onCompleted: { Component.onCompleted: {
// ensure the gestures work immediately on load // ensure the gestures work immediately on load
@ -60,64 +48,78 @@ MobileShell.HomeScreen {
searchWidget.close(); searchWidget.close();
} }
} else if (homescreen.homeScreenState.currentView === HomeScreenState.PageView) { } else if (folioHomeScreen.homeScreenState.currentView === HomeScreenState.PageView) {
homescreen.homeScreenState.openAppDrawer(); folioHomeScreen.homeScreenState.openAppDrawer();
} else { } else {
homescreen.homeScreenState.closeAppDrawer(); folioHomeScreen.homeScreenState.closeAppDrawer();
} }
} }
contentItem: Item { MobileShell.HomeScreen {
// homescreen component id: homeScreen
HomeScreen {
id: homescreen
anchors.fill: parent
topMargin: root.topMargin onResetHomeScreenPosition: {
bottomMargin: root.bottomMargin folioHomeScreen.homeScreenState.animateGoToPageIndex(0, PlasmaCore.Units.longDuration);
leftMargin: root.leftMargin folioHomeScreen.homeScreenState.closeAppDrawer();
rightMargin: root.rightMargin
opacity: (1 - searchWidget.openFactor)
// make the homescreen not interactable when task switcher or startup feedback is on
interactive: !root.overlayShown
} }
// search component onHomeTriggered: {
MobileShell.KRunnerWidget { searchWidget.close();
id: searchWidget
anchors.fill: parent
visible: openFactor > 0
topMargin: root.topMargin
bottomMargin: root.bottomMargin
leftMargin: root.leftMargin
rightMargin: root.rightMargin
} }
}
Connections { property bool componentComplete: false
target: homescreen.homeScreenState
function onSwipeDownGestureBegin() { contentItem: Item {
searchWidget.startGesture(); // homescreen component
} HomeScreen {
function onSwipeDownGestureEnd() { id: folioHomeScreen
searchWidget.endGesture(); anchors.fill: parent
}
function onSwipeDownGestureOffset(offset) {
searchWidget.updateGestureOffset(-offset);
}
}
// listen to app launch errors topMargin: homeScreen.topMargin
Connections { bottomMargin: homeScreen.bottomMargin
target: Folio.ApplicationListModel leftMargin: homeScreen.leftMargin
function onLaunchError(msg) { rightMargin: homeScreen.rightMargin
MobileShellState.ShellDBusClient.closeAppLaunchAnimation()
opacity: (1 - searchWidget.openFactor)
// make the homescreen not interactable when task switcher or startup feedback is on
interactive: !homeScreen.overlayShown
}
// search component
MobileShell.KRunnerWidget {
id: searchWidget
anchors.fill: parent
visible: openFactor > 0
topMargin: homeScreen.topMargin
bottomMargin: homeScreen.bottomMargin
leftMargin: homeScreen.leftMargin
rightMargin: homeScreen.rightMargin
}
}
Connections {
target: folioHomeScreen.homeScreenState
function onSwipeDownGestureBegin() {
searchWidget.startGesture();
}
function onSwipeDownGestureEnd() {
searchWidget.endGesture();
}
function onSwipeDownGestureOffset(offset) {
searchWidget.updateGestureOffset(-offset);
}
}
// listen to app launch errors
Connections {
target: Folio.ApplicationListModel
function onLaunchError(msg) {
MobileShellState.ShellDBusClient.closeAppLaunchAnimation()
}
} }
} }
} }

View file

@ -14,33 +14,15 @@ import org.kde.plasma.private.mobileshell.state as MobileShellState
import org.kde.private.mobile.homescreen.halcyon as Halcyon import org.kde.private.mobile.homescreen.halcyon as Halcyon
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
MobileShell.HomeScreen { ContainmentItem {
id: root id: root
onResetHomeScreenPosition: {
homescreen.triggerHomescreen();
}
onHomeTriggered: {
search.close();
}
Component.onCompleted: { Component.onCompleted: {
Halcyon.ApplicationListModel.loadApplications(); Halcyon.ApplicationListModel.loadApplications();
Halcyon.PinnedModel.applet = plasmoid.nativeInterface; Halcyon.PinnedModel.applet = Plasmoid.nativeInterface;
forceActiveFocus(); forceActiveFocus();
} }
Rectangle {
id: darkenBackground
color: root.overlayShown ? 'transparent' : (homescreen.page == 1 ? Qt.rgba(0, 0, 0, 0.7) : Qt.rgba(0, 0, 0, 0.2))
anchors.fill: parent
z: -1
Behavior on color {
ColorAnimation { duration: PlasmaCore.Units.longDuration }
}
}
Plasmoid.onActivated: { Plasmoid.onActivated: {
// there's a couple of steps: // there's a couple of steps:
// - minimize windows (only if we are in an app) // - minimize windows (only if we are in an app)
@ -58,45 +40,68 @@ MobileShell.HomeScreen {
search.close(); search.close();
} }
homescreen.page = 0; halcyonHomeScreen.page = 0;
WindowPlugin.WindowUtil.isShowingDesktop = true; WindowPlugin.WindowUtil.isShowingDesktop = true;
} else if (homescreen.page == 0) { } else if (halcyonHomeScreen.page == 0) {
homescreen.page = 1; halcyonHomeScreen.page = 1;
} else { } else {
WindowPlugin.WindowUtil.isShowingDesktop = false; WindowPlugin.WindowUtil.isShowingDesktop = false;
homescreen.page = 0; halcyonHomeScreen.page = 0;
} }
} }
// homescreen component Rectangle {
contentItem: Item { id: darkenBackground
HomeScreen { color: homeScreen.overlayShown ? 'transparent' : (halcyonHomeScreen.page == 1 ? Qt.rgba(0, 0, 0, 0.7) : Qt.rgba(0, 0, 0, 0.2))
id: homescreen anchors.fill: parent
anchors.fill: parent z: -1
Behavior on color {
ColorAnimation { duration: PlasmaCore.Units.longDuration }
}
}
topMargin: root.topMargin MobileShell.HomeScreen {
bottomMargin: root.bottomMargin id: homeScreen
leftMargin: root.leftMargin anchors.fill: parent
rightMargin: root.rightMargin
// make the homescreen not interactable when task switcher or startup feedback is on onResetHomeScreenPosition: {
interactive: !root.overlayShown halcyonHomeScreen.triggerHomescreen();
searchWidget: search
} }
// search component onHomeTriggered: {
MobileShell.KRunnerWidget { search.close();
id: search }
anchors.fill: parent
visible: openFactor > 0
onActionTriggered: search.close() // homescreen component
contentItem: Item {
HomeScreen {
id: halcyonHomeScreen
anchors.fill: parent
topMargin: root.topMargin topMargin: homeScreen.topMargin
bottomMargin: root.bottomMargin bottomMargin: homeScreen.bottomMargin
leftMargin: root.leftMargin leftMargin: homeScreen.leftMargin
rightMargin: root.rightMargin rightMargin: homeScreen.rightMargin
// make the homescreen not interactable when task switcher or startup feedback is on
interactive: !homeScreen.overlayShown
searchWidget: search
}
// search component
MobileShell.KRunnerWidget {
id: search
anchors.fill: parent
visible: openFactor > 0
onActionTriggered: search.close()
topMargin: homeScreen.topMargin
bottomMargin: homeScreen.bottomMargin
leftMargin: homeScreen.leftMargin
rightMargin: homeScreen.rightMargin
}
} }
} }
} }