add option to set date label as system locale format

This commit is contained in:
dries.k
2023-05-22 23:22:23 +02:00
parent 42f3cfcd9d
commit 234557df46
5 changed files with 20 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ from ..__version__ import __title__
DEFAULT_SETTINGS = {
"theme": "automatic",
"message/check_missed/notify": True,
"locale": False,
"logging/level": "Disabled",
"export/path": os.path.join(
Path.home(), f"{__title__.replace(' ', '-').lower()}-settings.bytes"
@@ -30,4 +31,4 @@ DEFAULT_SETTINGS = {
"ImagePopup/extensions": [".jpg", ".jpeg", ".png", ".svg"],
"ImagePopup/w": 400,
"ImagePopup/h": 400,
}
}

View File

@@ -12,7 +12,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(402, 392)
Dialog.resize(415, 450)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
@@ -81,6 +81,9 @@ class Ui_Dialog(object):
self.cb_priority_colors = QtWidgets.QCheckBox(self.groupBox_2)
self.cb_priority_colors.setObjectName("cb_priority_colors")
self.verticalLayout_2.addWidget(self.cb_priority_colors)
self.cb_locale = QtWidgets.QCheckBox(self.groupBox_2)
self.cb_locale.setObjectName("cb_locale")
self.verticalLayout_2.addWidget(self.cb_locale)
self.verticalLayout_4.addWidget(self.groupBox_2)
self.groupBox_server_info = QtWidgets.QGroupBox(self.tab_general)
self.groupBox_server_info.setObjectName("groupBox_server_info")
@@ -240,6 +243,7 @@ class Ui_Dialog(object):
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_locale.setText(_translate("Dialog", "Display date in the system locale format"))
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"))

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>392</height>
<width>415</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
@@ -168,6 +168,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_locale">
<property name="text">
<string>Display date in the system locale format</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -41,7 +41,7 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
# Display message contents
self.label_title.setText(message.title)
self.label_date.setText(message.date.strftime("%Y-%m-%d, %H:%M"))
self.label_date.setText(message.date.strftime("%x, %X" if settings.value("locale", type=bool) else "%Y-%m-%d, %H:%M"))
if message.get("extras", {}).get("client::display", {}).get("contentType") == "text/markdown":
self.label_message.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)

View File

@@ -65,6 +65,7 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
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))
self.cb_locale.setChecked(settings.value("locale", type=bool))
# Logging
self.combo_logging.addItems(
@@ -197,6 +198,7 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
# Interface
self.combo_theme.currentTextChanged.connect(self.settings_changed_callback)
self.cb_priority_colors.stateChanged.connect(self.settings_changed_callback)
self.cb_locale.stateChanged.connect(self.settings_changed_callback)
# Server info
self.pb_change_server_info.clicked.connect(self.change_server_info_callback)
@@ -238,6 +240,7 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
self.theme_change_requested.emit(selected_theme)
settings.setValue("MessageWidget/priority_color", self.cb_priority_colors.isChecked())
settings.setValue("locale", self.cb_locale.isChecked())
# Logging
selected_level = self.combo_logging.currentText()