mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-24 04:32:49 -05:00
KDE Connect Devices list auto updating
This commit is contained in:
parent
9828b0f67c
commit
04f3b7c18d
2 changed files with 21 additions and 0 deletions
|
@ -9,16 +9,34 @@ KdeConnectDevicesModel::KdeConnectDevicesModel(QObject *parent)
|
|||
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "deviceAdded", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "deviceRemoved", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "deviceRemoved", this, SLOT(deviceVisibilityChanged()));
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
void KdeConnectDevicesModel::updateData() {
|
||||
for (QString device : devices) {
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "reachableChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "pluginsChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "trustedChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "nameChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "hasPairingRequestsChanged", this, SLOT(updateData()));
|
||||
}
|
||||
|
||||
if (daemon->isValid()) {
|
||||
devices = daemon->call("devices", false, false).arguments().first().toStringList();
|
||||
} else {
|
||||
devices.clear();
|
||||
}
|
||||
|
||||
for (QString device : devices) {
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "reachableChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "pluginsChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "trustedChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "nameChanged", this, SLOT(updateData()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device", "hasPairingRequestsChanged", this, SLOT(updateData()));
|
||||
}
|
||||
|
||||
this->dataChanged(this->index(0), this->index(this->rowCount()));
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,14 @@ void KdeConnectWidget::kdeConnectGone() {
|
|||
devicesModel->updateData();
|
||||
ui->announcedName->setText(tr("KDE Connect is not running"));
|
||||
ui->panes->setCurrentIndex(5);
|
||||
ui->devicesView->clearSelection();
|
||||
}
|
||||
|
||||
void KdeConnectWidget::selectedDeviceChanged(QModelIndex current, QModelIndex previous) {
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (currentId != "") {
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "reachableChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "pluginsChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "trustedChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().disconnect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "nameChanged", this, SLOT(updateCurrentDevice()));
|
||||
|
@ -62,6 +64,7 @@ void KdeConnectWidget::selectedDeviceChanged(QModelIndex current, QModelIndex pr
|
|||
ui->panes->setCurrentIndex(1);
|
||||
currentId = current.data(Qt::UserRole + 1).toString();
|
||||
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "reachableChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "pluginsChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "trustedChanged", this, SLOT(updateCurrentDevice()));
|
||||
QDBusConnection::sessionBus().connect("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + currentId, "org.kde.kdeconnect.device", "nameChanged", this, SLOT(updateCurrentDevice()));
|
||||
|
|
Loading…
Add table
Reference in a new issue