add option to toggle server watchdog thread

This commit is contained in:
dries.k
2023-07-09 15:03:10 +02:00
parent 9668fd6bb8
commit 84495caf43
5 changed files with 96 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ DEFAULT_SETTINGS = {
"tray/notifications/icon/show": True,
"tray/notifications/click": True,
"tray/icon/unread": False,
"watchdog/enabled": True,
"watchdog/interval/s": 60,
"MessageWidget/height/min": 100,
"MessageWidget/image/size": 33,

View File

@@ -94,7 +94,8 @@ class MainApplication(QtWidgets.QApplication):
self.link_callbacks()
self.init_shortcuts()
self.watchdog.start()
if settings.value("watchdog/enabled", type=bool):
self.watchdog.start()
def set_theme(self):
set_theme(self)

View File

@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs\widget_settings.ui'
#
# Created by: PyQt6 UI code generator 6.5.0
# Created by: PyQt6 UI code generator 6.5.1
#
# 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.
@@ -12,7 +12,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(415, 420)
Dialog.resize(415, 426)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
@@ -166,6 +166,28 @@ class Ui_Dialog(object):
self.horizontalLayout_4.addItem(spacerItem4)
self.gridLayout_2.addLayout(self.horizontalLayout_4, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.groupbox_image_popup)
self.groupbox_watchdog = QtWidgets.QGroupBox(parent=self.tab_advanced)
self.groupbox_watchdog.setCheckable(True)
self.groupbox_watchdog.setObjectName("groupbox_watchdog")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupbox_watchdog)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_watchdog_interval = QtWidgets.QLabel(parent=self.groupbox_watchdog)
self.label_watchdog_interval.setObjectName("label_watchdog_interval")
self.horizontalLayout_3.addWidget(self.label_watchdog_interval)
self.spin_watchdog_interval = QtWidgets.QSpinBox(parent=self.groupbox_watchdog)
self.spin_watchdog_interval.setMinimum(1)
self.spin_watchdog_interval.setMaximum(100000)
self.spin_watchdog_interval.setObjectName("spin_watchdog_interval")
self.horizontalLayout_3.addWidget(self.spin_watchdog_interval)
self.label_watchdog_interval_s = QtWidgets.QLabel(parent=self.groupbox_watchdog)
self.label_watchdog_interval_s.setObjectName("label_watchdog_interval_s")
self.horizontalLayout_3.addWidget(self.label_watchdog_interval_s)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_3.addItem(spacerItem5)
self.verticalLayout_3.addLayout(self.horizontalLayout_3)
self.verticalLayout.addWidget(self.groupbox_watchdog)
self.groupBox_cache = QtWidgets.QGroupBox(parent=self.tab_advanced)
self.groupBox_cache.setObjectName("groupBox_cache")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.groupBox_cache)
@@ -179,8 +201,8 @@ class Ui_Dialog(object):
self.label_cache = QtWidgets.QLabel(parent=self.groupBox_cache)
self.label_cache.setObjectName("label_cache")
self.horizontalLayout_6.addWidget(self.label_cache)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_6.addItem(spacerItem5)
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_6.addItem(spacerItem6)
self.verticalLayout.addWidget(self.groupBox_cache)
self.groupBox_logging = QtWidgets.QGroupBox(parent=self.tab_advanced)
self.groupBox_logging.setObjectName("groupBox_logging")
@@ -189,8 +211,8 @@ class Ui_Dialog(object):
self.combo_logging = QtWidgets.QComboBox(parent=self.groupBox_logging)
self.combo_logging.setObjectName("combo_logging")
self.gridLayout_6.addWidget(self.combo_logging, 0, 1, 1, 1)
spacerItem6 = QtWidgets.QSpacerItem(190, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.gridLayout_6.addItem(spacerItem6, 0, 3, 1, 1)
spacerItem7 = QtWidgets.QSpacerItem(190, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.gridLayout_6.addItem(spacerItem7, 0, 3, 1, 1)
self.pb_open_log = QtWidgets.QPushButton(parent=self.groupBox_logging)
self.pb_open_log.setMaximumSize(QtCore.QSize(30, 16777215))
self.pb_open_log.setObjectName("pb_open_log")
@@ -199,8 +221,8 @@ class Ui_Dialog(object):
self.label_logging.setObjectName("label_logging")
self.gridLayout_6.addWidget(self.label_logging, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.groupBox_logging)
spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.verticalLayout.addItem(spacerItem7)
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)
@@ -252,6 +274,9 @@ class Ui_Dialog(object):
self.label_2.setToolTip(_translate("Dialog", "Maximum pop-up height"))
self.label_2.setText(_translate("Dialog", "Height"))
self.spin_popup_h.setToolTip(_translate("Dialog", "Maximum pop-up height"))
self.groupbox_watchdog.setTitle(_translate("Dialog", "Server watchdog thread (requires restart)"))
self.label_watchdog_interval.setText(_translate("Dialog", "Interval:"))
self.label_watchdog_interval_s.setText(_translate("Dialog", "s"))
self.groupBox_cache.setTitle(_translate("Dialog", "Cache"))
self.pb_clear_cache.setText(_translate("Dialog", "Clear"))
self.pb_open_cache_dir.setText(_translate("Dialog", "Open"))

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>415</width>
<height>420</height>
<height>426</height>
</rect>
</property>
<property name="windowTitle">
@@ -391,6 +391,59 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_watchdog">
<property name="title">
<string>Server watchdog thread (requires restart)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_watchdog_interval">
<property name="text">
<string>Interval:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spin_watchdog_interval">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_watchdog_interval_s">
<property name="text">
<string>s</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_cache">
<property name="title">

View File

@@ -82,6 +82,8 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
self.spin_popup_h.setValue(settings.value("ImagePopup/h", type=int))
self.label_cache.setText("0 MB")
self.compute_cache_size()
self.groupbox_watchdog.setChecked(settings.value("watchdog/enabled", type=bool))
self.spin_watchdog_interval.setValue(settings.value("watchdog/interval/s", type=int))
def add_message_widget(self):
self.message_widget = MessageWidget(
@@ -215,6 +217,8 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
self.spin_popup_h.valueChanged.connect(self.settings_changed_callback)
self.pb_clear_cache.clicked.connect(self.clear_cache_callback)
self.pb_open_cache_dir.clicked.connect(lambda: open_file(Cache().directory()))
self.groupbox_watchdog.toggled.connect(self.settings_changed_callback)
self.spin_watchdog_interval.valueChanged.connect(self.settings_changed_callback)
def apply_settings(self):
# Priority
@@ -246,6 +250,8 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
settings.setValue("ImagePopup/enabled", self.groupbox_image_popup.isChecked())
settings.setValue("ImagePopup/w", self.spin_popup_w.value())
settings.setValue("ImagePopup/h", self.spin_popup_h.value())
settings.setValue("watchdog/enabled", self.groupbox_watchdog.isChecked())
settings.setValue("watchdog/interval/s", self.spin_watchdog_interval.value())
self.settings_changed = False
self.buttonBox.button(