OK, so this builds; but doesn't return the right type now. Untested if

the UI does what we want
This commit is contained in:
Rob Emery 2024-10-05 14:40:38 +01:00 committed by Carl Schwan
parent 837c2af9bf
commit 0bb9c8e294
No known key found for this signature in database
GPG key ID: 02325448204E452A
3 changed files with 66 additions and 33 deletions

View file

@ -149,11 +149,20 @@ QSet<LinkProvider *> Daemon::getLinkProviders() const
QStringList Daemon::linkProviders() const
{
QStringList returnValue;
QString allStr = QStringLiteral("all");
QString enabledStr = QStringLiteral("enabled");
QMap<QString, QStringList> 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
{

View file

@ -12,6 +12,7 @@
#include <KLocalizedString>
#include <KPluginFactory>
#include <KPluginMetaData>
#include <QtWidgets/QListView>
#include <kcmutils_version.h>
#include <QQmlContext>
@ -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);

View file

@ -46,6 +46,19 @@
</property>
<item>
<layout class="QHBoxLayout" name="rename_group_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="rename_label">
<property name="font">
@ -62,19 +75,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="renameShow_button">
<property name="text">
@ -109,26 +109,38 @@
</layout>
</item>
<item>
<widget class="QQuickWidget" name="list_quick_widget">
<widget class="QListView" name="deviceList">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="resizeMode">
<enum>QQuickWidget::ResizeMode::SizeRootObjectToView</enum>
</widget>
</item>
<item>
<widget class="QLabel" name="linkProvider_label">
<property name="text">
<string>Link Providers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="bluetoothEnabled_checkbox">
<property name="text">
<string>Bluetooth Enabled</string>
<widget class="QListWidget" name="linkProviders_list">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="checked">
<bool>true</bool>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<item>
<property name="text">
<string>Placeholder</string>
</property>
</item>
</widget>
</item>
<item>