From 166a8206a3747628182a97acbc25bf393e78eac9 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sat, 15 Apr 2017 16:08:40 +0200 Subject: Handle joining of channels, tab UI, probably some other things --- IrcWindow.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'IrcWindow.py') diff --git a/IrcWindow.py b/IrcWindow.py index 77a61cd..4dc0d4c 100644 --- a/IrcWindow.py +++ b/IrcWindow.py @@ -1,5 +1,5 @@ from PyQt5.QtCore import QUrl, QThread, pyqtSignal, QObject, pyqtSlot, Qt -from PyQt5.QtWidgets import QApplication +from PyQt5.QtWidgets import QApplication, QTabBar from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow from PyQt5.QtQml import QQmlApplicationEngine from PyQt5.QtGui import QGuiApplication, QKeyEvent @@ -11,34 +11,43 @@ class IrcWindow(QQuickWindow): def __init__(self, view): super(self.__class__, self).__init__() self.view = view - self.handler = IrcHandler.IrcHandler() + self.handler = IrcHandler.IrcHandler(self) self.dumpQMLComponents(self.view) + self.connect_button = self.view.findChild(QQuickItem, "connect_button") self.send_button = self.view.findChild(QQuickItem, "send_button") self.input_field = self.view.findChild(QQuickItem, "input") self.chat_area = self.view.findChild(QQuickItem, "chat_area") + self.nick_list = self.view.findChild(QQuickItem, "nick_list") + self.channel_tabs = self.view.findChild(QQuickItem, "channel_tabs") self.send_button.clicked.connect(self.handle_input) self.connect_button.clicked.connect(self.connect_to_irc) self.input_field.send_to_irc.connect(self.handle_input) - print(self.input_field) def connect_to_irc(self): self.handler.connect_to_irc(self) def handle_input(self): - self.handler.handle_input(self) + self.handler.handle_input() - def get_input(self): - return self.input_field.property("text") + def get_input(self, channel): + print(channel) + channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) + channel_input = channel_tab.findChild(QQuickItem, "input") + return channel_input.property("text") - def reset_input(self): - self.input_field.setProperty("text", "") + def reset_input(self, channel): + channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) + channel_input = channel_tab.findChild(QQuickItem, "input") + channel_input.setProperty("text", "") @pyqtSlot(str) - def update_chat(self, text): - self.chat_area.append(text) + def update_chat(self, channel, text): + channel_tab = self.view.findChild(QQuickItem, "channel-" + channel) + channel_chat_area = channel_tab.findChild(QQuickItem, "chat_area") + channel_chat_area.append(text) def dumpQMLComponents(self, root): children = root.findChildren(QObject) -- cgit v1.2.3