This commit is contained in:
DonRenando 2015-04-06 17:11:47 +02:00
parent 86f33b67b9
commit 4adfe09390
5 changed files with 242 additions and 114 deletions

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'mainWindow.ui'
#
# Created: Sat Apr 4 23:06:45 2015
# Created: Sun Apr 5 15:23:56 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
@ -27,7 +27,7 @@ class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.setEnabled(True)
Dialog.resize(827, 558)
Dialog.resize(813, 558)
Dialog.setMaximumSize(QtCore.QSize(827, 558))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("../../../../../../Images/Homer-Simpson-homer-simpson-3065329-800-600.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)

View File

@ -1,72 +0,0 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pm.ui'
#
# Created: Sat Apr 4 23:20:13 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(560, 339)
self.txtOutput = QtGui.QTextEdit(Form)
self.txtOutput.setGeometry(QtCore.QRect(20, 40, 531, 231))
self.txtOutput.setMinimumSize(QtCore.QSize(200, 0))
font = QtGui.QFont()
font.setFamily(_fromUtf8("Arial"))
font.setPointSize(14)
font.setItalic(False)
self.txtOutput.setFont(font)
self.txtOutput.setFocusPolicy(QtCore.Qt.NoFocus)
self.txtOutput.setAcceptDrops(False)
self.txtOutput.setFrameShape(QtGui.QFrame.NoFrame)
self.txtOutput.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.txtOutput.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
self.txtOutput.setObjectName(_fromUtf8("txtOutput"))
self.horizontalLayoutWidget = QtGui.QWidget(Form)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(20, 290, 431, 31))
self.horizontalLayoutWidget.setObjectName(_fromUtf8("horizontalLayoutWidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.lineEdit = QtGui.QLineEdit(self.horizontalLayoutWidget)
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.horizontalLayout.addWidget(self.lineEdit)
self.pushButton = QtGui.QPushButton(self.horizontalLayoutWidget)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.horizontalLayout.addWidget(self.pushButton)
self.pushButton_2 = QtGui.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(460, 290, 91, 27))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.txtOutput.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Arial\'; font-size:14pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Inconsolata\';\"><br /></p></body></html>", None))
self.pushButton.setText(_translate("Form", "Send message", None))
self.pushButton_2.setText(_translate("Form", "send", None))

105
client/view/pmWindow.py Normal file
View File

@ -0,0 +1,105 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pmWindow.ui'
#
# Created: Mon Apr 6 17:05:26 2015
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog2(object):
def setupUi(self, Dialog2):
Dialog2.setObjectName(_fromUtf8("Dialog2"))
Dialog2.resize(605, 373)
self.horizontalLayoutWidget_2 = QtGui.QWidget(Dialog2)
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(50, 50, 531, 31))
self.horizontalLayoutWidget_2.setObjectName(_fromUtf8("horizontalLayoutWidget_2"))
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.horizontalLayoutWidget_2)
self.horizontalLayout_2.setMargin(0)
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.pushButton_3 = QtGui.QPushButton(self.horizontalLayoutWidget_2)
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.horizontalLayout_2.addWidget(self.pushButton_3)
self.pushButton_4 = QtGui.QPushButton(self.horizontalLayoutWidget_2)
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.horizontalLayout_2.addWidget(self.pushButton_4)
self.horizontalLayoutWidget = QtGui.QWidget(Dialog2)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(50, 320, 531, 41))
self.horizontalLayoutWidget.setObjectName(_fromUtf8("horizontalLayoutWidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.lineEdit = QtGui.QLineEdit(self.horizontalLayoutWidget)
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.horizontalLayout.addWidget(self.lineEdit)
self.pushButton = QtGui.QPushButton(self.horizontalLayoutWidget)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.horizontalLayout.addWidget(self.pushButton)
self.pushButton_2 = QtGui.QPushButton(self.horizontalLayoutWidget)
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.horizontalLayout.addWidget(self.pushButton_2)
self.txtOutput = QtGui.QTextEdit(Dialog2)
self.txtOutput.setGeometry(QtCore.QRect(50, 80, 531, 231))
self.txtOutput.setMinimumSize(QtCore.QSize(200, 0))
font = QtGui.QFont()
font.setFamily(_fromUtf8("Arial"))
font.setPointSize(14)
font.setItalic(False)
self.txtOutput.setFont(font)
self.txtOutput.setFocusPolicy(QtCore.Qt.NoFocus)
self.txtOutput.setAcceptDrops(False)
self.txtOutput.setFrameShape(QtGui.QFrame.NoFrame)
self.txtOutput.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.txtOutput.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
self.txtOutput.setObjectName(_fromUtf8("txtOutput"))
self.horizontalLayoutWidget_3 = QtGui.QWidget(Dialog2)
self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(50, 10, 531, 41))
self.horizontalLayoutWidget_3.setObjectName(_fromUtf8("horizontalLayoutWidget_3"))
self.horizontalLayout_4 = QtGui.QHBoxLayout(self.horizontalLayoutWidget_3)
self.horizontalLayout_4.setMargin(0)
self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
self.label = QtGui.QLabel(self.horizontalLayoutWidget_3)
self.label.setObjectName(_fromUtf8("label"))
self.horizontalLayout_4.addWidget(self.label)
self.label_2 = QtGui.QLabel(self.horizontalLayoutWidget_3)
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.horizontalLayout_4.addWidget(self.label_2)
self.retranslateUi(Dialog2)
QtCore.QMetaObject.connectSlotsByName(Dialog2)
def retranslateUi(self, Dialog2):
Dialog2.setWindowTitle(_translate("Dialog2", "Dialog", None))
self.pushButton_3.setText(_translate("Dialog2", "Accept", None))
self.pushButton_4.setText(_translate("Dialog2", "Refuse", None))
self.pushButton.setText(_translate("Dialog2", "Send message", None))
self.pushButton_2.setText(_translate("Dialog2", "send file", None))
self.txtOutput.setHtml(_translate("Dialog2", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Arial\'; font-size:14pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Inconsolata\';\"><br /></p></body></html>", None))
self.label.setText(_translate("Dialog2", "Private Discussion with :", None))
self.label_2.setText(_translate("Dialog2", "TextLabel", None))

View File

@ -1,23 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<class>Dialog2</class>
<widget class="QDialog" name="Dialog2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>339</height>
<width>605</width>
<height>373</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Dialog</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>531</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Accept</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Refuse</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>50</x>
<y>320</y>
<width>531</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Send message</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>send file</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QTextEdit" name="txtOutput">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<x>50</x>
<y>80</y>
<width>531</width>
<height>231</height>
</rect>
@ -58,41 +113,39 @@ p, li { white-space: pre-wrap; }
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>20</x>
<y>290</y>
<width>431</width>
<height>31</height>
<x>50</x>
<y>10</y>
<width>531</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLabel" name="label">
<property name="text">
<string>Private Discussion with :</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Send message</string>
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>460</x>
<y>290</y>
<width>91</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>send file</string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -4,7 +4,7 @@ from PySide.QtCore import *
from PySide.QtGui import *
import time, threading, datetime, time, random,re
from socket import *
from pm import Ui_Form
from pmWindow import Ui_Dialog2
Host = "127.0.0.1"
Port = 2222
@ -46,26 +46,29 @@ class MyThread(QThread):
self.gui = gui
class privateMessage () :
def __init__(self,main,s):
def __init__(self,main,s, pmPerson):
self.main = main
self.s = s
self.pmPerson = pmPerson
self.g = QtGui.QWidget()
self.ui = Ui_Form()
self.ui = Ui_Dialog2()
self.ui.setupUi(self.g)
self.g.show()
old = start()
self.message_buffer2 = ""
self.queueMsg= []
self.queueMsg2= []
self.thread = MyThread()
self.thread.finished.connect(old.UpdateChat)
self.thread.finished.connect(self.UpdateChatP)
self.ui.pushButton.clicked.connect(self.send)
self.ui.pushButton_2.clicked.connect(self.selectFile)
self.ui.label_2.setText(pmPerson)
def selectFile(self):
self.ui.lineEdit.setText(''.join(QFileDialog.getOpenFileName()))
self.ui.lineEdit.setText('/pmfile '+self.pmPerson+ ' '.join(QFileDialog.getOpenFileName()))
@ -88,8 +91,24 @@ class privateMessage () :
self.ui.txtOutput.setText(self.message_buffer)
sb = self.ui.txtOutput.verticalScrollBar()
sb.setValue(sb.maximum())
def UpdateChatP(self) :
if self.queueMsg2 :
m = self.queueMsg2.pop(0)
if m :
self.thread.start()
self.ShowMessageAsTextPm(m)
self.ui.txtOutput.setText(self.message_buffer2)
sb = self.ui.txtOutput.verticalScrollBar()
sb.setValue(sb.maximum())
def ShowMessageAsTextPm(self,txt) :
if txt.split(" ")[0] == "NEW_MSG" :
self.message_buffer2 += '<br><span style="color : grey"> ' + self.getTimeStamp() + '</span> <span style="color : red"> &#60; '+txt.split(" ")[1] +' &#62; </span> ' + self.htmlToText(' '.join(txt.split(" ")[2:])) + ''
if txt == "SUCC_MESSAGE_SENDED" :
self.message_buffer += '<br><span style="color : grey"> ' + self.getTimeStamp() + '</span> <span style="color : red"> &#60; '+ self.pseudo +' &#62; </span> ' + self.htmlToText(self.cmd) + ''
class start(QtGui.QDialog):
def __init__(self):
@ -153,11 +172,11 @@ class start(QtGui.QDialog):
if txt.split(" ")[0] == "SUCC_INVITED" :
self.ShowMessageOK("invitation requested")
self.admin = privateMessage(self,self.s,self.demande)
if txt.split(" ")[0] == "ASKING_FOR_PM" :
self.ShowMessageOK("private discution from "+ txt.split(" ")[1] )
#ouvrir fenetre !!!!
self.admin = privateMessage(self,self.s)
self.admin = privateMessage(self,self.s,txt.split(" ")[1])
if txt.split(" ")[0] == "SUCCESSFUL_LOGOUT" :
@ -182,7 +201,9 @@ class start(QtGui.QDialog):
if txt.split(" ")[0] == "SUCC_VALID_NICKNAME" :
self.ShowMessageOK("Sucessful nickname change !")
if txt.split(" ")[0] == "ERR_INVALID_NICKNAME" :
self.pseudo = "INVALID_NICKNAME"
#HAS_LEFT anonymous52
if txt.split(" ")[0] == "NAME_CHANGED" :
self.ShowMessageNameChange(txt.split(" ")[1], txt.split(" ")[2])
@ -250,9 +271,27 @@ class start(QtGui.QDialog):
self.ui.pushButton_3.clicked.connect(self.deco)
self.ui.pushButton.clicked.connect(self.client)
self.ui.pushButton_6.clicked.connect(self.changeN)
self.ui.pushButton_5.clicked.connect(self.away)
#self.connect(self.ui.listNames,
# QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem *)"),
# self.someMethod)
self.ui.listNames.itemActivated.connect(self.someMethod)
def someMethod(self,item):
nom = item.text()
cmdPM = "/askpm "+nom
try:
self.s.send(cmdPM.encode())
self.demande = nom
except timeout:
self.ShowMessageErreur("Erreur : Timeout. Le serveur ne repond pas")
self.ui.txtOutput.setText(self.message_buffer)
sb = self.ui.txtOutput.verticalScrollBar()
sb.setValue(sb.maximum())
def away(self):
@ -400,6 +439,9 @@ class start(QtGui.QDialog):
if self.cmd.split(" ")[0] == "/name":
self.pseudo = self.cmd.split(" ")[1]
if self.cmd.split(" ")[0]=="/askpm":
self.demande = self.cmd.split(" ")[1]
except timeout:
self.ShowMessageErreur("Erreur : Timeout. Le serveur ne repond pas")