Skip to content

Commit c868fdd

Browse files
committed
Workaround for Win10's broken scaling of taskbar icons
Also set the app user model id explicitly for all three main calibre GUI programs.
1 parent eb91bf7 commit c868fdd

9 files changed

Lines changed: 28 additions & 5 deletions

File tree

icons/ebook-edit.ico

16.6 KB
Binary file not shown.

icons/favicon.ico

16.6 KB
Binary file not shown.

icons/library.ico

16.6 KB
Binary file not shown.

icons/make_ico_files.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
os.mkdir('ico_temp')
2020
try:
2121
names = []
22-
for sz in (16, 32, 48, 256):
22+
for sz in (16, 24, 32, 48, 64, 256):
2323
iname = os.path.join('ico_temp', '{0}x{0}.png'.format(sz))
2424
subprocess.check_call(['rsvg-convert', src, '-w', str(sz), '-h', str(sz), '-o', iname])
2525
subprocess.check_call(['optipng', '-o7', '-strip', 'all', iname])
26+
if sz >= 128:
27+
names.append('-r') # store as raw PNG to reduce size
28+
else:
29+
names.extend(['-t', '0']) # see https://bugzilla.gnome.org/show_bug.cgi?id=755200
2630
names.append(iname)
27-
names[-1:-1] = ['-r']
2831
subprocess.check_call(['icotool', '-c', '--output=' + name+'.ico'] + names)
2932
finally:
3033
shutil.rmtree('ico_temp')

icons/viewer.ico

16.6 KB
Binary file not shown.

src/calibre/gui2/main.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def init_qt(args):
100100
override = 'calibre-gui' if islinux else None
101101
app = Application(args, override_program_name=override)
102102
app.file_event_hook = EventAccumulator()
103-
app.setWindowIcon(QIcon(I('lt.png', allow_user_override=False)))
103+
app.setWindowIcon(QIcon(I('library.png', allow_user_override=False)))
104104
return app, opts, args
105105

106106

@@ -462,6 +462,16 @@ def main(args=sys.argv):
462462
gui_debug = args[1]
463463
args = ['calibre']
464464

465+
if iswindows:
466+
# Ensure that all ebook editor instances are grouped together in the task
467+
# bar. This prevents them from being grouped with viewer process when
468+
# launched from within calibre, as both use calibre-parallel.exe
469+
import ctypes
470+
try:
471+
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.main-gui')
472+
except Exception:
473+
pass # Only available on windows 7 and newer
474+
465475
try:
466476
app, opts, args = init_qt(args)
467477
except AbortInit:

src/calibre/gui2/tweak_book/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _run(args, notify=None):
4848
import ctypes
4949
try:
5050
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.edit-book')
51-
except:
51+
except Exception:
5252
pass # Only available on windows 7 and newer
5353

5454
# The following two lines are needed to prevent circular imports causing

src/calibre/gui2/ui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
134134
def __init__(self, opts, parent=None, gui_debug=None):
135135
global _gui
136136
MainWindow.__init__(self, opts, parent=parent, disable_automatic_gc=True)
137+
self.setWindowIcon(QIcon(I('library.png', allow_user_override=False)))
137138
self.jobs_pointer = Pointer(self)
138139
self.proceed_requested.connect(self.do_proceed,
139140
type=Qt.QueuedConnection)

src/calibre/gui2/viewer/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Application, ORG_NAME, APP_UID, choose_files, info_dialog, error_dialog,
1717
open_url, setup_gui_option_parser)
1818
from calibre.ebooks.oeb.iterator.book import EbookIterator
19-
from calibre.constants import islinux, filesystem_encoding, DEBUG
19+
from calibre.constants import islinux, filesystem_encoding, DEBUG, iswindows
2020
from calibre.utils.config import Config, StringConfig, JSONConfig
2121
from calibre.customize.ui import available_input_formats
2222
from calibre import as_unicode, force_unicode, isbytestring, prints
@@ -1207,6 +1207,15 @@ def main(args=sys.argv):
12071207
# Ensure viewer can continue to function if GUI is closed
12081208
os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None)
12091209
reset_base_dir()
1210+
if iswindows:
1211+
# Ensure that all ebook editor instances are grouped together in the task
1212+
# bar. This prevents them from being grouped with viewer process when
1213+
# launched from within calibre, as both use calibre-parallel.exe
1214+
import ctypes
1215+
try:
1216+
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.viewer')
1217+
except Exception:
1218+
pass # Only available on windows 7 and newer
12101219

12111220
parser = option_parser()
12121221
opts, args = parser.parse_args(args)

0 commit comments

Comments
 (0)