Merge pairingSuccessful and unpaired signals into pairingChanged(bool)
REVIEW: 124067
This commit is contained in:
parent
a83bf73a4d
commit
b592dc99a0
4 changed files with 17 additions and 40 deletions
|
@ -226,7 +226,7 @@ void Device::unpairInternal()
|
||||||
m_pairStatus = Device::NotPaired;
|
m_pairStatus = Device::NotPaired;
|
||||||
KdeConnectConfig::instance()->removeTrustedDevice(id());
|
KdeConnectConfig::instance()->removeTrustedDevice(id());
|
||||||
reloadPlugins(); //Will unload the plugins
|
reloadPlugins(); //Will unload the plugins
|
||||||
Q_EMIT unpaired();
|
Q_EMIT pairingChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::pairingTimeout()
|
void Device::pairingTimeout()
|
||||||
|
@ -440,7 +440,7 @@ void Device::setAsPaired()
|
||||||
|
|
||||||
reloadPlugins(); //Will actually load the plugins
|
reloadPlugins(); //Will actually load the plugins
|
||||||
|
|
||||||
Q_EMIT pairingSuccesful();
|
Q_EMIT pairingChanged(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class KDECONNECTCORE_EXPORT Device
|
||||||
Q_PROPERTY(QString iconName READ iconName CONSTANT)
|
Q_PROPERTY(QString iconName READ iconName CONSTANT)
|
||||||
Q_PROPERTY(QString statusIconName READ statusIconName)
|
Q_PROPERTY(QString statusIconName READ statusIconName)
|
||||||
Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableStatusChanged)
|
Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableStatusChanged)
|
||||||
Q_PROPERTY(bool isPaired READ isPaired)
|
Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChanged)
|
||||||
|
|
||||||
enum PairStatus {
|
enum PairStatus {
|
||||||
NotPaired,
|
NotPaired,
|
||||||
|
@ -123,9 +123,8 @@ private Q_SLOTS:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
Q_SCRIPTABLE void reachableStatusChanged();
|
Q_SCRIPTABLE void reachableStatusChanged();
|
||||||
Q_SCRIPTABLE void pluginsChanged();
|
Q_SCRIPTABLE void pluginsChanged();
|
||||||
Q_SCRIPTABLE void pairingSuccesful();
|
Q_SCRIPTABLE void pairingChanged(bool paired);
|
||||||
Q_SCRIPTABLE void pairingFailed(const QString& error);
|
Q_SCRIPTABLE void pairingFailed(const QString& error);
|
||||||
Q_SCRIPTABLE void unpaired();
|
|
||||||
Q_SCRIPTABLE void nameChanged(const QString& name);
|
Q_SCRIPTABLE void nameChanged(const QString& name);
|
||||||
|
|
||||||
private: //Methods
|
private: //Methods
|
||||||
|
@ -134,6 +133,7 @@ private: //Methods
|
||||||
void unpairInternal();
|
void unpairInternal();
|
||||||
void setAsPaired();
|
void setAsPaired();
|
||||||
bool sendOwnPublicKey();
|
bool sendOwnPublicKey();
|
||||||
|
void setPairing(PairStatus newPairing);
|
||||||
|
|
||||||
private: //Fields (TODO: dPointer!)
|
private: //Fields (TODO: dPointer!)
|
||||||
const QString m_deviceId;
|
const QString m_deviceId;
|
||||||
|
|
44
kcm/kcm.cpp
44
kcm/kcm.cpp
|
@ -140,12 +140,10 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
kcmUi->noDevicePlaceholder->setVisible(false);
|
kcmUi->noDevicePlaceholder->setVisible(false);
|
||||||
|
|
||||||
if (currentDevice) {
|
if (currentDevice) {
|
||||||
disconnect(currentDevice,SIGNAL(pairingSuccesful()),
|
disconnect(currentDevice,SIGNAL(pairingChanged(bool)),
|
||||||
this, SLOT(pairingSuccesful()));
|
this, SLOT(pairingChanged(bool)));
|
||||||
disconnect(currentDevice,SIGNAL(pairingFailed(QString)),
|
disconnect(currentDevice,SIGNAL(pairingFailed(QString)),
|
||||||
this, SLOT(pairingFailed(QString)));
|
this, SLOT(pairingFailed(QString)));
|
||||||
disconnect(currentDevice,SIGNAL(unpaired()),
|
|
||||||
this, SLOT(unpaired()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store previous device config
|
//Store previous device config
|
||||||
|
@ -194,12 +192,10 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
kcmUi->name_label->setText(currentDevice->name());
|
kcmUi->name_label->setText(currentDevice->name());
|
||||||
kcmUi->status_label->setText(currentDevice->isPaired()? i18n("(paired)") : i18n("(unpaired)"));
|
kcmUi->status_label->setText(currentDevice->isPaired()? i18n("(paired)") : i18n("(unpaired)"));
|
||||||
|
|
||||||
connect(currentDevice,SIGNAL(pairingSuccesful()),
|
connect(currentDevice,SIGNAL(pairingChanged(bool)),
|
||||||
this, SLOT(pairingSuccesful()));
|
this, SLOT(pairingChanged(bool)));
|
||||||
connect(currentDevice,SIGNAL(pairingFailed(QString)),
|
connect(currentDevice,SIGNAL(pairingFailed(QString)),
|
||||||
this, SLOT(pairingFailed(QString)));
|
this, SLOT(pairingFailed(QString)));
|
||||||
connect(currentDevice,SIGNAL(unpaired()),
|
|
||||||
this, SLOT(unpaired()));
|
|
||||||
|
|
||||||
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
|
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
|
||||||
KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile());
|
KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile());
|
||||||
|
@ -234,46 +230,28 @@ void KdeConnectKcm::unpair()
|
||||||
currentDevice->unpair();
|
currentDevice->unpair();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::unpaired()
|
|
||||||
{
|
|
||||||
DeviceDbusInterface* senderDevice = (DeviceDbusInterface*) sender();
|
|
||||||
devicesModel->deviceStatusChanged(senderDevice->id());
|
|
||||||
|
|
||||||
if (senderDevice != currentDevice) return;
|
|
||||||
|
|
||||||
kcmUi->pair_button->setVisible(true);
|
|
||||||
kcmUi->unpair_button->setVisible(false);
|
|
||||||
kcmUi->progressBar->setVisible(false);
|
|
||||||
kcmUi->ping_button->setVisible(false);
|
|
||||||
kcmUi->status_label->setText(i18n("(unpaired)"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void KdeConnectKcm::pairingFailed(const QString& error)
|
void KdeConnectKcm::pairingFailed(const QString& error)
|
||||||
{
|
{
|
||||||
if (sender() != currentDevice) return;
|
if (sender() != currentDevice) return;
|
||||||
|
|
||||||
kcmUi->pair_button->setVisible(true);
|
pairingChanged(false);
|
||||||
kcmUi->unpair_button->setVisible(false);
|
|
||||||
kcmUi->progressBar->setVisible(false);
|
|
||||||
kcmUi->ping_button->setVisible(false);
|
|
||||||
kcmUi->status_label->setText(i18n("(unpaired)"));
|
|
||||||
|
|
||||||
kcmUi->messages->setText(i18n("Error trying to pair: %1",error));
|
kcmUi->messages->setText(i18n("Error trying to pair: %1",error));
|
||||||
kcmUi->messages->animatedShow();
|
kcmUi->messages->animatedShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::pairingSuccesful()
|
void KdeConnectKcm::pairingChanged(bool pairing)
|
||||||
{
|
{
|
||||||
DeviceDbusInterface* senderDevice = (DeviceDbusInterface*) sender();
|
DeviceDbusInterface* senderDevice = (DeviceDbusInterface*) sender();
|
||||||
devicesModel->deviceStatusChanged(senderDevice->id());
|
devicesModel->deviceStatusChanged(senderDevice->id());
|
||||||
|
|
||||||
if (senderDevice != currentDevice) return;
|
if (senderDevice != currentDevice) return;
|
||||||
|
|
||||||
kcmUi->pair_button->setVisible(false);
|
kcmUi->pair_button->setVisible(!pairing);
|
||||||
kcmUi->unpair_button->setVisible(true);
|
kcmUi->unpair_button->setVisible(pairing);
|
||||||
kcmUi->progressBar->setVisible(false);
|
kcmUi->progressBar->setVisible(!pairing);
|
||||||
kcmUi->ping_button->setVisible(true);
|
kcmUi->ping_button->setVisible(pairing);
|
||||||
kcmUi->status_label->setText(i18n("(paired)"));
|
kcmUi->status_label->setText(pairing ? i18n("(paired)") : i18n("(unpaired)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::pluginsConfigChanged()
|
void KdeConnectKcm::pluginsConfigChanged()
|
||||||
|
|
|
@ -53,9 +53,8 @@ private Q_SLOTS:
|
||||||
void pluginsConfigChanged();
|
void pluginsConfigChanged();
|
||||||
void sendPing();
|
void sendPing();
|
||||||
void resetSelection();
|
void resetSelection();
|
||||||
void pairingSuccesful();
|
void pairingChanged(bool);
|
||||||
void pairingFailed(const QString& error);
|
void pairingFailed(const QString& error);
|
||||||
void unpaired();
|
|
||||||
void refresh();
|
void refresh();
|
||||||
void renameShow();
|
void renameShow();
|
||||||
void renameDone();
|
void renameDone();
|
||||||
|
|
Loading…
Reference in a new issue