mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
Instead of getting all devices and filtering them, we can now ask KWin for a list of devices of a certain kind. This reduces DBus traffic to a single call on creation of the model. A custom filter can still be provided to e.g. narrow down pointer to touchpad only. We still have to introspect the device when it gets added to see whether it is relevant but that's just a single additional call compared to the ones we did initially. Also puts it in a namespace to avoid future clashes of "InputDevice" in the KCMs.
27 lines
898 B
C++
27 lines
898 B
C++
/**
|
|
* SPDX-FileCopyrightText: 2025 Nicolas Fella <nicolas.fella@gmx.de>
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
*/
|
|
|
|
#include "touchscreenmoduledata.h"
|
|
|
|
#include "devicesmodel.h"
|
|
|
|
TouchscreenModuleData::TouchscreenModuleData(QObject *parent)
|
|
: KCModuleData(parent)
|
|
, m_devices(new KWinDevices::DevicesModel(KWinDevices::DevicesModel::Kind::Touch, {}, this))
|
|
{
|
|
connect(m_devices, &QAbstractItemModel::rowsInserted, this, &TouchscreenModuleData::updateRelevance);
|
|
connect(m_devices, &QAbstractItemModel::rowsRemoved, this, &TouchscreenModuleData::updateRelevance);
|
|
connect(m_devices, &QAbstractItemModel::modelReset, this, &TouchscreenModuleData::updateRelevance);
|
|
updateRelevance();
|
|
}
|
|
|
|
void TouchscreenModuleData::updateRelevance()
|
|
{
|
|
bool relevant = m_devices->rowCount(QModelIndex()) > 0;
|
|
setRelevant(relevant);
|
|
}
|
|
|
|
#include "moc_touchscreenmoduledata.cpp"
|