mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 09:18:18 +00:00
PICARD-2331: Fixed resource loading with Qt6
This requires the Qt6 rcc utility (instead of the no longer maintained pyrcc utility).
This commit is contained in:
44341
picard/resources.py
44341
picard/resources.py
File diff suppressed because it is too large
Load Diff
@@ -151,6 +151,8 @@ from picard.webservice.api_helpers import (
|
||||
MBAPIHelper,
|
||||
)
|
||||
|
||||
import picard.resources # noqa: F401 # pylint: disable=unused-import
|
||||
|
||||
from picard.ui import (
|
||||
FONT_FAMILY_MONOSPACE,
|
||||
theme,
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -33,20 +34,29 @@ from distutils.spawn import (
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user