diff --git a/panels/notification/center/GroupNotify.qml b/panels/notification/center/GroupNotify.qml index 7a17299f4..3fa6755cb 100644 --- a/panels/notification/center/GroupNotify.qml +++ b/panels/notification/center/GroupNotify.qml @@ -106,7 +106,7 @@ NotifyItem { onClicked: function () { console.log("group setting", root.appName) let pos = mapToItem(root, Qt.point(width / 2, height)) - root.setting(pos) + root.setting(pos, false) } } AnimationSettingButton { diff --git a/panels/notification/center/NotifySettingMenu.qml b/panels/notification/center/NotifySettingMenu.qml index e7775a95d..fd31aca34 100644 --- a/panels/notification/center/NotifySettingMenu.qml +++ b/panels/notification/center/NotifySettingMenu.qml @@ -13,14 +13,35 @@ Menu { closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape modal: true - function toggle() + Timer { + id: closePolicyTimer + interval: 1000 + onTriggered: { + if (root.visible) { + root.closePolicy = Popup.CloseOnPressOutside | Popup.CloseOnEscape + } + } + } + + function toggle(isTouch) { if (!visible) { console.log("Open menu") + if (isTouch) { + closePolicy = Popup.CloseOnEscape + } open() + if (isTouch) { + closePolicyTimer.restart() + } } else { console.log("Close menu") close() } } + + onClosed: { + closePolicyTimer.stop() + closePolicy = Popup.CloseOnPressOutside | Popup.CloseOnEscape + } } diff --git a/panels/notification/center/NotifyView.qml b/panels/notification/center/NotifyView.qml index 9c97772a3..a4e57dfc8 100644 --- a/panels/notification/center/NotifyView.qml +++ b/panels/notification/center/NotifyView.qml @@ -128,7 +128,7 @@ Control { id: notifyDelegate notifyModel: root.notifyModel view: view - onSetting: function (pos, params) { + onSetting: function (pos, params, isTouch) { let appName = params.appName let pinned = params.pinned notifySetting.x = pos.x - notifySetting.width / 2 @@ -137,7 +137,7 @@ Control { notifySetting.pinned = pinned console.log("setting", appName, pinned) - notifySetting.toggle(); + notifySetting.toggle(isTouch); } } add: Transition { diff --git a/panels/notification/center/NotifyViewDelegate.qml b/panels/notification/center/NotifyViewDelegate.qml index 51480a659..c894d7c25 100644 --- a/panels/notification/center/NotifyViewDelegate.qml +++ b/panels/notification/center/NotifyViewDelegate.qml @@ -14,7 +14,7 @@ DelegateChooser { required property NotifyModel notifyModel required property Item view - signal setting(var pos, var params) + signal setting(var pos, var params, bool isTouch) role: "type" @@ -74,12 +74,12 @@ DelegateChooser { root.view.requestFocusOnExpand(collapseIndex) } - onSetting: function (pos) { + onSetting: function (pos, isTouch) { let tmp = mapToItem(root.view, pos) root.setting(tmp, { appName: model.appName, pinned: model.pinned - }) + }, isTouch) } onRemove: function () { console.log("remove group", model.appName) @@ -116,18 +116,20 @@ DelegateChooser { acceptedButtons: Qt.RightButton onPressedChanged: function () { if (pressed) { + if (point.device.type === PointerDevice.TouchScreen) + return let pos = point.position - setting(pos) + setting(pos, false) } } } - onSetting: function (pos) { + onSetting: function (pos, isTouch) { let tmp = mapToItem(root.view, pos) root.setting(tmp, { appName: model.appName, pinned: model.pinned - }) + }, isTouch) } onRemove: function () { console.log("remove normal", model.id) @@ -201,12 +203,26 @@ DelegateChooser { acceptedButtons: Qt.RightButton onPressedChanged: function () { if (pressed) { + if (point.device.type === PointerDevice.TouchScreen) + return let pos = point.position - setting(pos) + setting(pos, false) } } } + TapHandler { + acceptedDevices: PointerDevice.TouchScreen + onTapped: { + overlapNotify.forceActiveFocus() + overlapNotify.expand() + } + onLongPressed: { + let pos = point.position + setting(pos, true) + } + } + onExpand: function () { console.log("expand") @@ -215,12 +231,12 @@ DelegateChooser { root.view.jiggleUpdate() root.view.requestFocusOnExpand(expandIndex + 1) } - onSetting: function (pos) { + onSetting: function (pos, isTouch) { let tmp = mapToItem(root.view, pos) root.setting(tmp, { appName: model.appName, pinned: model.pinned - }) + }, isTouch) } onRemove: function () { console.log("remove overlap", model.appName) diff --git a/panels/notification/center/OverlapNotify.qml b/panels/notification/center/OverlapNotify.qml index ba674931b..ae1c6eb82 100644 --- a/panels/notification/center/OverlapNotify.qml +++ b/panels/notification/center/OverlapNotify.qml @@ -187,6 +187,7 @@ NotifyItem { TapHandler { enabled: !root.enableDismissed acceptedButtons: Qt.LeftButton + acceptedDevices: PointerDevice.Mouse onTapped: { root.forceActiveFocus() root.expand() diff --git a/panels/notification/plugin/NotifyItem.qml b/panels/notification/plugin/NotifyItem.qml index 189e2650b..70f68d0af 100644 --- a/panels/notification/plugin/NotifyItem.qml +++ b/panels/notification/plugin/NotifyItem.qml @@ -36,7 +36,7 @@ FocusScope { signal remove() signal dismiss() - signal setting(var pos) + signal setting(var pos, bool isTouch) signal actionInvoked(var actionId) signal linkActivated(var link)