aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/project_lib/design_studio_project.py
diff options
context:
space:
mode:
authorJaime Resano <Jaime.Resano-Aisa@qt.io>2025-01-21 11:23:15 +0100
committerJaime Resano <Jaime.Resano-Aisa@qt.io>2025-01-23 11:10:26 +0100
commit658724013cd177123e97bad8fd7c24e639ce2b66 (patch)
treed14a70cc620cfda2985aff6c780feccb0b589d67 /sources/pyside-tools/project_lib/design_studio_project.py
parent23b7ff61fb899ef8ae305df134d2c0968dce1fa2 (diff)
pyside6-project: 4. Enable building Design Studio projects
pyside6-project tool needs to be more flexible to build Design Studio projects. The path where a .qrc compilation output is stored has to be configurable. In addition, a check is performed to see whether the .qrc file needs to be rebuild by looking at the files that are referenced. This avoids unnecesary rebuilds. Task-number: PYSIDE-1612 Pick-to: 6.8 Change-Id: I8aafd5e66e477bbb360f3cf691d43e12c8866ec4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/project_lib/design_studio_project.py')
-rw-r--r--sources/pyside-tools/project_lib/design_studio_project.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/sources/pyside-tools/project_lib/design_studio_project.py b/sources/pyside-tools/project_lib/design_studio_project.py
index ef1935dc4..6c69e4c02 100644
--- a/sources/pyside-tools/project_lib/design_studio_project.py
+++ b/sources/pyside-tools/project_lib/design_studio_project.py
@@ -1,7 +1,8 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
+import logging
from pathlib import Path
+from typing import Optional
class DesignStudioProject:
@@ -14,7 +15,7 @@ class DesignStudioProject:
- main.py
<ProjectName>.qrc (Resources collection file)
<ProjectName>.qmlproject
- <ProjectName>.qmlproject.qtds
+ <ProjectName>.qmlproject.qtds (should be added to .gitignore)
... Other files and folders ...
"""
@@ -25,13 +26,40 @@ class DesignStudioProject:
@staticmethod
def is_ds_project(main_file: Path) -> bool:
- return bool(*main_file.parent.parent.glob("*.qmlproject")) and bool(
- *main_file.parent.parent.glob("*.qmlproject.qtds")
- )
+ return bool(*main_file.parent.parent.glob("*.qmlproject"))
def compiled_resources_available(self) -> bool:
"""
Returns whether the resources of the project have been compiled into a .py file.
- TODO: Make the resources path configurable. Wait for the TOML configuration change
+ TODO: Make the resources path configurable. Wait for the pyproject TOML configuration
"""
return self.compiled_resources_file.exists()
+
+ def get_resource_file_path(self) -> Optional[Path]:
+ """
+ Return the path to the *.qrc resources file from the project root folder.
+ If not found, log an error message and return None
+ If multiple files are found, log an error message and return None
+ If a single file is found, return its path
+ """
+ resource_files = list(self.project_dir.glob("*.qrc"))
+ if not resource_files:
+ logging.error("No *.qrc resources file found in the project root folder")
+ return None
+ if len(resource_files) > 1:
+ logging.error("Multiple *.qrc resources files found in the project root folder")
+ return None
+ return resource_files[0]
+
+ def get_compiled_resources_file_path(self) -> Path:
+ """
+ Return the path of the output file generated by compiling the *.qrc resources file
+ """
+ # TODO: make this more robust and configurable. Wait for the pyproject TOML configuration
+ return self.main_file.parent / "autogen" / "resources.py"
+
+ def clean(self):
+ """
+ Remove the compiled resources file if it exists
+ """
+ self.compiled_resources_file.unlink(missing_ok=True)