def __init__(self): super(SendFiles, self).__init__() QtCore.QObject.connect(self.sth, QtCore.SIGNAL("connectionStart()"), self.on_connection_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("compressStart(QString)"), self.on_compress_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("cryptStart(QString)"), self.on_crypt_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendStart(QString)"), self.on_send_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendComplete()"), self.on_send_complete) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendFileComplete()"), self.on_send_file_complete) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("err(QString)"), self.on_error) self.uploadWnd = UploadWindow()
class SendFiles(QtCore.QObject): sth = SendFilesThread() def __init__(self): super(SendFiles, self).__init__() QtCore.QObject.connect(self.sth, QtCore.SIGNAL("connectionStart()"), self.on_connection_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("compressStart(QString)"), self.on_compress_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("cryptStart(QString)"), self.on_crypt_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendStart(QString)"), self.on_send_start) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendComplete()"), self.on_send_complete) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("sendFileComplete()"), self.on_send_file_complete) QtCore.QObject.connect(self.sth, QtCore.SIGNAL("err(QString)"), self.on_error) self.uploadWnd = UploadWindow() def on_connection_start(self): self.uploadWnd.ui.pB.setValue(0) self.uploadWnd.show() self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Соединение...</span></p></body></html>") self.uploadWnd.ui.lbFile.setText("") def on_compress_start(self, filename): self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Сжатие:</span></p></body></html>") self.uploadWnd.ui.lbFile.setText( "<html><head/><body><p><span style=' color:#ffffff;'>" + filename + "</span></p></body></html>") self.uploadWnd.ui.pB.setValue(0) def on_crypt_start(self, filename): self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Шифрование:</span></p></body></html>") self.uploadWnd.ui.pB.setValue(33) def on_send_start(self, filename): self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Отправка:</span></p></body></html>") self.uploadWnd.ui.pB.setValue(66) def on_send_file_complete(self): self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Готово.</span></p></body></html>") self.uploadWnd.ui.lbFile.setText("") self.uploadWnd.ui.pB.setValue(100) def on_send_complete(self): self.uploadWnd.ui.lbAct.setText( "<html><head/><body><p><span style=' color:#00d4ff;'>Готово.</span></p></body></html>") self.uploadWnd.ui.lbFile.setText("") self.uploadWnd.ui.pB.setValue(100) QtGui.QMessageBox.information(self.uploadWnd, "Complete", "Файлы отправлены!", QtGui.QMessageBox.Yes) self.uploadWnd.hide() def on_error(self, txt): QtGui.QMessageBox.critical(self.uploadWnd, "Ошибка", txt, QtGui.QMessageBox.Yes) self.uploadWnd.hide() def send(self, wnd, flist, toUsr): if toUsr == "": QtGui.QMessageBox.warning(wnd, 'Complete', 'Выберите пользователя!', QtGui.QMessageBox.Yes) return self._wnd = wnd self.sth.send(wnd, wnd.TCPServer, wnd.TCPPort, flist, toUsr) try: self.sth.start() except: self.on_error("Ошибка отправки файлов") Log().local("Ошибка отправки файлов")