From cc8795bc6f45cf4dea898e5fc07d9d7b007c5e8e Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Wed, 24 Jul 2024 15:04:03 +0200 Subject: [PATCH] refacto: rename into nickname to make it generic --- qtribu/gui/dck_qchat.py | 14 +++++++------- qtribu/gui/wdg_authoring.py | 4 ++-- qtribu/toolbelt/preferences.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/qtribu/gui/dck_qchat.py b/qtribu/gui/dck_qchat.py index ad408528..c823b148 100644 --- a/qtribu/gui/dck_qchat.py +++ b/qtribu/gui/dck_qchat.py @@ -119,7 +119,7 @@ def load_settings(self) -> None: self.grb_instance.setTitle( self.tr("Instance: {uri}").format(uri=self.settings.qchat_instance_uri) ) - self.lbl_nickname.setText(self.settings.qchat_nickname) + self.lbl_nickname.setText(self.settings.author_nickname) def on_widget_opened(self) -> None: """ @@ -194,12 +194,12 @@ def on_settings_button_clicked(self) -> None: """ # save current instance and nickname to check afterwards if they have changed old_instance = self.settings.qchat_instance_uri - old_nickname = self.settings.qchat_nickname + old_nickname = self.settings.author_nickname self.iface.showOptionsDialog(currentPage=f"mOptionsPage{__title__}") # get new instance and nickname settings new_instance = self.settings.qchat_instance_uri - new_nickname = self.settings.qchat_nickname + new_nickname = self.settings.author_nickname # disconnect if instance or nickname have changed if old_instance != new_instance or old_nickname != new_nickname: @@ -319,7 +319,7 @@ def on_ws_message_received(self, message: str) -> None: return # check if message mentions current user - if f"@{self.settings.qchat_nickname}" in message["message"]: + if f"@{self.settings.author_nickname}" in message["message"]: item = self.create_message_item( self.current_room, message["author"], @@ -334,7 +334,7 @@ def on_ws_message_received(self, message: str) -> None: push=PlgOptionsManager().get_plg_settings().notify_push_info, duration=PlgOptionsManager().get_plg_settings().notify_push_duration, ) - elif message["author"] == self.settings.qchat_nickname: + elif message["author"] == self.settings.author_nickname: item = self.create_message_item( self.current_room, message["author"], @@ -350,7 +350,7 @@ def on_ws_message_received(self, message: str) -> None: # check if a notification sound should be played if ( self.settings.qchat_play_sounds - and message["author"] != self.settings.qchat_nickname + and message["author"] != self.settings.author_nickname ): play_resource_sound( self.settings.qchat_ring_tone, self.settings.qchat_sound_volume @@ -381,7 +381,7 @@ def on_send_button_clicked(self) -> None: """ # retrieve nickname and message - nickname = self.settings.qchat_nickname + nickname = self.settings.author_nickname message_text = self.lne_message.text() if not nickname: diff --git a/qtribu/gui/wdg_authoring.py b/qtribu/gui/wdg_authoring.py index f0715848..68b6f3e5 100644 --- a/qtribu/gui/wdg_authoring.py +++ b/qtribu/gui/wdg_authoring.py @@ -37,7 +37,7 @@ def load_settings(self) -> dict: settings = self.plg_settings.get_plg_settings() # author - self.lne_qchat_nickname.setText(settings.qchat_nickname) + self.lne_qchat_nickname.setText(settings.author_nickname) self.lne_firstname.setText(settings.author_firstname) self.lne_lastname.setText(settings.author_lastname) self.lne_email.setText(settings.author_email) @@ -52,7 +52,7 @@ def save_settings(self) -> None: settings = self.plg_settings.get_plg_settings() # store user inputs - settings.qchat_nickname = self.lne_qchat_nickname.text() + settings.author_nickname = self.lne_qchat_nickname.text() settings.author_firstname = self.lne_firstname.text() settings.author_lastname = self.lne_lastname.text() settings.author_email = self.lne_email.text() diff --git a/qtribu/toolbelt/preferences.py b/qtribu/toolbelt/preferences.py index 5e713f06..d507303c 100644 --- a/qtribu/toolbelt/preferences.py +++ b/qtribu/toolbelt/preferences.py @@ -33,7 +33,6 @@ class PlgSettingsStructure: # QChat qchat_instance_uri: str = "https://gischat.geotribu.net" - qchat_nickname: str = "J.D." qchat_activate_cheatcode: bool = True qchat_play_sounds: bool = True qchat_sound_volume: int = 33 @@ -55,6 +54,7 @@ class PlgSettingsStructure: ) # authoring + author_nickname: str = "" author_firstname: str = "" author_lastname: str = "" author_email: str = ""