From fb21e41090ec471b55c459dd79c650f2bbba195e Mon Sep 17 00:00:00 2001 From: Faerbit Date: Wed, 17 Nov 2021 16:03:16 +0100 Subject: [PATCH] Bundle icons --- LICENSE | 3 + src/fime/icons/__init__.py | 325 +++++++++++++++++++++++++ src/fime/icons/appointment-new.svg | 18 ++ src/fime/icons/arrow-left.svg | 10 + src/fime/icons/arrow-right.svg | 10 + src/fime/icons/dialog-cancel.svg | 13 + src/fime/icons/dialog-ok.svg | 1 + src/fime/icons/go-next.svg | 10 + src/fime/icons/list-add.svg | 12 + src/fime/icons/list-remove.svg | 12 + src/fime/icons/resources.qrc | 13 + src/fime/icons/update-bundled-icons.sh | 2 + src/fime/import_task.py | 5 +- src/fime/main.py | 14 +- src/fime/report.py | 12 +- src/fime/task_edit.py | 8 +- src/fime/util.py | 8 + 17 files changed, 459 insertions(+), 17 deletions(-) create mode 100644 src/fime/icons/__init__.py create mode 100644 src/fime/icons/appointment-new.svg create mode 100644 src/fime/icons/arrow-left.svg create mode 100644 src/fime/icons/arrow-right.svg create mode 100644 src/fime/icons/dialog-cancel.svg create mode 100644 src/fime/icons/dialog-ok.svg create mode 100644 src/fime/icons/go-next.svg create mode 100644 src/fime/icons/list-add.svg create mode 100644 src/fime/icons/list-remove.svg create mode 100644 src/fime/icons/resources.qrc create mode 100755 src/fime/icons/update-bundled-icons.sh diff --git a/LICENSE b/LICENSE index d560612..3da73b5 100644 --- a/LICENSE +++ b/LICENSE @@ -17,3 +17,6 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Included icons are taken from KDE breeze-icons (https://invent.kde.org/frameworks/breeze-icons), +which are licensed under LGPL 3. \ No newline at end of file diff --git a/src/fime/icons/__init__.py b/src/fime/icons/__init__.py new file mode 100644 index 0000000..c994718 --- /dev/null +++ b/src/fime/icons/__init__.py @@ -0,0 +1,325 @@ +# Resource object code (Python 3) +# Created by: object code +# Created by: The Resource Compiler for Qt version 5.15.2 +# WARNING! All changes made in this file will be lost! + +from PySide2 import QtCore + +qt_resource_data = b"\ +\x00\x00\x02\xdd\ +<\ +svg xmlns=\x22http:\ +//www.w3.org/200\ +0/svg\x22 viewBox=\x22\ +0 0 32 32\x22>\x0a \x0a \ +\x0a \x0a \x0a\x0a\ +\x00\x00\x02`\ +<\ +svg xmlns=\x22http:\ +//www.w3.org/200\ +0/svg\x22 viewBox=\x22\ +0 0 32 32\x22>\x0a \x0a \x0a \ + .ColorScheme-T\ +ext {\x0a co\ +lor:#232629;\x0a \ + }\x0a \x0a \x0a \ +\x0a\x0a\ +\x00\x00\x01L\ +<\ +svg viewBox=\x220 0\ + 32 32\x22 xmlns=\x22h\ +ttp://www.w3.org\ +/2000/svg\x22>\x0a \ +\x0a .Color\ +Scheme-Text {\x0a \ + color:\ +#232629;\x0a \ + }\x0a \x0a\ + \x0a\x0a\ +\x00\x00\x01K\ +<\ +svg viewBox=\x220 0\ + 32 32\x22 xmlns=\x22h\ +ttp://www.w3.org\ +/2000/svg\x22>\x0a \ +\x0a .Color\ +Scheme-Text {\x0a \ + color:\ +#232629;\x0a \ + }\x0a \x0a\ + \x0a\x0a\ +\x00\x00\x01\xe6\ +<\ +svg xmlns=\x22http:\ +//www.w3.org/200\ +0/svg\x22 viewBox=\x22\ +0 0 24 24\x22 width\ +=\x2224\x22 height=\x2224\ +\x22>\x0a \x0a \x0a\ + .ColorSche\ +me-Text {\x0a \ + color:#232629;\ +\x0a }\x0a <\ +/style>\x0a \x0a \x0a \x0a \x0a\x0a\ +\x00\x00\x01L\ +<\ +svg viewBox=\x220 0\ + 32 32\x22 xmlns=\x22h\ +ttp://www.w3.org\ +/2000/svg\x22>\x0a \ +\x0a .Color\ +Scheme-Text {\x0a \ + color:\ +#232629;\x0a \ + }\x0a \x0a\ + \x0a\x0a\ +\x00\x00\x01c\ +<\ +svg viewBox=\x220 0\ + 32 32\x22 xmlns=\x22h\ +ttp://www.w3.org\ +/2000/svg\x22>.Col\ +orScheme-Text{co\ +lor:#232629;}\ +\x00\x00\x01\xa2\ +<\ +svg xmlns=\x22http:\ +//www.w3.org/200\ +0/svg\x22 viewBox=\x22\ +0 0 24 24\x22 width\ +=\x2224\x22 height=\x2224\ +\x22>\x0a \x0a \x0a\ + .ColorSche\ +me-Text {\x0a \ + color:#232629;\ +\x0a }\x0a <\ +/style>\x0a \x0a \x0a \x0a \x0a\ +\x0a\ +" + +qt_resource_name = b"\ +\x00\x05\ +\x00o\xa6S\ +\x00i\ +\x00c\x00o\x00n\x00s\ +\x00\x11\ +\x03S\x8a\x87\ +\x00d\ +\x00i\x00a\x00l\x00o\x00g\x00-\x00c\x00a\x00n\x00c\x00e\x00l\x00.\x00s\x00v\x00g\ +\ +\x00\x13\ +\x03gvg\ +\x00a\ +\x00p\x00p\x00o\x00i\x00n\x00t\x00m\x00e\x00n\x00t\x00-\x00n\x00e\x00w\x00.\x00s\ +\x00v\x00g\ +\x00\x0f\ +\x0f\x22iG\ +\x00a\ +\x00r\x00r\x00o\x00w\x00-\x00r\x00i\x00g\x00h\x00t\x00.\x00s\x00v\x00g\ +\x00\x0e\ +\x08\xfa8\xa7\ +\x00a\ +\x00r\x00r\x00o\x00w\x00-\x00l\x00e\x00f\x00t\x00.\x00s\x00v\x00g\ +\x00\x0c\ +\x09\xc6\x14\xa7\ +\x00l\ +\x00i\x00s\x00t\x00-\x00a\x00d\x00d\x00.\x00s\x00v\x00g\ +\x00\x0b\ +\x0c+\x12G\ +\x00g\ +\x00o\x00-\x00n\x00e\x00x\x00t\x00.\x00s\x00v\x00g\ +\x00\x0d\ +\x09\xae0'\ +\x00d\ +\x00i\x00a\x00l\x00o\x00g\x00-\x00o\x00k\x00.\x00s\x00v\x00g\ +\x00\x0f\ +\x020\x86g\ +\x00l\ +\x00i\x00s\x00t\x00-\x00r\x00e\x00m\x00o\x00v\x00e\x00.\x00s\x00v\x00g\ +" + +qt_resource_struct = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x08\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x01\x04\x00\x00\x00\x00\x00\x01\x00\x00\x0c\x85\ +\x00\x00\x01}.b\xfd-\ +\x00\x00\x00\x10\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +\x00\x00\x01}.a\xe4+\ +\x00\x00\x008\x00\x00\x00\x00\x00\x01\x00\x00\x02\xe1\ +\x00\x00\x01}.\x1a\xb9\xf9\ +\x00\x00\x00\x88\x00\x00\x00\x00\x00\x01\x00\x00\x06\x95\ +\x00\x00\x01}.b $\ +\x00\x00\x00\xe4\x00\x00\x00\x00\x00\x01\x00\x00\x0b\x1e\ +\x00\x00\x01}.a\xce_\ +\x00\x00\x00\xaa\x00\x00\x00\x00\x00\x01\x00\x00\x07\xe4\ +\x00\x00\x01}.b\xe1.\ +\x00\x00\x00\xc8\x00\x00\x00\x00\x00\x01\x00\x00\x09\xce\ +\x00\x00\x01}.b\x05\xfc\ +\x00\x00\x00d\x00\x00\x00\x00\x00\x01\x00\x00\x05E\ +\x00\x00\x01}.b1)\ +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/src/fime/icons/appointment-new.svg b/src/fime/icons/appointment-new.svg new file mode 100644 index 0000000..6c3fec5 --- /dev/null +++ b/src/fime/icons/appointment-new.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/fime/icons/arrow-left.svg b/src/fime/icons/arrow-left.svg new file mode 100644 index 0000000..e5b8d02 --- /dev/null +++ b/src/fime/icons/arrow-left.svg @@ -0,0 +1,10 @@ + + + + diff --git a/src/fime/icons/arrow-right.svg b/src/fime/icons/arrow-right.svg new file mode 100644 index 0000000..1859a8e --- /dev/null +++ b/src/fime/icons/arrow-right.svg @@ -0,0 +1,10 @@ + + + + diff --git a/src/fime/icons/dialog-cancel.svg b/src/fime/icons/dialog-cancel.svg new file mode 100644 index 0000000..2179310 --- /dev/null +++ b/src/fime/icons/dialog-cancel.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/fime/icons/dialog-ok.svg b/src/fime/icons/dialog-ok.svg new file mode 100644 index 0000000..d05eca7 --- /dev/null +++ b/src/fime/icons/dialog-ok.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/fime/icons/go-next.svg b/src/fime/icons/go-next.svg new file mode 100644 index 0000000..1859a8e --- /dev/null +++ b/src/fime/icons/go-next.svg @@ -0,0 +1,10 @@ + + + + diff --git a/src/fime/icons/list-add.svg b/src/fime/icons/list-add.svg new file mode 100644 index 0000000..faf7f59 --- /dev/null +++ b/src/fime/icons/list-add.svg @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/fime/icons/list-remove.svg b/src/fime/icons/list-remove.svg new file mode 100644 index 0000000..16bf531 --- /dev/null +++ b/src/fime/icons/list-remove.svg @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/fime/icons/resources.qrc b/src/fime/icons/resources.qrc new file mode 100644 index 0000000..a202299 --- /dev/null +++ b/src/fime/icons/resources.qrc @@ -0,0 +1,13 @@ + + + + appointment-new.svg + arrow-left.svg + arrow-right.svg + dialog-cancel.svg + dialog-ok.svg + go-next.svg + list-add.svg + list-remove.svg + + \ No newline at end of file diff --git a/src/fime/icons/update-bundled-icons.sh b/src/fime/icons/update-bundled-icons.sh new file mode 100755 index 0000000..cc9fe04 --- /dev/null +++ b/src/fime/icons/update-bundled-icons.sh @@ -0,0 +1,2 @@ +#!/bin/sh +rcc resources.qrc -g python -o __init__.py diff --git a/src/fime/import_task.py b/src/fime/import_task.py index 44b8f02..1c0e6d4 100644 --- a/src/fime/import_task.py +++ b/src/fime/import_task.py @@ -1,6 +1,7 @@ from PySide2 import QtGui, QtWidgets from fime.task_completer import TaskCompleter +from fime.util import get_icon class ImportTask(QtWidgets.QDialog): @@ -15,13 +16,13 @@ class ImportTask(QtWidgets.QDialog): ok_button = QtWidgets.QPushButton() ok_button.setText("OK") - ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok")) + ok_button.setIcon(get_icon("dialog-ok")) ok_button.pressed.connect(self.accept) ok_button.setAutoDefault(True) cancel_button = QtWidgets.QPushButton() cancel_button.setText("Cancel") - cancel_button.setIcon(QtGui.QIcon.fromTheme("dialog-cancel")) + cancel_button.setIcon(get_icon("dialog-cancel")) cancel_button.pressed.connect(self.reject) cancel_button.setAutoDefault(False) diff --git a/src/fime/main.py b/src/fime/main.py index 6b3b8c8..8ae4743 100755 --- a/src/fime/main.py +++ b/src/fime/main.py @@ -1,18 +1,20 @@ #!/usr/bin/env python3 -import sys import signal +import sys from functools import partial -from PySide2 import QtCore, QtGui, QtWidgets +from PySide2 import QtCore, QtWidgets from PySide2.QtWidgets import QMessageBox +# noinspection PyUnresolvedReferences +import fime.icons from fime.data import Tasks, Log, Data from fime.exceptions import FimeException from fime.import_task import ImportTask -from fime.task_edit import TaskEdit from fime.report import Report -from fime.util import get_screen_height +from fime.task_edit import TaskEdit +from fime.util import get_screen_height, get_icon class App: @@ -24,7 +26,7 @@ class App: self.log = Log(data) self._active_task = self.log.last_log() or "Nothing" - icon = QtGui.QIcon.fromTheme("appointment-new") + icon = get_icon("appointment-new") self.menu = QtWidgets.QMenu() @@ -79,7 +81,7 @@ class App: action = self.menu.addAction(t) action.triggered.connect(partial(self.change_task, t)) if t == self.active_task: - action.setIcon(QtGui.QIcon.fromTheme("go-next")) + action.setIcon(get_icon("go-next")) tmp_action = self.menu.addAction("tmp") action_height = self.menu.actionGeometry(tmp_action).height() diff --git a/src/fime/report.py b/src/fime/report.py index e5bb8d5..cc4c2ec 100644 --- a/src/fime/report.py +++ b/src/fime/report.py @@ -5,7 +5,7 @@ from datetime import datetime from PySide2.QtWidgets import QHeaderView from fime.data import Tasks -from fime.util import get_screen_height +from fime.util import get_screen_height, get_icon class Report(QtWidgets.QDialog): @@ -47,31 +47,31 @@ class Report(QtWidgets.QDialog): self.previous_button = QtWidgets.QPushButton() self.previous_button.setText("Previous") - self.previous_button.setIcon(QtGui.QIcon.fromTheme("arrow-left")) + self.previous_button.setIcon(get_icon("arrow-left")) self.previous_button.pressed.connect(self.previous) self.previous_button.setAutoDefault(False) self.next_button = QtWidgets.QPushButton() self.next_button.setText("Next") - self.next_button.setIcon(QtGui.QIcon.fromTheme("arrow-right")) + self.next_button.setIcon(get_icon("arrow-right")) self.next_button.pressed.connect(self.next) self.next_button.setAutoDefault(False) new_button = QtWidgets.QPushButton() new_button.setText("New item") - new_button.setIcon(QtGui.QIcon.fromTheme("list-add")) + new_button.setIcon(get_icon("list-add")) new_button.pressed.connect(self.new_log) new_button.setAutoDefault(False) del_button = QtWidgets.QPushButton() del_button.setText("Delete item") - del_button.setIcon(QtGui.QIcon.fromTheme("list-remove")) + del_button.setIcon(get_icon("list-remove")) del_button.pressed.connect(self.del_log) del_button.setAutoDefault(False) ok_button = QtWidgets.QPushButton() ok_button.setText("OK") - ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok")) + ok_button.setIcon(get_icon("dialog-ok")) ok_button.pressed.connect(self._accept) ok_button.setAutoDefault(True) diff --git a/src/fime/task_edit.py b/src/fime/task_edit.py index cda6d2e..f0d77d2 100644 --- a/src/fime/task_edit.py +++ b/src/fime/task_edit.py @@ -1,5 +1,7 @@ from PySide2 import QtCore, QtGui, QtWidgets +from fime.util import get_icon + class TaskEdit(QtWidgets.QDialog): def __init__(self, parent, *args, **kwargs): @@ -15,19 +17,19 @@ class TaskEdit(QtWidgets.QDialog): new_button = QtWidgets.QPushButton() new_button.setText("New item") - new_button.setIcon(QtGui.QIcon.fromTheme("list-add")) + new_button.setIcon(get_icon("list-add")) new_button.pressed.connect(self.new_task) new_button.setAutoDefault(False) del_button = QtWidgets.QPushButton() del_button.setText("Delete item") - del_button.setIcon(QtGui.QIcon.fromTheme("list-remove")) + del_button.setIcon(get_icon("list-remove")) del_button.pressed.connect(self.del_task) del_button.setAutoDefault(False) ok_button = QtWidgets.QPushButton() ok_button.setText("OK") - ok_button.setIcon(QtGui.QIcon.fromTheme("dialog-ok")) + ok_button.setIcon(get_icon("dialog-ok")) ok_button.pressed.connect(self.accept) ok_button.setAutoDefault(True) diff --git a/src/fime/util.py b/src/fime/util.py index 012bc77..d38294b 100644 --- a/src/fime/util.py +++ b/src/fime/util.py @@ -1,6 +1,14 @@ +from PySide2 import QtGui + + def get_screen_height(qobject): if hasattr(qobject, "screen"): return qobject.screen().size().height() else: print("unable to detect screen height falling back to default value of 1080") return 1080 + + +def get_icon(icon_name): + fallback = QtGui.QIcon(f":/icons/{icon_name}").pixmap(256, 256) + return QtGui.QIcon.fromTheme(icon_name, fallback)