8import QtQuick.Controls as QQC2
9import org.kde.kirigami as Kirigami
10import org.kde.kirigami.delegates as KirigamiDelegates
11import org.kde.kcmutils as KCM
12import org.kde.kunifiedpush.kcm
16 readonly property var pushProviderConfig: kcm.pushProviderConfiguration(pushProviderBox.currentValue)
18 headerPaddingEnabled: false
20 header: ColumnLayout {
24 Kirigami.InlineMessage {
25 Layout.fillWidth: true
26 showCloseButton: false
27 type: Kirigami.MessageType.Error
28 text: i18n("There is no push notification service running!")
29 icon.name:
"dialog-error"
30 visible: !kcm.hasDistributor
34 Layout.fillWidth: true
35 showCloseButton: false
37 text:
i18n(
"There is a 3rd party push notification service running. Push notifications are available, but cannot be configured here.")
38 icon.
name:
"dialog-information"
39 visible: !kcm.hasKDEDistributor && kcm.hasDistributor
43 Layout.fillWidth: true
44 showCloseButton: false
46 text:
i18n(
"<b>Online</b><br>Connected to the push notification server and operational.")
47 icon.
name:
"media-playback-playing"
48 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.
Connected
52 Layout.fillWidth: true
53 showCloseButton: false
55 text:
i18n(
"<b>Idle</b><br>There are no applications using push notifications.")
56 icon.
name:
"media-playback-paused"
57 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.Idle
61 Layout.fillWidth: true
62 showCloseButton: false
64 text: kcm.distributorErrorMessage ?
65 i18n(
"<b>Offline</b><br>Network connection to the server could not be established (%1).", kcm.distributorErrorMessage) :
66 i18n(
"<b>Offline</b><br>Network connection to the server could not be established.")
67 icon.
name:
"network-disconnect"
68 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoNetwork
72 Layout.fillWidth: true
73 showCloseButton: false
75 text: kcm.distributorErrorMessage ?
76 i18n(
"<b>Offline</b><br>Could not authenticate at the server (%1).", kcm.distributorErrorMessage) :
77 i18n(
"<b>Offline</b><br>Could not authenticate at the server.")
78 icon.
name:
"dialog-error"
79 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.AuthenticationError
83 Layout.fillWidth: true
84 showCloseButton: false
86 text:
i18n(
"<b>Offline</b><br>Push notifications are not set up yet.")
87 icon.
name:
"configure"
88 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoSetup
94 visible: kcm.hasKDEDistributor
95 Layout.fillWidth: true
97 background: Rectangle {
101 color:
Kirigami.Theme.backgroundColor
105 contentItem: ColumnLayout {
110 Layout.fillWidth: true
116 ListElement { text:
"Gotify"; key:
"Gotify" }
117 ListElement { text:
"Mozilla WebPush"; key:
"Autopush" }
118 ListElement { text:
"NextPush"; key:
"NextPush" }
119 ListElement { text:
"Ntfy"; key:
"Ntfy" }
123 currentIndex: indexOfValue(kcm.pushProviderId)
124 Component.onCompleted: currentIndex = indexOfValue(kcm.pushProviderId)
129 id: providerFormLoader
130 Layout.fillWidth:
true
131 visible: kcm.hasKDEDistributor
133 const forms = [gotifyForm, autopushForm, nextpushForm, ntfyForm];
134 return forms[pushProviderBox.currentIndex];
142 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || tokenField.text != root.pushProviderConfig[
'ClientToken']
145 let c = root.pushProviderConfig;
146 c[
'Url'] = urlField.text;
147 c[
'ClientToken'] = tokenField.text;
151 twinFormLayouts: [topForm]
155 text: root.pushProviderConfig['Url'] ?? ''
160 text: root.pushProviderConfig['ClientToken'] ?? ''
168 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || userField.text != root.pushProviderConfig[
'Username'] || appPassword != root.pushProviderConfig[
'AppPassword']
169 property string appPassword: root.pushProviderConfig[
'AppPassword'] ??
'';
171 let c = root.pushProviderConfig;
172 c[
'Url'] = urlField.text;
173 c[
'Username'] = userField.text;
174 c[
'AppPassword'] = appPassword;
178 twinFormLayouts: [topForm]
182 text: root.pushProviderConfig['Url'] ?? ''
187 text: root.pushProviderConfig['Username'] ?? ''
191 enabled: urlField.text !=
""
192 text:
i18n(
"Authenticate")
194 authBusy.running =
true;
195 kcm.nextcloudAuthenticate(urlField.text);
207 function onNextcloudAuthenticated(loginName, appPassword) {
208 userField.text = loginName;
209 nextpushConfig.appPassword = appPassword
210 authBusy.running =
false;
219 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url']
222 let c = root.pushProviderConfig;
223 c[
'Url'] = urlField.text;
227 twinFormLayouts: [topForm]
231 text: root.pushProviderConfig['Url'] ?? ''
238 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url']
241 let c = root.pushProviderConfig;
242 c[
'Url'] = urlField.text;
246 twinFormLayouts: [topForm]
250 text: root.pushProviderConfig['Url'] ?? 'https:
258 function onSaveRequested() {
259 kcm.setPushProviderConfiguration(pushProviderBox.currentValue, providerFormLoader.item.config());
264 property:
"needsSave"
265 value: providerFormLoader.item.dirty || pushProviderBox.currentValue != kcm.pushProviderId
270 visible: kcm.hasDistributor
271 enabled: !kcm.needsSave
274 switch (kcm.selfTest.state) {
276 return "dialog-positive";
278 return "dialog-error";
280 return "network-connect";
282 return "cloud-upload";
284 return "cloud-download";
289 Layout.fillWidth:
true
291 switch (kcm.selfTest.state) {
295 return i18n(
"Push notifications are working correctly.")
297 return
i18n(
"Push notification test failed.")
299 return
i18n(
"Registering with push server…")
301 return
i18n(
"Sending push notification…")
303 return
i18n(
"Waiting to receive push notification…")
306 subtitle: kcm.selfTest.errorMessage
310 text:
i18nc(
"@action:button",
"Test")
311 icon.name:
"media-playback-start"
312 visible: kcm.selfTest.state ===
SelfTest.Idle || kcm.selfTest.state ===
SelfTest.Success || kcm.selfTest.state ===
SelfTest.Error
313 onClicked: kcm.selfTest.
start()
316 visible: !testButton.visible
324 model: kcm.clientModel
326 width: ListView.view.width
327 text:
i18n(
"Applications")
331 delegate: QQC2.ItemDelegate {
332 width: ListView.view.width
340 Kirigami.Theme.useAlternateBackgroundColor:
true
342 contentItem: RowLayout {
344 KirigamiDelegates.IconTitleSubtitle {
346 subtitle: model.description
347 icon.source: model.iconName
350 Layout.fillWidth:
true
353 icon.name:
"edit-delete"
355 onClicked: removePrompt.open()
357 QQC2.ToolTip.text:
i18n(
"Unregister application from push notifications")
362 parent: QQC2.Overlay.overlay
364 title:
i18nc(
"@title:window",
"Unregister Application")
365 subtitle:
i18nc(
"%1 is an application name",
"Are you sure you want to unregister '%1'?", model.name)
368 onAccepted: kcm.forceUnregister(model.token)
Push notification self-test state machine.
Q_SCRIPTABLE QString start(QString train="")
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
AKONADI_MIME_EXPORT const char Header[]
Type type(const QSqlDatabase &db)
QString name(StandardAction id)
QString label(StandardShortcut id)