Use asynchronous calls to the device interface when possible
Summary: Use setWhenAvailable for isTrusted calls Just deal with the pairing buttons state only once. Unify semantics (paired vs trusted) Reviewers: albertvaka, #kde_connect Reviewed By: albertvaka, #kde_connect Differential Revision: https://phabricator.kde.org/D4125
This commit is contained in:
parent
07b191ca71
commit
b947ef6b60
2 changed files with 14 additions and 17 deletions
30
kcm/kcm.cpp
30
kcm/kcm.cpp
|
@ -184,16 +184,6 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
|||
}
|
||||
|
||||
kcmUi->messages->setVisible(false);
|
||||
kcmUi->progressBar->setVisible(false);
|
||||
if (currentDevice->isTrusted()) {
|
||||
kcmUi->unpair_button->setVisible(true);
|
||||
kcmUi->pair_button->setVisible(false);
|
||||
kcmUi->ping_button->setVisible(true);
|
||||
} else {
|
||||
kcmUi->unpair_button->setVisible(false);
|
||||
kcmUi->pair_button->setVisible(true);
|
||||
kcmUi->ping_button->setVisible(false);
|
||||
}
|
||||
resetDeviceView();
|
||||
|
||||
connect(currentDevice, SIGNAL(pluginsChanged()), this, SLOT(resetCurrentDevice()));
|
||||
|
@ -220,7 +210,9 @@ void KdeConnectKcm::resetDeviceView()
|
|||
kcmUi->pluginSelector->setConfigurationArguments(QStringList(currentDevice->id()));
|
||||
|
||||
kcmUi->name_label->setText(currentDevice->name());
|
||||
kcmUi->status_label->setText(currentDevice->isTrusted()? i18n("(trusted)") : i18n("(not trusted)"));
|
||||
setWhenAvailable(currentDevice->isTrusted(), [this](bool trusted) {
|
||||
setCurrentDeviceTrusted(trusted);
|
||||
}, this);
|
||||
|
||||
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")));
|
||||
QList<KPluginInfo> availablePluginInfo;
|
||||
|
@ -272,16 +264,20 @@ void KdeConnectKcm::pairingFailed(const QString& error)
|
|||
kcmUi->messages->animatedShow();
|
||||
}
|
||||
|
||||
void KdeConnectKcm::trustedChanged(bool paired)
|
||||
void KdeConnectKcm::trustedChanged(bool trusted)
|
||||
{
|
||||
DeviceDbusInterface* senderDevice = (DeviceDbusInterface*) sender();
|
||||
if (senderDevice != currentDevice) return;
|
||||
if (senderDevice == currentDevice)
|
||||
setCurrentDeviceTrusted(trusted);
|
||||
}
|
||||
|
||||
kcmUi->pair_button->setVisible(!paired);
|
||||
kcmUi->unpair_button->setVisible(paired);
|
||||
void KdeConnectKcm::setCurrentDeviceTrusted(bool trusted)
|
||||
{
|
||||
kcmUi->pair_button->setVisible(!trusted);
|
||||
kcmUi->unpair_button->setVisible(trusted);
|
||||
kcmUi->progressBar->setVisible(false);
|
||||
kcmUi->ping_button->setVisible(paired);
|
||||
kcmUi->status_label->setText(paired ? i18n("(paired)") : i18n("(unpaired)"));
|
||||
kcmUi->ping_button->setVisible(trusted);
|
||||
kcmUi->status_label->setText(trusted ? i18n("(paired)") : i18n("(not paired)"));
|
||||
}
|
||||
|
||||
void KdeConnectKcm::pluginsConfigChanged()
|
||||
|
|
|
@ -62,6 +62,7 @@ private Q_SLOTS:
|
|||
void resetCurrentDevice();
|
||||
|
||||
private:
|
||||
void setCurrentDeviceTrusted(bool trusted);
|
||||
void resetDeviceView();
|
||||
|
||||
Ui::KdeConnectKcmUi* kcmUi;
|
||||
|
|
Loading…
Reference in a new issue