diff --git a/indicator/deviceindicator.cpp b/indicator/deviceindicator.cpp index bda4ec512..986eca0f9 100644 --- a/indicator/deviceindicator.cpp +++ b/indicator/deviceindicator.cpp @@ -31,9 +31,9 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) addAction(battery); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_battery")), - [battery](bool available) { - battery->setVisible(available); - battery->setDisabled(available); + [battery](bool error, bool available) { + battery->setVisible(available && !error); + battery->setDisabled(true); }, this); @@ -41,9 +41,9 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) addAction(connectivity); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_connectivity_report")), - [connectivity](bool available) { - connectivity->setVisible(available); - connectivity->setDisabled(available); + [connectivity](bool error, bool available) { + connectivity->setVisible(available && !error); + connectivity->setDisabled(true); }, this); @@ -58,8 +58,8 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) }); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_sftp")), - [browse](bool available) { - browse->setVisible(available); + [browse](bool error, bool available) { + browse->setVisible(available && !error); }, this); @@ -72,8 +72,8 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) }); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_clipboard")), - [clipboard](bool available) { - clipboard->setVisible(available); + [clipboard](bool error, bool available) { + clipboard->setVisible(available && !error); }, this); @@ -86,8 +86,8 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) }); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_findmyphone")), - [findDevice](bool available) { - findDevice->setVisible(available); + [findDevice](bool error, bool available) { + findDevice->setVisible(available && !error); }, this); @@ -106,8 +106,8 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) }); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_share")), - [sendFile](bool available) { - sendFile->setVisible(available); + [sendFile](bool error, bool available) { + sendFile->setVisible(available && !error); }, this); @@ -120,8 +120,8 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) }); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_sms")), - [smsapp](bool available) { - smsapp->setVisible(available); + [smsapp](bool error, bool available) { + smsapp->setVisible(available && !error); }, this); } @@ -135,11 +135,12 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) addAction(menuAction); setWhenAvailable( device->hasPlugin(QStringLiteral("kdeconnect_remotecommands")), - [this, remoteCommandsMenu, menuAction](bool available) { - menuAction->setVisible(available); + [this, remoteCommandsMenu, menuAction](bool error, bool available) { + menuAction->setVisible(available && !error); - if (!available) + if (!available || error) { return; + } const auto cmds = QJsonDocument::fromJson(m_remoteCommandsInterface->commands()).object(); diff --git a/interfaces/dbushelpers.h b/interfaces/dbushelpers.h index 00401ee64..e4764e17f 100644 --- a/interfaces/dbushelpers.h +++ b/interfaces/dbushelpers.h @@ -38,7 +38,7 @@ static void setWhenAvailable(const QDBusPendingReply &pending, W func, QObjec QObject::connect(watcher, &QDBusPendingCallWatcher::finished, parent, [func](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); QDBusPendingReply reply = *watcher; - func(reply.value()); + func(reply.isError(), reply.value()); }); } diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 886c8cac6..4cd9add52 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -51,9 +51,14 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q setWhenAvailable( daemon->announcedName(), - [this](const QString &announcedName) { - kcmUi.rename_label->setText(announcedName); - kcmUi.rename_edit->setText(announcedName); + [this](bool error, const QString &announcedName) { + kcmUi.renameShow_button->setEnabled(!error); + if (error) { + kcmUi.rename_label->setText(i18n("Error: KDE Connect is not running")); + } else { + kcmUi.rename_label->setText(announcedName); + kcmUi.rename_edit->setText(announcedName); + } }, this); connect(daemon, &DaemonDbusInterface::announcedNameChanged, kcmUi.rename_edit, &QLineEdit::setText); @@ -185,8 +190,10 @@ void KdeConnectKcm::resetDeviceView() kcmUi.name_label->setText(currentDevice->name()); setWhenAvailable( currentDevice->pairStateAsInt(), - [this](int pairStateAsInt) { - setCurrentDevicePairState(pairStateAsInt); + [this](bool error, int pairStateAsInt) { + if (!error) { + setCurrentDevicePairState(pairStateAsInt); + } }, this); diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index 95c213de9..460306bad 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -101,8 +101,11 @@ void ConversationListModel::prepareConversationsList() setWhenAvailable( validThreadIDsReply, - [this](const QVariantList &convs) { + [this](bool error, const QVariantList &convs) { clear(); // If we clear before we receive the reply, there might be a (several second) visual gap! + if (error) { + return; + } for (const QVariant &headMessage : convs) { createRowFromMessage(qdbus_cast(headMessage)); }