Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(qchat): use self.settings instead of PlgOptionsManager #217

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading