From 435e739df302114517f1685a5146e4741454ad9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Fri, 8 Nov 2024 18:38:00 +0100 Subject: doc: Avoid same name for directory and main qml file Discovered while testing deployment on macOS, nuitka fails when the directory and file (e.g. Main/Main.qml) have the same name. This might be able to be fixed by other arguments or even upstream in Nuitka, this is a simple change that will encourage people not to use the same name in the meantime Pick-to: 6.8 Fixes: PYSIDE-2919 Task-number: PYSIDE-2910 Change-Id: I596d820e4a30996f9cf934a9f93e6436e51ad0d2 Reviewed-by: Shyamnath Premnadh Reviewed-by: Christian Tismer Reviewed-by: Friedemann Kleint --- .../doc/tutorials/qmlsqlintegration/App/Main.qml | 98 ++++++++++++++++++++++ .../doc/tutorials/qmlsqlintegration/App/qmldir | 2 + .../doc/tutorials/qmlsqlintegration/Main/Main.qml | 98 ---------------------- .../doc/tutorials/qmlsqlintegration/main.py | 2 +- .../qmlsqlintegration/qmlsqlintegration.rst | 20 ++--- 5 files changed, 111 insertions(+), 109 deletions(-) create mode 100644 sources/pyside6/doc/tutorials/qmlsqlintegration/App/Main.qml create mode 100644 sources/pyside6/doc/tutorials/qmlsqlintegration/App/qmldir delete mode 100644 sources/pyside6/doc/tutorials/qmlsqlintegration/Main/Main.qml (limited to 'sources/pyside6/doc/tutorials/qmlsqlintegration') diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/App/Main.qml b/sources/pyside6/doc/tutorials/qmlsqlintegration/App/Main.qml new file mode 100644 index 000000000..889385fa2 --- /dev/null +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/App/Main.qml @@ -0,0 +1,98 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import ChatModel + +ApplicationWindow { + id: window + title: qsTr("Chat") + width: 640 + height: 960 + visible: true + + SqlConversationModel { + id: chat_model + } + + ColumnLayout { + anchors.fill: parent + + ListView { + id: listView + Layout.fillWidth: true + Layout.fillHeight: true + Layout.margins: pane.leftPadding + messageField.leftPadding + displayMarginBeginning: 40 + displayMarginEnd: 40 + verticalLayoutDirection: ListView.BottomToTop + spacing: 12 + model: chat_model + delegate: Column { + anchors.right: sentByMe ? listView.contentItem.right : undefined + spacing: 6 + + readonly property bool sentByMe: model.recipient !== "Me" + Row { + id: messageRow + spacing: 6 + anchors.right: sentByMe ? parent.right : undefined + + Rectangle { + width: Math.min(messageText.implicitWidth + 24, + listView.width - (!sentByMe ? messageRow.spacing : 0)) + height: messageText.implicitHeight + 24 + radius: 15 + color: sentByMe ? "lightgrey" : "steelblue" + + Label { + id: messageText + text: model.message + color: sentByMe ? "black" : "white" + anchors.fill: parent + anchors.margins: 12 + wrapMode: Label.Wrap + } + } + } + + Label { + id: timestampText + text: Qt.formatDateTime(model.timestamp, "d MMM hh:mm") + color: "lightgrey" + anchors.right: sentByMe ? parent.right : undefined + } + } + + ScrollBar.vertical: ScrollBar {} + } + + Pane { + id: pane + Layout.fillWidth: true + + RowLayout { + width: parent.width + + TextArea { + id: messageField + Layout.fillWidth: true + placeholderText: qsTr("Compose message") + wrapMode: TextArea.Wrap + } + + Button { + id: sendButton + text: qsTr("Send") + enabled: messageField.length > 0 + onClicked: { + listView.model.send_message("machine", messageField.text, "Me"); + messageField.text = ""; + } + } + } + } + } +} diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/App/qmldir b/sources/pyside6/doc/tutorials/qmlsqlintegration/App/qmldir new file mode 100644 index 000000000..f093374fa --- /dev/null +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/App/qmldir @@ -0,0 +1,2 @@ +module App +Main 254.0 Main.qml diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/Main/Main.qml b/sources/pyside6/doc/tutorials/qmlsqlintegration/Main/Main.qml deleted file mode 100644 index 889385fa2..000000000 --- a/sources/pyside6/doc/tutorials/qmlsqlintegration/Main/Main.qml +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Layouts -import QtQuick.Controls -import ChatModel - -ApplicationWindow { - id: window - title: qsTr("Chat") - width: 640 - height: 960 - visible: true - - SqlConversationModel { - id: chat_model - } - - ColumnLayout { - anchors.fill: parent - - ListView { - id: listView - Layout.fillWidth: true - Layout.fillHeight: true - Layout.margins: pane.leftPadding + messageField.leftPadding - displayMarginBeginning: 40 - displayMarginEnd: 40 - verticalLayoutDirection: ListView.BottomToTop - spacing: 12 - model: chat_model - delegate: Column { - anchors.right: sentByMe ? listView.contentItem.right : undefined - spacing: 6 - - readonly property bool sentByMe: model.recipient !== "Me" - Row { - id: messageRow - spacing: 6 - anchors.right: sentByMe ? parent.right : undefined - - Rectangle { - width: Math.min(messageText.implicitWidth + 24, - listView.width - (!sentByMe ? messageRow.spacing : 0)) - height: messageText.implicitHeight + 24 - radius: 15 - color: sentByMe ? "lightgrey" : "steelblue" - - Label { - id: messageText - text: model.message - color: sentByMe ? "black" : "white" - anchors.fill: parent - anchors.margins: 12 - wrapMode: Label.Wrap - } - } - } - - Label { - id: timestampText - text: Qt.formatDateTime(model.timestamp, "d MMM hh:mm") - color: "lightgrey" - anchors.right: sentByMe ? parent.right : undefined - } - } - - ScrollBar.vertical: ScrollBar {} - } - - Pane { - id: pane - Layout.fillWidth: true - - RowLayout { - width: parent.width - - TextArea { - id: messageField - Layout.fillWidth: true - placeholderText: qsTr("Compose message") - wrapMode: TextArea.Wrap - } - - Button { - id: sendButton - text: qsTr("Send") - enabled: messageField.length > 0 - onClicked: { - listView.model.send_message("machine", messageField.text, "Me"); - messageField.text = ""; - } - } - } - } - } -} diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py index 92fcf7c87..e42f8f2e9 100644 --- a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py @@ -50,7 +50,7 @@ if __name__ == "__main__": engine = QQmlApplicationEngine() engine.addImportPath(sys.path[0]) - engine.loadFromModule("Main", "Main") + engine.loadFromModule("App", "Main") if not engine.rootObjects(): sys.exit(-1) diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/qmlsqlintegration.rst b/sources/pyside6/doc/tutorials/qmlsqlintegration/qmlsqlintegration.rst index 21d8c9950..85db25def 100644 --- a/sources/pyside6/doc/tutorials/qmlsqlintegration/qmlsqlintegration.rst +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/qmlsqlintegration.rst @@ -64,7 +64,7 @@ Main.qml Let's look at the ``Main.qml`` file. -.. literalinclude:: Main/Main.qml +.. literalinclude:: App/Main.qml :linenos: :lines: 4-6 @@ -77,9 +77,9 @@ Next, import the Qt Quick Controls module. Among other things, this provides access to ``ApplicationWindow``, which replaces the existing root type, Window: -Let's step through the ``Main/Main.qml`` file. +Let's step through the ``App/Main.qml`` file. -.. literalinclude:: Main/Main.qml +.. literalinclude:: App/Main.qml :linenos: :lines: 9-14 @@ -94,7 +94,7 @@ Once we've set these, we have a properly sized, empty window ready to be filled Because we are exposing the :code:`SqlConversationModel` class to QML, we will declare a component to access it: -.. literalinclude:: Main/Main.qml +.. literalinclude:: App/Main.qml :linenos: :lines: 16-18 @@ -106,11 +106,11 @@ There are two ways of laying out items in QML: `Item Positioners`_ and `Qt Quick resizable user interfaces. Below, we use `ColumnLayout`_ to vertically lay out a `ListView`_ and a `Pane`_. - .. literalinclude:: Main/Main.qml + .. literalinclude:: App/Main.qml :linenos: :lines: 20-23 - .. literalinclude:: Main/Main.qml + .. literalinclude:: App/Main.qml :linenos: :lines: 72-74 @@ -141,7 +141,7 @@ remaining space that is left after accommodating the Pane. Let's look at the ``Listview`` in detail: -.. literalinclude:: Main/Main.qml +.. literalinclude:: App/Main.qml :linenos: :lines: 23-70 @@ -170,7 +170,7 @@ At the bottom of the screen, we place a `TextArea`_ item to allow multi-line tex button to send the message. We use Pane to cover the area under these two items: -.. literalinclude:: Main/Main.qml +.. literalinclude:: App/Main.qml :linenos: :lines: 72-96 @@ -187,10 +187,10 @@ recipient and one possible sender for this conversation we're just using strings .. _displayMarginEnd: https://doc.qt.io/qt-5/qml-qtquick-listview.html#displayMarginEnd-prop .. _TextArea: https://doc.qt.io/qt-5/qml-qtquick-controls2-textarea.html -``Main.qml`` needs to be put into a directory named :code:`Main` along +``Main.qml`` needs to be put into a directory named :code:`App` along with a file named ``qmldir`` to describe a basic QML module: -.. literalinclude:: Main/qmldir +.. literalinclude:: App/qmldir main.py ------- -- cgit v1.2.3