From 706fc86ac231208894ff7e2e8b26bfe596f55a45 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Oct 2021 08:27:44 +0200 Subject: PySide6: Fix constructing a QFont from a family string Change qtbase/d8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 added QFont(QStringList) which now triggers for strings as well since they are a sequence. Fix by specifying overload numbers. Fixes: PYSIDE-1685 Change-Id: Ic78c2b273fe81949f852ea6e0f578613bc0a623a Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 0c4b73611801c788849f0bcf93737c670b61ee03) Reviewed-by: Qt Cherry-pick Bot --- .../PySide6/QtGui/typesystem_gui_common.xml | 3 ++ sources/pyside6/tests/QtGui/CMakeLists.txt | 1 + sources/pyside6/tests/QtGui/qfont_test.py | 60 ++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 sources/pyside6/tests/QtGui/qfont_test.py diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml index 275359ff8..a22e9c85c 100644 --- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml +++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml @@ -690,6 +690,9 @@ + + + diff --git a/sources/pyside6/tests/QtGui/CMakeLists.txt b/sources/pyside6/tests/QtGui/CMakeLists.txt index 179e88fd6..dc3056643 100644 --- a/sources/pyside6/tests/QtGui/CMakeLists.txt +++ b/sources/pyside6/tests/QtGui/CMakeLists.txt @@ -22,6 +22,7 @@ PYSIDE_TEST(qcolor_reduce_test.py) PYSIDE_TEST(qcursor_test.py) PYSIDE_TEST(qdatastream_gui_operators_test.py) PYSIDE_TEST(qdesktopservices_test.py) +PYSIDE_TEST(qfont_test.py) PYSIDE_TEST(qfontmetrics_test.py) PYSIDE_TEST(qguiapplication_test.py) PYSIDE_TEST(qicon_test.py) diff --git a/sources/pyside6/tests/QtGui/qfont_test.py b/sources/pyside6/tests/QtGui/qfont_test.py new file mode 100644 index 000000000..131992b52 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qfont_test.py @@ -0,0 +1,60 @@ +############################################################################# +## +## Copyright (C) 2021 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$ +## +############################################################################# + +import os +import sys +import unittest + +from pathlib import Path +sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QFont +from helper.usesqapplication import UsesQApplication + + +class QFontTest(UsesQApplication): + + def testStringConstruction(self): + """PYSIDE-1685: Test that passing str to QFont works after addding + QFont(QStringList) by qtbase/d8602ce58b6ef268be84b9aa0166b0c3fa6a96e8""" + font_name = 'Times Roman' + font = QFont(font_name) + families = font.families() + self.assertEqual(len(families), 1) + self.assertEqual(families[0], font_name) + + font = QFont([font_name]) + families = font.families() + self.assertEqual(len(families), 1) + self.assertEqual(families[0], font_name) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3