-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathGroupNotify.qml
More file actions
133 lines (121 loc) · 4.11 KB
/
GroupNotify.qml
File metadata and controls
133 lines (121 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.deepin.dtk 1.0
import org.deepin.ds.notification
import org.deepin.ds.notificationcenter
NotifyItem {
id: root
implicitWidth: impl.implicitWidth
implicitHeight: impl.implicitHeight
property bool focusedByNavigation: false
onActiveFocusChanged: if (!activeFocus) focusedByNavigation = false
signal collapse()
signal gotoNextItem() // Signal to navigate to next notify item
signal gotoPrevItem() // Signal to navigate to previous notify item
function resetFocus() {
impl.forceActiveFocus()
}
// Focus the first button for Tab navigation into group
function focusFirstButton() {
foldBtn.forceActiveFocus()
return true
}
// Focus the last button for Shift+Tab navigation into group
function focusLastButton() {
groupClearBtn.forceActiveFocus()
return true
}
Control {
id: impl
anchors.fill: parent
focus: true
Keys.onTabPressed: function(event) {
if (root.focusFirstButton()) {
event.accepted = true
} else {
root.gotoNextItem()
event.accepted = true
}
}
Keys.onBacktabPressed: function(event) {
root.gotoPrevItem()
event.accepted = true
}
contentItem: RowLayout {
NotifyHeaderTitleText {
text: root.appName
Layout.alignment: Qt.AlignLeft
Layout.leftMargin: 18
tFont: DTK.fontManager.t5
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: 1
}
AnimationSettingButton {
id: foldBtn
Layout.alignment: Qt.AlignRight
activeFocusOnTab: false
focusBorderVisible: activeFocus
icon.name: "fold"
text: qsTr("Fold")
Keys.onTabPressed: function(event) {
groupMoreBtn.forceActiveFocus()
event.accepted = true
}
Keys.onBacktabPressed: function(event) {
root.gotoPrevItem()
event.accepted = true
}
onClicked: {
console.log("collapse")
root.collapse()
}
}
AnimationSettingButton {
id: groupMoreBtn
Layout.alignment: Qt.AlignRight
activeFocusOnTab: false
focusBorderVisible: activeFocus
icon.name: "more"
text: qsTr("More")
Keys.onTabPressed: function(event) {
groupClearBtn.forceActiveFocus()
event.accepted = true
}
Keys.onBacktabPressed: function(event) {
foldBtn.forceActiveFocus()
event.accepted = true
}
onClicked: function () {
console.log("group setting", root.appName)
let pos = mapToItem(root, Qt.point(width / 2, height))
root.setting(pos, false)
}
}
AnimationSettingButton {
id: groupClearBtn
Layout.alignment: Qt.AlignRight
activeFocusOnTab: false
focusBorderVisible: activeFocus
icon.name: "clean-group"
text: qsTr("Clear All")
Keys.onTabPressed: function(event) {
root.gotoNextItem()
event.accepted = true
}
Keys.onBacktabPressed: function(event) {
groupMoreBtn.forceActiveFocus()
event.accepted = true
}
onClicked: function () {
root.remove()
}
}
}
}
}