Пример #1
0
class Chat_Controller(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = chat.Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.chatInput.installEventFilter(self)
        #Loading theme and things like photos and names
        self.theme = Theme()
        self.theme.user.setPhoto("qrc:/resourcedir/nophoto.png")
        self.theme.user.setName("My Name")
        self.theme.guest.setPhoto("qrc:/resourcedir/nophoto.png")
        self.theme.guest.setName("Guest's Name")
        self.talkContent = ""

    def eventFilter(self, obj, event):
        if event.type() == QtCore.QEvent.KeyPress:
            if event.key() == QtCore.Qt.Key_Return:
                self.getTextReturned(obj, event)
                return True
        return False

    def getTextReturned(self, obj, event):
        text = obj.toPlainText()
        obj.setText("")
        self.setTextChatHistory(text)
        pass

    def setTextChatHistory(self, text, isuser=True):
        chatHistory = self.ui.chatHistory
        speakHtml = self.theme.speak(text, isuser)

        chatHistory.setHtml(speakHtml, QtCore.QUrl('qrc:/'))
Пример #2
0
 def __init__(self):
     QtGui.QMainWindow.__init__(self)
     self.ui = chat.Ui_MainWindow()
     self.ui.setupUi(self)
     self.ui.chatInput.installEventFilter(self)
     #Loading theme and things like photos and names
     self.theme = Theme()
     self.theme.user.setPhoto("qrc:/resourcedir/nophoto.png")
     self.theme.user.setName("My Name")
     self.theme.guest.setPhoto("qrc:/resourcedir/nophoto.png")
     self.theme.guest.setName("Guest's Name")
     self.talkContent = ""