mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 13:47:13 -05:00
Means URLs like :/icons/foo.jpg should become icons:foo.jpg This is part of the prep work for a PyQt6 update. PyQt6 has dropped pyrcc, so we can longer generate the icons_qrc.py file we did previously. Qt Designer expects us to use the resource system, so we continue to generate the icons.qrc file to make editing the UI files easier. But at runtime, we no longer use that file.
31 lines
796 B
Python
31 lines
796 B
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import os
|
|
import sys
|
|
|
|
qrc_file = os.path.abspath(sys.argv[1])
|
|
icons = sys.argv[2:]
|
|
|
|
file_skeleton = """
|
|
<RCC>
|
|
<qresource prefix="/">
|
|
FILES
|
|
</qresource>
|
|
</RCC>
|
|
""".strip()
|
|
|
|
indent = " " * 8
|
|
lines = []
|
|
for icon in icons:
|
|
base = os.path.basename(icon)
|
|
path = os.path.relpath(icon, start=os.path.dirname(qrc_file))
|
|
if not path.startswith("icons/"):
|
|
path = f"../data/qt/icons/{base}"
|
|
else:
|
|
path = f"../../../bazel-bin/qt/aqt/data/qt/icons/{base}"
|
|
line = f'{indent}<file alias="icons/{base}">{path}</file>'
|
|
lines.append(line)
|
|
|
|
with open(qrc_file, "w") as file:
|
|
file.write(file_skeleton.replace("FILES", "\n".join(lines)))
|