diff --git a/src/mambatray b/src/mambatray index ed9dafb..980c329 100755 --- a/src/mambatray +++ b/src/mambatray @@ -8,11 +8,12 @@ import sys import os import gettext import libproxy -from PyQt4.QtCore import SIGNAL -from PyQt4 import QtGui -from PyQt4 import QtCore +from PyQt5.QtCore import pyqtSignal +from PyQt5 import QtGui +from PyQt5 import QtWidgets +from PyQt5 import QtCore -class SystemTrayIcon(QtGui.QSystemTrayIcon): +class SystemTrayIcon(QtWidgets.QSystemTrayIcon): def __init__(self, icon, parent=None): global w, menu, contatore, srpm, lista, NetsrpmsArg, nOre, desktop_session @@ -22,14 +23,15 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): lista = [] contatore = 0 w = parent - QtGui.QSystemTrayIcon.__init__(self, icon, parent) - menu = QtGui.QMenu(parent) + QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) + menu = QtWidgets.QMenu(parent) + + desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION')) - desktop_session = QtCore.QString(os.getenv('DESKTOP_SESSION')) if desktop_session == 'default': - desktop_session = QtCore.QString('kde') - if desktop_session.left(3) == 'kde': - desktop_session = QtCore.QString('kde') + desktop_session = 'plasma' + elif desktop_session[:3] == 'kde': + desktop_session = 'kde' # refresh packages cache timer global refreshPackagesTimer, refreshPackagesCacheProcess, checkSRPMSUpdatesTimer, SRPMUpdateProcess, networkOnlineProcess @@ -38,9 +40,9 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): refreshPackagesCacheProcess = QtCore.QProcess(self) SRPMUpdateProcess = QtCore.QProcess(self) networkOnlineProcess = QtCore.QProcess(self) - self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache) - self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer) - self.connect(checkSRPMSUpdatesTimer, SIGNAL("timeout()"), self.SRPMSCheckUpgradeList) + refreshPackagesTimer.timeout.connect(self.refreshPackagesCache) + refreshPackagesCacheProcess.finished.connect(self.restartRefreshPackagesTimer) + checkSRPMSUpdatesTimer.timeout.connect(self.SRPMSCheckUpgradeList) # software menu global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess @@ -51,13 +53,13 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): softwareMenu = menu.addMenu(QtGui.QIcon.fromTheme("applications-system"),_("Software")) softwareManageAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("applications-other"),_("Add/Remove software packages...")) - self.connect(softwareManageAction, SIGNAL("triggered()"), self.softwareManager) + softwareManageAction.triggered.connect(self.softwareManager) softwareCheckUpgradesAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("system-software-update"),_("Check for updates now...")) - self.connect(softwareCheckUpgradesAction, SIGNAL("triggered()"), self.softwareCheckUpgrades) + softwareCheckUpgradesAction.triggered.connect(self.softwareCheckUpgrades) softwareBaseInstallsAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("openmamba"),_("openmamba components...")) - self.connect(softwareBaseInstallsAction, SIGNAL("triggered()"), self.softwareBaseInstalls) + softwareBaseInstallsAction.triggered.connect(self.softwareBaseInstalls) # network menu global networkFirewallDisableProcess, networkFirewallEnableProcess, networkFirewallConfigureProcess, networkProxyProcess @@ -69,22 +71,22 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): networkMenu = menu.addMenu(QtGui.QIcon.fromTheme("preferences-system-network"),_("Network")) networkFirewallMenu = networkMenu.addMenu(QtGui.QIcon.fromTheme("security-medium"),_("Firewall")) networkFirewallDisableAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-low"),_("Disable")) - self.connect(networkFirewallDisableAction, SIGNAL("triggered()"), self.networkFirewallDisable) - self.connect(networkFirewallDisableProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.networkFirewallDisableMessage) + networkFirewallDisableAction.triggered.connect(self.networkFirewallDisable) + networkFirewallDisableProcess.finished.connect(self.networkFirewallDisableMessage) networkFirewallEnableAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-high"),_("Enable")) - self.connect(networkFirewallEnableAction, SIGNAL("triggered()"), self.networkFirewallEnable) - self.connect(networkFirewallEnableProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.networkFirewallEnableMessage) + networkFirewallEnableAction.triggered.connect(self.networkFirewallEnable) + networkFirewallEnableProcess.finished.connect(self.networkFirewallEnableMessage) networkFirewallConfigureAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-medium"),_("Configure...")) - self.connect(networkFirewallConfigureAction, SIGNAL("triggered()"), self.networkFirewallConfigure) + networkFirewallConfigureAction.triggered.connect(self.networkFirewallConfigure) networkProxyAction = networkMenu.addAction(QtGui.QIcon.fromTheme("network-server"),_("Proxy...")) - self.connect(networkProxyAction, SIGNAL("triggered()"), self.networkProxy) - self.connect(SRPMUpdateProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.SRPMSCheckUpgrade) + networkProxyAction.triggered.connect(self.networkProxy) + SRPMUpdateProcess.finished.connect(self.SRPMSCheckUpgrade) # about box aboutAction = menu.addSeparator() aboutAction = menu.addAction(QtGui.QIcon.fromTheme("help-about"),_("About")) - self.connect(aboutAction, SIGNAL("triggered()"), self.about) + aboutAction.triggered.connect(self.about) self.setContextMenu(menu) self.setToolTip(_("openmamba control center")) @@ -95,6 +97,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): # the first time check for SRPMS updates after 4 minutes checkSRPMSUpdatesTimer.start( 4 * 60000 ) + def setProxyForSmart(self): setProxyProcess = QtCore.QProcess(self) pf = libproxy.ProxyFactory() @@ -109,7 +112,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): break def iconActivated(self, reason): - if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): + if reason in (QtWidgets.QSystemTrayIcon.Trigger, QtWidgets.QSystemTrayIcon.DoubleClick): menu.popup(self.geometry().center()) def about(self): @@ -123,7 +126,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): v.close() else: version = _("Error: Unable to find /etc/openmamba-release") - QtGui.QMessageBox.about(menu, _("About"), + QtWidgets.QMessageBox.about(menu, _("About"), "