Example #1
0
	def __init__(self, parent=None):
		#QMainWindow.__init__(self, None, Qt.WindowStaysOnTopHint) # always on top
		super(MainWindow, self).__init__(parent)
		
		self.settings = QSettings("Dae-ekleN", "PyTalk")
		
		# add logs widget		
		QWidget.__init__(self)
		self.logsWidget = uic.loadUi(PATH_UI_LOGS)
		self.logsWidget.etx_logs.setReadOnly(True)
		
		# loading .ui
		uic.loadUi(PATH_UI_MAIN, self)
		
		# Set status Offline
		self.cmb_status_box.setCurrentIndex(5)
		self.cmb_status_box.setEnabled(False)
		self.eln_status_edit.hide()
		
		# connecting signals
		self.connect(self.cmb_status_box, SIGNAL("activated(int)"), self.statusUpdate)
		self.connect(self.eln_status_edit, SIGNAL("returnPressed()"), self.statusUpdate)
        
        # Set BuddyList
		self.BuddyList = BuddyList(self)
		self.vboxlayout.insertWidget(0, self.BuddyList)
		#self.connect(self.BuddyList, SIGNAL("rename"), self.addBuddy)
		
		# sleekxmpp connection
		self.im = None
		
		# Account
		self.connect(self.act_connection, SIGNAL("triggered()"), self.showConnectDialog)
		self.connect(self.act_deconnection, SIGNAL("triggered()"), self.disconnect)
		self.connect(self.act_join_group_chat, SIGNAL("triggered()"), self.showMUCDialog)
		self.connect(self.act_add_buddy, SIGNAL("triggered()"), self.showBuddyDialog)
		self.connect(self.act_quit, SIGNAL("triggered()"), self.quitApp)
		self.act_join_group_chat.setEnabled(False)
		self.act_add_buddy.setEnabled(False)
		
		# View
		self.act_away_buddies.setEnabled(False)
		self.act_offline_buddies.setEnabled(False)
		self.connect(self.act_away_buddies, SIGNAL("toogled()"), self.showAwayBuddies)
		self.connect(self.act_offline_buddies, SIGNAL("toogled()"), self.showOfflineBuddies)
		self.connect(self.act_away_buddies, SIGNAL("triggered()"), self.showAwayBuddies)
		self.connect(self.act_offline_buddies, SIGNAL("triggered()"), self.showOfflineBuddies)
		
		# Tools
		self.connect(self.act_logs, SIGNAL("triggered()"), self.showLogs)
		
		# About Dialogs
		self.connect(self.act_about_pytalk, SIGNAL("triggered()"), self.aboutPyTalk)
		self.act_help.triggered.connect(self.showHelp)
		self.act_about_pystudy.triggered.connect(self.aboutPyStudy)
