Load icons via importlib.resources
The PyQt resources system is gone in 6.2 and deprecated before that. This should be the last usage of it. Switches icons to be read with `utils.resources.read_file_binary()` in `notification.py` (fallback desktop notification icon) and `app.py` (icon for the desktop window). importlib only loads resources under a package, so the icons are moved under the `qutebrowser/` directory. Closes: #6062
|
|
@ -4,7 +4,7 @@ recursive-include qutebrowser/javascript *.js
|
|||
graft tests
|
||||
graft qutebrowser/html
|
||||
graft qutebrowser/3rdparty
|
||||
graft icons
|
||||
graft qutebrowser/icons
|
||||
graft doc/img
|
||||
graft misc/apparmor
|
||||
graft misc/userscripts
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ qutebrowser
|
|||
===========
|
||||
|
||||
// QUTE_WEB_HIDE
|
||||
image:icons/qutebrowser-64x64.png[qutebrowser logo] *A keyboard-driven, vim-like browser based on PyQt5 and Qt.*
|
||||
image:qutebrowser/icons/qutebrowser-64x64.png[qutebrowser logo] *A keyboard-driven, vim-like browser based on PyQt5 and Qt.*
|
||||
|
||||
image:https://github.com/qutebrowser/qutebrowser/workflows/CI/badge.svg["Build Status", link="https://github.com/qutebrowser/qutebrowser/actions?query=workflow%3ACI"]
|
||||
image:https://codecov.io/github/qutebrowser/qutebrowser/coverage.svg?branch=master["coverage badge",link="https://codecov.io/github/qutebrowser/qutebrowser?branch=master"]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ install: man
|
|||
"$(DESTDIR)$(MANDIR)/man1/qutebrowser.1"
|
||||
install -Dm644 misc/org.qutebrowser.qutebrowser.desktop \
|
||||
"$(DESTDIR)$(DATADIR)/applications/org.qutebrowser.qutebrowser.desktop"
|
||||
$(foreach i,$(ICONSIZES),install -Dm644 "icons/qutebrowser-$(i)x$(i).png" \
|
||||
$(foreach i,$(ICONSIZES),install -Dm644 "qutebrowser/icons/qutebrowser-$(i)x$(i).png" \
|
||||
"$(DESTDIR)$(DATADIR)/icons/hicolor/$(i)x$(i)/apps/qutebrowser.png";)
|
||||
install -Dm644 icons/qutebrowser.svg \
|
||||
"$(DESTDIR)$(DATADIR)/icons/hicolor/scalable/apps/qutebrowser.svg"
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>../icons/qutebrowser-16x16.png</file>
|
||||
<file>../icons/qutebrowser-24x24.png</file>
|
||||
<file>../icons/qutebrowser-32x32.png</file>
|
||||
<file>../icons/qutebrowser-48x48.png</file>
|
||||
<file>../icons/qutebrowser-64x64.png</file>
|
||||
<file>../icons/qutebrowser-96x96.png</file>
|
||||
<file>../icons/qutebrowser-128x128.png</file>
|
||||
<file>../icons/qutebrowser-256x256.png</file>
|
||||
<file>../icons/qutebrowser-512x512.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -40,9 +40,9 @@ setupcommon.write_git_file()
|
|||
|
||||
|
||||
if os.name == 'nt':
|
||||
icon = '../icons/qutebrowser.ico'
|
||||
icon = '../qutebrowser/icons/qutebrowser.ico'
|
||||
elif sys.platform == 'darwin':
|
||||
icon = '../icons/qutebrowser.icns'
|
||||
icon = '../qutebrowser/icons/qutebrowser.icns'
|
||||
else:
|
||||
icon = None
|
||||
|
||||
|
|
|
|||
|
|
@ -182,8 +182,9 @@ def _init_icon():
|
|||
"""Initialize the icon of qutebrowser."""
|
||||
fallback_icon = QIcon()
|
||||
for size in [16, 24, 32, 48, 64, 96, 128, 256, 512]:
|
||||
filename = ':/icons/qutebrowser-{size}x{size}.png'.format(size=size)
|
||||
pixmap = QPixmap(filename)
|
||||
filename = 'icons/qutebrowser-{size}x{size}.png'.format(size=size)
|
||||
pixmap = QPixmap()
|
||||
pixmap.loadFromData(resources.read_file_binary(filename))
|
||||
if pixmap.isNull():
|
||||
log.init.warning("Failed to load {}".format(filename))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ if TYPE_CHECKING:
|
|||
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.misc import objects
|
||||
from qutebrowser.utils import qtutils, log, utils, debug, message, version, objreg
|
||||
from qutebrowser.utils import (
|
||||
qtutils, log, utils, debug, message, version, objreg, resources,
|
||||
)
|
||||
from qutebrowser.qt import sip
|
||||
|
||||
|
||||
|
|
@ -965,8 +967,8 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
|
|||
|
||||
icon = qt_notification.icon()
|
||||
if icon.isNull():
|
||||
filename = ':/icons/qutebrowser-64x64.png'
|
||||
icon = QImage(filename)
|
||||
filename = 'icons/qutebrowser-64x64.png'
|
||||
icon = QImage.fromData(resources.read_file_binary(filename))
|
||||
|
||||
key = self._quirks.icon_key or "image-data"
|
||||
data = self._convert_image(icon)
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
|
@ -196,7 +196,11 @@ class AsciiDoc:
|
|||
continue
|
||||
self._build_website_file(item_path.parent, item_path.name)
|
||||
|
||||
copy = {'icons': 'icons', 'doc/img': 'doc/img', 'www/media': 'media/'}
|
||||
copy = {
|
||||
'qutebrowser/icons': 'icons',
|
||||
'doc/img': 'doc/img',
|
||||
'www/media': 'media/',
|
||||
}
|
||||
|
||||
for src, dest in copy.items():
|
||||
full_src = REPO_ROOT / src
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2014-2021 Florian Bruhin (The-Compiler) <me@the-compiler.org>
|
||||
|
||||
# this file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the gnu general public license as published by
|
||||
# the free software foundation, either version 3 of the license, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but without any warranty; without even the implied warranty of
|
||||
# merchantability or fitness for a particular purpose. see the
|
||||
# gnu general public license for more details.
|
||||
#
|
||||
# you should have received a copy of the gnu general public license
|
||||
# along with qutebrowser. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Generate Qt resources based on source files."""
|
||||
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
ROOT = pathlib.Path(__file__).parents[2]
|
||||
OUTPUT = ROOT / 'qutebrowser' / 'resources.py'
|
||||
INPUT = ROOT / 'misc' / 'qutebrowser.rcc'
|
||||
|
||||
subprocess.run(['pyrcc5', '-o', str(OUTPUT), str(INPUT)], check=True)
|
||||
|
|
@ -294,7 +294,7 @@ def view_user_agent():
|
|||
def favicon():
|
||||
# WORKAROUND for https://github.com/PyCQA/pylint/issues/5783
|
||||
# pylint: disable-next=no-member,useless-suppression
|
||||
icon_dir = END2END_DIR.parents[1] / 'icons'
|
||||
icon_dir = END2END_DIR.parents[1] / 'qutebrowser' / 'icons'
|
||||
return flask.send_from_directory(
|
||||
icon_dir, 'qutebrowser.ico', mimetype='image/vnd.microsoft.icon')
|
||||
|
||||
|
|
|
|||