Skip to content

Commit

Permalink
add option to reset fonts to default
Browse files Browse the repository at this point in the history
  • Loading branch information
seird committed Nov 4, 2022
1 parent 332a22b commit f10ada6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
7 changes: 7 additions & 0 deletions gotify_tray/gui/designs/widget_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def setupUi(self, Dialog):
self.tab_fonts.setObjectName("tab_fonts")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tab_fonts)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.pb_reset_fonts = QtWidgets.QPushButton(self.tab_fonts)
self.pb_reset_fonts.setObjectName("pb_reset_fonts")
self.horizontalLayout_5.addWidget(self.pb_reset_fonts)
self.verticalLayout_5.addLayout(self.horizontalLayout_5)
self.groupBox_fonts_message = QtWidgets.QGroupBox(self.tab_fonts)
self.groupBox_fonts_message.setObjectName("groupBox_fonts_message")
self.layout_fonts_message = QtWidgets.QVBoxLayout(self.groupBox_fonts_message)
Expand Down Expand Up @@ -215,6 +221,7 @@ def retranslateUi(self, Dialog):
self.groupBox_server_info.setTitle(_translate("Dialog", "Server info"))
self.pb_change_server_info.setText(_translate("Dialog", "Change server info"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_general), _translate("Dialog", "General"))
self.pb_reset_fonts.setText(_translate("Dialog", "Reset all fonts"))
self.groupBox_fonts_message.setTitle(_translate("Dialog", "Message"))
self.pb_font_message_title.setText(_translate("Dialog", "Title"))
self.pb_font_message_date.setText(_translate("Dialog", "Date"))
Expand Down
11 changes: 11 additions & 0 deletions gotify_tray/gui/designs/widget_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@
<string>Fonts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="pb_reset_fonts">
<property name="text">
<string>Reset all fonts</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_fonts_message">
<property name="title">
Expand Down
33 changes: 26 additions & 7 deletions gotify_tray/gui/widgets/SettingsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def initUI(self):
self.combo_logging.setCurrentText(settings.value("logging/level", type=str))

# Fonts
self.add_message_widget()

# Advanced
self.groupbox_image_popup.setChecked(
settings.value("ImagePopup/enabled", type=bool)
)
self.spin_popup_w.setValue(settings.value("ImagePopup/w", type=int))
self.spin_popup_h.setValue(settings.value("ImagePopup/h", type=int))

def add_message_widget(self):
self.message_widget = MessageWidget(
MessagesModelItem(
GotifyMessageModel(
Expand All @@ -97,13 +107,6 @@ def initUI(self):
)
self.layout_fonts_message.addWidget(self.message_widget)

# Advanced
self.groupbox_image_popup.setChecked(
settings.value("ImagePopup/enabled", type=bool)
)
self.spin_popup_w.setValue(settings.value("ImagePopup/w", type=int))
self.spin_popup_h.setValue(settings.value("ImagePopup/h", type=int))

def change_server_info_callback(self):
self.server_changed = verify_server(force_new=True, enable_import=False)

Expand Down Expand Up @@ -149,6 +152,20 @@ def import_callback(self):
self.import_settings_task.success.connect(self.import_success_callback)
self.import_settings_task.start()

def reset_fonts_callback(self):
response = QtWidgets.QMessageBox.warning(
self,
"Are you sure?",
"Reset all fonts?",
QtWidgets.QMessageBox.StandardButton.Ok
| QtWidgets.QMessageBox.StandardButton.Cancel,
defaultButton=QtWidgets.QMessageBox.StandardButton.Cancel,
)
if response == QtWidgets.QMessageBox.StandardButton.Ok:
settings.remove("MessageWidget/font")
self.layout_fonts_message.removeWidget(self.message_widget)
self.add_message_widget()

def reset_callback(self):
response = QtWidgets.QMessageBox.warning(
self,
Expand Down Expand Up @@ -187,6 +204,8 @@ def link_callbacks(self):
)

# Fonts
self.pb_reset_fonts.clicked.connect(self.reset_fonts_callback)

self.pb_font_message_title.clicked.connect(
lambda: self.change_font_callback("title")
)
Expand Down

0 comments on commit f10ada6

Please sign in to comment.