#940: OGAgent "about" box supporting Qt5

remotes/github/python3
Ramón M. Gómez 2020-05-04 19:42:33 +02:00
parent 0440c7c37a
commit 1528428d8b
1 changed files with 14 additions and 14 deletions

View File

@ -31,12 +31,12 @@
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import json
import sys import sys
import time import time
import json from PyQt5 import QtCore, QtGui, QtWidgets
import six import six
import atexit import atexit
from PyQt4 import QtCore, QtGui # @UnresolvedImport
from opengnsys import VERSION, ipc, operations, utils from opengnsys import VERSION, ipc, operations, utils
from opengnsys.log import logger from opengnsys.log import logger
@ -63,7 +63,7 @@ def sigAtExit():
# About dialog # About dialog
class OGAAboutDialog(QtGui.QDialog): class OGAAboutDialog(QtGui.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) QtWidgets.QDialog.__init__(self, parent)
self.ui = Ui_OGAAboutDialog() self.ui = Ui_OGAAboutDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.ui.VersionLabel.setText("Version " + VERSION) self.ui.VersionLabel.setText("Version " + VERSION)
@ -72,9 +72,9 @@ class OGAAboutDialog(QtGui.QDialog):
self.hide() self.hide()
class OGAMessageDialog(QtGui.QDialog): class OGAMessageDialog(QtWidgets.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) QtWidgets.QDialog.__init__(self, parent)
self.ui = Ui_OGAMessageDialog() self.ui = Ui_OGAMessageDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
@ -89,7 +89,7 @@ class OGAMessageDialog(QtGui.QDialog):
class MessagesProcessor(QtCore.QThread): class MessagesProcessor(QtCore.QThread):
logoff = QtCore.pyqtSignal(name='logoff') logoff = QtCore.pyqtSignal(name='logoff')
message = QtCore.pyqtSignal(tuple, name='message') message = QtCore.pyqtSignal(tuple, name='message')
script = QtCore.pyqtSignal(QtCore.QString, name='script') script = QtCore.pyqtSignal(str, name='script')
exit = QtCore.pyqtSignal(name='exit') exit = QtCore.pyqtSignal(name='exit')
def __init__(self, port): def __init__(self, port):
@ -157,7 +157,7 @@ class MessagesProcessor(QtCore.QThread):
self.exit.emit() self.exit.emit()
class OGASystemTray(QtGui.QSystemTrayIcon): class OGASystemTray(QtWidgets.QSystemTrayIcon):
def __init__(self, app_, parent=None): def __init__(self, app_, parent=None):
self.app = app_ self.app = app_
self.config = readConfig(client=True) self.config = readConfig(client=True)
@ -174,10 +174,10 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
# icon = QtGui.QIcon(style.standardPixmap(QtGui.QStyle.SP_ComputerIcon)) # icon = QtGui.QIcon(style.standardPixmap(QtGui.QStyle.SP_ComputerIcon))
icon = QtGui.QIcon(':/images/img/oga.png') icon = QtGui.QIcon(':/images/img/oga.png')
QtGui.QSystemTrayIcon.__init__(self, icon, parent) QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
self.menu = QtGui.QMenu(parent) self.menu = QtWidgets.QMenu(parent)
exitAction = self.menu.addAction("About") exit_action = self.menu.addAction("About")
exitAction.triggered.connect(self.about) exit_action.triggered.connect(self.about)
self.setContextMenu(self.menu) self.setContextMenu(self.menu)
self.ipc = MessagesProcessor(self.ipcport) self.ipc = MessagesProcessor(self.ipcport)
@ -310,14 +310,14 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
if __name__ == '__main__': if __name__ == '__main__':
app = QtGui.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
if not QtGui.QSystemTrayIcon.isSystemTrayAvailable(): if not QtWidgets.QSystemTrayIcon.isSystemTrayAvailable():
# QtGui.QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system.") # QtGui.QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system.")
sys.exit(1) sys.exit(1)
# This is important so our app won't close on messages windows (alerts, etc...) # This is important so our app won't close on messages windows (alerts, etc...)
QtGui.QApplication.setQuitOnLastWindowClosed(False) QtWidgets.QApplication.setQuitOnLastWindowClosed(False)
try: try:
trayIcon = OGASystemTray(app) trayIcon = OGASystemTray(app)