Skip to content

Commit

Permalink
add option to disable showing image urls as images
Browse files Browse the repository at this point in the history
  • Loading branch information
seird committed May 17, 2024
1 parent 357cd89 commit 7a173db
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 8 deletions.
1 change: 1 addition & 0 deletions gotify_tray/database/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"MessageWidget/content_image/W_percentage": 1.0,
"MessageWidget/content_image/H_percentage": 0.5,
"MessageWidget/priority_color": True,
"MessageWidget/image_urls": True,
"MainWindow/label/size": 25,
"MainWindow/button/size": 33,
"MainWindow/application/icon/size": 40,
Expand Down
33 changes: 28 additions & 5 deletions gotify_tray/gui/designs/widget_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs\widget_settings.ui'
# Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_settings.ui'
#
# Created by: PyQt6 UI code generator 6.5.2
# Created by: PyQt6 UI code generator 6.4.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
Expand All @@ -12,7 +12,7 @@
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(415, 446)
Dialog.resize(442, 530)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
Expand Down Expand Up @@ -70,6 +70,9 @@ def setupUi(self, Dialog):
self.cb_priority_colors = QtWidgets.QCheckBox(parent=self.groupBox_2)
self.cb_priority_colors.setObjectName("cb_priority_colors")
self.verticalLayout_2.addWidget(self.cb_priority_colors)
self.cb_image_urls = QtWidgets.QCheckBox(parent=self.groupBox_2)
self.cb_image_urls.setObjectName("cb_image_urls")
self.verticalLayout_2.addWidget(self.cb_image_urls)
self.cb_locale = QtWidgets.QCheckBox(parent=self.groupBox_2)
self.cb_locale.setObjectName("cb_locale")
self.verticalLayout_2.addWidget(self.cb_locale)
Expand Down Expand Up @@ -253,10 +256,29 @@ def setupUi(self, Dialog):
Dialog.setTabOrder(self.tabWidget, self.spin_priority)
Dialog.setTabOrder(self.spin_priority, self.spin_duration)
Dialog.setTabOrder(self.spin_duration, self.cb_notify)
Dialog.setTabOrder(self.cb_notify, self.pb_change_server_info)
Dialog.setTabOrder(self.pb_change_server_info, self.pb_font_message_title)
Dialog.setTabOrder(self.cb_notify, self.cb_notification_click)
Dialog.setTabOrder(self.cb_notification_click, self.cb_tray_icon_unread)
Dialog.setTabOrder(self.cb_tray_icon_unread, self.cb_priority_colors)
Dialog.setTabOrder(self.cb_priority_colors, self.cb_image_urls)
Dialog.setTabOrder(self.cb_image_urls, self.cb_locale)
Dialog.setTabOrder(self.cb_locale, self.cb_sort_applications)
Dialog.setTabOrder(self.cb_sort_applications, self.pb_change_server_info)
Dialog.setTabOrder(self.pb_change_server_info, self.pb_reset_fonts)
Dialog.setTabOrder(self.pb_reset_fonts, self.pb_font_message_title)
Dialog.setTabOrder(self.pb_font_message_title, self.pb_font_message_date)
Dialog.setTabOrder(self.pb_font_message_date, self.pb_font_message_content)
Dialog.setTabOrder(self.pb_font_message_content, self.pb_reset)
Dialog.setTabOrder(self.pb_reset, self.pb_import)
Dialog.setTabOrder(self.pb_import, self.pb_export)
Dialog.setTabOrder(self.pb_export, self.groupbox_image_popup)
Dialog.setTabOrder(self.groupbox_image_popup, self.spin_popup_w)
Dialog.setTabOrder(self.spin_popup_w, self.spin_popup_h)
Dialog.setTabOrder(self.spin_popup_h, self.groupbox_watchdog)
Dialog.setTabOrder(self.groupbox_watchdog, self.spin_watchdog_interval)
Dialog.setTabOrder(self.spin_watchdog_interval, self.pb_clear_cache)
Dialog.setTabOrder(self.pb_clear_cache, self.pb_open_cache_dir)
Dialog.setTabOrder(self.pb_open_cache_dir, self.combo_logging)
Dialog.setTabOrder(self.combo_logging, self.pb_open_log)

