Changeset View
Changeset View
Standalone View
Standalone View
kcms/notifications/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.9 | ||||
22 | import QtQuick.Layouts 1.1 | ||||
23 | import QtQuick.Controls 2.3 as QtControls | ||||
24 | import org.kde.kirigami 2.4 as Kirigami | ||||
25 | import org.kde.kcm 1.2 as KCM | ||||
26 | | ||||
27 | import org.kde.notificationmanager 1.0 as NotificationManager | ||||
28 | | ||||
29 | KCM.SimpleKCM { | ||||
30 | id: root | ||||
31 | KCM.ConfigModule.quickHelp: i18n("This module lets you manage application and system notifications.") | ||||
32 | KCM.ConfigModule.buttons: KCM.ConfigModule.Help | KCM.ConfigModule.Apply | ||||
33 | | ||||
34 | function openSourcesSettings() { | ||||
35 | // TODO would be nice to re-use the current SourcesPage instead of pushing a new one that lost all state | ||||
36 | // but there's no pageAt(index) method in KConfigModuleQml | ||||
37 | kcm.push("SourcesPage.qml"); | ||||
38 | } | ||||
39 | | ||||
40 | Binding { | ||||
41 | target: kcm | ||||
42 | property: "needsSave" | ||||
43 | value: kcm.settings.dirty // TODO or other stuff | ||||
44 | } | ||||
45 | | ||||
46 | Kirigami.FormLayout { | ||||
47 | QtControls.CheckBox { | ||||
48 | Kirigami.FormData.label: i18n("Critical notifications:") | ||||
49 | text: i18n("Show in do not disturb mode") | ||||
50 | checked: kcm.settings.criticalPopupsInDoNotDisturbMode | ||||
51 | onClicked: kcm.settings.criticalPopupsInDoNotDisturbMode = checked | ||||
52 | } | ||||
53 | | ||||
54 | QtControls.CheckBox { | ||||
55 | text: i18n("Always keep on top") | ||||
56 | checked: kcm.settings.keepCriticalAlwaysOnTop | ||||
57 | onClicked: kcm.settings.keepCriticalAlwaysOnTop = checked | ||||
58 | } | ||||
59 | | ||||
60 | QtControls.CheckBox { | ||||
61 | Kirigami.FormData.label: i18n("Low priority notifications:") | ||||
62 | text: i18n("Show popup") | ||||
63 | checked: kcm.settings.lowPriorityPopups | ||||
64 | onClicked: kcm.settings.lowPriorityPopups = checked | ||||
65 | } | ||||
66 | | ||||
67 | QtControls.CheckBox { | ||||
68 | text: i18n("Show in history") | ||||
69 | checked: kcm.settings.lowPriorityHistory | ||||
70 | onClicked: kcm.settings.lowPriorityHistory = checked | ||||
71 | } | ||||
72 | | ||||
73 | QtControls.ButtonGroup { | ||||
74 | id: positionGroup | ||||
75 | buttons: [positionCloseToWidget, positionCustomPosition] | ||||
76 | } | ||||
77 | | ||||
78 | QtControls.RadioButton { | ||||
79 | id: positionCloseToWidget | ||||
80 | Kirigami.FormData.label: i18n("Popup position:") | ||||
81 | text: i18nc("Popup position near notification plasmoid", "Near the notification icon") // "widget" | ||||
82 | checked: kcm.settings.popupPosition === NotificationManager.Settings.CloseToWidget | ||||
83 | onClicked: kcm.settings.popupPosition = NotificationManager.Settings.CloseToWidget | ||||
84 | } | ||||
85 | | ||||
86 | RowLayout { | ||||
87 | spacing: 0 | ||||
88 | QtControls.RadioButton { | ||||
89 | id: positionCustomPosition | ||||
90 | checked: kcm.settings.popupPosition !== NotificationManager.Settings.CloseToWidget | ||||
91 | activeFocusOnTab: false | ||||
92 | | ||||
93 | MouseArea { | ||||
94 | anchors.fill: parent | ||||
95 | onClicked: positionCustomButton.clicked() | ||||
96 | } | ||||
97 | } | ||||
98 | QtControls.Button { | ||||
99 | id: positionCustomButton | ||||
100 | text: i18n("Choose Custom Position...") | ||||
101 | icon.name: "preferences-desktop-display" | ||||
102 | onClicked: kcm.push("PopupPositionPage.qml") | ||||
103 | } | ||||
104 | } | ||||
105 | | ||||
106 | TextMetrics { | ||||
107 | id: timeoutSpinnerMetrics | ||||
108 | font: timeoutSpinner.font | ||||
109 | text: i18np("%1 second", "%1 seconds", 888) | ||||
110 | } | ||||
111 | | ||||
112 | QtControls.SpinBox { | ||||
113 | id: timeoutSpinner | ||||
114 | Kirigami.FormData.label: i18n("Hide popup after:") | ||||
115 | Layout.preferredWidth: timeoutSpinnerMetrics.width + leftPadding + rightPadding | ||||
116 | from: 1000 // 1 second | ||||
117 | to: 120000 // 2 minutes | ||||
118 | stepSize: 1000 | ||||
119 | value: kcm.settings.popupTimeout | ||||
120 | editable: true | ||||
121 | valueFromText: function(text, locale) { | ||||
122 | return parseInt(text) * 1000; | ||||
123 | } | ||||
124 | textFromValue: function(value, locale) { | ||||
125 | return i18np("%1 second", "%1 seconds", Math.round(value / 1000)); | ||||
126 | } | ||||
127 | onValueModified: kcm.settings.popupTimeout = value | ||||
128 | } | ||||
129 | | ||||
130 | Kirigami.Separator { | ||||
131 | Kirigami.FormData.isSection: true | ||||
132 | } | ||||
133 | | ||||
134 | QtControls.CheckBox { | ||||
135 | Kirigami.FormData.label: i18n("Application progress:") | ||||
136 | text: i18n("Show in task manager") | ||||
137 | checked: kcm.settings.jobsInTaskManager | ||||
138 | onClicked: kcm.settings.jobsInTaskManager = checked | ||||
139 | } | ||||
140 | | ||||
141 | QtControls.CheckBox { | ||||
142 | id: applicationJobsEnabledCheck | ||||
143 | text: i18nc("Show application jobs in notification widget", "Show in notifications") | ||||
144 | checked: kcm.settings.jobsInNotifications | ||||
145 | onClicked: kcm.settings.jobsInNotifications = checked | ||||
146 | } | ||||
147 | | ||||
148 | RowLayout { // just for indentation | ||||
149 | QtControls.CheckBox { | ||||
150 | Layout.leftMargin: mirrored ? 0 : indicator.width | ||||
151 | Layout.rightMargin: mirrored ? indicator.width : 0 | ||||
152 | text: i18nc("Keep application job popup open for entire duration of job", "Keep popup open during progress") | ||||
153 | enabled: applicationJobsEnabledCheck.checked | ||||
154 | checked: kcm.settings.permanentJobPopups | ||||
155 | onClicked: kcm.settings.permanentJobPopups = checked | ||||
156 | } | ||||
157 | } | ||||
158 | | ||||
159 | QtControls.CheckBox { | ||||
160 | Kirigami.FormData.label: i18n("Notification badges:") | ||||
161 | text: i18n("Show in task manager") | ||||
162 | checked: kcm.settings.badgesInTaskManager | ||||
163 | onClicked: kcm.settings.badgesInTaskManager = checked | ||||
164 | } | ||||
165 | | ||||
166 | Kirigami.Separator { | ||||
167 | Kirigami.FormData.isSection: true | ||||
168 | } | ||||
169 | | ||||
170 | QtControls.Button { | ||||
171 | Kirigami.FormData.label: i18n("Applications:") | ||||
172 | text: i18n("Configure...") | ||||
173 | icon.name: "configure" | ||||
174 | onClicked: root.openSourcesSettings() | ||||
175 | } | ||||
176 | } | ||||
177 | | ||||
178 | Component.onCompleted: { | ||||
179 | if (kcm.initialDesktopEntry || kcm.initialNotifyRcName) { | ||||
180 | // FIXME doing that right in onCompleted doesn't work | ||||
181 | Qt.callLater(root.openSourcesSettings); | ||||
182 | } | ||||
183 | } | ||||
184 | } |