summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevtablet
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-08 12:00:05 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-06-11 23:30:05 +0200
commit3f5d27bfda7b6d486d20869b6ce4a4362087d0c9 (patch)
tree7a9767f15d6f8298bdf84bb721a204f9cf2128e5 /src/platformsupport/input/evdevtablet
parentd6cd1a3c2b6d2d67ba58673b9c3dfc35784f0bc4 (diff)
QEvdev: Extract Method updateDeviceCount()
The code is noisy and repeats, so wrap it in a function. Change-Id: I5e6e924e22b0bc631eb8176de96c49066b1c9029 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/platformsupport/input/evdevtablet')
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp12
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
index da4b6e5172..eedde9a96e 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
@@ -109,8 +109,7 @@ void QEvdevTabletManager::addDevice(const QString &deviceNode)
handler = new QEvdevTabletHandlerThread(deviceNode, m_spec);
if (handler) {
m_activeDevices.insert(deviceNode, handler);
- QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
- QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());
+ updateDeviceCount();
} else {
qWarning("evdevtablet: Failed to open tablet device %ls", qUtf16Printable(deviceNode));
}
@@ -122,10 +121,15 @@ void QEvdevTabletManager::removeDevice(const QString &deviceNode)
qCDebug(qLcEvdevTablet, "Removing device at %ls", qUtf16Printable(deviceNode));
QEvdevTabletHandlerThread *handler = m_activeDevices.value(deviceNode);
m_activeDevices.remove(deviceNode);
- QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
- QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());
+ updateDeviceCount();
delete handler;
}
}
+void QEvdevTabletManager::updateDeviceCount()
+{
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
index b598156e52..5178e167b0 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
@@ -70,6 +70,8 @@ public:
void removeDevice(const QString &deviceNode);
private:
+ void updateDeviceCount();
+
QString m_spec;
QDeviceDiscovery *m_deviceDiscovery;
QHash<QString, QEvdevTabletHandlerThread *> m_activeDevices;