From effec111c39110f5057f49224f07bdd0730e7862 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 3 Oct 2013 17:19:50 -0300 Subject: Add preference to set autostart EIP option. --- src/leap/bitmask/gui/eip_preferenceswindow.py | 43 ++++++++- src/leap/bitmask/gui/ui/eippreferences.ui | 125 ++++++++++++++++++++++---- 2 files changed, 149 insertions(+), 19 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/gui/eip_preferenceswindow.py b/src/leap/bitmask/gui/eip_preferenceswindow.py index 0e6e8dda..9f8c4ff4 100644 --- a/src/leap/bitmask/gui/eip_preferenceswindow.py +++ b/src/leap/bitmask/gui/eip_preferenceswindow.py @@ -50,6 +50,7 @@ class EIPPreferencesWindow(QtGui.QDialog): self.ui = Ui_EIPPreferences() self.ui.setupUi(self) self.ui.lblProvidersGatewayStatus.setVisible(False) + self.ui.lblAutoStartEIPStatus.setVisible(False) # Connections self.ui.cbProvidersGateway.currentIndexChanged[unicode].connect( @@ -58,8 +59,40 @@ class EIPPreferencesWindow(QtGui.QDialog): self.ui.cbGateways.currentIndexChanged[unicode].connect( lambda x: self.ui.lblProvidersGatewayStatus.setVisible(False)) + self.ui.cbProvidersEIP.currentIndexChanged[unicode].connect( + lambda x: self.ui.lblAutoStartEIPStatus.setVisible(False)) + + self.ui.cbAutoStartEIP.toggled.connect( + lambda x: self.ui.lblAutoStartEIPStatus.setVisible(False)) + + self.ui.pbSaveAutoStartEIP.clicked.connect(self._save_auto_start_eip) + self._add_configured_providers() + # Load auto start EIP settings + self.ui.cbAutoStartEIP.setChecked(self._settings.get_autostart_eip()) + default_provider = self._settings.get_defaultprovider() + idx = self.ui.cbProvidersEIP.findText(default_provider) + self.ui.cbProvidersEIP.setCurrentIndex(idx) + + def _save_auto_start_eip(self): + """ + SLOT + TRIGGER: + self.ui.cbAutoStartEIP.toggled + + Saves the automatic start of EIP user preference. + """ + default_provider = self.ui.cbProvidersEIP.currentText() + enabled = self.ui.cbAutoStartEIP.isChecked() + + self._settings.set_autostart_eip(enabled) + self._settings.set_defaultprovider(default_provider) + + self.ui.lblAutoStartEIPStatus.show() + logger.debug('Auto start EIP saved: {0} {1}.'.format( + default_provider, enabled)) + def _set_providers_gateway_status(self, status, success=False, error=False): """ @@ -87,8 +120,16 @@ class EIPPreferencesWindow(QtGui.QDialog): Add the client's configured providers to the providers combo boxes. """ self.ui.cbProvidersGateway.clear() - for provider in self._settings.get_configured_providers(): + self.ui.cbProvidersEIP.clear() + providers = self._settings.get_configured_providers() + if not providers: + self.ui.gbAutomaticEIP.setEnabled(False) + self.ui.gbGatewaySelector.setEnabled(False) + return + + for provider in providers: self.ui.cbProvidersGateway.addItem(provider) + self.ui.cbProvidersEIP.addItem(provider) def _save_selected_gateway(self, provider): """ diff --git a/src/leap/bitmask/gui/ui/eippreferences.ui b/src/leap/bitmask/gui/ui/eippreferences.ui index e9bc203d..9493d330 100644 --- a/src/leap/bitmask/gui/ui/eippreferences.ui +++ b/src/leap/bitmask/gui/ui/eippreferences.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 170 + 398 + 262 @@ -17,8 +17,8 @@ :/images/mask-icon.png:/images/mask-icon.png - - + + true @@ -30,6 +30,16 @@ false + + + + &Select provider: + + + cbProvidersGateway + + + @@ -39,13 +49,20 @@ - - + + - &Select provider: + Save this provider settings - - cbProvidersGateway + + + + + + < Providers Gateway Status > + + + Qt::AlignCenter @@ -65,30 +82,102 @@ - - + + + + + + + Automatic EIP start + + + + + + Qt::LeftToRight + + + + + + QFrame::NoFrame + + + QFrame::Plain + - Save this provider settings + <font color='green'><b>Automatic EIP start saved!</b></font> + + + Qt::AlignCenter - - + + - < Providers Gateway Status > + Save auto start setting - - Qt::AlignCenter + + + + + + Qt::LeftToRight + + + Enable Automatic start of EIP + + + true + + + + + <Select provider> + + + + + cbAutoStartEIP + lblAutoStartEIPStatus + pbSaveAutoStartEIP + cbProvidersEIP + + cbAutoStartEIP + cbProvidersEIP + pbSaveAutoStartEIP + cbProvidersGateway + cbGateways + pbSaveGateway + - + + + cbAutoStartEIP + toggled(bool) + cbProvidersEIP + setEnabled(bool) + + + 180 + 53 + + + 238 + 53 + + + + -- cgit v1.2.3