Skip to content

Commit

Permalink
PICARD-2331: Fixed resource loading with Qt6
Browse files Browse the repository at this point in the history
This requires the Qt6 rcc utility (instead of the no longer maintained pyrcc utility).
  • Loading branch information
phw committed Oct 13, 2023
1 parent 390c65c commit 61fc0d6
Show file tree
Hide file tree
Showing 7 changed files with 22,129 additions and 22,387 deletions.
44,483 changes: 22,107 additions & 22,376 deletions picard/resources.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
MBAPIHelper,
)

import picard.resources # noqa: F401 # pylint: disable=unused-import

from picard.ui import (
FONT_FAMILY_MONOSPACE,
theme,
Expand Down
2 changes: 1 addition & 1 deletion requirements-macos-10.14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mutagen==1.47.0
PyJWT==2.8.0
pyobjc-core==9.1.1
pyobjc-framework-Cocoa==9.1.1
PyQt6==6.3.0
PyQt6==6.3.1
python-dateutil==2.8.2
PyYAML==6.0.1
2 changes: 1 addition & 1 deletion requirements-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ discid==1.2.0
Markdown==3.4.4
mutagen==1.47.0
PyJWT==2.8.0
PyQt6==6.3.0
PyQt6==6.3.1
python-dateutil==2.8.2
pywin32==306
PyYAML==6.0.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mutagen~=1.37
PyJWT~=2.0
pyobjc-core>=6.2, <10; sys_platform == 'darwin'
pyobjc-framework-Cocoa>=6.2, <10; sys_platform == 'darwin'
PyQt6~=6.3.0
PyQt6~=6.3.1
python-dateutil~=2.7
pywin32; sys_platform == 'win32'
PyYAML>=5.1, <7
5 changes: 2 additions & 3 deletions resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ Updating Resources

This directory contains all external resources, like icons, used by Picard.

Picard utilizes the PyQt5 Resource System for using these resources in
application. For more information about the PyQt5 Resource System see this
[documentation](http://pyqt.sourceforge.net/Docs/PyQt5/resources.html).
Picard utilizes the Qt6 Resource Compiler rcc for using these resources in
application. For more information see the [documentation](https://doc.qt.io/qt-6/rcc.html).

For adding a new image into existing resources, follow these steps:

Expand Down
20 changes: 15 additions & 5 deletions resources/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Copyright (C) 2013-2014, 2018 Laurent Monin
# Copyright (C) 2014 Shadab Zafar
# Copyright (C) 2016 Sambhav Kothari
# Copyright (C) 2022 Philipp Wolfer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -33,20 +34,29 @@
import os.path


def fix_qtcore_import(path):
with open(path, 'r') as f:
data = f.read()
data = data.replace('PySide6', 'PyQt6')
with open(path, 'w') as f:
f.write(data)


def main():
scriptdir = os.path.dirname(os.path.abspath(__file__))
topdir = os.path.abspath(os.path.join(scriptdir, ".."))
pyfile = os.path.join(topdir, "picard", "resources.py")
qrcfile = os.path.join(topdir, "resources", "picard.qrc")
if newer(qrcfile, pyfile):
pyrcc = 'pyrcc5'
pyrcc_path = find_executable(pyrcc)
if pyrcc_path is None:
log.error("%s command not found, cannot build resource file !", pyrcc)
rcc = 'rcc'
rcc_path = find_executable(rcc, path='/usr/lib/qt6/libexec/') or find_executable(rcc)
if rcc_path is None:
log.error("%s command not found, cannot build resource file !", rcc)
else:
cmd = [pyrcc_path, qrcfile, "-o", pyfile]
cmd = [rcc_path, '-g', 'python', '-o', pyfile, qrcfile]
try:
spawn(cmd, search_path=0)
fix_qtcore_import(pyfile)
except DistutilsExecError as e:
log.error(e)

Expand Down

0 comments on commit 61fc0d6

Please sign in to comment.