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.currentText)
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:
i18n(
"<b>Offline</b><br>Network connection to the server could not be established.")
65 icon.
name:
"network-disconnect"
66 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoNetwork
70 Layout.fillWidth: true
71 showCloseButton: false
73 text:
i18n(
"<b>Offline</b><br>Could not authenticate at the server.")
74 icon.
name:
"dialog-error"
75 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.AuthenticationError
79 Layout.fillWidth: true
80 showCloseButton: false
82 text:
i18n(
"<b>Offline</b><br>Push notifications are not set up yet.")
83 icon.
name:
"configure"
84 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoSetup
90 visible: kcm.hasKDEDistributor
91 Layout.fillWidth: true
93 background: Rectangle {
97 color:
Kirigami.Theme.backgroundColor
101 contentItem: ColumnLayout {
106 Layout.fillWidth: true
111 model: [
"Gotify",
"NextPush",
"Ntfy"]
112 currentIndex:
find(kcm.pushProviderId)
113 Component.onCompleted: currentIndex =
find(kcm.pushProviderId)
118 id: providerFormLoader
119 Layout.fillWidth: true
120 visible: kcm.hasKDEDistributor
122 switch (pushProviderBox.currentIndex) {
138 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || tokenField.text != root.pushProviderConfig[
'ClientToken']
141 let c = root.pushProviderConfig;
142 c[
'Url'] = urlField.text;
143 c[
'ClientToken'] = tokenField.text;
147 twinFormLayouts: [topForm]
151 text: root.pushProviderConfig['Url'] ?? ''
156 text: root.pushProviderConfig['ClientToken'] ?? ''
164 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || userField.text != root.pushProviderConfig[
'Username'] || appPassword != root.pushProviderConfig[
'AppPassword']
165 property string appPassword: root.pushProviderConfig[
'AppPassword'] ??
'';
167 let c = root.pushProviderConfig;
168 c[
'Url'] = urlField.text;
169 c[
'Username'] = userField.text;
170 c[
'AppPassword'] = appPassword;
174 twinFormLayouts: [topForm]
178 text: root.pushProviderConfig['Url'] ?? ''
183 text: root.pushProviderConfig['Username'] ?? ''
187 enabled: urlField.text !=
""
188 text:
i18n(
"Authenticate")
190 authBusy.running =
true;
191 kcm.nextcloudAuthenticate(urlField.text);
203 function onNextcloudAuthenticated(loginName, appPassword) {
204 userField.text = loginName;
205 nextpushConfig.appPassword = appPassword
206 authBusy.running =
false;
215 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url']
218 let c = root.pushProviderConfig;
219 c[
'Url'] = urlField.text;
223 twinFormLayouts: [topForm]
227 text: root.pushProviderConfig['Url'] ?? ''
235 function onSaveRequested() {
236 kcm.setPushProviderConfiguration(pushProviderBox.currentText, providerFormLoader.item.config());
241 property:
"needsSave"
242 value: providerFormLoader.item.dirty || pushProviderBox.currentText != kcm.pushProviderId
249 model: kcm.clientModel
251 width: ListView.view.width
252 text:
i18n(
"Applications")
256 delegate: QQC2.ItemDelegate {
257 width: ListView.view.width
265 Kirigami.Theme.useAlternateBackgroundColor:
true
267 contentItem: RowLayout {
269 KirigamiDelegates.IconTitleSubtitle {
271 subtitle: model.description
272 icon.source: model.iconName
275 Layout.fillWidth:
true
278 icon.name:
"edit-delete"
280 onClicked: removePrompt.open()
282 QQC2.ToolTip.text:
i18n(
"Unregister application from push notifications")
287 parent: QQC2.Overlay.overlay
289 title:
i18nc(
"@title:window",
"Unregister Application")
290 subtitle: i18nc("%1 is an application name", "Are you sure you want to unregister '%1'?", model.name)
293 onAccepted: kcm.forceUnregister(model.token)
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)
const QList< QKeySequence > & find()
QString label(StandardShortcut id)