Use Qt resources for the window icon.

This commit is contained in:
Florian Bruhin 2014-12-28 15:05:49 +01:00
parent ea5ee0e7c8
commit d1d6fb3dce
7 changed files with 5730 additions and 25 deletions

1
.gitignore vendored
View File

@ -10,7 +10,6 @@ __pycache__
/setuptools-*.egg
/setuptools-*.zip
/qutebrowser/git-commit-id
/qutebrowser/icons
/doc/*.html
/README.html
/qutebrowser/html/doc/

View File

@ -1,6 +1,5 @@
recursive-include qutebrowser/html *.html
recursive-include qutebrowser/test *.py
recursive-include qutebrowser/icons *
recursive-include icons *
include qutebrowser/test/testfile
include qutebrowser/git-commit-id

13
qutebrowser.rcc Normal file
View File

@ -0,0 +1,13 @@
<!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>

View File

@ -37,6 +37,7 @@ from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
QStandardPaths, QObject, Qt)
import qutebrowser
import qutebrowser.resources # pylint: disable=unused-import
from qutebrowser.commands import cmdutils, runners
from qutebrowser.config import style, config, websettings
from qutebrowser.browser import quickmarks, cookies, cache, adblock
@ -202,12 +203,8 @@ class Application(QApplication):
"""Initialize the icon of qutebrowser."""
icon = QIcon()
for size in (16, 24, 32, 48, 64, 96, 128, 256, 512):
filename = 'icons/qutebrowser-{}x{}.png'.format(size, size)
data = utils.read_file(filename, binary=True)
pixmap = QPixmap()
ok = pixmap.loadFromData(data, 'PNG')
if not ok:
raise ValueError("Could not load icon!")
filename = ':/icons/qutebrowser-{}x{}.png'.format(size, size)
pixmap = QPixmap(filename)
qtutils.ensure_not_null(pixmap)
icon.addPixmap(pixmap)
qtutils.ensure_not_null(icon)

5707
qutebrowser/resources.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,6 @@ build_exe_options = {
('qutebrowser/html', 'html'),
('qutebrowser/html/doc', 'html/doc'),
('qutebrowser/git-commit-id', 'git-commit-id'),
('icons', 'icons'),
],
'include_msvcr': True,
'excludes': ['tkinter'],

View File

@ -23,25 +23,16 @@
import os
import os.path
import glob
import shutil
from scripts import setupcommon as common
import setuptools
BASEDIR = os.path.dirname(os.path.realpath(__file__))
icon_path = os.path.join('qutebrowser', 'icons')
try:
shutil.rmtree(icon_path)
except OSError:
pass
os.mkdir(icon_path)
for fn in glob.glob('icons/*.png'):
shutil.copy(fn, icon_path)
BASEDIR = os.path.dirname(os.path.realpath(__file__))
except NameError:
BASEDIR = None
try:
@ -54,10 +45,10 @@ try:
test_suite='qutebrowser.test',
zip_safe=True,
install_requires=['pypeg2', 'jinja2', 'pygments'],
data_files=[('icons', glob.glob('icons/*'))],
**common.setupdata
)
finally:
if BASEDIR is not None:
path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id')
if os.path.exists(path):
os.remove(path)