From def537bb5a78e046a75a9e13ea75449eec2b34c8 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 16 Apr 2014 14:48:53 -0300 Subject: Use Slot decorator instead of SLOT docstring. --- src/leap/bitmask/gui/mainwindow.py | 75 +++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 42 deletions(-) (limited to 'src/leap/bitmask/gui/mainwindow.py') diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index e5c11eb7..6bdfe7c0 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -457,9 +457,9 @@ class MainWindow(QtGui.QMainWindow): self._backend_connected_signals = {} + @QtCore.Slot() def _rejected_wizard(self): """ - SLOT TRIGGERS: self._wizard.rejected Called if the wizard has been cancelled or closed before @@ -481,9 +481,9 @@ class MainWindow(QtGui.QMainWindow): if self._wizard_firstrun: self._finish_init() + @QtCore.Slot() def _launch_wizard(self): """ - SLOT TRIGGERS: self._login_widget.show_wizard self.ui.action_wizard.triggered @@ -509,9 +509,9 @@ class MainWindow(QtGui.QMainWindow): self._wizard.finished.connect(self._wizard_finished) self._settings.set_skip_first_run(True) + @QtCore.Slot() def _wizard_finished(self): """ - SLOT TRIGGERS self._wizard.finished @@ -534,9 +534,9 @@ class MainWindow(QtGui.QMainWindow): return h return None + @QtCore.Slot() def _show_logger_window(self): """ - SLOT TRIGGERS: self.ui.action_show_logs.triggered @@ -555,9 +555,9 @@ class MainWindow(QtGui.QMainWindow): else: self._logger_window.setVisible(not self._logger_window.isVisible()) + @QtCore.Slot() def _show_AKM(self): """ - SLOT TRIGGERS: self.ui.action_advanced_key_management.triggered @@ -569,9 +569,9 @@ class MainWindow(QtGui.QMainWindow): logged_user, self._keymanager, self._soledad) self._akm.show() + @QtCore.Slot() def _show_preferences(self): """ - SLOT TRIGGERS: self.ui.btnPreferences.clicked (disabled for now) self.ui.action_preferences @@ -586,9 +586,9 @@ class MainWindow(QtGui.QMainWindow): preferences.show() preferences.preferences_saved.connect(self._update_eip_enabled_status) + @QtCore.Slot() def _update_eip_enabled_status(self): """ - SLOT TRIGGER: PreferencesWindow.preferences_saved @@ -622,9 +622,9 @@ class MainWindow(QtGui.QMainWindow): return eip_enabled + @QtCore.Slot() def _show_eip_preferences(self): """ - SLOT TRIGGERS: self.ui.btnEIPPreferences.clicked self.ui.action_eip_preferences (disabled for now) @@ -647,9 +647,9 @@ class MainWindow(QtGui.QMainWindow): """ self.new_updates.emit(req) + @QtCore.Slot(object) def _react_to_new_updates(self, req): """ - SLOT TRIGGER: self._new_updates_available Displays the new updates label and sets the updates_content @@ -659,9 +659,9 @@ class MainWindow(QtGui.QMainWindow): self.ui.btnMore.setVisible(True) self._updates_content = req.content + @QtCore.Slot() def _updates_details(self): """ - SLOT TRIGGER: self.ui.btnMore.clicked Parses and displays the updates details @@ -686,9 +686,9 @@ class MainWindow(QtGui.QMainWindow): self.tr("Updates available"), msg) + @QtCore.Slot() def _finish_init(self): """ - SLOT TRIGGERS: self._wizard.accepted @@ -832,9 +832,9 @@ class MainWindow(QtGui.QMainWindow): # we wait for the systray to be ready reactor.callLater(1, hello) + @QtCore.Slot(int) def _tray_activated(self, reason=None): """ - SLOT TRIGGER: self._systray.activated Displays the context menu from the tray icon @@ -862,9 +862,9 @@ class MainWindow(QtGui.QMainWindow): visible = self.isVisible() and self.isActiveWindow() self._action_visible.setText(get_action(visible)) + @QtCore.Slot() def _toggle_visible(self): """ - SLOT TRIGGER: self._action_visible.triggered Toggles the window visibility @@ -909,9 +909,9 @@ class MainWindow(QtGui.QMainWindow): if state is not None: self.restoreState(state) + @QtCore.Slot() def _about(self): """ - SLOT TRIGGERS: self.ui.action_about_leap.triggered Display the About Bitmask dialog @@ -936,9 +936,9 @@ class MainWindow(QtGui.QMainWindow): "More about LEAP" "") % (VERSION, VERSION_HASH[:10], greet)) + @QtCore.Slot() def _help(self): """ - SLOT TRIGGERS: self.ui.action_help.triggered Display the Bitmask help dialog. @@ -1036,9 +1036,9 @@ class MainWindow(QtGui.QMainWindow): provider = self._login_widget.get_selected_provider() self._backend.setup_provider(provider) + @QtCore.Slot(dict) def _load_provider_config(self, data): """ - SLOT TRIGGER: self._backend.signaler.prov_download_provider_info Once the provider config has been downloaded, this loads the @@ -1064,9 +1064,9 @@ class MainWindow(QtGui.QMainWindow): self.tr("Unable to login: Problem with provider")) self._login_widget.set_enabled(True) + @QtCore.Slot() def _login(self): """ - SLOT TRIGGERS: self._login_widget.login @@ -1092,9 +1092,9 @@ class MainWindow(QtGui.QMainWindow): if self._login_widget.start_login(): self._download_provider_config() + @QtCore.Slot(unicode) def _authentication_error(self, msg): """ - SLOT TRIGGERS: Signaler.srp_auth_error Signaler.srp_auth_server_error @@ -1110,9 +1110,9 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_enabled(True) self.ui.action_create_new_account.setEnabled(True) + @QtCore.Slot() def _cancel_login(self): """ - SLOT TRIGGERS: self._login_widget.cancel_login @@ -1134,9 +1134,9 @@ class MainWindow(QtGui.QMainWindow): self._soledad_defer.cancel() self._soledad_defer = None + @QtCore.Slot() def _set_login_cancelled(self): """ - SLOT TRIGGERS: Signaler.prov_cancelled_setup fired by self._backend.cancel_setup_provider() @@ -1147,9 +1147,9 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_status(self.tr("Log in cancelled by the user.")) self._login_widget.set_enabled(True) + @QtCore.Slot(dict) def _provider_config_loaded(self, data): """ - SLOT TRIGGER: self._backend.signaler.prov_check_api_certificate Once the provider configuration is loaded, this starts the SRP @@ -1171,9 +1171,9 @@ class MainWindow(QtGui.QMainWindow): logger.error(data[self._backend.ERROR_KEY]) self._login_widget.set_enabled(True) + @QtCore.Slot() def _authentication_finished(self): """ - SLOT TRIGGER: self._srp_auth.authentication_finished Once the user is properly authenticated, try starting the EIP @@ -1285,10 +1285,10 @@ class MainWindow(QtGui.QMainWindow): ################################################################### # Service control methods: soledad + @QtCore.Slot(dict) def _soledad_intermediate_stage(self, data): # TODO missing param docstring """ - SLOT TRIGGERS: self._soledad_bootstrapper.download_config @@ -1320,9 +1320,9 @@ class MainWindow(QtGui.QMainWindow): logger.warning("Max number of soledad initialization " "retries reached.") + @QtCore.Slot(dict) def _soledad_bootstrapped_stage(self, data): """ - SLOT TRIGGERS: self._soledad_bootstrapper.gen_key self._soledad_bootstrapper.local_only_ready @@ -1364,7 +1364,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _start_smtp_bootstrapping(self): """ - SLOT TRIGGERS: self.soledad_ready """ @@ -1385,7 +1384,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _stop_smtp_service(self): """ - SLOT TRIGGERS: self.logout """ @@ -1398,7 +1396,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _start_imap_service(self): """ - SLOT TRIGGERS: self.soledad_ready """ @@ -1428,7 +1425,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _fetch_incoming_mail(self): """ - SLOT TRIGGERS: self.mail_client_logged_in """ @@ -1438,7 +1434,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _stop_imap_service(self): """ - SLOT TRIGGERS: self.logout """ @@ -1487,7 +1482,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _on_eip_connection_connected(self): """ - SLOT TRIGGERS: self._eip_status.eip_connection_connected Emits the EIPConnection.qtsigs.connected_signal @@ -1589,9 +1583,9 @@ class MainWindow(QtGui.QMainWindow): self._backend.start_eip() + @QtCore.Slot() def _on_eip_connection_aborted(self): """ - SLOT TRIGGERS: Signaler.eip_connection_aborted """ @@ -1667,7 +1661,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _stop_eip(self): """ - SLOT TRIGGERS: self._eip_connection.qtsigs.do_disconnect_signal (via state machine) @@ -1697,7 +1690,6 @@ class MainWindow(QtGui.QMainWindow): def _on_eip_network_unreachable(self): # XXX Should move to EIP Conductor """ - SLOT TRIGGERS: self._eip_connection.qtsigs.network_unreachable @@ -1711,7 +1703,7 @@ class MainWindow(QtGui.QMainWindow): def _do_eip_restart(self): # XXX Should move to EIP Conductor """ - SLOT + TRIGGER: self._eip_connection.qtsigs.process_restart Restart the connection. @@ -1729,9 +1721,9 @@ class MainWindow(QtGui.QMainWindow): self._eip_status.set_eip_status("", error=error) self._eip_status.set_eip_status_icon("error") + @QtCore.Slot(int) def _eip_finished(self, exitCode): """ - SLOT TRIGGERS: Signaler.eip_process_finished @@ -1822,9 +1814,9 @@ class MainWindow(QtGui.QMainWindow): # eip will not start, so we start soledad anyway self._maybe_run_soledad_setup_checks() + @QtCore.Slot(dict) def _finish_eip_bootstrap(self, data): """ - SLOT TRIGGER: self._backend.signaler.eip_client_certificate_ready Starts the VPN thread if the eip configuration is properly @@ -1842,10 +1834,10 @@ class MainWindow(QtGui.QMainWindow): # DO START EIP Connection! self._eip_connection.qtsigs.do_connect_signal.emit() + @QtCore.Slot(dict) def _eip_intermediate_stage(self, data): # TODO missing param """ - SLOT TRIGGERS: self._backend.signaler.eip_config_ready @@ -1889,7 +1881,6 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _logout(self): """ - SLOT TRIGGER: self._login_widget.logout Starts the logout sequence @@ -1907,9 +1898,9 @@ class MainWindow(QtGui.QMainWindow): self._backend.logout() self.logout.emit() + @QtCore.Slot() def _logout_error(self): """ - SLOT TRIGGER: self._srp_auth.logout_error Inform the user about a logout error. @@ -1919,9 +1910,9 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_status( self.tr("Something went wrong with the logout.")) + @QtCore.Slot() def _logout_ok(self): """ - SLOT TRIGGER: self._srp_auth.logout_ok Switches the stackedWidget back to the login stage after @@ -1934,10 +1925,10 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.logged_out() self._mail_status.mail_state_disabled() + @QtCore.Slot(dict) def _intermediate_stage(self, data): # TODO this method name is confusing as hell. """ - SLOT TRIGGERS: self._backend.signaler.prov_name_resolution self._backend.signaler.prov_https_connection @@ -1967,9 +1958,9 @@ class MainWindow(QtGui.QMainWindow): raise_window_ack() self.raise_window.emit() + @QtCore.Slot() def _do_raise_mainwindow(self): """ - SLOT TRIGGERS: self._on_raise_window_event -- cgit v1.2.3 From 5218fda6b524cb8e694113e123e7b0d05b205ddc Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 16 Apr 2014 15:25:41 -0300 Subject: Use consistent wording for triggers documentation. --- src/leap/bitmask/gui/mainwindow.py | 85 ++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 35 deletions(-) (limited to 'src/leap/bitmask/gui/mainwindow.py') diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 6bdfe7c0..708ecf7f 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -460,7 +460,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _rejected_wizard(self): """ - TRIGGERS: self._wizard.rejected + TRIGGERS: + self._wizard.rejected Called if the wizard has been cancelled or closed before finishing. @@ -485,8 +486,8 @@ class MainWindow(QtGui.QMainWindow): def _launch_wizard(self): """ TRIGGERS: - self._login_widget.show_wizard - self.ui.action_wizard.triggered + self._login_widget.show_wizard + self.ui.action_wizard.triggered Also called in first run. @@ -512,8 +513,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _wizard_finished(self): """ - TRIGGERS - self._wizard.finished + TRIGGERS: + self._wizard.finished Called when the wizard has finished. """ @@ -538,7 +539,7 @@ class MainWindow(QtGui.QMainWindow): def _show_logger_window(self): """ TRIGGERS: - self.ui.action_show_logs.triggered + self.ui.action_show_logs.triggered Displays the window with the history of messages logged until now and displays the new ones on arrival. @@ -573,8 +574,8 @@ class MainWindow(QtGui.QMainWindow): def _show_preferences(self): """ TRIGGERS: - self.ui.btnPreferences.clicked (disabled for now) - self.ui.action_preferences + self.ui.btnPreferences.clicked (disabled for now) + self.ui.action_preferences Displays the preferences window. """ @@ -626,8 +627,8 @@ class MainWindow(QtGui.QMainWindow): def _show_eip_preferences(self): """ TRIGGERS: - self.ui.btnEIPPreferences.clicked - self.ui.action_eip_preferences (disabled for now) + self.ui.btnEIPPreferences.clicked + self.ui.action_eip_preferences (disabled for now) Displays the EIP preferences window. """ @@ -650,7 +651,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot(object) def _react_to_new_updates(self, req): """ - TRIGGER: self._new_updates_available + TRIGGERS: + self._new_updates_available Displays the new updates label and sets the updates_content """ @@ -662,7 +664,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _updates_details(self): """ - TRIGGER: self.ui.btnMore.clicked + TRIGGERS: + self.ui.btnMore.clicked Parses and displays the updates details """ @@ -690,7 +693,7 @@ class MainWindow(QtGui.QMainWindow): def _finish_init(self): """ TRIGGERS: - self._wizard.accepted + self._wizard.accepted Also called at the end of the constructor if not first run. @@ -835,7 +838,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot(int) def _tray_activated(self, reason=None): """ - TRIGGER: self._systray.activated + TRIGGERS: + self._systray.activated Displays the context menu from the tray icon """ @@ -865,7 +869,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _toggle_visible(self): """ - TRIGGER: self._action_visible.triggered + TRIGGERS: + self._action_visible.triggered Toggles the window visibility """ @@ -912,7 +917,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _about(self): """ - TRIGGERS: self.ui.action_about_leap.triggered + TRIGGERS: + self.ui.action_about_leap.triggered Display the About Bitmask dialog """ @@ -939,7 +945,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _help(self): """ - TRIGGERS: self.ui.action_help.triggered + TRIGGERS: + self.ui.action_help.triggered Display the Bitmask help dialog. """ @@ -1039,7 +1046,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot(dict) def _load_provider_config(self, data): """ - TRIGGER: self._backend.signaler.prov_download_provider_info + TRIGGERS: + self._backend.signaler.prov_download_provider_info Once the provider config has been downloaded, this loads the self._provider_config instance with it and starts the second @@ -1068,7 +1076,7 @@ class MainWindow(QtGui.QMainWindow): def _login(self): """ TRIGGERS: - self._login_widget.login + self._login_widget.login Starts the login sequence. Which involves bootstrapping the selected provider if the selection is valid (not empty), then @@ -1114,7 +1122,7 @@ class MainWindow(QtGui.QMainWindow): def _cancel_login(self): """ TRIGGERS: - self._login_widget.cancel_login + self._login_widget.cancel_login Stops the login sequence. """ @@ -1150,7 +1158,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot(dict) def _provider_config_loaded(self, data): """ - TRIGGER: self._backend.signaler.prov_check_api_certificate + TRIGGERS: + self._backend.signaler.prov_check_api_certificate Once the provider configuration is loaded, this starts the SRP authentication @@ -1174,7 +1183,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _authentication_finished(self): """ - TRIGGER: self._srp_auth.authentication_finished + TRIGGERS: + self._srp_auth.authentication_finished Once the user is properly authenticated, try starting the EIP service @@ -1290,7 +1300,7 @@ class MainWindow(QtGui.QMainWindow): # TODO missing param docstring """ TRIGGERS: - self._soledad_bootstrapper.download_config + self._soledad_bootstrapper.download_config If there was a problem, displays it, otherwise it does nothing. This is used for intermediate bootstrapping stages, in case @@ -1324,8 +1334,8 @@ class MainWindow(QtGui.QMainWindow): def _soledad_bootstrapped_stage(self, data): """ TRIGGERS: - self._soledad_bootstrapper.gen_key - self._soledad_bootstrapper.local_only_ready + self._soledad_bootstrapper.gen_key + self._soledad_bootstrapper.local_only_ready If there was a problem, displays it, otherwise it does nothing. This is used for intermediate bootstrapping stages, in case @@ -1484,6 +1494,7 @@ class MainWindow(QtGui.QMainWindow): """ TRIGGERS: self._eip_status.eip_connection_connected + Emits the EIPConnection.qtsigs.connected_signal This is a little workaround for connecting the vpn-connected @@ -1703,7 +1714,7 @@ class MainWindow(QtGui.QMainWindow): def _do_eip_restart(self): # XXX Should move to EIP Conductor """ - TRIGGER: + TRIGGERS: self._eip_connection.qtsigs.process_restart Restart the connection. @@ -1817,7 +1828,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot(dict) def _finish_eip_bootstrap(self, data): """ - TRIGGER: self._backend.signaler.eip_client_certificate_ready + TRIGGERS: + self._backend.signaler.eip_client_certificate_ready Starts the VPN thread if the eip configuration is properly loaded @@ -1839,7 +1851,7 @@ class MainWindow(QtGui.QMainWindow): # TODO missing param """ TRIGGERS: - self._backend.signaler.eip_config_ready + self._backend.signaler.eip_config_ready If there was a problem, displays it, otherwise it does nothing. This is used for intermediate bootstrapping stages, in case @@ -1881,7 +1893,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _logout(self): """ - TRIGGER: self._login_widget.logout + TRIGGERS: + self._login_widget.logout Starts the logout sequence """ @@ -1901,7 +1914,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _logout_error(self): """ - TRIGGER: self._srp_auth.logout_error + TRIGGER: + self._srp_auth.logout_error Inform the user about a logout error. """ @@ -1913,7 +1927,8 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _logout_ok(self): """ - TRIGGER: self._srp_auth.logout_ok + TRIGGER: + self._srp_auth.logout_ok Switches the stackedWidget back to the login stage after logging out @@ -1930,10 +1945,10 @@ class MainWindow(QtGui.QMainWindow): # TODO this method name is confusing as hell. """ TRIGGERS: - self._backend.signaler.prov_name_resolution - self._backend.signaler.prov_https_connection - self._backend.signaler.prov_download_ca_cert - self._backend.signaler.eip_config_ready + self._backend.signaler.prov_name_resolution + self._backend.signaler.prov_https_connection + self._backend.signaler.prov_download_ca_cert + self._backend.signaler.eip_config_ready If there was a problem, displays it, otherwise it does nothing. This is used for intermediate bootstrapping stages, in case -- cgit v1.2.3 From fa81e2f08335334f8def3a9275c00ba133e5f714 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 17 Apr 2014 11:45:03 -0300 Subject: Improve parameters docstrings. Also rename a parameter named 'param' to a more meaningful 'idx'. --- src/leap/bitmask/gui/mainwindow.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/leap/bitmask/gui/mainwindow.py') diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 708ecf7f..b911e5d8 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -652,9 +652,12 @@ class MainWindow(QtGui.QMainWindow): def _react_to_new_updates(self, req): """ TRIGGERS: - self._new_updates_available + self.new_updates Displays the new updates label and sets the updates_content + + :param req: Request type + :type req: leap.common.events.events_pb2.SignalRequest """ self.moveToThread(QtCore.QCoreApplication.instance().thread()) self.ui.lblNewUpdates.setVisible(True) @@ -841,6 +844,9 @@ class MainWindow(QtGui.QMainWindow): TRIGGERS: self._systray.activated + :param reason: the reason why the tray got activated. + :type reason: int + Displays the context menu from the tray icon """ self._update_hideshow_menu() -- cgit v1.2.3