mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix custom icon overrides not working for Qt builtin controls
This commit is contained in:
parent
19265be1d9
commit
8f416fe715
@ -1332,7 +1332,20 @@ class Application(QApplication):
|
||||
'#FF2400' if is_error else '#50c878')
|
||||
|
||||
def load_calibre_style(self):
|
||||
from calibre.utils.resources import get_user_path
|
||||
icon_map = self.__icon_map_memory_ = {}
|
||||
user_path = get_user_path()
|
||||
if user_path:
|
||||
user_path = os.path.join(user_path, 'images')
|
||||
|
||||
@lru_cache(maxsize=64)
|
||||
def check_for_custom_icon(v):
|
||||
if user_path:
|
||||
q = os.path.join(user_path, v)
|
||||
if os.path.exists(q):
|
||||
return q
|
||||
return v.rpartition('.')[0]
|
||||
|
||||
for k, v in {
|
||||
'DialogYesButton': 'ok.png',
|
||||
'DialogNoButton': 'window-close.png',
|
||||
@ -1353,7 +1366,7 @@ class Application(QApplication):
|
||||
'ToolBarHorizontalExtensionButton': 'v-ellipsis.png',
|
||||
'ToolBarVerticalExtensionButton': 'h-ellipsis.png',
|
||||
}.items():
|
||||
icon_map[getattr(QStyle.StandardPixmap, 'SP_'+k).value] = v.rpartition('.')[0]
|
||||
icon_map[getattr(QStyle.StandardPixmap, 'SP_'+k).value] = check_for_custom_icon(v)
|
||||
transient_scroller = 0
|
||||
if ismacos:
|
||||
from calibre_extensions.cocoa import transient_scroller
|
||||
|
@ -158,6 +158,8 @@ int CalibreStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
|
||||
|
||||
QIcon CalibreStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption * option, const QWidget * widget) const {
|
||||
if (icon_map.contains(standardIcon)) {
|
||||
QString q = icon_map.value(standardIcon);
|
||||
if (q.contains('.')) return QIcon(q);
|
||||
QIcon ans = QIcon::fromTheme(icon_map.value(standardIcon));
|
||||
if (ans.isNull() && QIcon::themeName().contains("user-any")) {
|
||||
const bool is_dark_theme = QApplication::instance()->property("is_dark_theme").toBool();
|
||||
|
@ -101,5 +101,9 @@ def set_data(path, data=None):
|
||||
return _resolver.set_data(path, data)
|
||||
|
||||
|
||||
def get_user_path():
|
||||
return _resolver.user_path
|
||||
|
||||
|
||||
builtins.__dict__['P'] = get_path
|
||||
builtins.__dict__['I'] = get_image_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user