import os
from PyQt4 import QtGui
from PyQt4.QtCore import SIGNAL
+from qmenutooltip import QMenuToolTip
from apperror import AppError
from settings import appconf
action to add a new One """
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
- self.menuProfiles = QtGui.QMenu()
+ self.menuProfiles = QMenuToolTip()
self.menuProfiles.setTitle("Profiles")
#Get profiles from the ProfHandler embedded in the gui
#Using lambda function to pass additional arguments to the function, in this case the path of the profile
receiver = lambda pr=pr: self.profileManager.activateProfile(pr)
self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver)
+ #set menu item ToolTip
+ menuItem_Profile.setToolTip("Activate profile: "+pr)
self.menuProfiles.addAction(menuItem_Profile)
--- /dev/null
+#!/bin/python
+
+from PyQt4 import QtGui, QtCore
+class QMenuToolTip(QtGui.QMenu):
+ """ Implements a QMenu where it is possible to set a ToolTip and display it on mouse hover """
+ def __init__(self, parent=None):
+ QtGui.QMenu.__init__(self, parent)
+
+ def event(self, e):
+ if e.type() == QtCore.QEvent.ToolTip:
+ if not self.activeAction() is None:
+ QtGui.QToolTip.showText(e.globalPos(), self.activeAction().toolTip())
+ else:
+ QtGui.QToolTip.hideText()
+ return QtGui.QMenu.event(self, e)