From 6714b423a4ae879e23a82a60480387186e737ab1 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 7 Nov 2013 17:46:02 -0300 Subject: 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] --- src/leap/bitmask/gui/systray.py | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/leap/bitmask/gui/systray.py (limited to 'src/leap/bitmask/gui/systray.py') 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 . +""" +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) -- cgit v1.2.3