From dca8064ca25844d2258a0c9c8c488f6e70a06755 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 11 Feb 2022 17:50:17 -0500 Subject: [PATCH] actiondrawer: Use passed in notifications model and settings --- .../qml/actiondrawer/ActionDrawer.qml | 10 +++++ .../LandscapeContentContainer.qml | 3 ++ .../actiondrawer/PortraitContentContainer.qml | 3 ++ .../dataproviders/NotificationProvider.qml | 39 ------------------- components/mobileshell/qml/qmldir | 1 - .../notifications/NotificationsWidget.qml | 4 +- .../panel/package/contents/ui/main.qml | 28 ++++++++++++- 7 files changed, 45 insertions(+), 43 deletions(-) delete mode 100644 components/mobileshell/qml/dataproviders/NotificationProvider.qml diff --git a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml index a5b4e73f..d013d64f 100644 --- a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml +++ b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml @@ -25,6 +25,16 @@ import "../components" as Components NanoShell.FullScreenOverlay { id: window + + /** + * The model for the notification widget. + */ + property var notificationModel + + /** + * The notification settings object to be used in the notification widget. + */ + property var notificationSettings /** * The amount of pixels moved by touch/mouse in the process of opening/closing the panel. diff --git a/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml b/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml index 72b08876..5863dff7 100644 --- a/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml +++ b/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml @@ -94,6 +94,9 @@ PlasmaCore.ColorScope { MobileShell.NotificationsWidget { id: notificationWidget + historyModel: root.actionDrawer.notificationModel + notificationSettings: root.actionDrawer.notificationSettings + // don't allow notifications widget to get too wide Layout.maximumWidth: PlasmaCore.Units.gridUnit * 25 Layout.fillHeight: true diff --git a/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml b/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml index c22bca87..ce0a2d42 100644 --- a/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml +++ b/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml @@ -78,6 +78,9 @@ PlasmaCore.ColorScope { MobileShell.NotificationsWidget { id: notificationWidget + historyModel: root.actionDrawer.notificationModel + notificationSettings: root.actionDrawer.notificationSettings + anchors { top: quickSettings.top topMargin: quickSettings.height + translate.y diff --git a/components/mobileshell/qml/dataproviders/NotificationProvider.qml b/components/mobileshell/qml/dataproviders/NotificationProvider.qml deleted file mode 100644 index e8e45d22..00000000 --- a/components/mobileshell/qml/dataproviders/NotificationProvider.qml +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Devin Lin - * SPDX-FileCopyrightText: 2018-2019 Kai Uwe Broulik - * - * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL -*/ - -import QtQuick 2.2 - -import org.kde.notificationmanager 1.0 as NotificationManager - -pragma Singleton - -QtObject { - - property var notificationSettings: NotificationManager.Settings {} - - property var historyModel: NotificationManager.Notifications { - showExpired: true - showDismissed: true - showJobs: notificationSettings.jobsInNotifications - sortMode: NotificationManager.Notifications.SortByTypeAndUrgency - groupMode: NotificationManager.Notifications.GroupApplicationsFlat - groupLimit: 2 - expandUnread: true - blacklistedDesktopEntries: notificationSettings.historyBlacklistedApplications - blacklistedNotifyRcNames: notificationSettings.historyBlacklistedServices - urgencies: { - var urgencies = NotificationManager.Notifications.CriticalUrgency - | NotificationManager.Notifications.NormalUrgency; - if (notificationSettings.lowPriorityHistory) { - urgencies |= NotificationManager.Notifications.LowUrgency; - } - return urgencies; - } - } -} - - diff --git a/components/mobileshell/qml/qmldir b/components/mobileshell/qml/qmldir index 1d36cdd1..d6fbd659 100644 --- a/components/mobileshell/qml/qmldir +++ b/components/mobileshell/qml/qmldir @@ -18,7 +18,6 @@ VelocityCalculator 1.0 components/VelocityCalculator.qml # /dataproviders singleton BatteryProvider 1.0 dataproviders/BatteryProvider.qml singleton BluetoothProvider 1.0 dataproviders/BluetoothProvider.qml -singleton NotificationProvider 1.0 dataproviders/NotificationProvider.qml singleton SignalStrengthProvider 1.0 dataproviders/SignalStrengthProvider.qml singleton VolumeProvider 1.0 dataproviders/VolumeProvider.qml singleton WifiProvider 1.0 dataproviders/WifiProvider.qml diff --git a/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml b/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml index 079771fd..bd2707e7 100644 --- a/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml +++ b/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml @@ -26,8 +26,8 @@ import org.kde.notificationmanager 1.0 as NotificationManager Item { id: root - property var historyModel: MobileShell.NotificationProvider.historyModel - property var notificationSettings: MobileShell.NotificationProvider.notificationSettings + property var historyModel: [] + property var notificationSettings: NotificationManager.Settings {} readonly property bool hasNotifications: list.count > 0 diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index f7a0288d..f5986703 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -18,6 +18,8 @@ import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.notificationmanager 1.0 as NotificationManager + Item { id: root @@ -59,7 +61,7 @@ Item { //END API implementation Component.onCompleted: { - // we want to bind global shortcuts here + // we want to bind global volume shortcuts here MobileShell.VolumeProvider.bindShortcuts = true; } @@ -67,6 +69,7 @@ Item { MobileShell.StatusBar { id: topPanel anchors.fill: parent + showDropShadow: !root.showingApp colorGroup: root.showingApp ? PlasmaCore.Theme.HeaderColorGroup : PlasmaCore.Theme.ComplementaryColorGroup backgroundColor: !root.showingApp ? "transparent" : root.backgroundColor @@ -78,7 +81,30 @@ Item { anchors.fill: parent } + // swipe-down drawer component MobileShell.ActionDrawer { id: drawer + + notificationSettings: NotificationManager.Settings {} + + notificationModel: NotificationManager.Notifications { + showExpired: true + showDismissed: true + showJobs: drawer.notificationSettings.jobsInNotifications + sortMode: NotificationManager.Notifications.SortByTypeAndUrgency + groupMode: NotificationManager.Notifications.GroupApplicationsFlat + groupLimit: 2 + expandUnread: true + blacklistedDesktopEntries: drawer.notificationSettings.historyBlacklistedApplications + blacklistedNotifyRcNames: drawer.notificationSettings.historyBlacklistedServices + urgencies: { + var urgencies = NotificationManager.Notifications.CriticalUrgency + | NotificationManager.Notifications.NormalUrgency; + if (drawer.notificationSettings.lowPriorityHistory) { + urgencies |= NotificationManager.Notifications.LowUrgency; + } + return urgencies; + } + } } }