diff --git a/core/device.cpp b/core/device.cpp index f0c29f9e6..d93b3acbb 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -224,7 +224,7 @@ void Device::requestPairing() { qCDebug(KDECONNECT_CORE) << "Request pairing"; d->m_pairingHandler->requestPairing(); - Q_EMIT pairStateChanged(pairStateAsInt()); + Q_EMIT pairStateChanged(pairState()); } void Device::unpair() @@ -248,7 +248,7 @@ void Device::cancelPairing() void Device::pairingHandler_incomingPairRequest() { Q_ASSERT(d->m_pairingHandler->pairState() == PairState::RequestedByPeer); - Q_EMIT pairStateChanged(pairStateAsInt()); + Q_EMIT pairStateChanged(pairState()); } void Device::pairingHandler_pairingSuccessful() @@ -257,14 +257,14 @@ void Device::pairingHandler_pairingSuccessful() KdeConnectConfig::instance().addTrustedDevice(id(), name(), type()); KdeConnectConfig::instance().setDeviceProperty(d->m_deviceId, QStringLiteral("certificate"), QString::fromLatin1(certificate().toPem())); reloadPlugins(); // Will load/unload plugins - Q_EMIT pairStateChanged(pairStateAsInt()); + Q_EMIT pairStateChanged(pairState()); } void Device::pairingHandler_pairingFailed(const QString &errorMessage) { Q_ASSERT(d->m_pairingHandler->pairState() == PairState::NotPaired); Q_EMIT pairingFailed(errorMessage); - Q_EMIT pairStateChanged(pairStateAsInt()); + Q_EMIT pairStateChanged(pairState()); } void Device::pairingHandler_unpaired() @@ -273,7 +273,7 @@ void Device::pairingHandler_unpaired() qCDebug(KDECONNECT_CORE) << "Unpaired"; KdeConnectConfig::instance().removeTrustedDevice(id()); reloadPlugins(); // Will load/unload plugins - Q_EMIT pairStateChanged(pairStateAsInt()); + Q_EMIT pairStateChanged(pairState()); } static bool lessThan(DeviceLink *p1, DeviceLink *p2) @@ -381,11 +381,6 @@ PairState Device::pairState() const return d->m_pairingHandler->pairState(); } -int Device::pairStateAsInt() const -{ - return (int)pairState(); -} - bool Device::isPaired() const { return d->m_pairingHandler->pairState() == PairState::Paired; diff --git a/core/device.h b/core/device.h index f649638f4..366daba6a 100644 --- a/core/device.h +++ b/core/device.h @@ -30,7 +30,7 @@ class KDECONNECTCORE_EXPORT Device : public QObject Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairStateChanged) Q_PROPERTY(bool isPairRequested READ isPairRequested NOTIFY pairStateChanged) Q_PROPERTY(bool isPairRequestedByPeer READ isPairRequestedByPeer NOTIFY pairStateChanged) - Q_PROPERTY(int pairState READ pairStateAsInt NOTIFY pairStateChanged) + Q_PROPERTY(PairState pairState READ pairState NOTIFY pairStateChanged) Q_PROPERTY(QStringList supportedPlugins READ supportedPlugins NOTIFY pluginsChanged) public: @@ -76,7 +76,6 @@ public: void removeLink(DeviceLink *); PairState pairState() const; - Q_SCRIPTABLE int pairStateAsInt() const; // Hack because qdbus doesn't like enums Q_SCRIPTABLE bool isPaired() const; Q_SCRIPTABLE bool isPairRequested() const; Q_SCRIPTABLE bool isPairRequestedByPeer() const; @@ -125,7 +124,7 @@ private Q_SLOTS: Q_SIGNALS: Q_SCRIPTABLE void pluginsChanged(); Q_SCRIPTABLE void reachableChanged(bool reachable); - Q_SCRIPTABLE void pairStateChanged(int pairState); // Hack because qdbus doesn't like enums + Q_SCRIPTABLE void pairStateChanged(PairState pairState); Q_SCRIPTABLE void pairingFailed(const QString &error); Q_SCRIPTABLE void nameChanged(const QString &name); Q_SCRIPTABLE void typeChanged(const QString &type); diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index b135b257b..4c96d72ec 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -59,7 +59,7 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface : public OrgKdeKdeconnectD Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairStateChangedProxy) Q_PROPERTY(bool isPairRequested READ isPairRequested NOTIFY pairStateChangedProxy) Q_PROPERTY(bool isPairRequestedByPeer READ isPairRequestedByPeer NOTIFY pairStateChangedProxy) - Q_PROPERTY(int pairState READ pairState NOTIFY pairStateChangedProxy) + Q_PROPERTY(PairState pairState READ pairState NOTIFY pairStateChangedProxy) Q_PROPERTY(QString name READ name NOTIFY nameChangedProxy) public: @@ -71,7 +71,7 @@ public: Q_SIGNALS: void nameChangedProxy(const QString &name); - void pairStateChangedProxy(int pairState); + void pairStateChangedProxy(PairState pairState); void reachableChangedProxy(bool reachable); private: diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 5ed77385d..718d27032 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -207,9 +207,9 @@ void KdeConnectKcm::resetDeviceView() kcmUi->name_label->setText(currentDevice->name()); setWhenAvailable( - currentDevice->pairStateAsInt(), - [this](int pairStateAsInt) { - setCurrentDevicePairState(pairStateAsInt); + currentDevice->pairState(), + [this](PairState pairState) { + setCurrentDevicePairState(pairState); }, this); @@ -279,9 +279,8 @@ void KdeConnectKcm::pairingFailed(const QString &error) } -void KdeConnectKcm::setCurrentDevicePairState(int pairStateAsInt) +void KdeConnectKcm::setCurrentDevicePairState(PairState pairState) { - PairState state = (PairState)pairStateAsInt; // Hack because qdbus doesn't like enums kcmUi->accept_button->setVisible(state == PairState::RequestedByPeer); kcmUi->reject_button->setVisible(state == PairState::RequestedByPeer); kcmUi->cancel_button->setVisible(state == PairState::Requested); diff --git a/kcm/kcm.h b/kcm/kcm.h index 31e6d4504..759d084b1 100644 --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -47,7 +47,7 @@ private Q_SLOTS: void renameDone(); void setRenameMode(bool b); void resetCurrentDevice(); - void setCurrentDevicePairState(int pairStateAsInt); + void setCurrentDevicePairState(PairState pairState); void acceptPairing(); void cancelPairing();