Example #2
0
	def __init__(self, parent = None):
	
		QMainWindow.__init__(self, parent)
		self.setupUi(self)
		
		self.console = QDialog()
		self.te = QTextEdit(self.console)
		self.te.setReadOnly(True)
		vl = QVBoxLayout()
		vl.addWidget(self.te)
		self.console.setLayout(vl)
		
		# Set status Offline
		self.statusBox.setCurrentIndex(5)
		self.statusEdit.hide()

		# Set connect
		self.connect(self.statusBox, SIGNAL("currentIndexChanged(int)"), self.changeStatus)
		self.connect(self.statusEdit, SIGNAL("returnPressed()"), self.changeStatus)

		# Set BuddyList
		self.BuddyList = BuddyList(self)
		self.vboxlayout.insertWidget(0, self.BuddyList)
		self.connect(self.BuddyList, SIGNAL("rename"), self.addBuddy)

		# Connection
		"""
		connection = ConnectionDialog(self)
		self.connect(self.actionConnection, SIGNAL("triggered()"), connection, SLOT("exec()"))
		self.connect(self.actionDeconnection, SIGNAL("triggered()"), self.disconnect)
		self.connect(connection, SIGNAL("configured()"), self.on_connection)
		"""
		# Contacts
		self.connect(self.actionAdd_a_buddy, SIGNAL("triggered()"), self.addBuddy)
		self.connect(self.actionAdd_a_group, SIGNAL("triggered()"), self.addGroup)

		# View
		self.connect(self.actionAway_buddies, SIGNAL("toogled()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("toogled()"), self.setOffline)
		self.connect(self.actionAway_buddies, SIGNAL("triggered()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("triggered()"), self.setOffline)

		# Tools
		self.connect(self.actionConsole, SIGNAL("triggered()"), self.swapConsole)
		
		# About Dialog
		about = AboutDialog(self)
		self.connect(self.actionAbout, SIGNAL("triggered()"), about, SLOT("exec()"))
		self.connect(self.actionAboutQt, SIGNAL("triggered()"), QApplication.instance(), SLOT("aboutQt()"))
		
		# Quit Signal connection
		self.connect(self.actionQuit, SIGNAL("triggered()"), self.quit)
		
		QTimer.singleShot(500, self.show_connection_dialog)
Example #3
0
	def __init__(self, parent=None):
		QtGui.QMainWindow.__init__(self, parent)
		
		self.connectorThread = None
		
		self.setObjectName("MainWindow")
		self.setMaximumWidth(300)
		self.setMaximumHeight(600)
		
		#self.resize(QtCore.QSize(QtCore.QRect(0,0,316,407).size()).expandedTo(MainWindow.minimumSizeHint()))
		self.setWindowIcon(QtGui.QIcon("images/im-jabber.png"))
		self.setUnifiedTitleAndToolBarOnMac(False)

		toolbar = QtGui.QToolBar()
		self.addToolBar(QtCore.Qt.TopToolBarArea, toolbar)

		## Central Widget and Layout
		self.centralwidget = QtGui.QWidget()
		#self.centralwidget.setObjectName("centralwidget")

		self.vboxlayout = QtGui.QVBoxLayout(self.centralwidget)
		#self.vboxlayout.setObjectName("vboxlayout")

		self.statusCombo = QtGui.QComboBox(self.centralwidget)
		#self.statusBox.setObjectName("statusBox")
		self.vboxlayout.addWidget(self.statusCombo)

		self.statusEdit = QtGui.QLineEdit(self.centralwidget)
		#self.statusEdit.setObjectName("statusEdit")
		self.vboxlayout.addWidget(self.statusEdit)
		self.setCentralWidget(self.centralwidget)

		self.menubar = QtGui.QMenuBar()
		self.menubar.setGeometry(QtCore.QRect(0,0,316,29))
		#self.menubar.setObjectName("menubar")

		self.menuContacts = QtGui.QMenu(self.menubar)
		#self.menuContacts.setObjectName("menuContacts")

		self.menuAffichage = QtGui.QMenu(self.menubar)
		#self.menuAffichage.setObjectName("menuAffichage")

		self.menuHelp = QtGui.QMenu(self.menubar)
		self.menuHelp.setObjectName("menuHelp")

		self.menuBuddies = QtGui.QMenu(self.menubar)
		self.menuBuddies.setObjectName("menuBuddies")

		self.menuTools = QtGui.QMenu(self.menubar)
		self.menuTools.setObjectName("menuTools")
		self.setMenuBar(self.menubar)

		self.actionConnection = QtGui.QAction(self)
		self.actionConnection.setIcon(QtGui.QIcon("images/status/log-in.png"))

		self.actionDeconnection = QtGui.QAction(self)
		self.actionDeconnection.setEnabled(False)
		self.actionDeconnection.setIcon(QtGui.QIcon("images/status/log-out.png"))
		self.actionDeconnection.setObjectName("actionDeconnection")

		self.actionOffline_buddies = QtGui.QAction(self)
		self.actionOffline_buddies.setCheckable(True)
		self.actionOffline_buddies.setObjectName("actionOffline_buddies")

		self.actionAway_buddies = QtGui.QAction(self)
		self.actionAway_buddies.setCheckable(True)
		self.actionAway_buddies.setChecked(True)
		self.actionAway_buddies.setObjectName("actionAway_buddies")

		self.actionAbout = QtGui.QAction(self)
		self.actionAbout.setIcon(QtGui.QIcon("images/about.png"))
		self.actionAbout.setObjectName("actionAbout")

		self.actionAboutQt = QtGui.QAction(self)
		self.actionAboutQt.setIcon(QtGui.QIcon("images/qt4.png"))
		self.actionAboutQt.setObjectName("actionAboutQt")

		self.actionQuit = QtGui.QAction(self)
		self.actionQuit.setIcon(QtGui.QIcon("images/exit.png"))
		self.actionQuit.setObjectName("actionQuit")

		self.actionAdd_a_buddy = QtGui.QAction(self)
		self.actionAdd_a_buddy.setIcon(QtGui.QIcon("images/plus.png"))
		self.actionAdd_a_buddy.setObjectName("actionAdd_a_buddy")

		self.actionAdd_a_group = QtGui.QAction(self)
		self.actionAdd_a_group.setIcon(QtGui.QIcon("images/plus.png"))
		self.actionAdd_a_group.setObjectName("actionAdd_a_group")

		self.actionPreferences = QtGui.QAction(self)
		self.actionPreferences.setIcon(QtGui.QIcon("images/preferences.png"))
		self.actionPreferences.setObjectName("actionPreferences")

		self.actionConsole = QtGui.QAction(self)
		self.actionConsole.setObjectName("actionConsole")
		
		self.menuContacts.addAction(self.actionConnection)
		toolbar.addAction(self.actionConnection)
		
		self.menuContacts.addAction(self.actionDeconnection)
		toolbar.addAction(self.actionDeconnection)
		
		self.menuContacts.addAction(self.actionQuit)
		self.menuAffichage.addAction(self.actionOffline_buddies)
		self.menuAffichage.addAction(self.actionAway_buddies)
		self.menuHelp.addAction(self.actionAbout)
		self.menuHelp.addAction(self.actionAboutQt)
		self.menuBuddies.addAction(self.actionAdd_a_buddy)
		self.menuBuddies.addAction(self.actionAdd_a_group)
		self.menuTools.addAction(self.actionPreferences)
		self.menuTools.addAction(self.actionConsole)
		self.menubar.addAction(self.menuContacts.menuAction())
		self.menubar.addAction(self.menuBuddies.menuAction())
		self.menubar.addAction(self.menuAffichage.menuAction())
		self.menubar.addAction(self.menuTools.menuAction())
		self.menubar.addAction(self.menuHelp.menuAction())

		self.console = QtGui.QDialog()
		self.te = QtGui.QTextEdit(self.console)
		self.te.setReadOnly(True)
		vl = QtGui.QVBoxLayout()
		vl.addWidget(self.te)
		self.console.setLayout(vl)
		
		# Set status Offline
		self.statusCombo.setCurrentIndex(5)
		self.statusEdit.hide()

		# Set connect
		self.connect(self.statusCombo, SIGNAL("currentIndexChanged(int)"), self.on_change_status)
		self.connect(self.statusEdit, SIGNAL("returnPressed()"), self.on_change_status)

		# Set BuddyList
		self.buddyList = BuddyList(self)
		self.vboxlayout.insertWidget(0, self.buddyList)
		self.connect(self.buddyList, SIGNAL("rename"), self.on_add_buddy)
		
		self.retranslateUi(MainWindow)
		QtCore.QMetaObject.connectSlotsByName(self)



		# Connection
		"""
		connection = ConnectionDialog(self)
		self.connect(self.actionConnection, SIGNAL("triggered()"), connection, SLOT("exec()"))
		self.connect(self.actionDeconnection, SIGNAL("triggered()"), self.disconnect)
		self.connect(connection, SIGNAL("configured()"), self.on_connection)
		"""
		
		# Contacts
		self.connect(self.actionAdd_a_buddy, SIGNAL("triggered()"), self.on_add_buddy)
		self.connect(self.actionAdd_a_group, SIGNAL("triggered()"), self.on_add_group)

		# View
		self.connect(self.actionAway_buddies, SIGNAL("toogled()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("toogled()"), self.setOffline)
		self.connect(self.actionAway_buddies, SIGNAL("triggered()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("triggered()"), self.setOffline)

		# Tools
		self.connect(self.actionConsole, SIGNAL("triggered()"), self.swapConsole)
		
		# About Dialog
		"""
		about = AboutDialog(self)
		self.connect(self.actionAbout, SIGNAL("triggered()"), about, SLOT("exec()"))
		"""
		self.connect(self.actionAboutQt, SIGNAL("triggered()"), QtGui.QApplication.instance(), SLOT("aboutQt()"))
		
		
		# Quit Signal connection
		self.connect(self.actionQuit, SIGNAL("triggered()"), self.quit)
		
		## Show the Connection dialog after a few moments
		QtCore.QTimer.singleShot(500, self.show_connection_dialog)
Example #4
0
class MainWindow(QtGui.QMainWindow):
	
	def __init__(self, parent=None):
		QtGui.QMainWindow.__init__(self, parent)
		
		self.connectorThread = None
		
		self.setObjectName("MainWindow")
		self.setMaximumWidth(300)
		self.setMaximumHeight(600)
		
		#self.resize(QtCore.QSize(QtCore.QRect(0,0,316,407).size()).expandedTo(MainWindow.minimumSizeHint()))
		self.setWindowIcon(QtGui.QIcon("images/im-jabber.png"))
		self.setUnifiedTitleAndToolBarOnMac(False)

		toolbar = QtGui.QToolBar()
		self.addToolBar(QtCore.Qt.TopToolBarArea, toolbar)

		## Central Widget and Layout
		self.centralwidget = QtGui.QWidget()
		#self.centralwidget.setObjectName("centralwidget")

		self.vboxlayout = QtGui.QVBoxLayout(self.centralwidget)
		#self.vboxlayout.setObjectName("vboxlayout")

		self.statusCombo = QtGui.QComboBox(self.centralwidget)
		#self.statusBox.setObjectName("statusBox")
		self.vboxlayout.addWidget(self.statusCombo)

		self.statusEdit = QtGui.QLineEdit(self.centralwidget)
		#self.statusEdit.setObjectName("statusEdit")
		self.vboxlayout.addWidget(self.statusEdit)
		self.setCentralWidget(self.centralwidget)

		self.menubar = QtGui.QMenuBar()
		self.menubar.setGeometry(QtCore.QRect(0,0,316,29))
		#self.menubar.setObjectName("menubar")

		self.menuContacts = QtGui.QMenu(self.menubar)
		#self.menuContacts.setObjectName("menuContacts")

		self.menuAffichage = QtGui.QMenu(self.menubar)
		#self.menuAffichage.setObjectName("menuAffichage")

		self.menuHelp = QtGui.QMenu(self.menubar)
		self.menuHelp.setObjectName("menuHelp")

		self.menuBuddies = QtGui.QMenu(self.menubar)
		self.menuBuddies.setObjectName("menuBuddies")

		self.menuTools = QtGui.QMenu(self.menubar)
		self.menuTools.setObjectName("menuTools")
		self.setMenuBar(self.menubar)

		self.actionConnection = QtGui.QAction(self)
		self.actionConnection.setIcon(QtGui.QIcon("images/status/log-in.png"))

		self.actionDeconnection = QtGui.QAction(self)
		self.actionDeconnection.setEnabled(False)
		self.actionDeconnection.setIcon(QtGui.QIcon("images/status/log-out.png"))
		self.actionDeconnection.setObjectName("actionDeconnection")

		self.actionOffline_buddies = QtGui.QAction(self)
		self.actionOffline_buddies.setCheckable(True)
		self.actionOffline_buddies.setObjectName("actionOffline_buddies")

		self.actionAway_buddies = QtGui.QAction(self)
		self.actionAway_buddies.setCheckable(True)
		self.actionAway_buddies.setChecked(True)
		self.actionAway_buddies.setObjectName("actionAway_buddies")

		self.actionAbout = QtGui.QAction(self)
		self.actionAbout.setIcon(QtGui.QIcon("images/about.png"))
		self.actionAbout.setObjectName("actionAbout")

		self.actionAboutQt = QtGui.QAction(self)
		self.actionAboutQt.setIcon(QtGui.QIcon("images/qt4.png"))
		self.actionAboutQt.setObjectName("actionAboutQt")

		self.actionQuit = QtGui.QAction(self)
		self.actionQuit.setIcon(QtGui.QIcon("images/exit.png"))
		self.actionQuit.setObjectName("actionQuit")

		self.actionAdd_a_buddy = QtGui.QAction(self)
		self.actionAdd_a_buddy.setIcon(QtGui.QIcon("images/plus.png"))
		self.actionAdd_a_buddy.setObjectName("actionAdd_a_buddy")

		self.actionAdd_a_group = QtGui.QAction(self)
		self.actionAdd_a_group.setIcon(QtGui.QIcon("images/plus.png"))
		self.actionAdd_a_group.setObjectName("actionAdd_a_group")

		self.actionPreferences = QtGui.QAction(self)
		self.actionPreferences.setIcon(QtGui.QIcon("images/preferences.png"))
		self.actionPreferences.setObjectName("actionPreferences")

		self.actionConsole = QtGui.QAction(self)
		self.actionConsole.setObjectName("actionConsole")
		
		self.menuContacts.addAction(self.actionConnection)
		toolbar.addAction(self.actionConnection)
		
		self.menuContacts.addAction(self.actionDeconnection)
		toolbar.addAction(self.actionDeconnection)
		
		self.menuContacts.addAction(self.actionQuit)
		self.menuAffichage.addAction(self.actionOffline_buddies)
		self.menuAffichage.addAction(self.actionAway_buddies)
		self.menuHelp.addAction(self.actionAbout)
		self.menuHelp.addAction(self.actionAboutQt)
		self.menuBuddies.addAction(self.actionAdd_a_buddy)
		self.menuBuddies.addAction(self.actionAdd_a_group)
		self.menuTools.addAction(self.actionPreferences)
		self.menuTools.addAction(self.actionConsole)
		self.menubar.addAction(self.menuContacts.menuAction())
		self.menubar.addAction(self.menuBuddies.menuAction())
		self.menubar.addAction(self.menuAffichage.menuAction())
		self.menubar.addAction(self.menuTools.menuAction())
		self.menubar.addAction(self.menuHelp.menuAction())

		self.console = QtGui.QDialog()
		self.te = QtGui.QTextEdit(self.console)
		self.te.setReadOnly(True)
		vl = QtGui.QVBoxLayout()
		vl.addWidget(self.te)
		self.console.setLayout(vl)
		
		# Set status Offline
		self.statusCombo.setCurrentIndex(5)
		self.statusEdit.hide()

		# Set connect
		self.connect(self.statusCombo, SIGNAL("currentIndexChanged(int)"), self.on_change_status)
		self.connect(self.statusEdit, SIGNAL("returnPressed()"), self.on_change_status)

		# Set BuddyList
		self.buddyList = BuddyList(self)
		self.vboxlayout.insertWidget(0, self.buddyList)
		self.connect(self.buddyList, SIGNAL("rename"), self.on_add_buddy)
		
		self.retranslateUi(MainWindow)
		QtCore.QMetaObject.connectSlotsByName(self)



		# Connection
		"""
		connection = ConnectionDialog(self)
		self.connect(self.actionConnection, SIGNAL("triggered()"), connection, SLOT("exec()"))
		self.connect(self.actionDeconnection, SIGNAL("triggered()"), self.disconnect)
		self.connect(connection, SIGNAL("configured()"), self.on_connection)
		"""
		
		# Contacts
		self.connect(self.actionAdd_a_buddy, SIGNAL("triggered()"), self.on_add_buddy)
		self.connect(self.actionAdd_a_group, SIGNAL("triggered()"), self.on_add_group)

		# View
		self.connect(self.actionAway_buddies, SIGNAL("toogled()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("toogled()"), self.setOffline)
		self.connect(self.actionAway_buddies, SIGNAL("triggered()"), self.setAway)
		self.connect(self.actionOffline_buddies, SIGNAL("triggered()"), self.setOffline)

		# Tools
		self.connect(self.actionConsole, SIGNAL("triggered()"), self.swapConsole)
		
		# About Dialog
		"""
		about = AboutDialog(self)
		self.connect(self.actionAbout, SIGNAL("triggered()"), about, SLOT("exec()"))
		"""
		self.connect(self.actionAboutQt, SIGNAL("triggered()"), QtGui.QApplication.instance(), SLOT("aboutQt()"))
		
		
		# Quit Signal connection
		self.connect(self.actionQuit, SIGNAL("triggered()"), self.quit)
		
		## Show the Connection dialog after a few moments
		QtCore.QTimer.singleShot(500, self.show_connection_dialog)
		
	def retranslateUi(self, MainWindow):
		self.setWindowTitle(QtGui.QApplication.translate("MainWindow", "PyTalk", None, QtGui.QApplication.UnicodeUTF8))
		
		self.statusCombo.addItem(QtGui.QIcon("images/status/available.png"),QtGui.QApplication.translate("MainWindow", "Available", None, QtGui.QApplication.UnicodeUTF8))
		self.statusCombo.addItem(QtGui.QIcon("images/status/chat.png"),QtGui.QApplication.translate("MainWindow", "Chat", None, QtGui.QApplication.UnicodeUTF8))
		self.statusCombo.addItem(QtGui.QIcon("images/status/busy.png"),QtGui.QApplication.translate("MainWindow", "Do not disturb", None, QtGui.QApplication.UnicodeUTF8))
		self.statusCombo.addItem(QtGui.QIcon("images/status/away.png"),QtGui.QApplication.translate("MainWindow", "Away", None, QtGui.QApplication.UnicodeUTF8))
		self.statusCombo.addItem(QtGui.QIcon("images/status/extended-away.png"),QtGui.QApplication.translate("MainWindow", "Extended Away", None, QtGui.QApplication.UnicodeUTF8))
		self.statusCombo.addItem(QtGui.QIcon("images/status/offline.png"),QtGui.QApplication.translate("MainWindow", "Offline", None, QtGui.QApplication.UnicodeUTF8))
		
		self.menuContacts.setTitle(QtGui.QApplication.translate("MainWindow", "Account", None, QtGui.QApplication.UnicodeUTF8))
		self.menuAffichage.setTitle(QtGui.QApplication.translate("MainWindow", "View", None, QtGui.QApplication.UnicodeUTF8))
		self.menuHelp.setTitle(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
		self.menuBuddies.setTitle(QtGui.QApplication.translate("MainWindow", "Buddies", None, QtGui.QApplication.UnicodeUTF8))
		self.menuTools.setTitle(QtGui.QApplication.translate("MainWindow", "Tools", None, QtGui.QApplication.UnicodeUTF8))
		self.actionConnection.setText(QtGui.QApplication.translate("MainWindow", "L&og in", None, QtGui.QApplication.UnicodeUTF8))
		self.actionConnection.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8))
		self.actionDeconnection.setText(QtGui.QApplication.translate("MainWindow", "Log out", None, QtGui.QApplication.UnicodeUTF8))
		self.actionOffline_buddies.setText(QtGui.QApplication.translate("MainWindow", "Offline buddies", None, QtGui.QApplication.UnicodeUTF8))
		self.actionAway_buddies.setText(QtGui.QApplication.translate("MainWindow", "Away buddies", None, QtGui.QApplication.UnicodeUTF8))
		self.actionAbout.setText(QtGui.QApplication.translate("MainWindow", "About pyTalk", None, QtGui.QApplication.UnicodeUTF8))
		self.actionAboutQt.setText(QtGui.QApplication.translate("MainWindow", "About Qt", None, QtGui.QApplication.UnicodeUTF8))
		self.actionQuit.setText(QtGui.QApplication.translate("MainWindow", "&Quit", None, QtGui.QApplication.UnicodeUTF8))
		self.actionQuit.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+Q", None, QtGui.QApplication.UnicodeUTF8))
		self.actionAdd_a_buddy.setText(QtGui.QApplication.translate("MainWindow", "Add a buddy", None, QtGui.QApplication.UnicodeUTF8))
		self.actionAdd_a_group.setText(QtGui.QApplication.translate("MainWindow", "Add a group", None, QtGui.QApplication.UnicodeUTF8))
		self.actionPreferences.setText(QtGui.QApplication.translate("MainWindow", "&Preferences", None, QtGui.QApplication.UnicodeUTF8))
		self.actionPreferences.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+P", None, QtGui.QApplication.UnicodeUTF8))
		self.actionConsole.setText(QtGui.QApplication.translate("MainWindow", "XML Console", None, QtGui.QApplication.UnicodeUTF8))
		

		
	def show_connection_dialog(self):
		d = ConnectionDialog(self)
		if d.exec_():
			self.on_connection()
			self.on_change_status(0)
			#self.statusCombo.set

	def on_connection(self, status=STATUS.available):
		if not self.connectorThread:
			self.connectorThread = ConnectorThread(status)
			self.connectorThread.start()
			self.connect(self.connectorThread, SIGNAL("message"), self.buddyList.message)
			self.connect(self.connectorThread, SIGNAL("error"), self.error)
			self.connect(self.connectorThread, SIGNAL("connected()"), self.connected)
			self.connect(self.connectorThread, SIGNAL("disconnected()"), self.disconnect)
			self.connect(self.connectorThread, SIGNAL("presence"), self.buddyList.presence)
			self.connect(self.connectorThread, SIGNAL("debug"), self.debug)
			self.connect(self.connectorThread, SIGNAL("subscriptionRequest"), self.subscriptionRequest)
			self.connect(self.connectorThread, SIGNAL("addBuddy"), self.on_add_buddy)
			
		elif self.connectorThread.isConnected():
			self.connectorThread.change_status(status, self.statusEdit.text())
			self.statusEdit.clearFocus()

	def disconnect(self):
		self.actionConnection.setEnabled(True)
		self.actionDeconnection.setEnabled(False)
		self.statusEdit.hide()
		self.statusCombo.setCurrentIndex(STATUS.unavailable.index)
		if self.connectorThread:
			self.connectorThread.disconnect()
			self.connectorThread = None
		self.buddyList.clear()
		QtGui.QApplication.instance().quit()
		
			
	def connected(self):
		self.actionConnection.setEnabled(False)
		self.actionDeconnection.setEnabled(True)
		if self.statusCombo.currentIndex() == STATUS.unavailable:
			self.statusCombo.setCurrentIndex(STATUS.available)
		else:
			self.connectorThread.set_status(self.statusCombo.currentIndex(), self.statusEdit.text())
		self.statusEdit.show()
		self.statusEdit.setFocus()
		self.buddyList.setConnection(self.connectorThread)
		self.getRoster()
		self.setAway()
		self.setOffline()

	def error(self, title, content):
		QtGui.QMessageBox.critical(self, title, content, QtGui.QMessageBox.Ok)

	def closeEvent(self, event):
		self.quit()

	def quit(self):
		self.disconnect()
		sys.exit(0)

	def on_change_status(self, index=-1):
		print "on_status", index
		if index == -1:
			index = self.statusCombo.currentIndex()
		if index == STATUS.unavailable:
			self.statusEdit.hide()
			self.disconnect()
		#else:
		#	self.connection(index)

	def getRoster(self):
		roster = self.connectorThread.getRoster()
		for buddy in roster:
			self.buddyList.add_item(buddy)
		self.connect(self.buddyList, SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"), self.on_send_message)

	def on_send_message(self, item, col):
		print "on_send_message", item, col
		if item and item.type() == QtGui.QTreeWidgetItem.UserType+1:
			item.sendMessage()
			
	def setAway(self, checked=-1):
		if checked == -1:
			checked = self.actionAway_buddies.isChecked()
		self.buddyList.setAway(not checked)
			
	def setOffline(self, checked=-1):
		if checked == -1:
			checked = self.actionOffline_buddies.isChecked()
		self.buddyList.setOffline(not checked)

	def subscriptionRequest(self, presence):
		request = RosterRequest(self, self.connectorThread.jabber, presence)
		request.show()

	def debug(self, message):
		self.te.append(datetime.datetime.now().strftime("[%H:%M:%S]")+" : \n"+message)

	def swapConsole(self):
		self.console.setWindowTitle("XML Console")
		self.console.resize(QtCore.QSize(1024, 500))
		self.console.show()
		self.console.raise_()

	def on_add_buddy(self, item=None):
		if self.connectorThread:
			if item:
				jid = item.jid
			else:
				jid = ""
			newBuddy = AddBuddyDialog(self, self.connectorThread.jabber, self.buddyList.groups.keys(), jid)
			newBuddy.show()

	def on_add_group(self):
		newGroup = AddGroupDialog(self, self.BuddyList)
		newGroup.show()
Example #5
0
class MainWindow(QMainWindow):	
	def __init__(self, parent=None):
		#QMainWindow.__init__(self, None, Qt.WindowStaysOnTopHint) # always on top
		super(MainWindow, self).__init__(parent)
		
		self.settings = QSettings("Dae-ekleN", "PyTalk")
		
		# add logs widget		
		QWidget.__init__(self)
		self.logsWidget = uic.loadUi(PATH_UI_LOGS)
		self.logsWidget.etx_logs.setReadOnly(True)
		
		# loading .ui
		uic.loadUi(PATH_UI_MAIN, self)
		
		# Set status Offline
		self.cmb_status_box.setCurrentIndex(5)
		self.cmb_status_box.setEnabled(False)
		self.eln_status_edit.hide()
		
		# connecting signals
		self.connect(self.cmb_status_box, SIGNAL("activated(int)"), self.statusUpdate)
		self.connect(self.eln_status_edit, SIGNAL("returnPressed()"), self.statusUpdate)
        
        # Set BuddyList
		self.BuddyList = BuddyList(self)
		self.vboxlayout.insertWidget(0, self.BuddyList)
		#self.connect(self.BuddyList, SIGNAL("rename"), self.addBuddy)
		
		# sleekxmpp connection
		self.im = None
		
		# Account
		self.connect(self.act_connection, SIGNAL("triggered()"), self.showConnectDialog)
		self.connect(self.act_deconnection, SIGNAL("triggered()"), self.disconnect)
		self.connect(self.act_join_group_chat, SIGNAL("triggered()"), self.showMUCDialog)
		self.connect(self.act_add_buddy, SIGNAL("triggered()"), self.showBuddyDialog)
		self.connect(self.act_quit, SIGNAL("triggered()"), self.quitApp)
		self.act_join_group_chat.setEnabled(False)
		self.act_add_buddy.setEnabled(False)
		
		# View
		self.act_away_buddies.setEnabled(False)
		self.act_offline_buddies.setEnabled(False)
		self.connect(self.act_away_buddies, SIGNAL("toogled()"), self.showAwayBuddies)
		self.connect(self.act_offline_buddies, SIGNAL("toogled()"), self.showOfflineBuddies)
		self.connect(self.act_away_buddies, SIGNAL("triggered()"), self.showAwayBuddies)
		self.connect(self.act_offline_buddies, SIGNAL("triggered()"), self.showOfflineBuddies)
		
		# Tools
		self.connect(self.act_logs, SIGNAL("triggered()"), self.showLogs)
		
		# About Dialogs
		self.connect(self.act_about_pytalk, SIGNAL("triggered()"), self.aboutPyTalk)
		self.act_help.triggered.connect(self.showHelp)
		self.act_about_pystudy.triggered.connect(self.aboutPyStudy)
		
	def showHelp(self):
		# opens help dialog		
		QDialog.__init__(self)
		self.helpForm = uic.loadUi(PATH_UI_HELP)
		self.helpForm.show()
		
		self.connect(self.helpForm.btn_back, SIGNAL('clicked()'), 
			self.helpForm.tbr_help, SLOT("backward()"))
		self.connect(self.helpForm.btn_home, SIGNAL('clicked()'), 
			self.helpForm.tbr_help, SLOT("home()"))
		self.connect(self.helpForm.tbr_help, SIGNAL("sourceChanged(QUrl)"), 
			self.updatePageTitle)			
		self.helpForm.tbr_help.setSource((QUrl.fromLocalFile(PATH_DOC_HELP))) # "../docs/help/index.html")))	

	def updatePageTitle(self):
		# used to update label for title (helpForm.lab_title) in help dialog
		self.helpForm.lab_title.setText(self.helpForm.tbr_help.documentTitle())
		
	def aboutPyStudy(self):
		# opens about dialog
		QMessageBox.about(self, "About", 
				"""<p>The <b>PyStudy</b> is a tool for sharing your ideas and thoughts with others.
				The features that distinguish it from other instant messengers are canvas and voice sessions with
				further possibility of saving the data into various file formats.</p>
				
				<p>It is an open source project; you can always find the latest
				version of code at <a href="https://github.com/dae-eklen/E-learning">github</a>
				page.</p> 
				
				<p>Current version: 0.9</p>
				<p>Author: Casian Olga</p>
				""")	
		
	def aboutPyTalk(self):
		QDialog.__init__(self)
		self.aboutPyTalk = uic.loadUi(PATH_UI_ABOUT_PYTALK)
		self.aboutPyTalk.show()
		self.aboutPyTalk.raise_()
		
	def showBuddyDialog(self, jidFrom = None):
		QDialog.__init__(self)
		self.addNewBuddy = uic.loadUi(PATH_UI_ADD_BUDDY)
		if jidFrom:
			self.addNewBuddy.eln_jid.setText(jidFrom)
		for el in self.BuddyList.groups:
			self.addNewBuddy.cmb_group.addItem(el)
		if DEFAULT_GROUP not in self.BuddyList.groups:
			self.addNewBuddy.cmb_group.addItem(DEFAULT_GROUP)
		self.addNewBuddy.show()
		self.connect(self.addNewBuddy, SIGNAL("accepted()"), self.addBuddy)
		
	def addBuddy(self):
		username = str(self.addNewBuddy.eln_jid.text())
		server = str(self.addNewBuddy.cmb_server.currentText())
		group = str(self.addNewBuddy.cmb_group.currentText())
		jid = username + "@" + server
		#if not self.im.dicsoveryJid(str(jid)):
		#	self.information("Error", "The contact you want to add, " + jid + ", does not exist.")
		if jid == self.im.jabberID:
			self.information("Error", "You cannot add yourself.")
		elif jid not in self.BuddyList.buddies:
			self.BuddyList.newBuddy(jid, group, "offline")
			self.BuddyList.presence((jid, "offline", self.im.getSubscription(jid)))
			self.im.subscribeResp(True, jid, group)
		else:
			self.information("Contact already exists", "The contact that you want to add, " + jid + ", is already added.")
		
	def subscribeReq(self, jidFrom):
		reply = QMessageBox.question(self, "Subscription request", "New subscription request from " + jidFrom + 
			". Do you want to approve it and establish bidirectional subscription?", 
			QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)

		if reply == QMessageBox.Yes:
			if jidFrom not in self.BuddyList.buddies:
				namePattern = """([\w\-][\w\-\.]*)[email protected][\w\-][\w\-\.]+[a-zA-Z]{1,4}"""
				username = re.findall(namePattern, jidFrom)
				self.showBuddyDialog(username[0])
			else:
				# if subscription req without adding to list
				self.im.subscribeResp(True, jidFrom, self.im.getGroups(jidFrom))
		else:
			self.im.subscribeResp(False, jidFrom)
			
	def handleUnsubscribedReq(self, jidFrom):
		reply = QMessageBox.question(self, "Subscription removed", "Contact " + jidFrom + 
			" removed subscription from you. You will always see him offline. Do you want to remove him from your contact list?", 
			QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)

		if reply == QMessageBox.Yes:
			self.BuddyList.removeBuddy(jidFrom)
			self.im.unsubscribe(jidFrom)
		
	def showMUCDialog(self):
		QDialog.__init__(self)
		self.joinGroupChat = uic.loadUi(PATH_UI_JOIN_MUC)
		self.joinGroupChat.show()
		self.connect(self.joinGroupChat, SIGNAL("accepted()"), self.joinMUC)
		
	def joinMUC(self):
		room = str(self.joinGroupChat.eln_room.text()) # dae-eklen-test2|dae-eklen-test|dae-eklen
		server = str(self.joinGroupChat.cmb_server.currentText())
		
		self.checkAndJoinMUC(room)

	def inviteMUC(self, room, jidFrom):
		if jidFrom:
			text = "Received invitation from " + jidFrom + " to room " + room
		else:
			text = "Received invitation to room " + room		
		text += "\n\nDo you want to accept the invitation?"
		
		reply = QMessageBox.question(self, "Groupchat invitation", text, QMessageBox.Yes, QMessageBox.No)
		if reply == QMessageBox.Yes:
			mucTitlePattern = """([\w\-][\w\-\.\|]*)[email protected][\w\-][\w\-\.]+[a-zA-Z]{1,4}"""
			name = re.findall(mucTitlePattern, room)
			self.checkAndJoinMUC(name[0])
		else:
			self.im.declineMUCInvite(room, jidFrom)
	
	def checkAndJoinMUC(self, roomName):
		jids = roomName.split("|")
		match = 0 
		users = []
		for el in range(len(jids)): 
			users.append(unicode(jids[el] + "@talkr.im"))
			if self.im.dicsoveryJid(users[el]): # if user exists
				match += 1
					
		if len(jids) == match and match != 0:
			# our type of group
			if not self.BuddyList.MUCExists(users):
				self.im.joinMUC(users)
			else:
				self.information("Join Group Chat", "Specified room is already added to '" + MUC_GROUP_TITLE + "' group.")
		else:
			# usual group: currently unavaiilable
			self.information("Join Group Chat", "This type of group is currently N/A")
		
	def showConnectDialog(self):
		# opens connection dialog		
		QDialog.__init__(self)
		self.connectionDialog = uic.loadUi(PATH_UI_CONNECTION)
		self.connectionDialog.show()
		self.connect(self.connectionDialog, SIGNAL("accepted()"), self.connection)
		
		self.connectionDialog.eln_jid.setText(self.settings.value("jid", ""))
		self.connectionDialog.eln_pass.setText(self.settings.value("password", ""))
		self.connectionDialog.eln_resource.setText(self.settings.value("resource", ""))

	def closeEvent(self, event):
		# called on close (Ctrl+Q)
		reply = QMessageBox.question(self, app.translate("wnd_main", "Exit"),
			app.translate("wnd_main", "Are you sure to quit?"), 
			QMessageBox.Yes | QMessageBox.No, 
			QMessageBox.No)
			
		if reply == QMessageBox.Yes:			
			try:
				self.disconnect()
				event.accept()
			except:
				time.sleep(1)
		else:
			event.ignore()

	def quitApp(self):
		self.disconnect()
		QApplication.instance().quit()

	def disconnect(self):
		if self.im:
			self.im.stop()
			self.im = None
			self.BuddyList.clear()
			self.act_connection.setEnabled(True)
			self.act_deconnection.setEnabled(False)
			self.eln_status_edit.hide()
			self.cmb_status_box.setCurrentIndex(5)
			self.cmb_status_box.setEnabled(False)
			self.act_away_buddies.setEnabled(False)
			self.act_offline_buddies.setEnabled(False)
			self.act_join_group_chat.setEnabled(False)
			self.act_add_buddy.setEnabled(False)

	def failedAuth(self):
		self.critical("Authentication failed", "Authentication failed, please check Username - Password combination.")

	def connection(self):		
		# settings for jid and pass
		self.settings.setValue("jid", self.connectionDialog.eln_jid.text())
		self.settings.setValue("password", self.connectionDialog.eln_pass.text())
		if str(self.connectionDialog.eln_resource.text()) == "":
			resource = "PyStudy"
		else: resource = str(self.connectionDialog.eln_resource.text())
		self.settings.setValue("resource", resource)
			
		# latest status and show
		self.clientJid = str(self.connectionDialog.eln_jid.text() + "@" + self.connectionDialog.cmb_server.currentText())
		self.settings.beginGroup(self.clientJid)
		self.latestShow = self.settings.value("latestShow", "") # text as in SHOW
		self.latestStatus = self.settings.value("latestStatus", "")
		self.settings.endGroup()
			
		# starting xmpp thread
		self.im = Client(self.clientJid, resource, self.connectionDialog.eln_pass.text(),
			self.latestShow, self.latestStatus)
		self.connect(self.im, SIGNAL("failedAuth"), self.failedAuth)
		self.im.start()
			
		self.cmb_status_box.setItemText(5, "Please wait...")
			
		# connecting signals
		self.connect(self.im, SIGNAL("sessionStarted(PyQt_PyObject)"), self.sessionStarted)
		self.connect(self.im, SIGNAL("presence(PyQt_PyObject)"), self.BuddyList.presence)
		self.connect(self.im, SIGNAL("disconnect"), self.disconnect)
		self.connect(self.im, SIGNAL("message"), self.BuddyList.message)
		self.connect(self.im, SIGNAL("messageMUC"), self.BuddyList.messageMUC)
		self.connect(self.im, SIGNAL("inviteMUC"), self.inviteMUC)
		self.connect(self.im, SIGNAL("subscribeReq"), self.subscribeReq)
		self.connect(self.im, SIGNAL("handleUnsubscribedReq"), self.handleUnsubscribedReq)
		self.connect(self.im, SIGNAL("sendPresenceToBuddy"), self.statusUpdate)
		self.connect(self.im, SIGNAL("rcvCanvasStroke"), self.BuddyList.rcvCanvasStroke)
		self.connect(self.im, SIGNAL("rcvCanvasStrokeMUC"), self.BuddyList.rcvCanvasStrokeMUC)
		
		self.connect(self.im, SIGNAL("critical"), self.critical)
		self.connect(self.im, SIGNAL("information"), self.information)
		self.connect(self.im, SIGNAL("debug"), self.debug)
		
	def sessionStarted(self, roster_keys):
		self.act_connection.setEnabled(False)
		self.act_deconnection.setEnabled(True)
		self.act_join_group_chat.setEnabled(True)
		self.act_away_buddies.setEnabled(True)
		self.act_offline_buddies.setEnabled(True)
		self.act_add_buddy.setEnabled(True)
        
		# construct contact list	
		self.BuddyList.setConnection(self.im)
		#store roster in settings
		self.settings.beginGroup(self.clientJid)
		self.settings.setValue("roster", roster_keys)
		self.settings.endGroup()
		self.BuddyList.constructList(roster_keys)
		self.showAwayBuddies()
		self.showOfflineBuddies()
	
		# restore show and status
		self.eln_status_edit.show()
		self.eln_status_edit.setText(self.latestStatus)
		
		self.cmb_status_box.setItemText(5, "Offline")
		if self.latestShow == "": self.cmb_status_box.setCurrentIndex(SHOW.index('available'))
		else: self.cmb_status_box.setCurrentIndex(SHOW.index(self.latestShow))
		self.cmb_status_box.setEnabled(True)
	
	def statusUpdate(self, jidTo = None):
		if SHOW[self.cmb_status_box.currentIndex()] != "offline":
			# update settings
			self.settings.beginGroup(self.clientJid)
			self.settings.setValue("latestShow", SHOW[self.cmb_status_box.currentIndex()])
			self.settings.setValue("latestStatus", self.eln_status_edit.text())
			self.settings.endGroup()
			self.debug("new presence set. show: '" + SHOW[self.cmb_status_box.currentIndex()] +
				"'; status: '" + self.eln_status_edit.text() + "'\n\n")
			
		self.im.changeStatus(self.cmb_status_box.currentIndex(), self.eln_status_edit.text(), jidTo)
            
	def showLogs(self):
		self.logsWidget.show()
		self.logsWidget.raise_()
		
	def debug(self, message):
		self.logsWidget.etx_logs.append(datetime.datetime.now().strftime("[%H:%M:%S]")+":\n" + message)
	
	def showAwayBuddies(self):	
		self.BuddyList.showAwayBuddies(not self.act_away_buddies.isChecked())
		
	def showOfflineBuddies(self):
		self.BuddyList.showOfflineBuddies(not self.act_offline_buddies.isChecked())
	
	def critical(self, title, content):
		QMessageBox.critical(self, title, content, QMessageBox.Ok)
		
	def information(self, title, content):
		QMessageBox.information(self, title, content, QMessageBox.Ok)
Example #6
0
class MainWindow(QMainWindow, Ui_MainWindow):
    connectorThread = None

    def __init__(self, parent = None):
    
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        
        self.console = QDialog()
        self.te = QTextEdit(self.console)
        self.te.setReadOnly(True)
        vl = QVBoxLayout()
        vl.addWidget(self.te)
        self.console.setLayout(vl)
        
        # Set status Offline
        self.statusBox.setCurrentIndex(5)
        self.statusEdit.hide()

        # Set connect
        self.connect(self.statusBox, SIGNAL("currentIndexChanged(int)"), self.changeStatus)
        self.connect(self.statusEdit, SIGNAL("returnPressed()"), self.changeStatus)

        # Set BuddyList
        self.BuddyList = BuddyList(self)
        self.vboxlayout.insertWidget(0, self.BuddyList)
        self.connect(self.BuddyList, SIGNAL("rename"), self.addBuddy)

        # Connection
        connection = ConnectionDialog(self)
        self.connect(self.actionConnection, SIGNAL("triggered()"), connection, SLOT("exec()"))
        self.connect(self.actionDeconnection, SIGNAL("triggered()"), self.disconnect)
        self.connect(connection, SIGNAL("configured()"), self.connection)

        # Contacts
        self.connect(self.actionAdd_a_buddy, SIGNAL("triggered()"), self.addBuddy)
        self.connect(self.actionAdd_a_group, SIGNAL("triggered()"), self.addGroup)

        # View
        self.connect(self.actionAway_buddies, SIGNAL("toogled()"), self.setAway)
        self.connect(self.actionOffline_buddies, SIGNAL("toogled()"), self.setOffline)
        self.connect(self.actionAway_buddies, SIGNAL("triggered()"), self.setAway)
        self.connect(self.actionOffline_buddies, SIGNAL("triggered()"), self.setOffline)

        # Tools
        self.connect(self.actionConsole, SIGNAL("triggered()"), self.swapConsole)
        
        # About Dialog
        about = AboutDialog(self)
        self.connect(self.actionAbout, SIGNAL("triggered()"), about, SLOT("exec()"))
        self.connect(self.actionAboutQt, SIGNAL("triggered()"), QApplication.instance(), SLOT("aboutQt()"))
        
        # Quit Signal connection
        self.connect(self.actionQuit, SIGNAL("triggered()"), self.quit)

    def connection(self, status=STATUS.available):
        if not self.connectorThread:
            self.connectorThread = ConnectorThread(status)
            self.connectorThread.start()
            self.connect(self.connectorThread, SIGNAL("message"), self.BuddyList.message)
            self.connect(self.connectorThread, SIGNAL("error"), self.error)
            self.connect(self.connectorThread, SIGNAL("connected()"), self.connected)
            self.connect(self.connectorThread, SIGNAL("disconnected()"), self.disconnect)
            self.connect(self.connectorThread, SIGNAL("presence"), self.BuddyList.presence)
            self.connect(self.connectorThread, SIGNAL("debug"), self.debug)
            self.connect(self.connectorThread, SIGNAL("subscriptionRequest"), self.subscriptionRequest)
            self.connect(self.connectorThread, SIGNAL("addBuddy"), self.addBuddy)
        elif self.connectorThread.isConnected():
            self.connectorThread.changeStatus(status, self.statusEdit.text())
            self.statusEdit.clearFocus()

    def disconnect(self):
        self.actionConnection.setEnabled(True)
        self.actionDeconnection.setEnabled(False)
        self.statusEdit.hide()
        self.statusBox.setCurrentIndex(STATUS.unavailable.index)
        if self.connectorThread:
            self.connectorThread.disconnect()
            self.connectorThread = None
        self.BuddyList.clear()
        QApplication.instance().quit()
        
            
    def connected(self):
        self.actionConnection.setEnabled(False)
        self.actionDeconnection.setEnabled(True)
        if self.statusBox.currentIndex() == STATUS.unavailable.index:
            self.statusBox.setCurrentIndex(STATUS.available.index)
        else:
            self.connectorThread.changeStatus(self.statusBox.currentIndex(), self.statusEdit.text())
        self.statusEdit.show()
        self.statusEdit.setFocus()
        self.BuddyList.setConnection(self.connectorThread)
        self.getRoster()
        self.setAway()
        self.setOffline()

    def error(self, title, content):
        QMessageBox.critical(self, title, content, QMessageBox.Ok)

    def closeEvent(self, event):
        self.quit()

    def quit(self):
        self.disconnect()

    def changeStatus(self, index=-1):
        if index == -1:
            index = self.statusBox.currentIndex()
        if index == STATUS.unavailable.index:
            self.statusEdit.hide()
            self.disconnect()
        else:
            self.connection(index)

    def getRoster(self):
        roster = self.connectorThread.getRoster()
        for buddy in roster:
            self.BuddyList.addItem(buddy)
        self.connect(self.BuddyList, SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"), self.sendMessage)

    def sendMessage(self, item, col):
        if item and item.type() == QTreeWidgetItem.UserType+1:
            item.sendMessage()
            
    def setAway(self, checked=-1):
        if checked == -1:
            checked = self.actionAway_buddies.isChecked()
        self.BuddyList.setAway(not checked)
            
    def setOffline(self, checked=-1):
        if checked == -1:
            checked = self.actionOffline_buddies.isChecked()
        self.BuddyList.setOffline(not checked)

    def subscriptionRequest(self, presence):
        request = RosterRequest(self, self.connectorThread.jabber, presence)
        request.show()

    def debug(self, message):
        self.te.append(datetime.datetime.now().strftime("[%H:%M:%S]")+" : \n"+message)

    def swapConsole(self):
        self.console.setWindowTitle("XML Console")
        self.console.resize(QSize(1024, 500))
        self.console.show()
        self.console.raise_()

    def addBuddy(self, item=None):
        if self.connectorThread:
            if item:
                jid = item.jid
            else:
                jid = ""
            newBuddy = AddBuddyDialog(self, self.connectorThread.jabber, self.BuddyList.groups.keys(), jid)
            newBuddy.show()

    def addGroup(self):
        newGroup = AddGroupDialog(self, self.BuddyList)
        newGroup.show()