def initTray(self): self.trayIcon = TrayIcon(self) self.trayIcon.show()
class Panel(BaseView): hideOtherWindow = QtCore.pyqtSignal() mousePressed = QtCore.pyqtSignal(QtCore.QPointF) focusLosed =QtCore.pyqtSignal() def __init__(self): super(Panel, self).__init__() self.setMinimumSize(QtCore.QSize(336, 550)) self.resize(336, 700) QtWidgets.qApp.focusWindowChanged.connect(self.onFocusWindowChanged) self.setIcon(QtGui.QIcon(":/images/common/logo.png")) self.setTitle("Deepin Talk") QtWidgets.qApp.setApplicationName("Deepin Talk") cSignals.raise_window.connect(self.requestRaiseWindow) self.initTray() self.setContextProperty("commonManager", commonManager) self.setContextProperty("controlManager", controlManager) self.setContextProperty("serverManager", sessionManager) self.setContextProperty("trayIcon", self.trayIcon) self.setSource(QtCore.QUrl.fromLocalFile(get_qml('Main.qml'))) # self.chat = ChatWindow(None, None) # self.chat.show() self.initKeybinder() def onFocusWindowChanged(self, focusWindow): if focusWindow.__class__.__name__ != "QQuickWindow": self.hideOtherWindow.emit() if focusWindow is None: self.focusLosed.emit() def initTray(self): self.trayIcon = TrayIcon(self) self.trayIcon.show() def initKeybinder(self): keyBinder.bind("Ctrl+Alt+P", self.requestRaiseWindow) keyBinder.start() @QtCore.pyqtSlot() def closeWindow(self): keyBinder.stop() sessionManager.disconnect() self.hide() self.close() for w in QtWidgets.qApp.allWindows(): w.hide() w.close() self.trayIcon.hide() QtWidgets.qApp.quit() def mousePressEvent(self, event): self.mousePressed.emit(QtCore.QPointF(event.x(), event.y())) return super(Panel, self).mousePressEvent(event) def requestRaiseWindow(self, *args, **kwargs): if self.windowState() == QtCore.Qt.WindowMinimized: self.show() self.requestActivate() else: self.doMinimized()