diff --git a/components/mobileshell/qml/TopPanelControls.qml b/components/mobileshell/qml/TopPanelControls.qml index 58598ff2..2c66eaac 100644 --- a/components/mobileshell/qml/TopPanelControls.qml +++ b/components/mobileshell/qml/TopPanelControls.qml @@ -22,5 +22,6 @@ QtObject { signal openActionDrawer() property bool inSwipe: false property real panelHeight: PlasmaCore.Units.gridUnit // set and updated in panel containment - property bool actionDrawerVisible: false + property bool actionDrawerVisible: false + property var notificationsWidget // updated in panel containment } diff --git a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml index 46bbe2f3..6b790939 100644 --- a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml +++ b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml @@ -66,6 +66,11 @@ Item { */ property int direction: MobileShell.Direction.None + /** + * The notifications widget being shown. May be null. + */ + property var notificationsWidget: contentContainerLoader.item.notificationsWidget + /** * The mode of the action drawer (portrait or landscape). */ diff --git a/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml b/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml index 9880ae1a..a09107f4 100644 --- a/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml +++ b/components/mobileshell/qml/actiondrawer/LandscapeContentContainer.qml @@ -26,6 +26,8 @@ PlasmaCore.ColorScope { required property var actionDrawer + property alias notificationsWidget: notificationWidget + readonly property real minimizedQuickSettingsOffset: height readonly property real maximizedQuickSettingsOffset: height readonly property bool isOnLargeScreen: width > quickSettings.width * 2.5 diff --git a/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml b/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml index a585f293..6e58039a 100644 --- a/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml +++ b/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml @@ -24,6 +24,8 @@ PlasmaCore.ColorScope { required property var actionDrawer + property alias notificationsWidget: notificationWidget + // pinned position (disabled when openToPinnedMode is false) readonly property real minimizedQuickSettingsOffset: quickSettings.minimizedHeight diff --git a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml index 4fe42cdc..bcd743dc 100644 --- a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml @@ -18,7 +18,7 @@ Item { required property InternetIndicator internetIndicator // check if the internet indicator icon is a mobile data related one - readonly property bool isInternetIndicatorMobileData: internetIndicator.icon.startsWith('network-mobile-') + readonly property bool isInternetIndicatorMobileData: internetIndicator && internetIndicator.icon && internetIndicator.icon.startsWith('network-mobile-') property bool showLabel: true property real textPixelSize: PlasmaCore.Units.gridUnit * 0.6 diff --git a/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml b/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml index 978752bd..6fc09c9f 100644 --- a/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml +++ b/components/mobileshell/qml/widgets/notifications/NotificationsWidget.qml @@ -368,23 +368,10 @@ Item { bottomMargin: list.spacing } - PlasmaComponents3.ToolButton { - id: doNotDisturbButton - - Layout.alignment: hasNotifications ? Qt.AlignLeft : Qt.AlignHCenter - - font.bold: true - font.pointSize: Kirigami.Theme.smallFont.pointSize - - icon.name: doNotDisturbModeEnabled ? "notifications" : "notifications-disabled" - text: doNotDisturbModeEnabled ? "Enable Notifications" : "Do Not Disturb" - onClicked: toggleDoNotDisturbMode() - } - PlasmaComponents3.ToolButton { id: clearButton - Layout.alignment: Qt.AlignRight + Layout.alignment: Qt.AlignCenter visible: hasNotifications @@ -392,7 +379,7 @@ Item { font.pointSize: Kirigami.Theme.smallFont.pointSize icon.name: "edit-clear-history" - text: "Clear All Notifications" + text: i18n("Clear All Notifications") onClicked: clearHistory() } } diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index cec8ef5b..1a611e80 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -59,6 +59,12 @@ Item { value: drawer.visible } + Binding { + target: MobileShell.TopPanelControls + property: "notificationsWidget" + value: drawer.actionDrawer.notificationsWidget + } + Connections { target: MobileShell.TopPanelControls diff --git a/quicksettings/CMakeLists.txt b/quicksettings/CMakeLists.txt index 9cc20d54..fb4adf88 100644 --- a/quicksettings/CMakeLists.txt +++ b/quicksettings/CMakeLists.txt @@ -6,6 +6,7 @@ plasma_install_package(audio org.kde.plasma.quicksetting.audio quicksettings) plasma_install_package(battery org.kde.plasma.quicksetting.battery quicksettings) plasma_install_package(bluetooth org.kde.plasma.quicksetting.bluetooth quicksettings) plasma_install_package(caffeine org.kde.plasma.quicksetting.caffeine quicksettings) +plasma_install_package(donotdisturb org.kde.plasma.quicksetting.donotdisturb quicksettings) plasma_install_package(keyboardtoggle org.kde.plasma.quicksetting.keyboardtoggle quicksettings) plasma_install_package(location org.kde.plasma.quicksetting.location quicksettings) plasma_install_package(mobiledata org.kde.plasma.quicksetting.mobiledata quicksettings) diff --git a/quicksettings/donotdisturb/contents/main.qml b/quicksettings/donotdisturb/contents/main.qml new file mode 100644 index 00000000..5f795000 --- /dev/null +++ b/quicksettings/donotdisturb/contents/main.qml @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Devin Lin + * + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.private.mobileshell 1.0 as MobileShell + +MobileShell.QuickSetting { + text: i18n("Do Not Disturb") + icon: enabled ? "notifications" : "notifications-disabled" + status: "" + enabled: MobileShell.TopPanelControls.notificationsWidget && MobileShell.TopPanelControls.notificationsWidget.doNotDisturbModeEnabled + available: MobileShell.TopPanelControls.notificationsWidget + + function toggle() { + if (MobileShell.TopPanelControls.notificationsWidget) { + MobileShell.TopPanelControls.notificationsWidget.toggleDoNotDisturbMode(); + } + } +} diff --git a/quicksettings/donotdisturb/metadata.json b/quicksettings/donotdisturb/metadata.json new file mode 100644 index 00000000..8277b8a6 --- /dev/null +++ b/quicksettings/donotdisturb/metadata.json @@ -0,0 +1,21 @@ +{ + "KPlugin": { + "Authors": [ + { + "Email": "devin@kde.org", + "Name": "Devin Lin" + } + ], + "Description": "Quick setting to toggle do not disturb mode", + "Icon": "notifications", + "Id": "org.kde.plasma.quicksetting.donotdisturb", + "License": "GPL", + "Name": "Do Not Disturb", + "ServiceTypes": [ + "KPackage/GenericQML" + ], + "Version": "0.1", + "Website": "https://kde.org" + } +} +