display message priority colors
This commit is contained in:
@@ -34,6 +34,9 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
|
||||
# Fonts
|
||||
self.set_fonts()
|
||||
|
||||
# Display the message priority as a color
|
||||
self.set_priority_color(message.priority)
|
||||
|
||||
# Display message contents
|
||||
self.label_title.setText(message.title)
|
||||
self.label_date.setText(message.date.strftime("%Y-%m-%d, %H:%M"))
|
||||
@@ -68,7 +71,7 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
|
||||
self.label_image.hide()
|
||||
|
||||
# Set MessagesModelItem's size hint based on the size of this widget
|
||||
self.gridLayout_frame.setContentsMargins(5, 5, 5, 5)
|
||||
self.gridLayout_frame.setContentsMargins(0, 0, 5, 0)
|
||||
self.gridLayout.setContentsMargins(4, 5, 4, 0)
|
||||
self.adjustSize()
|
||||
size_hint = self.message_item.sizeHint()
|
||||
@@ -125,6 +128,16 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
|
||||
|
||||
self.label_message.setPixmap(pixmap)
|
||||
|
||||
def set_priority_color(self, priority: int):
|
||||
if not settings.value("MessageWidget/priority_color", type=bool):
|
||||
self.label_priority.setFixedWidth(0) # set width to 0 instead of hiding, so we still get the content margins
|
||||
return
|
||||
|
||||
if priority >= 4 and priority <= 7:
|
||||
self.label_priority.setStyleSheet("background-color: rgba(230, 126, 34, 0.7);")
|
||||
elif priority > 7:
|
||||
self.label_priority.setStyleSheet("background-color: #e74c3c;")
|
||||
|
||||
def link_hovered_callback(self, link: str):
|
||||
if not settings.value("ImagePopup/enabled", type=bool):
|
||||
return
|
||||
|
||||
@@ -71,9 +71,12 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
settings.value("tray/icon/unread", type=bool)
|
||||
)
|
||||
|
||||
# Theme
|
||||
# Interface
|
||||
self.combo_theme.addItems(get_themes())
|
||||
self.combo_theme.setCurrentText(settings.value("theme", type=str))
|
||||
self.cb_priority_colors.setChecked(
|
||||
settings.value("MessageWidget/priority_color", type=bool)
|
||||
)
|
||||
|
||||
# Logging
|
||||
self.combo_logging.addItems(
|
||||
@@ -108,6 +111,7 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
"date": "2021-01-01T11:11:00.928224+01:00",
|
||||
"message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin luctus.",
|
||||
"title": "Title",
|
||||
"priority": 4,
|
||||
}
|
||||
)
|
||||
),
|
||||
@@ -209,8 +213,9 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.cb_notification_click.stateChanged.connect(self.settings_changed_callback)
|
||||
self.cb_tray_icon_unread.stateChanged.connect(self.settings_changed_callback)
|
||||
|
||||
# Theme
|
||||
# Interface
|
||||
self.combo_theme.currentTextChanged.connect(self.settings_changed_callback)
|
||||
self.cb_priority_colors.stateChanged.connect(self.settings_changed_callback)
|
||||
|
||||
# Server info
|
||||
self.pb_change_server_info.clicked.connect(self.change_server_info_callback)
|
||||
@@ -254,13 +259,17 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
)
|
||||
settings.setValue("tray/icon/unread", self.cb_tray_icon_unread.isChecked())
|
||||
|
||||
# Theme
|
||||
# Interface
|
||||
current_theme = settings.value("theme", type=str)
|
||||
selected_theme = self.combo_theme.currentText()
|
||||
if current_theme != selected_theme:
|
||||
settings.setValue("theme", selected_theme)
|
||||
self.theme_change_requested.emit(selected_theme)
|
||||
|
||||
settings.setValue(
|
||||
"MessageWidget/priority_color", self.cb_priority_colors.isChecked()
|
||||
)
|
||||
|
||||
# Logging
|
||||
selected_level = self.combo_logging.currentText()
|
||||
settings.setValue("logging/level", selected_level)
|
||||
|
||||
Reference in New Issue
Block a user