Skip to content

Commit

Permalink
refactor(qchat): use self.settings instead of PlgOptionsManager (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux authored and Guts committed Nov 6, 2024
1 parent 2ab1b55 commit 2dd2c35
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def on_uncompliant_message_received(self, message: QChatUncompliantMessage) -> N
),
application=self.tr("QChat"),
log_level=Qgis.Critical,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)

def on_text_message_received(self, message: QChatTextMessage) -> None:
Expand Down Expand Up @@ -464,10 +464,8 @@ def on_text_message_received(self, message: QChatTextMessage) -> None:
).format(sender=message.author, message=message.text),
application=self.tr("QChat"),
log_level=Qgis.Info,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager()
.get_plg_settings()
.notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)

# check if a notification sound should be played
Expand Down Expand Up @@ -535,8 +533,8 @@ def on_like_message_received(self, message: QChatLikeMessage) -> None:
),
application=self.tr("QChat"),
log_level=Qgis.Success,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)
# play a notification sound if enabled
if self.settings.qchat_play_sounds:
Expand Down Expand Up @@ -691,8 +689,8 @@ def on_send_button_clicked(self) -> None:
self.log(
message=self.tr("Nickname not set : please open settings and set it"),
log_level=Qgis.Warning,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
button=True,
button_label=self.tr("Open Settings"),
button_connect=self.on_settings_button_clicked,
Expand All @@ -705,8 +703,8 @@ def on_send_button_clicked(self) -> None:
"Nickname too short : must be at least 3 characters. Please open settings and set it"
),
log_level=Qgis.Warning,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
button=True,
button_label=self.tr("Open Settings"),
button_connect=self.on_settings_button_clicked,
Expand Down Expand Up @@ -799,8 +797,8 @@ def check_cheatcode(self, text: str) -> bool:
message=self.tr("Your QGIS Pro license is about to expire"),
application=self.tr("QGIS Pro"),
log_level=Qgis.Warning,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
button=True,
button_label=self.tr("Click here to renew it"),
button_connect=self.on_renew_clicked,
Expand Down Expand Up @@ -851,8 +849,8 @@ def on_send_layer_to_qchat(self) -> None:
),
application=self.tr("QChat"),
log_level=Qgis.Critical,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)
return
layer = self.iface.activeLayer()
Expand All @@ -861,17 +859,17 @@ def on_send_layer_to_qchat(self) -> None:
message=self.tr("No active layer in current QGIS project"),
application=self.tr("QChat"),
log_level=Qgis.Critical,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)
return
if layer.type() != QgsMapLayer.VectorLayer:
self.log(
message=self.tr("Only vector layers can be sent on QChat"),
application=self.tr("QChat"),
log_level=Qgis.Critical,
push=PlgOptionsManager().get_plg_settings().notify_push_info,
duration=PlgOptionsManager().get_plg_settings().notify_push_duration,
push=self.settings.notify_push_info,
duration=self.settings.notify_push_duration,
)
return

Expand Down

0 comments on commit 2dd2c35

Please sign in to comment.