def __init__(self, mw, icon, parent=None): QtGui.QSystemTrayIcon.__init__(self, icon, parent) self._mw = mw menu = QtGui.QMenu(parent) cfg = Configs() shAction = menu.addAction("Показать") shAction.setIcon(QtGui.QIcon("".join((self._mw.app_path, "images/", cfg.get_icons()["Tray"])))) QtCore.QObject.connect(shAction, QtCore.SIGNAL("triggered()"), self.show_main) shAction2 = menu.addAction("О программе") shAction2.setIcon(QtGui.QIcon("".join((self._mw.app_path,"images/elena8d89.png")))) QtCore.QObject.connect(shAction2, QtCore.SIGNAL("triggered()"), self.show_about) shAction3 = menu.addAction("Выход") shAction3.setIcon(QtGui.QIcon("".join((self._mw.app_path, "images/exit.png")))) QtCore.QObject.connect(shAction3, QtCore.SIGNAL("triggered()"), self.close_app) self.setContextMenu(menu) QtCore.QObject.connect(self, QtCore.SIGNAL("activated()"), self.on_active)
class Recieve(QtCore.QObject): downloadComplete = QtCore.pyqtSignal(bool) def __init__(self): super(Recieve, self).__init__() self.dldWnd = DownloadWnd() self.updWnd = UpdateWnd() self.recieveTh = RecieveThread() self.cfg = Configs() QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("downloadStart(QString)"), self.on_download_start) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("decryptStart()"), self.on_decrypt_start) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("decompressStart()"), self.on_decompress_start) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("downloadComplete()"), self.on_download_complete) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("fileDownloaded(QString)"), self.on_file_downloaded) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("fileCount(int)"), self.on_file_count) QtCore.QObject.connect(self.recieveTh, QtCore.SIGNAL("err(QString)"), self.on_err) self.step = 0 self.update = False self.fname = str("") def set_configs(self, tcpserver, tcpport, usr, pwd, update, path): self.update = update self.recieveTh.set_configs(tcpserver, tcpport, usr, pwd, update, path) if not self.update: self.dldWnd.ui.pb2.setValue(0) def on_download_start(self, fname): self.fname = fname if not self.update: self.dldWnd.ui.pb1.setValue(0) self.dldWnd.ui.lbFile.setText("<html><head/><body><p><span style='color:#00ffd5;'>" + "Загрузка: " + fname + "</span></p></body></html>") else: self.updWnd.ui.lbFile.setText("<html><head/><body><p><span style='color:#00d2ff;'>Загрузка: " + fname + "</span></p></body></html>") def on_decrypt_start(self): if not self.update: self.dldWnd.ui.pb1.setValue(33) self.dldWnd.ui.lbFile.setText("<html><head/><body><p><span style='color:#00ffd5;'>" + "Дешифрование: " + self.fname + "</span></p></body></html>") def on_decompress_start(self): if not self.update: self.dldWnd.ui.lbFile.setText("<html><head/><body><p><span style='color:#00ffd5;'>" + "Распаковка: " + self.fname + "</span></p></body></html>") self.dldWnd.ui.pb1.setValue(66) def on_file_downloaded(self, fname): if not self.update: self.dldWnd.ui.lbFile.setText( "<html><head/><body><p><span style='color:#00ffd5;'>Готово.</span></p></body></html>") parts = fname.split('.') ext = parts[len(parts) - 1].lower() ico = "" try: ico = self.cfg.get_icons()["FileIcons"][ext] except: ico = self.cfg.get_icons()["FileIcons"]["default"] item = QtGui.QListWidgetItem() item.setIcon(QtGui.QIcon( "".join((self.dldWnd.app_path, "images/ext/", ico)))) item.setText(self.fname) self.dldWnd.ui.lwFiles.insertItem(0, item) self.dldWnd.ui.pb1.setValue(100) self.dldWnd.ui.pb2.setValue(self.dldWnd.ui.pb2.value() + self.step) def on_file_count(self, cnt): self.step = round(100 / cnt) def on_err(self, text): QtGui.QMessageBox.critical(self.dldWnd, 'Complete', text, QtGui.QMessageBox.Yes) def on_download_complete(self): if not self.update: self.dldWnd.ui.pb2.setValue(100) QtGui.QMessageBox.information(self.dldWnd, 'Complete', 'Приняты новые файлы!', QtGui.QMessageBox.Yes) self.downloadComplete.emit(self.update) def start(self): if not self.update: self.dldWnd.show() else: self.updWnd.show() self.recieveTh.start()