From 851056852d3a7aae5675935b019a3e4845ac1a50 Mon Sep 17 00:00:00 2001 From: "dries.k" Date: Tue, 22 Aug 2023 20:49:24 +0200 Subject: [PATCH] show version in settings window --- gotify_tray/gui/designs/widget_settings.py | 20 +++++++++++-- gotify_tray/gui/designs/widget_settings.ui | 32 +++++++++++++++++++-- gotify_tray/gui/images/qt.png | Bin 0 -> 729 bytes gotify_tray/gui/widgets/MessageWidget.py | 4 +-- gotify_tray/gui/widgets/SettingsDialog.py | 8 +++++- gotify_tray/utils.py | 8 ++++-- 6 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 gotify_tray/gui/images/qt.png diff --git a/gotify_tray/gui/designs/widget_settings.py b/gotify_tray/gui/designs/widget_settings.py index 92adc27..36f8568 100644 --- a/gotify_tray/gui/designs/widget_settings.py +++ b/gotify_tray/gui/designs/widget_settings.py @@ -19,7 +19,7 @@ class Ui_Dialog(object): self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Apply|QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonBox.setObjectName("buttonBox") - self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) + self.gridLayout.addWidget(self.buttonBox, 1, 4, 1, 1) self.tabWidget = QtWidgets.QTabWidget(parent=Dialog) self.tabWidget.setObjectName("tabWidget") self.tab_general = QtWidgets.QWidget() @@ -227,7 +227,23 @@ class Ui_Dialog(object): spacerItem8 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem8) self.tabWidget.addTab(self.tab_advanced, "") - self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) + self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 5) + self.label_qt_icon = QtWidgets.QLabel(parent=Dialog) + self.label_qt_icon.setText("") + self.label_qt_icon.setObjectName("label_qt_icon") + self.gridLayout.addWidget(self.label_qt_icon, 1, 2, 1, 1) + self.label_app_version = QtWidgets.QLabel(parent=Dialog) + self.label_app_version.setText("") + self.label_app_version.setObjectName("label_app_version") + self.gridLayout.addWidget(self.label_app_version, 1, 1, 1, 1) + self.label_app_icon = QtWidgets.QLabel(parent=Dialog) + self.label_app_icon.setText("") + self.label_app_icon.setObjectName("label_app_icon") + self.gridLayout.addWidget(self.label_app_icon, 1, 0, 1, 1) + self.label_qt_version = QtWidgets.QLabel(parent=Dialog) + self.label_qt_version.setText("") + self.label_qt_version.setObjectName("label_qt_version") + self.gridLayout.addWidget(self.label_qt_version, 1, 3, 1, 1) self.retranslateUi(Dialog) self.tabWidget.setCurrentIndex(0) diff --git a/gotify_tray/gui/designs/widget_settings.ui b/gotify_tray/gui/designs/widget_settings.ui index 9cec302..2850ce7 100644 --- a/gotify_tray/gui/designs/widget_settings.ui +++ b/gotify_tray/gui/designs/widget_settings.ui @@ -14,7 +14,7 @@ Dialog - + Qt::Horizontal @@ -24,7 +24,7 @@ - + 0 @@ -559,6 +559,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gotify_tray/gui/images/qt.png b/gotify_tray/gui/images/qt.png new file mode 100644 index 0000000000000000000000000000000000000000..2e0d97ff691058e952fcf78ab872635be28c299b GIT binary patch literal 729 zcmeAS@N?(olHy`uVBq!ia0vp^Vn8gw!3-o-jq62#6id3JuOkD)#(wTUiL5}rLb6AY zF9SoB8UsT^3j@P1pisjL28L1t28LG&3=CE?7#PG0=Ijcz0ZQBs@Ck7R(vD|?9L@zg zoDBvtfXE3sALKUw(i|G&l0*Gzx1AnHn{)7jvcKVRSYdfVfC#DRB5AAEmYb*F9T z+x_4Een0U3*zbRTHox9=uqcStHPU>?J{d!3<^P)m8rr{`C9%1BDoqyxm>+^7k5mIGhC@ zk;Oo|4TKr}L+`BtGT2KzeO=j~u!?Y-3fDMX00r$jPZ!4!iOad?uL>P95MaHqK>Y3_ zp#@7_y$f~Uefl5o(y*|l@pnP`bDI?N9z*fE!!xA+|5)0Xpz-JE`97D>_e(UVU;Z%Ly+)_X zNK`vr=(Y;q4E<>bvUE4@TA17FUVdQSiw{5f*8B;ye%X*0dS0kI=EbWs^Y{<%+pDfW z`G@TM`5Ud{Hi#5x`{!-~x?HuyHKHUXu_VKYk@7#doc8e17! zY8x0>85pEK6f8i|kei>9nO2EggUFthXMh?cK{f>ErERK(!v>gTe~DWM4f+&@J~ literal 0 HcmV?d00001 diff --git a/gotify_tray/gui/widgets/MessageWidget.py b/gotify_tray/gui/widgets/MessageWidget.py index 8d5afa9..ee550ff 100644 --- a/gotify_tray/gui/widgets/MessageWidget.py +++ b/gotify_tray/gui/widgets/MessageWidget.py @@ -6,7 +6,7 @@ from ..models.MessagesModel import MessageItemDataRole, MessagesModelItem from ..designs.widget_message import Ui_Form from gotify_tray.database import Downloader from gotify_tray.database import Settings -from gotify_tray.utils import convert_links, get_image, update_widget_property +from gotify_tray.utils import convert_links, extract_image, update_widget_property from gotify_tray.gui.themes import get_theme_file from gotify_tray.gotify.models import GotifyMessageModel @@ -50,7 +50,7 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form): # If the message is only an image URL, then instead of showing the message, # download the image and show it in the message label - if image_url := get_image(message.message): + if image_url := extract_image(message.message): downloader = Downloader() filename = downloader.get_filename(image_url) self.set_message_image(filename) diff --git a/gotify_tray/gui/widgets/SettingsDialog.py b/gotify_tray/gui/widgets/SettingsDialog.py index 70173a3..1c0555d 100644 --- a/gotify_tray/gui/widgets/SettingsDialog.py +++ b/gotify_tray/gui/widgets/SettingsDialog.py @@ -2,11 +2,12 @@ import logging import platform import os +from gotify_tray.__version__ import __version__ from gotify_tray.database import Cache, Settings from gotify_tray.gotify import GotifyMessageModel from gotify_tray.gui.models import MessagesModelItem from . import MessageWidget -from gotify_tray.utils import get_icon, verify_server, open_file +from gotify_tray.utils import get_image, get_icon, verify_server, open_file from gotify_tray.tasks import ( ExportSettingsTask, ImportSettingsTask, @@ -87,6 +88,11 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog): self.groupbox_watchdog.setChecked(settings.value("watchdog/enabled", type=bool)) self.spin_watchdog_interval.setValue(settings.value("watchdog/interval/s", type=int)) + self.label_app_version.setText(__version__) + self.label_qt_version.setText(QtCore.QT_VERSION_STR) + self.label_app_icon.setPixmap(QtGui.QIcon(get_image("logo.ico")).pixmap(22,22)) + self.label_qt_icon.setPixmap(QtGui.QIcon(get_image("qt.png")).pixmap(22,22)) + def add_message_widget(self): self.message_widget = MessageWidget( self, diff --git a/gotify_tray/utils.py b/gotify_tray/utils.py index 9a6e7d7..40d5fa3 100644 --- a/gotify_tray/utils.py +++ b/gotify_tray/utils.py @@ -35,7 +35,7 @@ def verify_server(force_new: bool = False, enable_import: bool = True) -> bool: def process_messages(messages: list[gotify.GotifyMessageModel]) -> Iterator[gotify.GotifyMessageModel]: downloader = Downloader() for message in messages: - if image_url := get_image(message.message): + if image_url := extract_image(message.message): downloader.get_filename(image_url) yield message @@ -57,7 +57,7 @@ def convert_links(text): return _link.sub(replace, text) -def get_image(s: str) -> str | None: +def extract_image(s: str) -> str | None: """If `s` contains only an image URL, this function returns that URL. This function also extracts a URL in the `![]()` markdown image format. """ @@ -91,6 +91,10 @@ def open_file(filename: str): subprocess.call(["open", filename]) +def get_image(name: str) -> str: + return get_abs_path(f"gotify_tray/gui/images/{name}") + + def get_icon(name: str) -> str: if platform.system() == "Darwin": name += "-macos"