def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Expand All @@ -272,6 +294,7 @@ def retranslateUi(self, Dialog):
self.cb_priority_colors.setToolTip(_translate("Dialog", "4..7 -> medium\n"
"8..10 -> high"))
self.cb_priority_colors.setText(_translate("Dialog", "Show message priority colors"))
self.cb_image_urls.setText(_translate("Dialog", "Show image urls as images"))
self.cb_locale.setText(_translate("Dialog", "Display date in the system locale format"))
self.cb_sort_applications.setText(_translate("Dialog", "Sort the application list alphabetically (requires restart)"))
self.groupBox_server_info.setTitle(_translate("Dialog", "Server info"))
Expand Down
30 changes: 28 additions & 2 deletions gotify_tray/gui/designs/widget_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>415</width>
<height>446</height>
<width>442</width>
<height>530</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -141,6 +141,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_image_urls">
<property name="text">
<string>Show image urls as images</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_locale">
<property name="text">
Expand Down Expand Up @@ -594,10 +601,29 @@
<tabstop>spin_priority</tabstop>
<tabstop>spin_duration</tabstop>
<tabstop>cb_notify</tabstop>
<tabstop>cb_notification_click</tabstop>
<tabstop>cb_tray_icon_unread</tabstop>
<tabstop>cb_priority_colors</tabstop>
<tabstop>cb_image_urls</tabstop>
<tabstop>cb_locale</tabstop>
<tabstop>cb_sort_applications</tabstop>
<tabstop>pb_change_server_info</tabstop>
<tabstop>pb_reset_fonts</tabstop>
<tabstop>pb_font_message_title</tabstop>
<tabstop>pb_font_message_date</tabstop>
<tabstop>pb_font_message_content</tabstop>
<tabstop>pb_reset</tabstop>
<tabstop>pb_import</tabstop>
<tabstop>pb_export</tabstop>
<tabstop>groupbox_image_popup</tabstop>
<tabstop>spin_popup_w</tabstop>
<tabstop>spin_popup_h</tabstop>
<tabstop>groupbox_watchdog</tabstop>
<tabstop>spin_watchdog_interval</tabstop>
<tabstop>pb_clear_cache</tabstop>
<tabstop>pb_open_cache_dir</tabstop>
<tabstop>combo_logging</tabstop>
<tabstop>pb_open_log</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down
3 changes: 2 additions & 1 deletion gotify_tray/gui/widgets/MessageWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(

# 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 := extract_image(message.message):
image_url = extract_image(message.message) if settings.value("MessageWidget/image_urls", type=bool) else ""
if image_url:
downloader = Downloader()
filename = downloader.get_filename(image_url)
self.set_message_image(filename)
Expand Down
3 changes: 3 additions & 0 deletions gotify_tray/gui/widgets/SettingsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def initUI(self):

# Interface
self.cb_priority_colors.setChecked(settings.value("MessageWidget/priority_color", type=bool))
self.cb_image_urls.setChecked(settings.value("MessageWidget/image_urls", type=bool))
self.cb_locale.setChecked(settings.value("locale", type=bool))
self.cb_sort_applications.setChecked(settings.value("ApplicationModel/sort", type=bool))

Expand Down Expand Up @@ -212,6 +213,7 @@ def link_callbacks(self):

# Interface
self.connect_signal(self.cb_priority_colors.stateChanged, self.cb_priority_colors)
self.connect_signal(self.cb_image_urls.stateChanged, self.cb_image_urls)
self.connect_signal(self.cb_locale.stateChanged, self.cb_locale)
self.connect_signal(self.cb_sort_applications.stateChanged, self.cb_sort_applications)

Expand Down Expand Up @@ -251,6 +253,7 @@ def apply_settings(self):

# Interface
self.set_value("MessageWidget/priority_color", self.cb_priority_colors.isChecked(), self.cb_priority_colors)
self.set_value("MessageWidget/image_urls", self.cb_image_urls.isChecked(), self.cb_image_urls)
self.set_value("locale", self.cb_locale.isChecked(), self.cb_locale)
self.set_value("ApplicationModel/sort", self.cb_sort_applications.isChecked(), self.cb_sort_applications)

Expand Down

0 comments on commit 7a173db

Please sign in to comment.