Set the device's announcedName when it's available
No need to block on it
This commit is contained in:
parent
8c9253440d
commit
c822ef8104
3 changed files with 16 additions and 14 deletions
|
@ -22,18 +22,6 @@
|
|||
#include <QFileDialog>
|
||||
#include <KLocalizedString>
|
||||
|
||||
template <typename T, typename W>
|
||||
static void setWhenAvailable(const QDBusPendingReply<T> &pending, W func, QObject* parent)
|
||||
{
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, parent);
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||
parent, [func](QDBusPendingCallWatcher* watcher) {
|
||||
watcher->deleteLater();
|
||||
QDBusPendingReply<T> reply = *watcher;
|
||||
func(reply.value());
|
||||
});
|
||||
}
|
||||
|
||||
class BatteryAction : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -180,4 +180,16 @@ public:
|
|||
~RemoteCommandsDbusInterface() override;
|
||||
};
|
||||
|
||||
template <typename T, typename W>
|
||||
static void setWhenAvailable(const QDBusPendingReply<T> &pending, W func, QObject* parent)
|
||||
{
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, parent);
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||
parent, [func](QDBusPendingCallWatcher* watcher) {
|
||||
watcher->deleteLater();
|
||||
QDBusPendingReply<T> reply = *watcher;
|
||||
func(reply.value());
|
||||
});
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -79,8 +79,10 @@ KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
|
|||
kcmUi->noDeviceLinks->setWordWrap(false);
|
||||
QTimer::singleShot(0, [this] { kcmUi->noDeviceLinks->setWordWrap(true); });
|
||||
|
||||
kcmUi->rename_label->setText(daemon->announcedName());
|
||||
kcmUi->rename_edit->setText(daemon->announcedName());
|
||||
setWhenAvailable(daemon->announcedName(), [this](const QString& announcedName) {
|
||||
kcmUi->rename_label->setText(announcedName);
|
||||
kcmUi->rename_edit->setText(announcedName);
|
||||
}, this);
|
||||
connect(daemon, SIGNAL(announcedNameChanged(QString)),
|
||||
kcmUi->rename_edit, SLOT(setText(QString)));
|
||||
connect(daemon, SIGNAL(announcedNameChanged(QString)),
|
||||
|
|
Loading…
Reference in a new issue