From b5bf26c91997c0ed11ee8a2803d7d4dabdb8d01c Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Tue, 8 Oct 2024 23:00:36 +0100 Subject: [PATCH] Refactoring --- core/daemon.cpp | 4 ++-- core/kdeconnectconfig.cpp | 10 +++------- core/kdeconnectconfig.h | 2 +- kcm/kcm.cpp | 4 ---- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/core/daemon.cpp b/core/daemon.cpp index df344a3cb..28a64fbb6 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -73,7 +73,7 @@ void Daemon::init() qCDebug(KDECONNECT_CORE) << "DBus registration complete"; auto configInstance = KdeConnectConfig::instance(); - auto status = configInstance.getLinkProviderStatus(); + auto status = configInstance.linkProviderStatus(); // Load backends if (d->m_testMode) { @@ -153,7 +153,7 @@ QSet Daemon::getLinkProviders() const QStringList Daemon::linkProviders() const { auto configInstance = KdeConnectConfig::instance(); - auto status = configInstance.getLinkProviderStatus(); + auto status = configInstance.linkProviderStatus(); QStringList returnValue; for (LinkProvider *a : std::as_const(d->m_linkProviders)) { diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp index 351789a76..e853ebbcf 100644 --- a/core/kdeconnectconfig.cpp +++ b/core/kdeconnectconfig.cpp @@ -83,14 +83,10 @@ void KdeConnectConfig::setLinkProviderStatus(const QStringList enabledProviders, d->m_config->sync(); } -QMap KdeConnectConfig::getLinkProviderStatus() +QMap KdeConnectConfig::linkProviderStatus() const { - QMap result; - - result[QStringLiteral("enabled")] = d->m_config->value(QStringLiteral("enabled_providers")).toStringList(); - result[QStringLiteral("disabled")] = d->m_config->value(QStringLiteral("disabled_providers")).toStringList(); - - return result; + return {{QStringLiteral("enabled"), d->m_config->value(QStringLiteral("enabled_providers")).toStringList()}, + {QStringLiteral("disabled"), d->m_config->value(QStringLiteral("disabled_providers")).toStringList()}}; } DeviceType KdeConnectConfig::deviceType() diff --git a/core/kdeconnectconfig.h b/core/kdeconnectconfig.h index 5cc1b256e..917e11316 100644 --- a/core/kdeconnectconfig.h +++ b/core/kdeconnectconfig.h @@ -36,7 +36,7 @@ public: void setName(const QString &name); void setLinkProviderStatus(const QStringList enabledProviders, const QStringList disabledProviders); - QMap getLinkProviderStatus(); + QMap linkProviderStatus() const; /* * Trusted devices diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 1c5375684..4be917473 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -101,7 +101,6 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q kcmUi.linkProviders_list->clear(); for (int i = 0; i < linkProviders.size(); ++i) { QStringList linkProvider = linkProviders.at(i).split(QStringLiteral("|")); - QString providerName = linkProvider.at(0); QString providerStatus = linkProvider.at(1); @@ -191,11 +190,8 @@ void KdeConnectKcm::refresh() QString providerIsEnabled = item->checkState() == Qt::Checked ? QStringLiteral("enabled") : QStringLiteral("disabled"); QString line = item->text() + QStringLiteral("|") + providerIsEnabled; providerStatusToSend.append(line); - // QMessageBox::information(widget(), QStringLiteral("thisLine"), line, QMessageBox::StandardButton::NoButton); } - // QMessageBox::information(widget(), QStringLiteral("ProviderStatus"),providerStatusToSend.join(QStringLiteral("")), - // QMessageBox::StandardButton::NoButton); daemon->setProviderStatus(providerStatusToSend); daemon->forceOnNetworkChange(); }