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 header: QQC2.Control {
19 padding: Kirigami.Units.largeSpacing
21 background: Rectangle {
22 Kirigami.Theme.colorSet: Kirigami.Theme.Window
23 Kirigami.Theme.inherit: false
25 color: Kirigami.Theme.backgroundColor
28 contentItem: ColumnLayout {
32 Kirigami.InlineMessage {
33 Layout.fillWidth: true
34 showCloseButton: false
35 type: Kirigami.MessageType.Error
36 text: i18n("There is no push notification service running!")
37 icon.name:
"dialog-error"
38 visible: !kcm.hasDistributor
41 Layout.fillWidth: true
42 showCloseButton: false
44 text:
i18n(
"There is a 3rd party push notification service running. Push notifications are available, but cannot be configured here.")
45 icon.
name:
"dialog-information"
46 visible: !kcm.hasKDEDistributor && kcm.hasDistributor
49 Layout.fillWidth: true
50 showCloseButton: false
52 text:
i18n(
"<b>Online</b><br>Connected to the push notification server and operational.")
53 icon.
name:
"media-playback-playing"
54 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.
Connected
57 Layout.fillWidth: true
58 showCloseButton: false
60 text:
i18n(
"<b>Idle</b><br>There are no applications using push notifications.")
61 icon.
name:
"media-playback-paused"
62 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.Idle
65 Layout.fillWidth: true
66 showCloseButton: false
68 text:
i18n(
"<b>Offline</b><br>Network connection to the server could not be established.")
69 icon.
name:
"network-disconnect"
70 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoNetwork
73 Layout.fillWidth: true
74 showCloseButton: false
76 text:
i18n(
"<b>Offline</b><br>Could not authenticate at the server.")
77 icon.
name:
"dialog-error"
78 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.AuthenticationError
81 Layout.fillWidth: true
82 showCloseButton: false
84 text:
i18n(
"<b>Offline</b><br>Push notifications are not set up yet.")
85 icon.
name:
"configure"
86 visible: kcm.hasKDEDistributor && kcm.distributorStatus == DistributorStatus.NoSetup
92 visible: kcm.hasKDEDistributor
93 Layout.fillWidth: true
97 model: [
"Gotify",
"NextPush",
"Ntfy"]
98 currentIndex:
find(kcm.pushProviderId)
99 Component.onCompleted: currentIndex =
find(kcm.pushProviderId)
106 readonly property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || tokenField.text != root.pushProviderConfig[
'ClientToken']
109 let c = root.pushProviderConfig;
110 c[
'Url'] = urlField.text;
111 c[
'ClientToken'] = tokenField.text;
115 twinFormLayouts: [topForm]
119 text: root.pushProviderConfig['Url']
124 text: root.pushProviderConfig['ClientToken']
132 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url'] || userField.text != root.pushProviderConfig[
'Username'] || appPassword != root.pushProviderConfig[
'AppPassword']
133 property string appPassword: root.pushProviderConfig[
'AppPassword'];
135 let c = root.pushProviderConfig;
136 c[
'Url'] = urlField.text;
137 c[
'Username'] = userField.text;
138 c[
'AppPassword'] = appPassword;
142 twinFormLayouts: [topForm]
146 text: root.pushProviderConfig['Url']
151 text: root.pushProviderConfig['Username']
155 enabled: urlField.text !=
""
156 text:
i18n(
"Authenticate")
158 authBusy.running =
true;
159 kcm.nextcloudAuthenticate(urlField.text);
171 function onNextcloudAuthenticated(loginName, appPassword) {
172 userField.text = loginName;
173 nextpushConfig.appPassword = appPassword
174 authBusy.running =
false;
183 readonly
property bool dirty: urlField.text != root.pushProviderConfig[
'Url']
186 let c = root.pushProviderConfig;
187 c[
'Url'] = urlField.text;
191 twinFormLayouts: [topForm]
195 text: root.pushProviderConfig['Url']
201 id: providerFormLoader
202 Layout.fillWidth:
true
203 visible: kcm.hasKDEDistributor
205 switch (pushProviderBox.currentIndex) {
220 function onSaveRequested() {
221 kcm.setPushProviderConfiguration(pushProviderBox.currentText, providerFormLoader.item.config());
226 property:
"needsSave"
227 value: providerFormLoader.item.dirty || pushProviderBox.currentText != kcm.pushProviderId
234 model: kcm.clientModel
236 width: ListView.view.width
237 text:
i18n(
"Applications")
241 delegate: QQC2.ItemDelegate {
242 width: ListView.view.width
250 Kirigami.Theme.useAlternateBackgroundColor:
true
252 contentItem: RowLayout {
254 KirigamiDelegates.IconTitleSubtitle {
256 subtitle: model.description
257 icon.source: model.iconName
260 Layout.fillWidth:
true
263 icon.name:
"edit-delete"
265 onClicked: removePrompt.open()
267 QQC2.ToolTip.text:
i18n(
"Unregister application from push notifications")
272 parent: QQC2.Overlay.overlay
274 title:
i18nc(
"@title:window",
"Unregister Application")
275 subtitle: i18nc("%1 is an application name", "Are you sure you want to unregister '%1'?", model.name)
278 onAccepted: kcm.forceUnregister(model.token)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
const QList< QKeySequence > & find()
QString label(StandardShortcut id)
QString name(StandardShortcut id)