diff --git a/src/debug_console.cpp b/src/debug_console.cpp index f4eb560e2f..6525d3a198 100644 --- a/src/debug_console.cpp +++ b/src/debug_console.cpp @@ -1591,29 +1591,29 @@ QModelIndex InputDeviceModel::parent(const QModelIndex &child) const return QModelIndex(); } +void InputDeviceModel::slotPropertyChanged() +{ + const auto device = static_cast(sender()); + + for (int i = 0; i < device->metaObject()->propertyCount(); ++i) { + const QMetaProperty metaProperty = device->metaObject()->property(i); + if (metaProperty.notifySignalIndex() == senderSignalIndex()) { + const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); + const QModelIndex child = index(i, 1, parent); + Q_EMIT dataChanged(child, child, QVector{Qt::DisplayRole}); + } + } +} + void InputDeviceModel::setupDeviceConnections(LibInput::Device *device) { - connect(device, &LibInput::Device::enabledChanged, this, - [this, device] { - const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); - const QModelIndex child = index(device->metaObject()->indexOfProperty("enabled"), 1, parent); - Q_EMIT dataChanged(child, child, QVector{Qt::DisplayRole}); + QMetaMethod handler = metaObject()->method(metaObject()->indexOfMethod("slotPropertyChanged()")); + for (int i = 0; i < device->metaObject()->propertyCount(); ++i) { + const QMetaProperty metaProperty = device->metaObject()->property(i); + if (metaProperty.hasNotifySignal()) { + connect(device, metaProperty.notifySignal(), this, handler); } - ); - connect(device, &LibInput::Device::leftHandedChanged, this, - [this, device] { - const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); - const QModelIndex child = index(device->metaObject()->indexOfProperty("leftHanded"), 1, parent); - Q_EMIT dataChanged(child, child, QVector{Qt::DisplayRole}); - } - ); - connect(device, &LibInput::Device::pointerAccelerationChanged, this, - [this, device] { - const QModelIndex parent = index(m_devices.indexOf(device), 0, QModelIndex()); - const QModelIndex child = index(device->metaObject()->indexOfProperty("pointerAcceleration"), 1, parent); - Q_EMIT dataChanged(child, child, QVector{Qt::DisplayRole}); - } - ); + } } QModelIndex DataSourceModel::index(int row, int column, const QModelIndex &parent) const diff --git a/src/debug_console.h b/src/debug_console.h index 810731a704..23d32ba207 100644 --- a/src/debug_console.h +++ b/src/debug_console.h @@ -181,6 +181,9 @@ public: int rowCount(const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; +private Q_SLOTS: + void slotPropertyChanged(); + private: void setupDeviceConnections(LibInput::Device *device); QVector m_devices;