diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-08 12:00:05 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-11 23:30:05 +0200 |
commit | 3f5d27bfda7b6d486d20869b6ce4a4362087d0c9 (patch) | |
tree | 7a9767f15d6f8298bdf84bb721a204f9cf2128e5 /src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp | |
parent | d6cd1a3c2b6d2d67ba58673b9c3dfc35784f0bc4 (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/evdevmouse/qevdevmousemanager.cpp')
-rw-r--r-- | src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 038ff7db43..7abca215da 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -167,8 +167,7 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode) connect(handler, &QEvdevMouseHandler::handleWheelEvent, this, &QEvdevMouseManager::handleWheelEvent); m_mice.insert(deviceNode, handler); - QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( - QInputDeviceManager::DeviceTypePointer, m_mice.count()); + updateDeviceCount(); } else { qWarning("evdevmouse: Failed to open mouse device %ls", qUtf16Printable(deviceNode)); } @@ -180,10 +179,15 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode) qCDebug(qLcEvdevMouse, "Removing mouse at %ls", qUtf16Printable(deviceNode)); QEvdevMouseHandler *handler = m_mice.value(deviceNode); m_mice.remove(deviceNode); - QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( - QInputDeviceManager::DeviceTypePointer, m_mice.count()); + updateDeviceCount(); delete handler; } } +void QEvdevMouseManager::updateDeviceCount() +{ + QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( + QInputDeviceManager::DeviceTypePointer, m_mice.count()); +} + QT_END_NAMESPACE |