diff --git a/core/daemon.cpp b/core/daemon.cpp index dd63c2cd9..e6949822d 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -149,11 +149,20 @@ QSet Daemon::getLinkProviders() const QStringList Daemon::linkProviders() const { - QStringList returnValue; + QString allStr = QStringLiteral("all"); + QString enabledStr = QStringLiteral("enabled"); + + QMap returnValue; + returnValue[allStr] = QStringList(); + returnValue[enabledStr] = QStringList(); + for (LinkProvider *a : std::as_const(d->m_linkProviders)) { - returnValue.append(a->name()); + returnValue[allStr].append(a->name()); + + // TODO add filtering by enabled config + returnValue[enabledStr].append(a->name()); } - return returnValue; + return returnValue[allStr]; } QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const { diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index b11c09a27..183bbda04 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -92,19 +93,30 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q } }, this); - - kcmUi.bluetoothEnabled_checkbox->setChecked(false); - + /* + setWhenAvailable( + daemon->linkProviders(), + [this](bool error, const QStringList linkProviders) { + for (int i = 0; i < linkProviders[QStringLiteral("all")].size(); ++i) { + QString linkProvider = QString(linkProviders[QStringLiteral("all")].at(i).constData()); + QListWidgetItem linkProviderItem = new QListWidgetItem(linkProvider, kcmUi.linkProviders_list); + linkProviderItem->setCheckState(Qt::Unchecked); + if(linkProviders[QStringLiteral("enabled")].contains(linkProvider)){ + linkProviderItem->setCheckState(Qt::Checked); + } + kcmUi.linkProviders_list->addItem(linkProviderItem); + } + }, + this); + */ setWhenAvailable( daemon->linkProviders(), [this](bool error, const QStringList linkProviders) { for (int i = 0; i < linkProviders.size(); ++i) { QString linkProvider = QString(linkProviders.at(i).constData()); - qDebug() << "link provider: " << linkProvider; - - if (linkProvider == QStringLiteral("BluetoothLinkProvider")) { - kcmUi.bluetoothEnabled_checkbox->setChecked(true); - } + QListWidgetItem *linkProviderItem = new QListWidgetItem(linkProvider, kcmUi.linkProviders_list); + linkProviderItem->setCheckState(Qt::Checked); + kcmUi.linkProviders_list->addItem(linkProviderItem); } }, this); diff --git a/kcm/kcm.ui b/kcm/kcm.ui index 4e9616eea..e1590e082 100644 --- a/kcm/kcm.ui +++ b/kcm/kcm.ui @@ -46,6 +46,19 @@ + + + + Qt::Horizontal + + + + 40 + 0 + + + + @@ -62,19 +75,6 @@ - - - - Qt::Orientation::Horizontal - - - - 40 - 0 - - - - @@ -109,26 +109,38 @@ - + - + 0 0 - - QQuickWidget::ResizeMode::SizeRootObjectToView + + + + + + Link Providers - - - Bluetooth Enabled + + + + 0 + 0 + - - true + + QAbstractItemView::MultiSelection + + + Placeholder + +