aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorAlexander Mishin <apmishin@yandex.com>2020-09-21 19:39:24 +0300
committerAlexander Mishin <apmishin@yandex.com>2020-09-22 13:43:21 +0000
commit229dfaab95325ce64e27fe4503c8b99e5ec90bff (patch)
tree92ec0053afb057944ae96f84d0b652cde8410aee /tests/manual
parent31ec38dba5efb731b0769a2d3e4d0232d9ba6e22 (diff)
Add qmlImportPaths property to .pyproject file
Users should be able to add custom QML import paths for Python/PySide2/PyQt5 projects in Qt Creator in order to get syntax highlighting and code completion for custom QML modules. Fixes: QTCREATORBUG-23679 Change-Id: Iec7c691c4b8709c48a790cd27ac7c6e755967796 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/python/pyproject/imports/Charts/chartbackground.qml36
-rw-r--r--tests/manual/python/pyproject/imports/Charts/qmldir2
-rw-r--r--tests/manual/python/pyproject/main.py58
-rw-r--r--tests/manual/python/pyproject/main.qml41
-rw-r--r--tests/manual/python/pyproject/pyproject.pyproject9
5 files changed, 146 insertions, 0 deletions
diff --git a/tests/manual/python/pyproject/imports/Charts/chartbackground.qml b/tests/manual/python/pyproject/imports/Charts/chartbackground.qml
new file mode 100644
index 0000000000..671048f9b5
--- /dev/null
+++ b/tests/manual/python/pyproject/imports/Charts/chartbackground.qml
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** 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.
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ width: 48
+ height: 48
+ border {
+ width: 1
+ color: "black"
+ }
+ color: "lightgrey"
+}
diff --git a/tests/manual/python/pyproject/imports/Charts/qmldir b/tests/manual/python/pyproject/imports/Charts/qmldir
new file mode 100644
index 0000000000..9e9f931d1e
--- /dev/null
+++ b/tests/manual/python/pyproject/imports/Charts/qmldir
@@ -0,0 +1,2 @@
+module Charts
+ChartBackground 1.0 ./chartbackground.qml
diff --git a/tests/manual/python/pyproject/main.py b/tests/manual/python/pyproject/main.py
new file mode 100644
index 0000000000..fba69c38d5
--- /dev/null
+++ b/tests/manual/python/pyproject/main.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: 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$
+##
+#############################################################################
+
+import os
+import sys
+
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import QQmlApplicationEngine
+
+
+if __name__ == "__main__":
+ app = QGuiApplication(sys.argv)
+
+ engine = QQmlApplicationEngine()
+ engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
+
+ if not engine.rootObjects():
+ sys.exit(-1)
+
+ sys.exit(app.exec_())
diff --git a/tests/manual/python/pyproject/main.qml b/tests/manual/python/pyproject/main.qml
new file mode 100644
index 0000000000..efa0cc8de7
--- /dev/null
+++ b/tests/manual/python/pyproject/main.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** 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.
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.12
+import Charts 1.0 as Charts // Qt Creator displays "QML module not found (Charts)."
+ // if qmlImportPaths value is missing from pyproject.pyproject file.
+
+Window {
+ width: 640
+ height: 480
+ visible: true
+ title: qsTr("pyproject")
+
+ Charts.ChartBackground { // Syntax highlight and code completion doesn't work
+ // if qmlImportPaths value is missing from pyproject.pyproject file.
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/manual/python/pyproject/pyproject.pyproject b/tests/manual/python/pyproject/pyproject.pyproject
new file mode 100644
index 0000000000..17839669da
--- /dev/null
+++ b/tests/manual/python/pyproject/pyproject.pyproject
@@ -0,0 +1,9 @@
+{
+ "files": [
+ "main.py",
+ "main.qml"
+ ],
+ "qmlImportPaths": [
+ "./imports"
+ ]
+}