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

[Notifications] Improve self-closing behavior

When a plasmoid collapses in Active state, the popup is hidden.
In Passive state, however, one is returned to the hidden items list, as it cannot tell whether
the plasmoid collapsed on its own or because the user clicked the same one in the hidden items list again.
When we clear notifications, plasmoid state updates immediately as a result of model signals,
and when we then try to collapse the plasmoid we're already hidden and just returned to the hidden items list.

This patch addresses this by delaying the state change slightly.
Futhermore, don't collapse the plasmoid when already hidden as that would just return the user to the hidden items list.

Differential Revision: https://phabricator.kde.org/D26091
parent 146865ac
......@@ -433,7 +433,7 @@ ColumnLayout{
onCloseClicked: {
historyModel.close(historyModel.index(index, 0))
if (list.count === 0) {
plasmoid.expanded = false;
root.closePassivePlasmoid();
}
}
......@@ -526,12 +526,12 @@ ColumnLayout{
onCloseClicked: {
historyModel.close(historyModel.index(index, 0));
if (list.count === 0) {
plasmoid.expanded = false;
root.closePassivePlasmoid();
}
}
onDismissClicked: {
model.dismissed = false;
plasmoid.expanded = false;
root.closePassivePlasmoid();
}
onConfigureClicked: historyModel.configure(historyModel.index(index, 0))
......
......@@ -34,10 +34,25 @@ import "global"
Item {
id: root
Plasmoid.status: historyModel.activeJobsCount > 0
readonly property int effectiveStatus: historyModel.activeJobsCount > 0
|| historyModel.unreadNotificationsCount > 0
|| Globals.inhibited ? PlasmaCore.Types.ActiveStatus
: PlasmaCore.Types.PassiveStatus
onEffectiveStatusChanged: {
if (effectiveStatus === PlasmaCore.Types.PassiveStatus) {
// HACK System Tray only lets applets self-hide when in Active state
// When we clear the notifications, the status is updated right away
// as a result of model signals, and when we then try to collapse
// the popup isn't hidden.
Qt.callLater(function() {
Plasmoid.status = effectiveStatus;
});
} else {
Plasmoid.status = effectiveStatus;
}
}
Plasmoid.status: effectiveStatus
Plasmoid.toolTipSubText: {
var lines = [];
......@@ -85,11 +100,8 @@ Item {
Plasmoid.onExpandedChanged: {
if (!plasmoid.expanded) {
// FIXME Qt.callLater because system tray gets confused when an applet becomes passive when clicking to hide it
Qt.callLater(function() {
historyModel.lastRead = undefined; // reset to now
historyModel.collapseAllGroups();
});
historyModel.lastRead = undefined; // reset to now
historyModel.collapseAllGroups();
}
}
......@@ -138,10 +150,16 @@ Item {
value: units.iconSizes.large
}
function closePassivePlasmoid() {
if (plasmoid.status !== PlasmaCore.Types.PassiveStatus) {
plasmoid.expanded = false;
}
}
function action_clearHistory() {
historyModel.clear(NotificationManager.Notifications.ClearExpired);
if (historyModel.count === 0) {
plasmoid.expanded = false;
closePassivePlasmoid();
}
}
......
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