Commit eb736685 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Notifications] Toggle do not disturb on icon middle click

It's pretty common for Plasma to do a start/stop action on middle click,
like middle click to play/pause or middle click to mute/unmute.

BUG: 422811
parent b88e9ac0
......@@ -26,6 +26,8 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.quickcharts 1.0 as Charts
import "global"
MouseArea {
id: compactRoot
......@@ -40,6 +42,8 @@ MouseArea {
Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
property int activeCount: 0
property int unreadCount: 0
......@@ -50,7 +54,13 @@ MouseArea {
property bool wasExpanded: false
onPressed: wasExpanded = plasmoid.expanded
onClicked: plasmoid.expanded = !wasExpanded
onClicked: {
if (mouse.button === Qt.MiddleButton) {
Globals.toggleDoNotDisturbMode();
} else {
plasmoid.expanded = !wasExpanded;
}
}
PlasmaCore.Svg {
id: notificationSvg
......
......@@ -652,8 +652,7 @@ QtObject {
value: globals.inhibited
}
property Notifications.GlobalShortcuts shortcuts: Notifications.GlobalShortcuts {
onToggleDoNotDisturbTriggered: {
function toggleDoNotDisturbMode() {
var oldInhibited = globals.inhibited;
if (oldInhibited) {
globals.revokeInhibitions();
......@@ -668,8 +667,11 @@ QtObject {
checkInhibition();
if (globals.inhibited !== oldInhibited) {
showDoNotDisturbOsd(globals.inhibited);
shortcuts.showDoNotDisturbOsd(globals.inhibited);
}
}
property Notifications.GlobalShortcuts shortcuts: Notifications.GlobalShortcuts {
onToggleDoNotDisturbTriggered: globals.toggleDoNotDisturbMode()
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment