Skip to content

Commit

Permalink
ui(qchat): vertically optimize the QChat widget
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Nov 1, 2024
1 parent 574c6b5 commit c7faeec
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 95 deletions.
39 changes: 35 additions & 4 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ def __init__(
QIcon(QgsApplication.iconPath("mActionAddImage.svg"))
)

# send extent message signa 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 signa 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()
Expand All @@ -187,7 +199,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))
)
Expand Down Expand Up @@ -360,8 +374,7 @@ 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.grb_room.setTitle(self.tr("Room ({room}) - connected").format(room=room))
self.btn_list_users.setEnabled(True)
self.grb_user.setEnabled(True)
self.current_room = room
Expand Down Expand Up @@ -397,7 +410,7 @@ 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 - disconnected"))
self.grb_room.setTitle(self.tr("Room"))
self.grb_qchat.setTitle(self.tr("QChat"))
self.btn_list_users.setEnabled(False)
Expand Down Expand Up @@ -747,6 +760,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:
Expand All @@ -759,6 +776,20 @@ 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
Expand Down
176 changes: 85 additions & 91 deletions qtribu/gui/dck_qchat.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>441</width>
<width>446</width>
<height>887</height>
</rect>
</property>
Expand Down Expand Up @@ -118,6 +118,25 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_list_users">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>List users</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_connect">
<property name="sizePolicy">
Expand All @@ -136,20 +155,6 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_status_text">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lbl_status">
<property name="text">
<string>Not connected</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -222,19 +227,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="hly_qchat_buttons">
<item>
<widget class="QPushButton" name="btn_list_users">
<property name="enabled">
<bool>false</bool>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>List users</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_clear_chat">
<property name="cursor">
Expand Down Expand Up @@ -276,70 +268,72 @@
<property name="title">
<string>User</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<widget class="QLabel" name="lbl_nickname_text">
<property name="text">
<string>Nickname:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_message">
<property name="text">
<string>Message:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="btn_send">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send message</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lbl_nickname">
<property name="cursor">
<cursorShape>ForbiddenCursor</cursorShape>
</property>
<property name="toolTip">
<string>Nickname set in QTribu's plugin settings</string>
</property>
<property name="text">
<string notr="true">Nickname</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QgsFilterLineEdit" name="lne_message">
<property name="qgisRelation" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="btn_send_image">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send Image</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="hly_text_message">
<item>
<widget class="QLabel" name="lbl_message">
<property name="text">
<string>Message:</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFilterLineEdit" name="lne_message">
<property name="qgisRelation" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_send">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="btn_send_screenshot">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send QGIS screenshot</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="hly_send_actions">
<item>
<widget class="QPushButton" name="btn_send_image">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send Image</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_send_screenshot">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Send QGIS screenshot</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_send_extent">
<property name="text">
<string>Send Extent</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_send_crs">
<property name="text">
<string>Send CRS</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down

0 comments on commit c7faeec

Please sign in to comment.