diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index c9080d33db..93ef7dae87 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1088,7 +1088,7 @@ class Application(QApplication): args = [override_program_name] + args[1:] self.palette_manager = PaletteManager(gprefs['color_palette'], gprefs['ui_style'], force_calibre_style, headless) if headless: - args.extend(['-platformpluginpath', plugins_loc, '-platform', 'headless']) + args.extend(('-platformpluginpath', plugins_loc, '-platform', 'headless')) else: args.extend(self.palette_manager.args_to_qt) diff --git a/src/calibre/gui2/palette.py b/src/calibre/gui2/palette.py index 0c9a9b377b..a592404ff3 100644 --- a/src/calibre/gui2/palette.py +++ b/src/calibre/gui2/palette.py @@ -5,7 +5,7 @@ import os import sys from contextlib import contextmanager from qt.core import ( - QAbstractNativeEventFilter, QApplication, QColor, QIcon, QPalette, QSettings, + QAbstractNativeEventFilter, QApplication, QColor, QIcon, QPalette, QSettings, QProxyStyle, QStyle, Qt, QTimer, pyqtSlot, QObject, QDataStream, QByteArray, QIODeviceBase ) @@ -19,6 +19,15 @@ light_text_color = QColor(0,0,0) light_link_color = QColor(0, 0, 255) +class UseCalibreIcons(QProxyStyle): + + def standardIcon(self, standard_pixmap, option=None, widget=None): + ic = QApplication.instance().get_qt_standard_icon(standard_pixmap) + if ic.isNull(): + return super().standardIcon(standard_pixmap, option, widget) + return ic + + if iswindows: import ctypes @@ -288,7 +297,7 @@ class PaletteManager(QObject): # own dark mode implementation when using calibre style so # prefer that and use darkmode=1 args.append('-platform') - args.append('windows:darkmode=' + '1' if self.using_calibre_style else '2') + args.append('windows:darkmode=' + ('1' if self.using_calibre_style else '2')) self.args_to_qt = tuple(args) if ismacos and not headless and self.has_fixed_palette: from calibre_extensions.cocoa import set_appearance @@ -297,7 +306,7 @@ class PaletteManager(QObject): def initialize(self): app = QApplication.instance() self.setParent(app) - if not self.using_calibre_style and self.style().objectName() == 'fusion': + if not self.using_calibre_style and app.style().objectName() == 'fusion': # Since Qt is using the fusion style anyway, specialize it self.using_calibre_style = True self.original_palette = QPalette(app.palette()) @@ -332,6 +341,10 @@ class PaletteManager(QObject): print('Using calibre Qt style:', self.using_calibre_style, file=sys.stderr) if self.using_calibre_style: self.load_calibre_style() + else: + app = QApplication.instance() + self.native_proxy_style = UseCalibreIcons(app.style()) + app.setStyle(self.native_proxy_style) self.on_palette_change() def get_qt_standard_icon(self, standard_pixmap): diff --git a/src/calibre/utils/rcc/__init__.py b/src/calibre/utils/rcc/__init__.py index 1cef190995..94ac2cf066 100644 --- a/src/calibre/utils/rcc/__init__.py +++ b/src/calibre/utils/rcc/__init__.py @@ -55,11 +55,6 @@ def compile_icon_dir_as_themes( path_to_dir, output_path, theme_name='calibre-default', inherits='', for_theme='any', prefix='/icons', ): - aliases = { - # these names are use by Qt commonstyle for line edit clear icons. The - # windows system style inherits it from commonstyle - 'clear_left.png': ('edit-clear-locationbar-ltr.png', 'edit-clear-locationbar-rtl.png') - } with tempfile.TemporaryDirectory(dir=path_to_dir) as tdir, open(os.path.join(tdir, 'icons.qrc'), 'w') as qrc: print('', file=qrc) print(f' ', file=qrc) @@ -114,10 +109,6 @@ def compile_icon_dir_as_themes( dest = theme_dir, 'images', (rp + dest_name) safe_link(image_path, os.path.join(tdir, *dest)) file('/'.join(dest)) - for alias in aliases.get(image_name, ()): - dest = theme_dir, 'images', (rp + alias) - safe_link(image_path, os.path.join(tdir, *dest)) - file('/'.join(dest)) for dirpath, dirnames, filenames in os.walk(path_to_dir): if 'textures' in dirnames: