2016-08-21 18:38:15 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2016-08-21 18:38:15 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2016-08-21 18:38:15 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQml 2.2
|
|
|
|
import org.kde.kdeconnect 1.0
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: prop
|
|
|
|
property QtObject object: null
|
|
|
|
property string read
|
|
|
|
property string change: read+"Changed"
|
|
|
|
|
|
|
|
Component.onCompleted: get();
|
|
|
|
|
|
|
|
onChangeChanged: {
|
|
|
|
if (object) {
|
|
|
|
var theSignal = object[change];
|
|
|
|
if (theSignal) {
|
|
|
|
theSignal.connect(valueReceived);
|
|
|
|
} else {
|
|
|
|
console.warn("couldn't find signal", change, "for", object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function valueReceived(val) {
|
|
|
|
if (!val) {
|
|
|
|
get();
|
|
|
|
} else {
|
|
|
|
_value = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var defaultValue
|
|
|
|
property var _value: defaultValue
|
|
|
|
readonly property var value: _value
|
|
|
|
|
|
|
|
readonly property var v: DBusAsyncResponse {
|
|
|
|
id: response
|
|
|
|
autoDelete: false
|
2023-04-29 14:54:38 +01:00
|
|
|
onSuccess: result => {
|
2016-08-21 18:38:15 +01:00
|
|
|
prop._value = result;
|
|
|
|
}
|
2023-04-29 14:54:38 +01:00
|
|
|
onError: message => {
|
2024-04-21 16:10:14 +01:00
|
|
|
console.warn("failed call", prop.object, prop.read, prop.change, message)
|
2016-08-21 18:38:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get() {
|
|
|
|
response.setPendingCall(object[read]());
|
|
|
|
}
|
|
|
|
}
|