From 65bbc9ac87092053a8079d4d7d88cac4df5fbc36 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 10 Apr 2014 16:59:07 -0300 Subject: Add flag to start the app hidden in the tray. Closes #4990. --- src/leap/bitmask/app.py | 4 +++- src/leap/bitmask/gui/mainwindow.py | 21 +++++++++++++++++---- src/leap/bitmask/util/leap_argparse.py | 3 +++ 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 02e27123..ca1226de 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -201,6 +201,7 @@ def main(): logfile = opts.log_file mail_logfile = opts.mail_log_file openvpn_verb = opts.openvpn_verb + start_hidden = opts.start_hidden ############################################################# # Given how paths and bundling works, we need to delay the imports @@ -307,7 +308,8 @@ def main(): window = MainWindow( lambda: twisted_main.quit(app), openvpn_verb=openvpn_verb, - bypass_checks=bypass_checks) + bypass_checks=bypass_checks, + start_hidden=start_hidden) sigint_window = partial(sigint_handler, window, logger=logger) signal.signal(signal.SIGINT, sigint_window) diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 5abfaa67..0cc6104b 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -124,7 +124,8 @@ class MainWindow(QtGui.QMainWindow): def __init__(self, quit_callback, openvpn_verb=1, - bypass_checks=False): + bypass_checks=False, + start_hidden=False): """ Constructor for the client main window @@ -136,6 +137,9 @@ class MainWindow(QtGui.QMainWindow): first round of checks for CA certificates at bootstrap :type bypass_checks: bool + :param start_hidden: Set to true if the app should not show the window + but just the tray. + :type start_hidden: bool """ QtGui.QMainWindow.__init__(self) @@ -342,6 +346,7 @@ class MainWindow(QtGui.QMainWindow): self._logger_window = None self._bypass_checks = bypass_checks + self._start_hidden = start_hidden # We initialize Soledad and Keymanager instances as # transparent proxies, so we can pass the reference freely @@ -666,9 +671,11 @@ class MainWindow(QtGui.QMainWindow): providers = self._settings.get_configured_providers() self._login_widget.set_providers(providers) self._show_systray() - self.show() - if IS_MAC: - self.raise_() + + if not self._start_hidden: + self.show() + if IS_MAC: + self.raise_() self._hide_unsupported_services() @@ -787,6 +794,12 @@ class MainWindow(QtGui.QMainWindow): self._mail_status.set_systray(self._systray) self._eip_status.set_systray(self._systray) + hello = lambda: self._systray.showMessage( + self.tr('Hello!'), + self.tr('Bitmask has started in the tray.')) + # we wait for the systray to be ready + reactor.callLater(1, hello) + def _tray_activated(self, reason=None): """ SLOT diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py index 88267ff8..8aacc85d 100644 --- a/src/leap/bitmask/util/leap_argparse.py +++ b/src/leap/bitmask/util/leap_argparse.py @@ -59,6 +59,9 @@ def build_parser(): action="store_false", dest="api_version_check", help='Skip the api version compatibility check with ' 'the provider.') + parser.add_argument('-H', '--start-hidden', default=False, + action="store_true", dest="start_hidden", + help='Starts the application just in the taskbar.') # openvpn options parser.add_argument('--openvpn-verbosity', nargs='?', -- cgit v1.2.3