summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/systray.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-11-07 17:46:02 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-11-08 16:11:51 -0300
commit6714b423a4ae879e23a82a60480387186e737ab1 (patch)
treecc5df06e6d72717be9529f54d415071d4293d38e /src/leap/bitmask/gui/systray.py
parentf3217d074ff20e6973ec382ad78100c77c6af081 (diff)
Use custom systray that ease the tooltip use.
- Create a custom SysTray that allows us to set services tooltips independently. - Initialize tooltip with service name at start. - Update required service status on tooltip update. [Closes #3998]
Diffstat (limited to 'src/leap/bitmask/gui/systray.py')
-rw-r--r--src/leap/bitmask/gui/systray.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/leap/bitmask/gui/systray.py b/src/leap/bitmask/gui/systray.py
new file mode 100644
index 00000000..d30b5f32
--- /dev/null
+++ b/src/leap/bitmask/gui/systray.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# systray.py
+# Copyright (C) 2013 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Custom system tray manager.
+"""
+
+from PySide import QtGui
+
+from leap.common.check import leap_assert_type
+
+
+class SysTray(QtGui.QSystemTrayIcon):
+ """
+ Custom system tray that allows us to use a more 'intelligent' tooltip.
+ """
+
+ def __init__(self, parent=None):
+ QtGui.QSystemTrayIcon.__init__(self, parent)
+ self._services = {}
+
+ def set_service_tooltip(self, service, tooltip):
+ """
+ Sets the service tooltip.
+
+ :param service: service name identifier
+ :type service: unicode
+ :param tooltip: tooltip to display for that service
+ :type tooltip: unicode
+ """
+ leap_assert_type(service, unicode)
+ leap_assert_type(tooltip, unicode)
+
+ self._services[service] = tooltip
+ tooltip = "\n".join(self._services.values())
+ self.setToolTip(tooltip)