diff options
-rw-r--r-- | IrcChannelForm.ui.qml | 8 | ||||
-rw-r--r-- | IrcConnection.py | 14 | ||||
-rw-r--r-- | IrcHandler.py | 16 | ||||
-rw-r--r-- | main.qml | 2 |
4 files changed, 33 insertions, 7 deletions
diff --git a/IrcChannelForm.ui.qml b/IrcChannelForm.ui.qml index a3158d0..993c41f 100644 --- a/IrcChannelForm.ui.qml +++ b/IrcChannelForm.ui.qml @@ -106,6 +106,14 @@ Item { } } } + + function update_nick(previous_nick, new_nick){ + for (var i = 0; i < nickListModel.count; ++i) { + if (nickListModel.get(i).nick === previous_nick) { + nickListModel.setProperty(i, "nick", new_nick) + } + } + } } Button { diff --git a/IrcConnection.py b/IrcConnection.py index 2df5913..7345f6d 100644 --- a/IrcConnection.py +++ b/IrcConnection.py @@ -5,9 +5,9 @@ import IrcHandler class ircConnectThread(QThread): sig = pyqtSignal(str, str, str) - nick_sig = pyqtSignal(str, str) + join_sig = pyqtSignal(str, str) part_sig = pyqtSignal(str, str) - join_sig = pyqtSignal(str) + nick_sig = pyqtSignal(str, str) topic_sig = pyqtSignal(str, str) namreply_sig = pyqtSignal(str, str) quit_sig = pyqtSignal(str, str) @@ -44,12 +44,13 @@ class ircConnectThread(QThread): self.c.add_global_handler("currenttopic", self.on_cur_topic) self.c.add_global_handler("topic", self.on_topic) self.c.add_global_handler("topicinfo", self.on_topic) + self.c.add_global_handler("nick", self.on_nick) self.c.add_global_handler("motd", self.on_motd) self.reactor.process_forever() def on_connect(self, connection, event): if irc.client.is_channel("#wtest"): - self.join_sig.emit("#wtest") + # self.join_sig.emit("#wtest") return def on_pubmsg(self, connection, event): print(event) @@ -61,7 +62,7 @@ class ircConnectThread(QThread): def on_join(self, connection, event): print(event) nick = event.source.split("!")[0] - self.nick_sig.emit(event.target, event.source.split("!")[0]) + self.join_sig.emit(event.target, event.source.split("!")[0]) def on_part(self, connection, event): nick = event.source.split("!")[0] @@ -102,6 +103,11 @@ class ircConnectThread(QThread): self.topic_sig.emit(event.target, event.arguments[0]) print(event) + def on_nick(self, connection, event): + source_nick = event.source.split("!")[0] + self.nick_sig.emit(source_nick, event.target) + print(event) + def on_motd(self, connection, event): print(event) diff --git a/IrcHandler.py b/IrcHandler.py index 7d87ac5..589087f 100644 --- a/IrcHandler.py +++ b/IrcHandler.py @@ -145,6 +145,18 @@ class IrcHandler(QObject): channel.set_topic(topic) self.window.update_topic(channel, topic) + def handle_nick(self, previous_nick, new_nick): + for channel_name, channel in self.channels.items(): + if (previous_nick in channel.get_users()): + channel = self.channels.get(channel_name) + user_list = channel.get_view().findChild(QQuickItem, "nick_list") + chat_area = channel.get_view().findChild(QQuickItem, "chat_area") + user_list.update_nick(previous_nick, new_nick) + new_user = User.User(new_nick, channel.get_users()[previous_nick].get_mode()) + channel.remove_user(previous_nick) + channel.add_user(new_user) + chat_area.append(previous_nick + " is now known as " + new_nick) + def handle_user_mode(self, channelStr, target_user, mode, source_user): if (channelStr in self.channels): channel = self.channels.get(channelStr) @@ -181,9 +193,9 @@ class IrcHandler(QObject): def connect_to_irc(self, view): self.irc.sig.connect(self.handle_msg) - self.irc.join_sig.connect(self.join_channel) self.irc.namreply_sig.connect(self.handle_nicks) - self.irc.nick_sig.connect(self.handle_join) + self.irc.join_sig.connect(self.handle_join) + self.irc.nick_sig.connect(self.handle_nick) self.irc.part_sig.connect(self.handle_part) self.irc.quit_sig.connect(self.handle_quit) self.irc.kick_sig.connect(self.handle_kick) @@ -15,6 +15,7 @@ ApplicationWindow { currentIndex: channel_tabs.currentIndex IrcChannel { + objectName: "channel-status" } } @@ -27,7 +28,6 @@ ApplicationWindow { id: channel_tabs objectName: "channel_tabs" TabButton { - objectName: "channel-status" text: "status" } |