Workaround for Win10's broken scaling of taskbar icons

Also set the app user model id explicitly for all three main calibre GUI
programs.
This commit is contained in:
Kovid Goyal 2016-09-01 14:11:47 +05:30
parent eb91bf77e2
commit c868fdd32e
9 changed files with 28 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -19,12 +19,15 @@ for name, src in sources.iteritems():
os.mkdir('ico_temp') os.mkdir('ico_temp')
try: try:
names = [] names = []
for sz in (16, 32, 48, 256): for sz in (16, 24, 32, 48, 64, 256):
iname = os.path.join('ico_temp', '{0}x{0}.png'.format(sz)) iname = os.path.join('ico_temp', '{0}x{0}.png'.format(sz))
subprocess.check_call(['rsvg-convert', src, '-w', str(sz), '-h', str(sz), '-o', iname]) subprocess.check_call(['rsvg-convert', src, '-w', str(sz), '-h', str(sz), '-o', iname])
subprocess.check_call(['optipng', '-o7', '-strip', 'all', iname]) subprocess.check_call(['optipng', '-o7', '-strip', 'all', iname])
if sz >= 128:
names.append('-r') # store as raw PNG to reduce size
else:
names.extend(['-t', '0']) # see https://bugzilla.gnome.org/show_bug.cgi?id=755200
names.append(iname) names.append(iname)
names[-1:-1] = ['-r']
subprocess.check_call(['icotool', '-c', '--output=' + name+'.ico'] + names) subprocess.check_call(['icotool', '-c', '--output=' + name+'.ico'] + names)
finally: finally:
shutil.rmtree('ico_temp') shutil.rmtree('ico_temp')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

@ -100,7 +100,7 @@ def init_qt(args):
override = 'calibre-gui' if islinux else None override = 'calibre-gui' if islinux else None
app = Application(args, override_program_name=override) app = Application(args, override_program_name=override)
app.file_event_hook = EventAccumulator() app.file_event_hook = EventAccumulator()
app.setWindowIcon(QIcon(I('lt.png', allow_user_override=False))) app.setWindowIcon(QIcon(I('library.png', allow_user_override=False)))
return app, opts, args return app, opts, args
@ -462,6 +462,16 @@ def main(args=sys.argv):
gui_debug = args[1] gui_debug = args[1]
args = ['calibre'] args = ['calibre']
if iswindows:
# Ensure that all ebook editor instances are grouped together in the task
# bar. This prevents them from being grouped with viewer process when
# launched from within calibre, as both use calibre-parallel.exe
import ctypes
try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.main-gui')
except Exception:
pass # Only available on windows 7 and newer
try: try:
app, opts, args = init_qt(args) app, opts, args = init_qt(args)
except AbortInit: except AbortInit:

View File

@ -48,7 +48,7 @@ def _run(args, notify=None):
import ctypes import ctypes
try: try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.edit-book') ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.edit-book')
except: except Exception:
pass # Only available on windows 7 and newer pass # Only available on windows 7 and newer
# The following two lines are needed to prevent circular imports causing # The following two lines are needed to prevent circular imports causing

View File

@ -134,6 +134,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
def __init__(self, opts, parent=None, gui_debug=None): def __init__(self, opts, parent=None, gui_debug=None):
global _gui global _gui
MainWindow.__init__(self, opts, parent=parent, disable_automatic_gc=True) MainWindow.__init__(self, opts, parent=parent, disable_automatic_gc=True)
self.setWindowIcon(QIcon(I('library.png', allow_user_override=False)))
self.jobs_pointer = Pointer(self) self.jobs_pointer = Pointer(self)
self.proceed_requested.connect(self.do_proceed, self.proceed_requested.connect(self.do_proceed,
type=Qt.QueuedConnection) type=Qt.QueuedConnection)

View File

@ -16,7 +16,7 @@ from calibre.gui2 import (
Application, ORG_NAME, APP_UID, choose_files, info_dialog, error_dialog, Application, ORG_NAME, APP_UID, choose_files, info_dialog, error_dialog,
open_url, setup_gui_option_parser) open_url, setup_gui_option_parser)
from calibre.ebooks.oeb.iterator.book import EbookIterator from calibre.ebooks.oeb.iterator.book import EbookIterator
from calibre.constants import islinux, filesystem_encoding, DEBUG from calibre.constants import islinux, filesystem_encoding, DEBUG, iswindows
from calibre.utils.config import Config, StringConfig, JSONConfig from calibre.utils.config import Config, StringConfig, JSONConfig
from calibre.customize.ui import available_input_formats from calibre.customize.ui import available_input_formats
from calibre import as_unicode, force_unicode, isbytestring, prints from calibre import as_unicode, force_unicode, isbytestring, prints
@ -1207,6 +1207,15 @@ def main(args=sys.argv):
# Ensure viewer can continue to function if GUI is closed # Ensure viewer can continue to function if GUI is closed
os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None) os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None)
reset_base_dir() reset_base_dir()
if iswindows:
# Ensure that all ebook editor instances are grouped together in the task
# bar. This prevents them from being grouped with viewer process when
# launched from within calibre, as both use calibre-parallel.exe
import ctypes
try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('com.calibre-ebook.viewer')
except Exception:
pass # Only available on windows 7 and newer
parser = option_parser() parser = option_parser()
opts, args = parser.parse_args(args) opts, args = parser.parse_args(args)