Commit 2da603f9 authored by Marco Martin's avatar Marco Martin
Browse files

auto hide popup when it opened itself

Summary:
when the device notifier pops up automatically, leave it open
if there is no user activity, if there is any, close after around
3 seconds. Suspend the countdown if the notifier window either has
focus or the mouse cursor is over it, leaving the user the time to
go interact. if it doesn't have focus and the mouse leaves, resume
the countdown
replaces D10591

Test Plan:
tested for a while in a real world usage, it behaves in a fairly natural
way

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10921
parent 240d0d6f
......@@ -22,13 +22,18 @@
*/
import QtQuick 2.2
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
Item {
MouseArea {
id: fullRep
property bool spontaneousOpen: false
hoverEnabled: true
Layout.minimumWidth: units.gridUnit * 12
Layout.minimumHeight: units.gridUnit * 12
......@@ -40,6 +45,28 @@ Item {
visible: notifierDialog.count === 0 && !devicenotifier.pendingDelegateRemoval
}
PlasmaCore.DataSource {
id: userActivitySource
engine: "powermanagement"
connectedSources: "UserActivity"
property int polls: 0
//poll only on plasmoid expanded
interval: !fullRep.containsMouse && !fullRep.Window.active && spontaneousOpen && plasmoid.expanded ? 3000 : 0
onIntervalChanged: polls = 0;
onDataChanged: {
//only do when polling
if (interval == 0 || polls++ < 1) {
return;
}
if (userActivitySource.data["UserActivity"]["IdleTime"] < interval) {
plasmoid.expanded = false;
spontaneousOpen = false;
}
}
}
// this item is reparented to a delegate that is showing a message to draw focus to it
PlasmaComponents.Highlight {
id: messageHighlight
......
......@@ -266,6 +266,7 @@ Item {
onTriggered: {
if (plasmoid.configuration.popupOnNewDevice) { // Bug 351592
plasmoid.expanded = true;
plasmoid.fullRepresentationItem.spontaneousOpen = true;
}
}
}
......
Supports Markdown
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