Changeset 718
- Timestamp:
- 07/18/08 06:03:22 (5 months ago)
- Files:
-
- oss/jlib/examples/basic/client.py (modified) (5 diffs)
- oss/jlib/jlib/core/chat.py (modified) (1 diff)
- oss/jlib/jlib/core/connection.py (modified) (4 diffs)
- oss/jlib/jlib/gui/chat.py (modified) (1 diff)
- oss/jlib/jlib/gui/connection.py (modified) (3 diffs)
- oss/jlib/jlib/gui/contact.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
oss/jlib/examples/basic/client.py
r717 r718 6 6 from jlib.gui.chat import jlibChatWidget 7 7 from jlib.gui.contact import jlibContactWidget 8 from jlib.core.chat import jlibChat, jlibChatComponent 8 9 9 10 from clientui import Ui_MainWindow … … 12 13 def setupUi(self, parent): 13 14 Ui_MainWindow.setupUi(self, parent) 14 QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL("triggered()"), self.showConnectionSettings) 15 QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL("triggered()"), 16 self.showConnectionSettings) 15 17 QtCore.QObject.connect(self.actionStart, QtCore.SIGNAL("triggered()"), self.start) 16 18 QtCore.QObject.connect(self.actionStop, QtCore.SIGNAL("triggered()"), self.stop) … … 19 21 self.actionStart.setEnabled(False) 20 22 self.actionStop.setEnabled(False) 23 24 self.openedChats = [] 21 25 22 26 self.connection = None … … 27 31 28 32 def start(self): 33 QtCore.QObject.connect(self.connection.qobj, QtCore.SIGNAL("sessionReady(PyQt_PyObject)"), 34 self.clientReady) 29 35 self.connection.emit(QtCore.SIGNAL("activateChat()")) 30 36 self.connection.emit(QtCore.SIGNAL("registerLinkages(PyQt_PyObject)"), self.contactUi.contact) … … 52 58 self.actionStart.setEnabled(True) 53 59 self.actionStop.setEnabled(True) 60 61 def clientReady(self, jid): 62 QtCore.QObject.connect(self.connection.qobj.chat, QtCore.SIGNAL("receivedMessage(PyQt_PyObject)"), 63 self.messageReceived) 64 65 def messageReceived(self, message): 66 contact_jid = str(message.from_jid.nodeid()) 67 if contact_jid not in self.openedChats: 68 self._openChat(contact_jid) 69 self.openedChats.append(contact_jid) 70 71 chat = self.connection.qobj.chat 72 chat.emit(QtCore.SIGNAL("receivedMessage.%s(PyQt_PyObject)" % contact_jid), message) 54 73 55 74 def openChat(self, contact): 75 self._openChat(str(contact.jid)) 76 77 def _openChat(self, contact_jid): 56 78 widget = QtGui.QWidget() 57 chatUi = jlibChatWidget( str(contact.jid), chat=self.connection.chat,79 chatUi = jlibChatWidget(contact_jid, chat=self.connection.qobj.chat, 58 80 parent=widget) 59 tab = self.tabWidget.addTab(widget, QtCore.QString( str(contact.jid)))81 tab = self.tabWidget.addTab(widget, QtCore.QString(contact_jid)) 60 82 self.tabWidget.setCurrentIndex(tab) 61 83 oss/jlib/jlib/core/chat.py
r717 r718 98 98 if self.dataReady("inbox"): 99 99 m = self.recv("inbox") 100 self.qobj.emit(QtCore.SIGNAL("receivedMessage .%s(PyQt_PyObject)" % str(m.from_jid.nodeid())), m)100 self.qobj.emit(QtCore.SIGNAL("receivedMessage(PyQt_PyObject)"), m) 101 101 102 102 if not self.anyReady(): oss/jlib/jlib/core/connection.py
r709 r718 22 22 23 23 from jlib.core.qaxon import QAxonObject 24 from jlib.core.chat import jlibChat, jlibChatComponent 24 25 25 26 __all__ = ['jlibConnection', 'jlibConnectionComponent'] … … 32 33 QtCore.QObject.connect(self, QtCore.SIGNAL("registerComponents(PyQt_PyObject, PyQt_PyObject)"), 33 34 self.registerComponents) 35 QtCore.QObject.connect(self, QtCore.SIGNAL("activateChat()"), self.enableChat) 34 36 35 37 def start(self): … … 41 43 def registerComponents(self, components, linkages): 42 44 self.component.registerComponents(components, linkages) 45 46 def enableChat(self): 47 self.chat = jlibChat() 48 self.chat.setComponent(jlibChatComponent()) 49 components, linkages = self.chat.getLinkages() 50 self.registerComponents(components, linkages) 51 52 def messageReceived(self, message): 53 print message 43 54 44 55 class jlibConnectionComponent(component): … … 199 210 if self.dataReady("jid"): 200 211 self.jid = self.recv('jid') 212 self.qobj.emit(QtCore.SIGNAL("sessionReady(PyQt_PyObject)"), self.jid) 201 213 202 214 if not self.anyReady(): oss/jlib/jlib/gui/chat.py
r717 r718 17 17 Ui_jlibChat.setupUi(self, parent) 18 18 QtCore.QObject.connect(self.message, QtCore.SIGNAL("returnPressed()"), self.sendMessage) 19 QtCore.QObject.connect(self.qobj, QtCore.SIGNAL("receivedMessage.%s(PyQt_PyObject)" % s elf.contact_jid),19 QtCore.QObject.connect(self.qobj, QtCore.SIGNAL("receivedMessage.%s(PyQt_PyObject)" % str(self.contact_jid)), 20 20 self.receivedMessage) 21 21 oss/jlib/jlib/gui/connection.py
r717 r718 4 4 from jlib.gui.connectionui import Ui_jlibConnection 5 5 from jlib.core.connection import jlibConnection, jlibConnectionComponent 6 from jlib.core.chat import jlibChat, jlibChatComponent7 6 8 7 __all__ = ['jlibConnectionWidget', 'jlibConnectionDialog'] … … 12 11 QtGui.QWidget.__init__(self, parent) 13 12 self.setupUi(parent=parent) 14 15 self.chat = None16 13 17 14 def setupUi(self, parent=None): … … 41 38 42 39 def enableChat(self): 43 self.chat = jlibChat(parent=self) 44 self.chat.setComponent(jlibChatComponent()) 45 self.registerLinkages(self.chat) 40 self.qobj.emit(QtCore.SIGNAL("activateChat()")) 46 41 47 42 def registerLinkages(self, qobj): oss/jlib/jlib/gui/contact.py
r717 r718 121 121 menu.addAction(actionNewGroup) 122 122 123 actionChangeGroup = QtGui.QAction(QtCore.QString("Change group"), self.parent()) 124 QtCore.QObject.connect(actionChangeGroup, QtCore.SIGNAL("triggered()"), self.changeGroup) 125 menu.addAction(actionChangeGroup) 126 123 127 menu.exec_(event.globalPos()) 124 128 125 129 def dragEnterEvent(self, event): 130 event.ignore() 131 132 133 126 134 data = event.mimeData() 127 135 model = self.contacts.model()
