Skip to content

Commit

Permalink
feat: remove Room column
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Jul 26, 2024
1 parent 4078135 commit 80b4db6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
17 changes: 5 additions & 12 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def __init__(self, iface: QgisInterface, parent: QWidget = None):
# tree widget initialization
self.twg_chat.setHeaderLabels(
[
self.tr("Room"),
self.tr("Date"),
self.tr("Nickname"),
self.tr("Message"),
Expand Down Expand Up @@ -361,7 +360,6 @@ def on_ws_message_received(self, message: str) -> None:
words = message["message"].split(" ")
if f"@{self.settings.author_nickname}" in words or "@all" in words:
item = self.create_message_item(
self.current_room,
message["author"],
message["avatar"],
message["message"],
Expand All @@ -378,15 +376,13 @@ def on_ws_message_received(self, message: str) -> None:
)
elif message["author"] == self.settings.author_nickname:
item = self.create_message_item(
self.current_room,
message["author"],
message["avatar"],
message["message"],
foreground_color=self.settings.qchat_color_self,
)
else:
item = self.create_message_item(
self.current_room,
message["author"],
message["avatar"],
message["message"],
Expand Down Expand Up @@ -421,16 +417,16 @@ def on_message_double_clicked(self, item: QTreeWidgetItem, column: int) -> None:
Action called when double clicking on a chat message
"""
text = self.lne_message.text()
author = item.text(2)
author = item.text(1)
self.lne_message.setText(f"{text}@{author} ")

def on_custom_context_menu_requested(self, point: QPoint) -> None:
"""
Action called when right clicking on a chat message
"""
item = self.twg_chat.itemAt(point)
author = item.text(2)
message = item.text(3)
author = item.text(1)
message = item.text(2)

menu = QMenu(self.tr("QChat Menu"), self)

Expand Down Expand Up @@ -540,7 +536,6 @@ def add_admin_message(self, room: str, message: str) -> None:
Adds an admin message to QTreeWidget chat
"""
item = self.create_message_item(
room,
ADMIN_MESSAGES_NICKNAME,
ADMIN_MESSAGES_AVATAR,
message,
Expand All @@ -550,7 +545,6 @@ def add_admin_message(self, room: str, message: str) -> None:

def create_message_item(
self,
room: str,
author: str,
avatar: Optional[str],
message: str,
Expand All @@ -562,15 +556,14 @@ def create_message_item(
Optionally with foreground / background colors given as hexa string
"""
item_data = [
room,
QTime.currentTime().toString(),
author,
message,
]
item = QTreeWidgetItem(item_data)
if self.settings.qchat_show_avatars and avatar:
item.setIcon(2, QIcon(QgsApplication.iconPath(avatar)))
item.setToolTip(3, message)
item.setIcon(1, QIcon(QgsApplication.iconPath(avatar)))
item.setToolTip(2, message)
if foreground_color:
for i in range(len(item_data)):
item.setForeground(i, QBrush(QColor(foreground_color)))
Expand Down
7 changes: 1 addition & 6 deletions qtribu/gui/dck_qchat.ui
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
<number>3</number>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
Expand All @@ -205,11 +205,6 @@
<string notr="true">3</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">4</string>
</property>
</column>
</widget>
</item>
<item>
Expand Down

0 comments on commit 80b4db6

Please sign in to comment.