aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2020-05-08 17:36:27 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-15 07:12:32 +0000
commit7a2562aabcc8e1c4659386340956ed44bfbfa6ca (patch)
treee8371e4c5bbbdcd5ad0768608255221ebd8ed3eb
parent70102765aaeaa926bd65f4e2a192268420b85459 (diff)
Add support for QSerialPort
QSerialPort is part of Qt since Qt 5.1. PySide2 so far had no support for QSerialPort. At the same time, QSerialPort was not listed as unsupported. Task-number: PYSIDE-487 Change-Id: I88d4282a206dadf6f398c3f0e5740f02641724b6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/cmake_helpers/helpers.cmake2
-rw-r--r--sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt31
-rw-r--r--sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml56
-rw-r--r--sources/pyside2/tests/QtSerialPort/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtSerialPort/serial.py58
-rw-r--r--tools/missing_bindings.py1
6 files changed, 148 insertions, 1 deletions
diff --git a/sources/cmake_helpers/helpers.cmake b/sources/cmake_helpers/helpers.cmake
index 81b52920..49141de6 100644
--- a/sources/cmake_helpers/helpers.cmake
+++ b/sources/cmake_helpers/helpers.cmake
@@ -17,7 +17,7 @@ endmacro()
macro(collect_optional_modules)
# Collect all optional modules.
set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia
-MultimediaWidgets OpenGL OpenGLFunctions Positioning Location Qml Quick QuickWidgets RemoteObjects Scxml Script ScriptTools Sensors TextToSpeech Charts Svg DataVisualization)
+MultimediaWidgets OpenGL OpenGLFunctions Positioning Location Qml Quick QuickWidgets RemoteObjects Scxml Script ScriptTools Sensors SerialPort TextToSpeech Charts Svg DataVisualization)
find_package(Qt5UiTools)
if(Qt5UiTools_FOUND)
list(APPEND ALL_OPTIONAL_MODULES UiTools)
diff --git a/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt b/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt
new file mode 100644
index 00000000..d79b3b1e
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt
@@ -0,0 +1,31 @@
+project(QtSerialPort)
+
+set(QtSerialPort_OPTIONAL_SRC )
+set(QtSerialPort_DROPPED_ENTRIES )
+
+set(QtSerialPort_SRC
+ ${QtSerialPort_GEN_DIR}/qserialport_wrapper.cpp
+ ${QtSerialPort_GEN_DIR}/qserialportinfo_wrapper.cpp
+# module is always needed
+ ${QtSerialPort_GEN_DIR}/qtserialport_module_wrapper.cpp
+)
+
+set(QtSerialPort_include_dirs ${QtSerialPort_SOURCE_DIR}
+ ${QtSerialPort_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5SerialPort_INCLUDE_DIRS}
+ ${libpyside_SOURCE_DIR}
+ ${QtCore_GEN_DIR})
+
+set(QtSerialPort_libraries pyside2
+ ${Qt5SerialPort_LIBRARIES})
+
+set(QtSerialPort_deps QtCore)
+
+create_pyside_module(NAME QtSerialPort
+ INCLUDE_DIRS QtSerialPort_include_dirs
+ LIBRARIES QtSerialPort_libraries
+ DEPS QtSerialPort_deps
+ TYPESYSTEM_PATH QtSerialPort_SOURCE_DIR
+ SOURCES QtSerialPort_SRC
+ DROPPED_ENTRIES QtSerialPort_DROPPED_ENTRIES)
diff --git a/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml b/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml
new file mode 100644
index 00000000..8548c543
--- /dev/null
+++ b/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+-->
+<typesystem package="PySide2.QtSerialPort">
+ <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/>
+ <object-type name="QSerialPort">
+ <enum-type name="BaudRate"/>
+ <enum-type name="DataBits"/>
+ <enum-type name="DataErrorPolicy"/>
+ <enum-type name="Direction" flags="Directions"/>
+ <enum-type name="FlowControl"/>
+ <enum-type name="Parity"/>
+ <enum-type name="PinoutSignal" flags="PinoutSignals"/>
+ <enum-type name="SerialPortError"/>
+ <enum-type name="StopBits"/>
+ </object-type>
+ <value-type name="QSerialPortInfo"/>
+</typesystem>
diff --git a/sources/pyside2/tests/QtSerialPort/CMakeLists.txt b/sources/pyside2/tests/QtSerialPort/CMakeLists.txt
new file mode 100644
index 00000000..55437344
--- /dev/null
+++ b/sources/pyside2/tests/QtSerialPort/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(serial.py)
diff --git a/sources/pyside2/tests/QtSerialPort/serial.py b/sources/pyside2/tests/QtSerialPort/serial.py
new file mode 100644
index 00000000..c30d9eb0
--- /dev/null
+++ b/sources/pyside2/tests/QtSerialPort/serial.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2020 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for QSerialPort'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide2.QtSerialPort import QSerialPort, QSerialPortInfo
+
+
+def callPortInfoMemberFunctions(portinfo):
+ portinfo.description()
+ portinfo.hasProductIdentifier()
+ portinfo.hasVendorIdentifier()
+ portinfo.isNull()
+
+
+class QSerialPortInfoTest(unittest.TestCase):
+ def test_available_ports(self):
+ allportinfos = QSerialPortInfo.availablePorts()
+ for portinfo in allportinfos:
+ callPortInfoMemberFunctions(portinfo)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tools/missing_bindings.py b/tools/missing_bindings.py
index a4a418a6..cfc885c6 100644
--- a/tools/missing_bindings.py
+++ b/tools/missing_bindings.py
@@ -115,6 +115,7 @@ modules_to_test['QtPositioning'] = 'qtpositioning-module.html'
modules_to_test['QtRemoteObjects'] = 'qtremoteobjects-module.html'
modules_to_test['QtScriptTools'] = 'qtscripttools-module.html'
modules_to_test['QtSensors'] = 'qtsensors-module.html'
+modules_to_test['QtSerialPort'] = 'qtserialport-module.html'
types_to_ignore = set()
# QtCore
types_to_ignore.add('QFlag')