Build a Qt resource file containing the icon themes generated from the actual image files

Loading from a resource file should be considerably faster
This commit is contained in:
Kovid Goyal 2022-01-10 14:46:43 +05:30
parent 62c8a0dcfb
commit bffaacd3c2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 9 additions and 4 deletions

View File

@ -133,10 +133,10 @@
}, },
{ {
"name": "rcc_backend", "name": "rcc_backend",
"sources": "calibre/gui2/rcc/rcc.cpp", "sources": "calibre/utils/rcc/rcc.cpp",
"headers": "calibre/gui2/rcc/rcc.h", "headers": "calibre/utils/rcc/rcc.h",
"sip_files": "calibre/gui2/rcc/rcc.sip", "sip_files": "calibre/utils/rcc/rcc.sip",
"inc_dirs": "calibre/gui2/rcc", "inc_dirs": "calibre/utils/rcc",
"qt_modules": ["-gui"] "qt_modules": ["-gui"]
}, },
{ {

View File

@ -14,6 +14,7 @@ class GUI(Command):
description = 'Compile all GUI forms' description = 'Compile all GUI forms'
PATH = os.path.join(Command.SRC, __appname__, 'gui2') PATH = os.path.join(Command.SRC, __appname__, 'gui2')
QRC = os.path.join(Command.RESOURCES, 'images.qrc') QRC = os.path.join(Command.RESOURCES, 'images.qrc')
RCC = os.path.join(Command.RESOURCES, 'icons.rcc')
def add_options(self, parser): def add_options(self, parser):
parser.add_option('--summary', default=False, action='store_true', parser.add_option('--summary', default=False, action='store_true',
@ -52,6 +53,10 @@ class GUI(Command):
for root, _, files2 in os.walk('images'): for root, _, files2 in os.walk('images'):
for name in files2: for name in files2:
sources.append(os.path.join(root, name)) sources.append(os.path.join(root, name))
if self.newer(self.RCC, sources):
self.info('Creating icon theme resource file')
from calibre.utils.rcc import compile_icon_dir_as_themes
compile_icon_dir_as_themes('images', self.RCC)
if self.newer(self.QRC, sources): if self.newer(self.QRC, sources):
self.info('Creating images.qrc') self.info('Creating images.qrc')
for s in sources: for s in sources: