Provide a QML UI to the new functionality

This commit is contained in:
Carl Schwan 2024-11-03 22:13:19 +01:00
parent 5b10d9632c
commit b2d0d5fa48
No known key found for this signature in database
GPG key ID: 02325448204E452A
2 changed files with 42 additions and 1 deletions

View file

@ -29,6 +29,44 @@ FormCard.FormCardPage {
}
}
FormCard.FormHeader {
title: i18nc("@title:group", "Backends")
}
FormCard.FormCard {
DBusProperty {
id: linkProvidersProperty
object: DaemonDbusInterface
read: "linkProviders"
defaultValue: []
}
Repeater {
model: linkProvidersProperty.value
FormCard.FormCheckDelegate {
required property string modelData
readonly property string linkProviderId: modelData.split('|')[0]
readonly property string displayName: switch (linkProviderId) {
case 'BluetoothLinkProvider':
return i18nc("@info KDE Connect provider name", "Bluetooth")
case 'LoopbackLinkProvider':
return i18nc("@info KDE Connect provider name", "Loopback")
case 'LanLinkProvider':
return i18nc("@info KDE Connect provider name", "WiFi Network")
}
checked: modelData.split('|')[1] === 'enabled'
text: displayName
onCheckedChanged: {
DaemonDbusInterface.setLinkProviderState(linkProviderId, checked);
}
}
}
}
FormCard.FormCard {
Layout.topMargin: Kirigami.Units.gridUnit

View file

@ -33,7 +33,8 @@ DBusResponseWaiter::DBusResponseWaiter()
m_registered << qRegisterMetaType<QDBusPendingReply<>>("QDBusPendingReply<>")
<< qRegisterMetaType<QDBusPendingReply<QVariant>>("QDBusPendingReply<QVariant>")
<< qRegisterMetaType<QDBusPendingReply<bool>>("QDBusPendingReply<bool>") << qRegisterMetaType<QDBusPendingReply<int>>("QDBusPendingReply<int>")
<< qRegisterMetaType<QDBusPendingReply<QString>>("QDBusPendingReply<QString>");
<< qRegisterMetaType<QDBusPendingReply<QString>>("QDBusPendingReply<QString>")
<< qRegisterMetaType<QDBusPendingReply<QStringList>>("QDBusPendingReply<QStringList>");
}
QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
@ -73,6 +74,8 @@ void DBusAsyncResponse::setPendingCall(QVariant variant)
connect(watcher, &QDBusPendingCallWatcher::finished, watcher, &QObject::deleteLater);
connect(&m_timeout, &QTimer::timeout, watcher, &QObject::deleteLater);
m_timeout.start();
} else {
qWarning() << "error: extractPendingCall didn't work";
}
}