qevdevtabletmanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qevdevtabletmanager_p.h"-
41#include "qevdevtablethandler_p.h"-
42-
43#include <QStringList>-
44#include <QGuiApplication>-
45#include <QLoggingCategory>-
46#include <QtPlatformSupport/private/qdevicediscovery_p.h>-
47#include <private/qguiapplication_p.h>-
48#include <private/qinputdevicemanager_p_p.h>-
49-
50QT_BEGIN_NAMESPACE-
51-
52Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTablet)-
53-
54QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &specification, QObject *parent)-
55 : QObject(parent)-
56{-
57 Q_UNUSED(key);-
58-
59 if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
qEnvironmentVa..._EVDEV_DEBUG")Description
TRUEnever evaluated
FALSEnever evaluated
0
60 const_cast<QLoggingCategory &>(qLcEvdevTablet()).setEnabled(QtDebugMsg, true);
never executed: const_cast<QLoggingCategory &>(qLcEvdevTablet()).setEnabled(QtDebugMsg, true);
0
61-
62 QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TABLET_PARAMETERS"));-
63-
64 if (spec.isEmpty())
spec.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
65 spec = specification;
never executed: spec = specification;
0
66-
67 QStringList args = spec.split(QLatin1Char(':'));-
68 QStringList devices;-
69-
70 foreach (const QString &arg, args) {-
71 if (arg.startsWith(QLatin1String("/dev/"))) {
arg.startsWith...ring("/dev/"))Description
TRUEnever evaluated
FALSEnever evaluated
0
72 devices.append(arg);-
73 args.removeAll(arg);-
74 }
never executed: end of block
0
75 }
never executed: end of block
0
76-
77 // build new specification without /dev/ elements-
78 m_spec = args.join(QLatin1Char(':'));-
79-
80 foreach (const QString &device, devices)-
81 addDevice(device);
never executed: addDevice(device);
0
82-
83 // when no devices specified, use device discovery to scan and monitor-
84 if (devices.isEmpty()) {
devices.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
85 qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery";
never executed: QMessageLogger(__FILE__, 85, __PRETTY_FUNCTION__, qLcEvdevTablet().categoryName()).debug() << "evdevtablet: Using device discovery";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this);-
87 if (m_deviceDiscovery) {
m_deviceDiscoveryDescription
TRUEnever evaluated
FALSEnever evaluated
0
88 QStringList devices = m_deviceDiscovery->scanConnectedDevices();-
89 foreach (const QString &device, devices)-
90 addDevice(device);
never executed: addDevice(device);
0
91 connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));-
92 connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));-
93 }
never executed: end of block
0
94 }
never executed: end of block
0
95}
never executed: end of block
0
96-
97QEvdevTabletManager::~QEvdevTabletManager()-
98{-
99 qDeleteAll(m_activeDevices);-
100}
never executed: end of block
0
101-
102void QEvdevTabletManager::addDevice(const QString &deviceNode)-
103{-
104 qCDebug(qLcEvdevTablet) << "Adding device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 104, __PRETTY_FUNCTION__, qLcEvdevTablet().categoryName()).debug() << "Adding device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
105 QEvdevTabletHandlerThread *handler;-
106 handler = new QEvdevTabletHandlerThread(deviceNode, m_spec);-
107 if (handler) {
handlerDescription
TRUEnever evaluated
FALSEnever evaluated
0
108 m_activeDevices.insert(deviceNode, handler);-
109 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
110 QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());-
111 } else {
never executed: end of block
0
112 qWarning("evdevtablet: Failed to open tablet device %s", qPrintable(deviceNode));-
113 }
never executed: end of block
0
114}-
115-
116void QEvdevTabletManager::removeDevice(const QString &deviceNode)-
117{-
118 if (m_activeDevices.contains(deviceNode)) {
m_activeDevice...ns(deviceNode)Description
TRUEnever evaluated
FALSEnever evaluated
0
119 qCDebug(qLcEvdevTablet) << "Removing device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 119, __PRETTY_FUNCTION__, qLcEvdevTablet().categoryName()).debug() << "Removing device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 QEvdevTabletHandlerThread *handler = m_activeDevices.value(deviceNode);-
121 m_activeDevices.remove(deviceNode);-
122 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
123 QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());-
124 delete handler;-
125 }
never executed: end of block
0
126}
never executed: end of block
0
127-
128QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9