summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IrcChannelForm.ui.qml1
-rw-r--r--IrcConnection.py7
-rw-r--r--IrcHandler.py21
-rw-r--r--main.qml13
4 files changed, 40 insertions, 2 deletions
diff --git a/IrcChannelForm.ui.qml b/IrcChannelForm.ui.qml
index 993c41f..a963dda 100644
--- a/IrcChannelForm.ui.qml
+++ b/IrcChannelForm.ui.qml
@@ -20,6 +20,7 @@ Item {
x: 8
y: 8
readOnly: true
+ selectByMouse: true
font.family: "Source Code Pro"
font.pointSize: 9
}
diff --git a/IrcConnection.py b/IrcConnection.py
index 7345f6d..08240fe 100644
--- a/IrcConnection.py
+++ b/IrcConnection.py
@@ -125,3 +125,10 @@ class ircConnectThread(QThread):
self.c.join(channel)
#TODO: handle errors such as invalid/passworded channel
return True
+
+ @pyqtSlot(str)
+ def part_channel(self, channel):
+ print(channel)
+ self.c.part(channel)
+ #TODO: handle errors such as invalid/passworded channel
+ return True
diff --git a/IrcHandler.py b/IrcHandler.py
index 589087f..9fd8b39 100644
--- a/IrcHandler.py
+++ b/IrcHandler.py
@@ -26,6 +26,9 @@ class IrcHandler(QObject):
def add_channel(self, channel):
self.channels[channel.get_name()] = channel
+ def remove_channel(self, channel_name):
+ del self.channels[channel_name]
+
def get_server():
return self.server
@@ -53,15 +56,29 @@ class IrcHandler(QObject):
input_field.send_to_irc.connect(self.handle_input)
channel.set_view(channel_view)
+ def part_channel(self, channelStr):
+ if (channelStr in self.channels):
+ res = self.irc.part_channel(channelStr)
+ if (res):
+ self.remove_channel(channelStr)
+ self.window.channel_tabs.remove_channel(channelStr)
+
def handle_input(self):
current_channel = self.window.channel_tabs.property('currentItem').property('text')
text = self.window.get_input(current_channel)
if (text.startswith("/")):
- command = text.split(" ")[0][1:]
+ params = text.split(" ")
+ command = params[0][1:]
if (command == "join"):
- channel = text.split(" ")[1]
+ channel = params[1]
self.join_channel(channel)
+ elif (command == "part"):
+ if (len(params) > 1 and params[1].strip() != ""):
+ channel = params[1]
+ else:
+ channel = current_channel
+ self.part_channel(channel)
else:
self.sig.emit(current_channel, text)
self.window.update_chat(current_channel, "<b>&lt;" + self.nick + "&gt;</b> " + text)
diff --git a/main.qml b/main.qml
index a4714a8..592e9f0 100644
--- a/main.qml
+++ b/main.qml
@@ -42,5 +42,18 @@ ApplicationWindow {
}
}
}
+
+ function remove_channel(channel) {
+ for (var i = 0; i < channel_tabs.count; ++i) {
+ if (channel_tabs.itemAt(i).text === channel) {
+ channel_tabs.removeItem(i)
+ }
+ }
+ for (var i = 0; i < swipeView.children.length; ++i) {
+ if (swipeView.children[i].objectName === "channel-"+channel) {
+ swipeView.children[i].destroy()
+ }
+ }
+ }
}
}