diff --git a/qtribu/constants.py b/qtribu/constants.py index a4be85b8..0a476a2a 100644 --- a/qtribu/constants.py +++ b/qtribu/constants.py @@ -194,10 +194,7 @@ def local_path(self, base_path: Path = Path().home() / ".geotribu/cdn/") -> Path # QChat QCHAT_NICKNAME_MINLENGTH = 3 ADMIN_MESSAGES_NICKNAME = "admin" -ADMIN_MESSAGES_COLOR = "#ffa500" ADMIN_MESSAGES_AVATAR = "mIconWarning.svg" -MENTION_MESSAGES_COLOR = "#4169e1" -USER_MESSAGES_COLOR = "#00cc00" ERROR_MESSAGES_COLOR = "#ff0000" INTERNAL_MESSAGE_AUTHOR = "internal" diff --git a/qtribu/gui/dck_qchat.py b/qtribu/gui/dck_qchat.py index 066e2a0f..259049de 100644 --- a/qtribu/gui/dck_qchat.py +++ b/qtribu/gui/dck_qchat.py @@ -17,7 +17,6 @@ from qtribu.__about__ import __title__ from qtribu.constants import ( ADMIN_MESSAGES_AVATAR, - ADMIN_MESSAGES_COLOR, ADMIN_MESSAGES_NICKNAME, CHEATCODE_10OCLOCK, CHEATCODE_DIZZY, @@ -25,9 +24,7 @@ CHEATCODE_IAMAROBOT, CHEATCODE_QGIS_PRO_LICENSE, INTERNAL_MESSAGE_AUTHOR, - MENTION_MESSAGES_COLOR, QCHAT_NICKNAME_MINLENGTH, - USER_MESSAGES_COLOR, ) from qtribu.logic.qchat_client import QChatApiClient from qtribu.tasks.dizzy import DizzyTask @@ -345,7 +342,7 @@ def on_ws_message_received(self, message: str) -> None: message["author"], message["avatar"], message["message"], - foreground_color=MENTION_MESSAGES_COLOR, + foreground_color=self.settings.qchat_color_mention, ) self.log( message=self.tr("You were mentionned by {sender}: {message}").format( @@ -362,7 +359,7 @@ def on_ws_message_received(self, message: str) -> None: message["author"], message["avatar"], message["message"], - foreground_color=USER_MESSAGES_COLOR, + foreground_color=self.settings.qchat_color_self, ) else: item = self.create_message_item( @@ -523,7 +520,7 @@ def add_admin_message(self, room: str, message: str) -> None: ADMIN_MESSAGES_NICKNAME, ADMIN_MESSAGES_AVATAR, message, - foreground_color=ADMIN_MESSAGES_COLOR, + foreground_color=self.settings.qchat_color_admin, ) self.twg_chat.insertTopLevelItem(0, item) diff --git a/qtribu/gui/dlg_settings.py b/qtribu/gui/dlg_settings.py index 3943862d..e3e8a283 100644 --- a/qtribu/gui/dlg_settings.py +++ b/qtribu/gui/dlg_settings.py @@ -13,7 +13,7 @@ from qgis.gui import QgsOptionsPageWidget, QgsOptionsWidgetFactory from qgis.PyQt import uic from qgis.PyQt.QtCore import Qt -from qgis.PyQt.QtGui import QIcon +from qgis.PyQt.QtGui import QColor, QIcon from qgis.PyQt.QtWidgets import QButtonGroup, QMessageBox # project @@ -114,6 +114,9 @@ def apply(self): settings.qchat_play_sounds = self.ckb_play_sounds.isChecked() settings.qchat_sound_volume = self.hsl_sound_volume.value() settings.qchat_ring_tone = self.cbb_ring_tone.currentText() + settings.qchat_color_mention = self.cbt_color_mention.color().name() + settings.qchat_color_self = self.cbt_color_self.color().name() + settings.qchat_color_admin = self.cbt_color_admin.color().name() # misc settings.debug_mode = self.opt_debug.isChecked() @@ -162,6 +165,9 @@ def load_settings(self) -> None: ) if beep_index >= 0: self.cbb_ring_tone.setCurrentIndex(beep_index) + self.cbt_color_mention.setColor(QColor(settings.qchat_color_mention)) + self.cbt_color_self.setColor(QColor(settings.qchat_color_self)) + self.cbt_color_admin.setColor(QColor(settings.qchat_color_admin)) # misc self.opt_debug.setChecked(settings.debug_mode) diff --git a/qtribu/gui/dlg_settings.ui b/qtribu/gui/dlg_settings.ui index ff88787a..f9312144 100644 --- a/qtribu/gui/dlg_settings.ui +++ b/qtribu/gui/dlg_settings.ui @@ -353,9 +353,9 @@ - + - Activate cheatcodes + Show avatars @@ -367,9 +367,9 @@ - + - Show avatars + Activate cheatcodes @@ -475,6 +475,79 @@ + + + + + + + 0 + 0 + + + + Mention message color: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Self message color: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Admin message color: + + + + + + + + 0 + 0 + + + + + + @@ -676,6 +749,11 @@ + + QgsColorButton + QToolButton +
qgscolorbutton.h
+
QgsSymbolButton QToolButton @@ -688,6 +766,31 @@ 1
+ + opt_browser_qt + opt_browser_os + opt_notif_push_msg + sbx_notif_duration + btn_reset_read_history + chb_integration_news_feed + chb_license_global_accept + mSymbolButton + cbb_qchat_instance_uri + btn_rules + ckb_show_avatars + ckb_display_admin_messages + ckb_cheatcodes + ckb_play_sounds + hsl_sound_volume + cbb_ring_tone + cbt_color_mention + cbt_color_self + cbt_color_admin + btn_help + btn_report + opt_debug + btn_reset + diff --git a/qtribu/toolbelt/preferences.py b/qtribu/toolbelt/preferences.py index 884ffec0..98f97ddc 100644 --- a/qtribu/toolbelt/preferences.py +++ b/qtribu/toolbelt/preferences.py @@ -39,6 +39,9 @@ class PlgSettingsStructure: qchat_play_sounds: bool = True qchat_sound_volume: int = 33 qchat_ring_tone: str = "beep_1" + qchat_color_mention: str = "#4169e1" + qchat_color_self: str = "#00cc00" + qchat_color_admin: str = "#ffa500" # usage browser: int = 1