Merge pairingSuccessful and unpaired signals into pairingChanged(bool)

REVIEW: 124067
This commit is contained in:
Aleix Pol 2015-06-11 16:19:00 +02:00
parent a83bf73a4d
commit b592dc99a0
4 changed files with 17 additions and 40 deletions

View file

@ -226,7 +226,7 @@ void Device::unpairInternal()
m_pairStatus = Device::NotPaired;
KdeConnectConfig::instance()->removeTrustedDevice(id());
reloadPlugins(); //Will unload the plugins
Q_EMIT unpaired();
Q_EMIT pairingChanged(false);
}
void Device::pairingTimeout()
@ -440,7 +440,7 @@ void Device::setAsPaired()
reloadPlugins(); //Will actually load the plugins
Q_EMIT pairingSuccesful();
Q_EMIT pairingChanged(true);
}

View file

@ -45,7 +45,7 @@ class KDECONNECTCORE_EXPORT Device
Q_PROPERTY(QString iconName READ iconName CONSTANT)
Q_PROPERTY(QString statusIconName READ statusIconName)
Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableStatusChanged)
Q_PROPERTY(bool isPaired READ isPaired)
Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChanged)
enum PairStatus {
NotPaired,
@ -123,9 +123,8 @@ private Q_SLOTS:
Q_SIGNALS:
Q_SCRIPTABLE void reachableStatusChanged();
Q_SCRIPTABLE void pluginsChanged();
Q_SCRIPTABLE void pairingSuccesful();
Q_SCRIPTABLE void pairingChanged(bool paired);
Q_SCRIPTABLE void pairingFailed(const QString& error);
Q_SCRIPTABLE void unpaired();
Q_SCRIPTABLE void nameChanged(const QString& name);
private: //Methods
@ -134,6 +133,7 @@ private: //Methods
void unpairInternal();
void setAsPaired();
bool sendOwnPublicKey();
void setPairing(PairStatus newPairing);
private: //Fields (TODO: dPointer!)
const QString m_deviceId;

View file

@ -140,12 +140,10 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
kcmUi->noDevicePlaceholder->setVisible(false);
if (currentDevice) {
disconnect(currentDevice,SIGNAL(pairingSuccesful()),
this, SLOT(pairingSuccesful()));
disconnect(currentDevice,SIGNAL(pairingChanged(bool)),
this, SLOT(pairingChanged(bool)));
disconnect(currentDevice,SIGNAL(pairingFailed(QString)),
this, SLOT(pairingFailed(QString)));
disconnect(currentDevice,SIGNAL(unpaired()),
this, SLOT(unpaired()));
}
//Store previous device config
@ -194,12 +192,10 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
kcmUi->name_label->setText(currentDevice->name());
kcmUi->status_label->setText(currentDevice->isPaired()? i18n("(paired)") : i18n("(unpaired)"));
connect(currentDevice,SIGNAL(pairingSuccesful()),
this, SLOT(pairingSuccesful()));
connect(currentDevice,SIGNAL(pairingChanged(bool)),
this, SLOT(pairingChanged(bool)));
connect(currentDevice,SIGNAL(pairingFailed(QString)),
this, SLOT(pairingFailed(QString)));
connect(currentDevice,SIGNAL(unpaired()),
this, SLOT(unpaired()));
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile());
@ -234,46 +230,28 @@ void KdeConnectKcm::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)
{
if (sender() != 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)"));
pairingChanged(false);
kcmUi->messages->setText(i18n("Error trying to pair: %1",error));
kcmUi->messages->animatedShow();
}
void KdeConnectKcm::pairingSuccesful()
void KdeConnectKcm::pairingChanged(bool pairing)
{
DeviceDbusInterface* senderDevice = (DeviceDbusInterface*) sender();
devicesModel->deviceStatusChanged(senderDevice->id());
if (senderDevice != currentDevice) return;
kcmUi->pair_button->setVisible(false);
kcmUi->unpair_button->setVisible(true);
kcmUi->progressBar->setVisible(false);
kcmUi->ping_button->setVisible(true);
kcmUi->status_label->setText(i18n("(paired)"));
kcmUi->pair_button->setVisible(!pairing);
kcmUi->unpair_button->setVisible(pairing);
kcmUi->progressBar->setVisible(!pairing);
kcmUi->ping_button->setVisible(pairing);
kcmUi->status_label->setText(pairing ? i18n("(paired)") : i18n("(unpaired)"));
}
void KdeConnectKcm::pluginsConfigChanged()

View file

@ -53,9 +53,8 @@ private Q_SLOTS:
void pluginsConfigChanged();
void sendPing();
void resetSelection();
void pairingSuccesful();
void pairingChanged(bool);
void pairingFailed(const QString& error);
void unpaired();
void refresh();
void renameShow();
void renameDone();