mambatray.py: wayland: workaround left-click causing menu to appear in screen center by disabling if plasmawayland session
This commit is contained in:
parent
ee9bf1f12b
commit
e0664fa1de
25
mambatray.py
25
mambatray.py
@ -20,8 +20,8 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
|
|
||||||
menu = None
|
menu = None
|
||||||
|
|
||||||
def __init__(self, icon, parent=None):
|
def __init__(self, icon):
|
||||||
QSystemTrayIcon.__init__(self, icon, parent)
|
QSystemTrayIcon.__init__(self, icon)
|
||||||
|
|
||||||
global w, contatore, srpm, lista, NetsrpmsArg, nOre, desktop_session
|
global w, contatore, srpm, lista, NetsrpmsArg, nOre, desktop_session
|
||||||
nOre = 2
|
nOre = 2
|
||||||
@ -32,8 +32,7 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
NetsrpmsArg = "-c"
|
NetsrpmsArg = "-c"
|
||||||
lista = []
|
lista = []
|
||||||
contatore = 0
|
contatore = 0
|
||||||
w = parent
|
self.menu = QMenu()
|
||||||
self.menu = QMenu(parent)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION'))
|
desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION'))
|
||||||
@ -65,6 +64,7 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
softwareBaseInstallsProcess = QProcess(self)
|
softwareBaseInstallsProcess = QProcess(self)
|
||||||
|
|
||||||
softwareMenu = self.menu.addMenu(QIcon.fromTheme("applications-system"),_("Software"))
|
softwareMenu = self.menu.addMenu(QIcon.fromTheme("applications-system"),_("Software"))
|
||||||
|
|
||||||
softwareManageAction = softwareMenu.addAction(QIcon.fromTheme("applications-other"),_("Add/Remove software packages..."))
|
softwareManageAction = softwareMenu.addAction(QIcon.fromTheme("applications-other"),_("Add/Remove software packages..."))
|
||||||
softwareManageAction.triggered.connect(self.softwareManager)
|
softwareManageAction.triggered.connect(self.softwareManager)
|
||||||
|
|
||||||
@ -84,6 +84,7 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
|
|
||||||
networkMenu = self.menu.addMenu(QIcon.fromTheme("preferences-system-network"),
|
networkMenu = self.menu.addMenu(QIcon.fromTheme("preferences-system-network"),
|
||||||
_("Network"))
|
_("Network"))
|
||||||
|
|
||||||
networkFirewallMenu = networkMenu.addMenu(QIcon.fromTheme("security-medium"),_("Firewall"))
|
networkFirewallMenu = networkMenu.addMenu(QIcon.fromTheme("security-medium"),_("Firewall"))
|
||||||
networkFirewallDisableAction = networkFirewallMenu.addAction(QIcon.fromTheme("security-low"),_("Disable"))
|
networkFirewallDisableAction = networkFirewallMenu.addAction(QIcon.fromTheme("security-low"),_("Disable"))
|
||||||
networkFirewallDisableAction.triggered.connect(self.networkFirewallDisable)
|
networkFirewallDisableAction.triggered.connect(self.networkFirewallDisable)
|
||||||
@ -105,7 +106,6 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
self.setToolTip(_("{} control center").format(distro.name()))
|
self.setToolTip(_("{} control center").format(distro.name()))
|
||||||
self.activated.connect(self.iconActivated)
|
self.activated.connect(self.iconActivated)
|
||||||
self.setContextMenu(self.menu)
|
self.setContextMenu(self.menu)
|
||||||
self.show()
|
|
||||||
|
|
||||||
# the first time refresh packages cache after 5 minutes
|
# the first time refresh packages cache after 5 minutes
|
||||||
refreshPackagesTimer.start( 5 * 60000 )
|
refreshPackagesTimer.start( 5 * 60000 )
|
||||||
@ -114,6 +114,9 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
|
|
||||||
def iconActivated(self, reason):
|
def iconActivated(self, reason):
|
||||||
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick, QSystemTrayIcon.Context):
|
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick, QSystemTrayIcon.Context):
|
||||||
|
# FIXME: on plasma wayland and left click menu will popup in the center of the screen
|
||||||
|
# disabling and only supporting right click.
|
||||||
|
if desktop_session != 'plasmawayland':
|
||||||
self.contextMenu().popup(QCursor.pos())
|
self.contextMenu().popup(QCursor.pos())
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
@ -234,17 +237,13 @@ class SystemTrayIcon(QSystemTrayIcon):
|
|||||||
return testo[0:len(testo)-2]
|
return testo[0:len(testo)-2]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
if __name__ == '__main__':
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
if app.isSessionRestored():
|
if app.isSessionRestored():
|
||||||
app.exit(1)
|
app.exit(1)
|
||||||
else:
|
else:
|
||||||
app.setQuitOnLastWindowClosed(0)
|
app.setQuitOnLastWindowClosed(0)
|
||||||
gettext.install('mambatray', '/usr/share/locale')
|
gettext.install('mambatray', '/usr/share/locale')
|
||||||
trayIcon = SystemTrayIcon(QIcon.fromTheme("mambatray")
|
trayIcon = SystemTrayIcon(QIcon.fromTheme("mambatray"))
|
||||||
)
|
trayIcon.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user