diff --git a/qtribu/gui/dck_qchat.py b/qtribu/gui/dck_qchat.py
index 6dc66aa4..e815bad9 100644
--- a/qtribu/gui/dck_qchat.py
+++ b/qtribu/gui/dck_qchat.py
@@ -140,6 +140,8 @@ def __init__(
QIcon(QgsApplication.iconPath("processingResult.svg"))
)
+ self.ckb_autoscroll.setChecked(True)
+
# clear chat signal listener
self.btn_clear_chat.pressed.connect(self.on_clear_chat_button_clicked)
self.btn_clear_chat.setIcon(
@@ -183,6 +185,18 @@ def __init__(
QIcon(QgsApplication.iconPath("mActionAddImage.svg"))
)
+ # send extent message signal listener
+ self.btn_send_extent.pressed.connect(self.on_send_extent_button_clicked)
+ self.btn_send_extent.setIcon(
+ QIcon(QgsApplication.iconPath("mActionViewExtentInCanvas.svg"))
+ )
+
+ # send CRS message signal listener
+ self.btn_send_crs.pressed.connect(self.on_send_crs_button_clicked)
+ self.btn_send_crs.setIcon(
+ QIcon(QgsApplication.iconPath("mActionSetProjection.svg"))
+ )
+
@property
def settings(self) -> PlgSettingsStructure:
return self.plg_settings.get_plg_settings()
@@ -192,7 +206,9 @@ 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.author_nickname)
+ self.grb_user.setTitle(
+ self.tr("User: {nickname}").format(nickname=self.settings.author_nickname)
+ )
self.btn_send.setIcon(
QIcon(QgsApplication.iconPath(self.settings.author_avatar))
)
@@ -365,8 +381,6 @@ def on_ws_connected(self, room: str) -> None:
Action called when websocket is connected to a room
"""
self.btn_connect.setText(self.tr("Disconnect"))
- self.lbl_status.setText("Connected")
- self.grb_room.setTitle(self.tr("Room: {room}").format(room=room))
self.btn_list_users.setEnabled(True)
self.grb_user.setEnabled(True)
self.current_room = room
@@ -402,8 +416,6 @@ def disconnect_from_room(self, log: bool = True, close_ws: bool = True) -> None:
),
)
self.btn_connect.setText(self.tr("Connect"))
- self.lbl_status.setText("Disconnected")
- self.grb_room.setTitle(self.tr("Room"))
self.grb_qchat.setTitle(self.tr("QChat"))
self.btn_list_users.setEnabled(False)
self.grb_user.setEnabled(False)
@@ -479,23 +491,22 @@ def on_text_message_received(self, message: QChatTextMessage) -> None:
self.settings.qchat_ring_tone, self.settings.qchat_sound_volume
)
- self.twg_chat.addTopLevelItem(item)
- self.twg_chat.scrollToItem(item)
+ self.add_tree_widget_item(item)
def on_image_message_received(self, message: QChatImageMessage) -> None:
"""
Launched when an image message is received from the websocket
"""
item = QChatImageTreeWidgetItem(self.twg_chat, message)
- self.twg_chat.addTopLevelItem(item)
- self.twg_chat.scrollToItem(item)
+ self.add_tree_widget_item(item)
def on_nb_users_message_received(self, message: QChatNbUsersMessage) -> None:
"""
Launched when a nb_users message is received from the websocket
"""
self.grb_qchat.setTitle(
- self.tr("QChat - {nb_users} {user_txt}").format(
+ self.tr("QChat - room: {room} - {nb_users} {user_txt}").format(
+ room=self.current_room,
nb_users=message.nb_users,
user_txt=self.tr("user") if message.nb_users <= 1 else self.tr("users"),
)
@@ -552,8 +563,7 @@ def on_geojson_message_received(self, message: QChatGeojsonMessage) -> None:
Launched when a geojson message is received from the websocket
"""
item = QChatGeojsonTreeWidgetItem(self.twg_chat, message)
- self.twg_chat.addTopLevelItem(item)
- self.twg_chat.scrollToItem(item)
+ self.add_tree_widget_item(item)
# endregion
@@ -753,6 +763,10 @@ def on_send_image_button_clicked(self) -> None:
self.qchat_ws.send_message(message)
def on_send_screenshot_button_clicked(self) -> None:
+ """
+ Action called when the Send QGIS screenshot button is clicked
+ """
+
sc_fp = os.path.join(tempfile.gettempdir(), "qgis_screenshot.png")
self.iface.mapCanvas().saveAsImage(sc_fp)
with open(sc_fp, "rb") as file:
@@ -765,13 +779,31 @@ def on_send_screenshot_button_clicked(self) -> None:
)
self.qchat_ws.send_message(message)
+ def on_send_extent_button_clicked(self) -> None:
+ """
+ Action called when the Send extent button is clicked
+ """
+ QMessageBox.critical(
+ self, self.tr("Send extent"), self.tr("Not implemented yet")
+ )
+
+ def on_send_crs_button_clicked(self) -> None:
+ """
+ Action called when the Send CRS button is clicked
+ """
+ QMessageBox.critical(self, self.tr("Send CRS"), self.tr("Not implemented yet"))
+
def add_admin_message(self, text: str) -> None:
"""
Adds an admin message to QTreeWidget chat
"""
item = QChatAdminTreeWidgetItem(self.twg_chat, text)
+ self.add_tree_widget_item(item)
+
+ def add_tree_widget_item(self, item: QTreeWidgetItem) -> None:
self.twg_chat.addTopLevelItem(item)
- self.twg_chat.scrollToItem(item)
+ if self.ckb_autoscroll.isChecked():
+ self.twg_chat.scrollToItem(item)
def on_widget_closed(self) -> None:
"""
diff --git a/qtribu/gui/dck_qchat.ui b/qtribu/gui/dck_qchat.ui
index b22c39cc..e62cdeeb 100644
--- a/qtribu/gui/dck_qchat.ui
+++ b/qtribu/gui/dck_qchat.ui
@@ -6,7 +6,7 @@
0
0
- 441
+ 446
887
@@ -51,7 +51,7 @@
-
-
+
0
0
@@ -91,33 +91,82 @@
-
-
+
+
+ true
+
-
+
0
0
+
+
+ 0
+ 1
+
+
+
+
+ 0
+ 1
+
+
- Room
+ QChat
-
-
-
-
-
- Room:
-
-
-
- -
-
+
+ false
+
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Room:
+
+
+
-
+
+
+ 0
+ 0
+
+
+ -
+
+
+ false
+
+
+
+ 0
+ 0
+
+
+
+ PointingHandCursor
+
+
+ List users
+
+
+
-
@@ -136,53 +185,6 @@
- -
-
-
- Status:
-
-
-
- -
-
-
- Not connected
-
-
-
-
-
-
- -
-
-
- true
-
-
-
- 0
- 0
-
-
-
-
- 0
- 1
-
-
-
-
- 0
- 1
-
-
-
- QChat
-
-
- false
-
-
-
@@ -223,15 +225,9 @@
-
-
-
-
- false
-
-
- PointingHandCursor
-
+
- List users
+ Autoscroll to last message
@@ -241,7 +237,7 @@
PointingHandCursor
- Clear
+ Clear chat
@@ -276,70 +272,72 @@
User
-
- -
-
-
- Nickname:
-
-
-
- -
-
-
- Message:
-
-
-
- -
-
-
- PointingHandCursor
-
-
- Send message
-
-
-
- -
-
-
- ForbiddenCursor
-
-
- Nickname set in QTribu's plugin settings
-
-
- Nickname
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- PointingHandCursor
-
-
- Send Image
-
-
+
+
-
+
+
-
+
+
+ Message:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ PointingHandCursor
+
+
+ Send
+
+
+
+
- -
-
-
- PointingHandCursor
-
-
- Send QGIS screenshot
-
-
+
-
+
+
-
+
+
+ PointingHandCursor
+
+
+ Send Image
+
+
+
+ -
+
+
+ PointingHandCursor
+
+
+ Send QGIS screenshot
+
+
+
+ -
+
+
+ Send Extent
+
+
+
+ -
+
+
+ Send CRS
+
+
+
+
diff --git a/qtribu/gui/dlg_settings.py b/qtribu/gui/dlg_settings.py
index 0732f58d..31f57832 100644
--- a/qtribu/gui/dlg_settings.py
+++ b/qtribu/gui/dlg_settings.py
@@ -24,7 +24,7 @@
__uri_tracker__,
__version__,
)
-from qtribu.logic.qchat_client import QChatApiClient
+from qtribu.logic.qchat_api_client import QChatApiClient
from qtribu.toolbelt import PlgLogger, PlgOptionsManager
from qtribu.toolbelt.commons import open_url_in_browser, play_resource_sound
from qtribu.toolbelt.preferences import PlgSettingsStructure