From 28c6e35dd676ae831dc6de4a9f113c6d6c0a9970f60c2a32d1bc2b399af47168 Mon Sep 17 00:00:00 2001 From: linuxero Date: Fri, 15 Nov 2024 14:57:52 +0100 Subject: [PATCH 1/2] Resources for QML assets --- gui/TopBar.qml => assets/TopBar.qml_ | 0 assets/qml.qrc | 6 ++++++ {gui => assets}/qmldir | 2 +- rc_qml.py => assets/rc_qml.py | 10 +++++----- gui/CustomerTables.qml | 25 +++++++++++++------------ gui/Dashboard.qml | 1 + gui/main.qml | 1 + main.py | 8 ++++---- pyqcrm.pyproject | 6 +++--- qml.qrc | 7 ------- 10 files changed, 34 insertions(+), 32 deletions(-) rename gui/TopBar.qml => assets/TopBar.qml_ (100%) create mode 100644 assets/qml.qrc rename {gui => assets}/qmldir (59%) rename rc_qml.py => assets/rc_qml.py (96%) delete mode 100644 qml.qrc diff --git a/gui/TopBar.qml b/assets/TopBar.qml_ similarity index 100% rename from gui/TopBar.qml rename to assets/TopBar.qml_ diff --git a/assets/qml.qrc b/assets/qml.qrc new file mode 100644 index 0000000..3066ba0 --- /dev/null +++ b/assets/qml.qrc @@ -0,0 +1,6 @@ + + + qmldir + TopBar.qml + + diff --git a/gui/qmldir b/assets/qmldir similarity index 59% rename from gui/qmldir rename to assets/qmldir index 3822178..ce353cb 100644 --- a/gui/qmldir +++ b/assets/qmldir @@ -1,2 +1,2 @@ -module TopBar +module PyqMenu TopBar 1.0 TopBar.qml diff --git a/rc_qml.py b/assets/rc_qml.py similarity index 96% rename from rc_qml.py rename to assets/rc_qml.py index 47adc72..79f4190 100644 --- a/rc_qml.py +++ b/assets/rc_qml.py @@ -36,11 +36,11 @@ R\xc2\x99\x15\xe6\xba7\xf5\xb1\x85]\xd9d4\xe6\x0c\ 6\x9e\x93%!~\x0d`\x01_\xdb(\x5c\xa0\xa7\x82\ \x03\xf0\xd6\xb8\x0d\x97\xd8n\x056\x87\xb4\xaf%\xb4\x0d\ \x83\xfb\x1b\xe6\x8aD\x22w*\ -\x00\x00\x00$\ +\x00\x00\x00%\ m\ -odule TopBar\x0aTop\ -Bar 1.0 TopBar.q\ -ml\x0a\ +odule PyqMenu\x0aTo\ +pBar 1.0 TopBar.\ +qml\x0a\ " qt_resource_name = b"\ @@ -64,7 +64,7 @@ qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\ \x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00&\x00\x00\x00\x00\x00\x01\x00\x00\x01\xbe\ -\x00\x00\x01\x93'\x9ft\xf1\ +\x00\x00\x01\x93+\x0f\xdbn\ \x00\x00\x00\x0c\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x01\x93'4I\xe1\ " diff --git a/gui/CustomerTables.qml b/gui/CustomerTables.qml index 9d2dcf6..f534430 100644 --- a/gui/CustomerTables.qml +++ b/gui/CustomerTables.qml @@ -22,6 +22,7 @@ Item { //icon.source: "../images/addbusiness.svg" icon.source: "qrc:/images/addbusiness.svg" icon.color: "olive" + //width: icon.width anchors.right: parent.right flat: true onClicked: appLoader.source = "AddCustomer.qml" @@ -132,18 +133,18 @@ Item { // return newWidth // } - Timer - { - running: true - interval: 3000 - repeat: true - onTriggered: - { - //testTable.columnWidths[2] = 150 - console.log("Timing..") - testTable.forceLayout(); - } - } + // Timer + // { + // running: true + // interval: 3000 + // repeat: true + // onTriggered: + // { + // //testTable.columnWidths[2] = 150 + // console.log("Timing..") + // testTable.forceLayout(); + // } + // } diff --git a/gui/Dashboard.qml b/gui/Dashboard.qml index f633c1e..20c8b14 100644 --- a/gui/Dashboard.qml +++ b/gui/Dashboard.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import "qrc:/gui" ColumnLayout { diff --git a/gui/main.qml b/gui/main.qml index d9765c7..3eb7b9b 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls +import "qrc:/gui" ApplicationWindow { diff --git a/main.py b/main.py index ac63f9d..3c2e9e6 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from PySide6.QtCore import QResource from lib.ConfigLoader import ConfigLoader from lib.DataBase import DataBase import rc_pyqcrm -import rc_qml +import assets.rc_qml import sqlite3 # [pyqcrm] @@ -37,10 +37,10 @@ def testConnection(): if __name__ == "__main__": - # QResource.registerResource("qml.qrc") + #QResource.registerResource("rc_qml.py") app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() - engine.addImportPath("qrc:/gui"); + engine.addImportPath("qrc:/gui") bad_config = False @@ -48,7 +48,7 @@ if __name__ == "__main__": qml_file = Path(__file__).resolve().parent / "gui/main.qml" - # qml_file = ":/gui/TopBar.qml" + #qml_file = ":/gui/main.qml" config = ConfigLoader() diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index 8974769..f6cd150 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -15,8 +15,8 @@ "gui/EmployeTables.qml", "gui/AddCustomer.qml", "pyqcrm.qrc", - "qml.qrc", - "gui/qmldir", - "gui/TopBar.qml" + "assets/qml.qrc", + "assets/qmldir", + "assets/TopBar.qml" ] } diff --git a/qml.qrc b/qml.qrc deleted file mode 100644 index db0fb5a..0000000 --- a/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - gui/qmldir - gui/TopBar.qml - - - From 1a115fecda05aebf1daffa376b76ab78cbc45113537c137a792c130c117736d5 Mon Sep 17 00:00:00 2001 From: linuxero Date: Fri, 15 Nov 2024 15:07:19 +0100 Subject: [PATCH 2/2] Revert QRC for QML assets --- assets/qml.qrc | 6 --- assets/qmldir | 2 - assets/rc_qml.py | 78 ---------------------------- gui/Dashboard.qml | 1 - assets/TopBar.qml_ => gui/TopBar.qml | 0 gui/main.qml | 1 - main.py | 2 - pyqcrm.pyproject | 4 +- 8 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 assets/qml.qrc delete mode 100644 assets/qmldir delete mode 100644 assets/rc_qml.py rename assets/TopBar.qml_ => gui/TopBar.qml (100%) diff --git a/assets/qml.qrc b/assets/qml.qrc deleted file mode 100644 index 3066ba0..0000000 --- a/assets/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - qmldir - TopBar.qml - - diff --git a/assets/qmldir b/assets/qmldir deleted file mode 100644 index ce353cb..0000000 --- a/assets/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module PyqMenu -TopBar 1.0 TopBar.qml diff --git a/assets/rc_qml.py b/assets/rc_qml.py deleted file mode 100644 index 79f4190..0000000 --- a/assets/rc_qml.py +++ /dev/null @@ -1,78 +0,0 @@ -# Resource object code (Python 3) -# Created by: object code -# Created by: The Resource Compiler for Qt version 6.8.0 -# WARNING! All changes made in this file will be lost! - -from PySide6 import QtCore - -qt_resource_data = b"\ -\x00\x00\x01\xba\ -(\ -\xb5/\xfd`\xdd\x04\x85\x0d\x00\xb6\x13=\x1f0s\x1e\ -\xb3\xfb\x92H\xd4\xdc\x08\xd0\xcdc\xdb\xa9\xa2\xa0\xc4\xa4\ -\xbco\x17:w\xe6&\x14T4\x0c\x034\x003\x00\ -4\x00{5\x07\x9f\x8a\x9d\x83\xa1\xb9\x87UdHh\ -\xae\x9a\xf1\xedE}\x17W\x7fsTl\x0c\xc4:]\ -a\x8c~\xed\xcfF\xa8l\xff\xd9\x0c\x89i^\xac\x94\ -\xa7\xb4\xf7\xbe\xac\x18M(4A\x9b,]>\xbe(\ -/+\x10M\x90n#\x02\xb8\x85n\x9a{\x0fs\xf5\ -o\xeeWb(\xdf^@\xba\xd4\xec\xff\xba\x081\xf6\ -\x18\x96\xd4\x1b\xbe\xb9\xd2O\xf6\x8f}Z\xfe\xb4C\xe2\ -\xfc\x91'\xdf\x8f\xd6\xe45\x9c\x99\x9a\xb2\x9c\xd6\xe2l\ -\xf5\xd3\xca\x80L\xa6f\xd5\x84\x22im\xa4\x96h\xfc\ -\xbc6\x95\x9c\xa9\xed\xc8u9\x8a5\x8c\x19\x8c\x85\x10\ -\xcd\xcdX\xf9J\x1eV\xd1#\x8a\xdd[\xf6\x8b*\x0e\ -\x95\xeadk@\xb9Z+\x0e\xdc\xf3M\xd4\xdc\xecG\ -;\xb3/e\xc4Ho/\x0a-\xfe\x87\xa2\x9au\xc2\ -N\xa0\x91\x1dB\x8a!\x91))LZ\x03@\x84\x18\ -\xc6\xec\x1c\x03\x00\xb53i!-\xd8t\x01r\x1e\xc8\ -R\xc2\x99\x15\xe6\xba7\xf5\xb1\x85]\xd9d4\xe6\x0c\ -\x07\x95\x88^\xe0\xf7\x96\x0d\xeb\xc7\xa2\xaeQ\xbf\x96\xfd\ -\x93\x9c\xd3\x1cX\x94L7\x1bB\xb5\xb0\xc2tNJ\ -\x5c\xf0x\x18\x1d\xd3vQ\x82w\xa5\xf6\x18\xb9\xbb\xaa\ -\x8d)z\x08\x8f\xf5\xb8\x80\xe7*\xab\xbd\x0f\xd2\x92;\ -\xc4\xaa@\x8bdyf\xa1\x0d\xc2[\xc6\xa0QD\x18\ -\x97p\xb1\x85\xf3m3\x04\x05\x95=^\xd8SU\xe5\ -6\x9e\x93%!~\x0d`\x01_\xdb(\x5c\xa0\xa7\x82\ -\x03\xf0\xd6\xb8\x0d\x97\xd8n\x056\x87\xb4\xaf%\xb4\x0d\ -\x83\xfb\x1b\xe6\x8aD\x22w*\ -\x00\x00\x00%\ -m\ -odule PyqMenu\x0aTo\ -pBar 1.0 TopBar.\ -qml\x0a\ -" - -qt_resource_name = b"\ -\x00\x03\ -\x00\x00n\xb9\ -\x00g\ -\x00u\x00i\ -\x00\x0a\ -\x08\x8e<\xbc\ -\x00T\ -\x00o\x00p\x00B\x00a\x00r\x00.\x00q\x00m\x00l\ -\x00\x06\ -\x07\x84+\x02\ -\x00q\ -\x00m\x00l\x00d\x00i\x00r\ -" - -qt_resource_struct = b"\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00&\x00\x00\x00\x00\x00\x01\x00\x00\x01\xbe\ -\x00\x00\x01\x93+\x0f\xdbn\ -\x00\x00\x00\x0c\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x93'4I\xe1\ -" - -def qInitResources(): - QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) - -def qCleanupResources(): - QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) - -qInitResources() diff --git a/gui/Dashboard.qml b/gui/Dashboard.qml index 20c8b14..f633c1e 100644 --- a/gui/Dashboard.qml +++ b/gui/Dashboard.qml @@ -1,7 +1,6 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts -import "qrc:/gui" ColumnLayout { diff --git a/assets/TopBar.qml_ b/gui/TopBar.qml similarity index 100% rename from assets/TopBar.qml_ rename to gui/TopBar.qml diff --git a/gui/main.qml b/gui/main.qml index 3eb7b9b..d9765c7 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -1,7 +1,6 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls -import "qrc:/gui" ApplicationWindow { diff --git a/main.py b/main.py index 3c2e9e6..b0dad5e 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,6 @@ from PySide6.QtCore import QResource from lib.ConfigLoader import ConfigLoader from lib.DataBase import DataBase import rc_pyqcrm -import assets.rc_qml import sqlite3 # [pyqcrm] @@ -40,7 +39,6 @@ if __name__ == "__main__": #QResource.registerResource("rc_qml.py") app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() - engine.addImportPath("qrc:/gui") bad_config = False diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index f6cd150..bceae6a 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -15,8 +15,6 @@ "gui/EmployeTables.qml", "gui/AddCustomer.qml", "pyqcrm.qrc", - "assets/qml.qrc", - "assets/qmldir", - "assets/TopBar.qml" + "gui/TopBar.qml" ] }