Skip to content

Commit

Permalink
ui(qchat): refactor qchat widget
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Nov 2, 2024
1 parent c7faeec commit bfd8c30
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 54 deletions.
12 changes: 6 additions & 6 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,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(
Expand Down Expand Up @@ -178,13 +180,13 @@ def __init__(
QIcon(QgsApplication.iconPath("mActionAddImage.svg"))
)

# send extent message signa listener
# 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 signa listener
# 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"))
Expand Down Expand Up @@ -374,7 +376,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.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 @@ -410,8 +411,6 @@ def disconnect_from_room(self, log: bool = True, close_ws: bool = True) -> None:
),
)
self.btn_connect.setText(self.tr("Connect"))
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)
self.grb_user.setEnabled(False)
Expand Down Expand Up @@ -505,7 +504,8 @@ 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"),
)
Expand Down
100 changes: 52 additions & 48 deletions qtribu/gui/dck_qchat.ui
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<item>
<widget class="QgsCollapsibleGroupBox" name="grb_instance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -91,28 +91,58 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="grb_room">
<widget class="QgsCollapsibleGroupBox" name="grb_qchat">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="title">
<string>Room</string>
<string notr="true">QChat</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lbl_room">
<property name="text">
<string>Room:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="collapsed">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="hly_room">
<item>
<widget class="QLabel" name="lbl_room">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Room:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbb_room">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentText">
<string notr="true"/>
</property>
Expand Down Expand Up @@ -155,39 +185,6 @@
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="grb_qchat">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="title">
<string notr="true">QChat</string>
</property>
<property name="collapsed">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTreeWidget" name="twg_chat">
<property name="uniformRowHeights">
Expand Down Expand Up @@ -227,13 +224,20 @@
</item>
<item>
<layout class="QHBoxLayout" name="hly_qchat_buttons">
<item>
<widget class="QCheckBox" name="ckb_autoscroll">
<property name="text">
<string>Autoscroll to last message</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_clear_chat">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Clear</string>
<string>Clear chat</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit bfd8c30

Please sign in to comment.