diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp index e71942b026..4066f807fb 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp @@ -133,3 +133,13 @@ int get_image_allocation_limit() { return QImageReader::allocationLimit(); } + +QImage +image_from_hicon(void* hicon) { +#ifdef Q_OS_WIN + return QImage::fromHICON((HICON)hicon); +#else + (void)hicon; + return QImage(); +#endif +} diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.h b/src/calibre/gui2/progress_indicator/QProgressIndicator.h index 82df47aea7..9817d4242a 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.h +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.h @@ -162,3 +162,4 @@ void set_menu_on_action(QAction* ac, QMenu* menu); QMenu* menu_for_action(const QAction *ac); void set_image_allocation_limit(int megabytes); int get_image_allocation_limit(); +QImage image_from_hicon(void* hicon); diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.sip b/src/calibre/gui2/progress_indicator/QProgressIndicator.sip index 5ba46a0aff..209a038009 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.sip +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.sip @@ -89,3 +89,4 @@ void set_menu_on_action(QAction* ac, QMenu* menu); QMenu* menu_for_action(const QAction *ac); void set_image_allocation_limit(int megabytes); int get_image_allocation_limit(); +QImage image_from_hicon(void*); diff --git a/src/calibre/utils/open_with/windows.py b/src/calibre/utils/open_with/windows.py index df3375c24e..b5de257c64 100644 --- a/src/calibre/utils/open_with/windows.py +++ b/src/calibre/utils/open_with/windows.py @@ -6,17 +6,17 @@ __copyright__ = '2015, Kovid Goyal ' import re import sys -from qt.core import QBuffer, QByteArray, QImage, QIODevice, QPixmap, Qt +from qt.core import QBuffer, QByteArray, QIODevice, QPixmap, Qt from calibre.gui2 import must_use_qt from calibre.utils.winreg.default_programs import split_commandline -from calibre_extensions import winutil +from calibre_extensions import winutil, progress_indicator ICON_SIZE = 256 def hicon_to_pixmap(hicon): - QPixmap.fromImage(QImage.fromHICON(int(hicon))) + return progress_indicator.image_from_hicon(int(hicon)) def pixmap_to_data(pixmap):