Show the announcedName in the qml app
Makes it possible to display it and modify it Introduces a DBusProperty component that can be used if we don't want to go through the QtDBus property generation hell.
This commit is contained in:
parent
b69247b4e5
commit
d9e7f308c2
7 changed files with 96 additions and 1 deletions
|
@ -50,6 +50,24 @@ Kirigami.ApplicationWindow
|
||||||
titleIcon: "kdeconnect"
|
titleIcon: "kdeconnect"
|
||||||
// bannerImageSource: "/home/apol/devel/kde5/share/wallpapers/Next/contents/images/1024x768.png"
|
// bannerImageSource: "/home/apol/devel/kde5/share/wallpapers/Next/contents/images/1024x768.png"
|
||||||
|
|
||||||
|
topContent: [
|
||||||
|
TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
DBusProperty {
|
||||||
|
id: announcedNameProperty
|
||||||
|
object: DaemonDbusInterface
|
||||||
|
read: "announcedName"
|
||||||
|
defaultValue: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
text: announcedNameProperty.value
|
||||||
|
onAccepted: {
|
||||||
|
DaemonDbusInterface.setAnnouncedName(text)
|
||||||
|
text = Qt.binding(function() {return announcedNameProperty.value})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
property var objects: [findDevicesAction]
|
property var objects: [findDevicesAction]
|
||||||
Instantiator {
|
Instantiator {
|
||||||
model: DevicesSortProxyModel {
|
model: DevicesSortProxyModel {
|
||||||
|
|
|
@ -214,6 +214,7 @@ void Daemon::setAnnouncedName(const QString &name)
|
||||||
qCDebug(KDECONNECT_CORE()) << "Announcing name";
|
qCDebug(KDECONNECT_CORE()) << "Announcing name";
|
||||||
KdeConnectConfig::instance()->setName(name);
|
KdeConnectConfig::instance()->setName(name);
|
||||||
forceOnNetworkChange();
|
forceOnNetworkChange();
|
||||||
|
Q_EMIT announcedNameChanged(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Daemon::announcedName()
|
QString Daemon::announcedName()
|
||||||
|
|
|
@ -73,6 +73,7 @@ Q_SIGNALS:
|
||||||
Q_SCRIPTABLE void deviceAdded(const QString& id);
|
Q_SCRIPTABLE void deviceAdded(const QString& id);
|
||||||
Q_SCRIPTABLE void deviceRemoved(const QString& id); //Note that paired devices will never be removed
|
Q_SCRIPTABLE void deviceRemoved(const QString& id); //Note that paired devices will never be removed
|
||||||
Q_SCRIPTABLE void deviceVisibilityChanged(const QString& id, bool isVisible);
|
Q_SCRIPTABLE void deviceVisibilityChanged(const QString& id, bool isVisible);
|
||||||
|
Q_SCRIPTABLE void announcedNameChanged(const QString &announcedName);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl);
|
void onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl);
|
||||||
|
|
|
@ -21,4 +21,4 @@ target_link_libraries(kdeconnectdeclarativeplugin
|
||||||
kdeconnectinterfaces
|
kdeconnectinterfaces
|
||||||
)
|
)
|
||||||
install(TARGETS kdeconnectdeclarativeplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect)
|
install(TARGETS kdeconnectdeclarativeplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect)
|
||||||
install(FILES qmldir qml/PluginChecker.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect)
|
install(FILES qmldir qml/PluginChecker.qml qml/DBusProperty.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/kdeconnect)
|
||||||
|
|
|
@ -86,6 +86,11 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
|
||||||
qmlRegisterUncreatableType<LockDeviceDbusInterface>(uri, 1, 0, "LockDeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
qmlRegisterUncreatableType<LockDeviceDbusInterface>(uri, 1, 0, "LockDeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
||||||
qmlRegisterUncreatableType<FindMyPhoneDeviceDbusInterface>(uri, 1, 0, "FindMyPhoneDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
qmlRegisterUncreatableType<FindMyPhoneDeviceDbusInterface>(uri, 1, 0, "FindMyPhoneDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
||||||
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
|
||||||
|
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface",
|
||||||
|
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||||
|
return new DaemonDbusInterface;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri)
|
void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri)
|
||||||
|
|
69
plasmoid/declarativeplugin/qml/DBusProperty.qml
Normal file
69
plasmoid/declarativeplugin/qml/DBusProperty.qml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of
|
||||||
|
* the License or (at your option) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
onSuccess: {
|
||||||
|
prop._value = result;
|
||||||
|
}
|
||||||
|
onError: {
|
||||||
|
console.warn("failed call", object, read, write, change)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
response.setPendingCall(object[read]());
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,3 +2,4 @@ module org.kde.kdeconnect
|
||||||
plugin kdeconnectdeclarativeplugin
|
plugin kdeconnectdeclarativeplugin
|
||||||
|
|
||||||
PluginChecker 1.0 PluginChecker.qml
|
PluginChecker 1.0 PluginChecker.qml
|
||||||
|
DBusProperty 1.0 DBusProperty.qml
|
||||||
|
|
Loading…
Reference in a new issue