Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for qt6 qml resources #50

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ovos_workshop/resource_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def _read(self) -> str:
class QmlFile(ResourceFile):
def _locate(self):
""" QML files are special because we do not want to walk the directory """
config = Configuration()
enclosure_config = config.get("gui") or {}
qt_version_target = enclosure_config.get("qt_version", 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be auto detected? if missing from config instead of assuming 5 we could do something to get a default value


file_path = None
if self.resource_name.endswith(self.resource_type.file_extension):
file_name = self.resource_name
Expand Down Expand Up @@ -296,6 +300,12 @@ def _locate(self):
if file_path is None:
LOG.error(f"Could not find resource file {file_name}")

# Will be used to load the correct UI file for the target Qt version
# TODO: Remove this when we drop Qt5 support
if qt_version_target == 6:
if "ui/" in str(file_path):
file_path = Path(str(file_path).replace("ui/", "ui6/"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will messup some file names and paths, the check needs to be for full words, maybe something like if "ui" in file_path.split("/") is enough

words = [w for w in file_path.split("/") if w != "ui" else "ui6"]
file_path = "/".join(words)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can not be done, i've seen skills that load stuff such as pictures from the ui folder, this will also mess their paths. at minimum this should have a check if file exists before changing the path, but this may still mess things up if there are duplicate files


return file_path

def load(self):
Expand Down