本文整理汇总了Python中leap.bitmask.config.leapsettings.LeapSettings.set_enabled_services方法的典型用法代码示例。如果您正苦于以下问题:Python LeapSettings.set_enabled_services方法的具体用法?Python LeapSettings.set_enabled_services怎么用?Python LeapSettings.set_enabled_services使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap.bitmask.config.leapsettings.LeapSettings
的用法示例。
在下文中一共展示了LeapSettings.set_enabled_services方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import set_enabled_services [as 别名]
#.........这里部分代码省略.........
# We hide the maybe-visible status label after a change
self.ui.lblProvidersServicesStatus.setVisible(False)
if not domain:
return
# set the proper connection for the 'save' button
try:
self.ui.pbSaveServices.clicked.disconnect()
except RuntimeError:
pass # Signal was not connected
save_services = partial(self._save_enabled_services, domain)
self.ui.pbSaveServices.clicked.connect(save_services)
self._backend.provider_get_supported_services(domain=domain)
@QtCore.Slot(str)
def _load_services(self, services):
"""
TRIGGERS:
self.ui.cbProvidersServices.currentIndexChanged[unicode]
Loads the services that the provider provides into the UI for
the user to enable or disable.
:param domain: the domain of the provider to load services from.
:type domain: str
"""
domain = self.ui.cbProvidersServices.currentText()
services_conf = self._settings.get_enabled_services(domain)
# discard changes if other provider is selected
self._selected_services = set()
# from: http://stackoverflow.com/a/13103617/687989
# remove existing checkboxes
layout = self.ui.vlServices
for i in reversed(range(layout.count())):
layout.itemAt(i).widget().setParent(None)
# add one checkbox per service and set the current configured value
for service in services:
try:
checkbox = QtGui.QCheckBox(self)
service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.vlServices.addWidget(checkbox)
checkbox.stateChanged.connect(
partial(self._service_selection_changed, service))
checkbox.setChecked(service in services_conf)
except ValueError:
logger.error("Something went wrong while trying to "
"load service %s" % (service,))
@QtCore.Slot(str)
def _save_enabled_services(self, provider):
"""
TRIGGERS:
self.ui.pbSaveServices.clicked
Saves the new enabled services settings to the configuration file.
:param provider: the provider config that we need to save.
:type provider: str
"""
services = list(self._selected_services)
self._settings.set_enabled_services(provider, services)
msg = self.tr(
"Services settings for provider '{0}' saved.".format(provider))
logger.debug(msg)
self._set_providers_services_status(msg, success=True)
self.preferences_saved.emit()
def _backend_connect(self):
"""
Helper to connect to backend signals
"""
sig = self._leap_signaler
sig.prov_get_supported_services.connect(self._load_services)
sig.srp_password_change_ok.connect(self._srp_change_password_ok)
pwd_change_error = lambda: self._srp_change_password_problem(
self.tr("There was a problem changing the password."))
sig.srp_password_change_error.connect(pwd_change_error)
pwd_change_badpw = lambda: self._srp_change_password_problem(
self.tr("You did not enter a correct current password."))
sig.srp_password_change_badpw.connect(pwd_change_badpw)
sig.soledad_password_change_ok.connect(
self._soledad_change_password_ok)
sig.soledad_password_change_error.connect(
self._soledad_change_password_problem)
示例2: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import set_enabled_services [as 别名]
#.........这里部分代码省略.........
# remove existing checkboxes
layout = self.ui.vlServices
for i in reversed(range(layout.count())):
layout.itemAt(i).widget().setParent(None)
# add one checkbox per service and set the current configured value
for service in services:
try:
checkbox = QtGui.QCheckBox(self)
service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.vlServices.addWidget(checkbox)
checkbox.stateChanged.connect(
partial(self._service_selection_changed, service))
checkbox.setChecked(service in services_conf)
except ValueError:
logger.error("Something went wrong while trying to "
"load service %s" % (service,))
def _save_enabled_services(self, provider):
"""
SLOT
TRIGGERS:
self.ui.pbSaveServices.clicked
Saves the new enabled services settings to the configuration file.
:param provider: the provider config that we need to save.
:type provider: str
"""
services = list(self._selected_services)
self._settings.set_enabled_services(provider, services)
msg = self.tr(
"Services settings for provider '{0}' saved.".format(provider))
logger.debug(msg)
self._set_providers_services_status(msg, success=True)
def _get_provider_config(self, domain):
"""
Helper to return a valid Provider Config from the domain name.
:param domain: the domain name of the provider.
:type domain: str
:rtype: ProviderConfig or None if there is a problem loading the config
"""
provider_config = ProviderConfig()
provider_config_path = os.path.join(
"leap", "providers", domain, "provider.json")
if not provider_config.load(provider_config_path):
provider_config = None
return provider_config
def _save_selected_gateway(self, provider):
"""
SLOT
TRIGGERS:
self.ui.pbSaveGateway.clicked
Saves the new gateway setting to the configuration file.
示例3: PreferencesWindow
# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import set_enabled_services [as 别名]
#.........这里部分代码省略.........
self._selected_services.difference(set([service]))
# We hide the maybe-visible status label after a change
self.ui.lblProvidersServicesStatus.setVisible(False)
def _populate_services(self, domain):
"""
SLOT
TRIGGERS:
self.ui.cbProvidersServices.currentIndexChanged[unicode]
Loads the services that the provider provides into the UI for
the user to enable or disable.
:param domain: the domain of the provider to load services from.
:type domain: str
"""
# We hide the maybe-visible status label after a change
self.ui.lblProvidersServicesStatus.setVisible(False)
if not domain:
return
provider_config = self._get_provider_config(domain)
if provider_config is None:
return
# set the proper connection for the 'save' button
try:
self.ui.pbSaveServices.clicked.disconnect()
except RuntimeError:
pass # Signal was not connected
save_services = partial(self._save_enabled_services, domain)
self.ui.pbSaveServices.clicked.connect(save_services)
services = get_supported(provider_config.get_services())
services_conf = self._settings.get_enabled_services(domain)
# discard changes if other provider is selected
self._selected_services = set()
# from: http://stackoverflow.com/a/13103617/687989
# remove existing checkboxes
layout = self.ui.vlServices
for i in reversed(range(layout.count())):
layout.itemAt(i).widget().setParent(None)
# add one checkbox per service and set the current configured value
for service in services:
try:
checkbox = QtGui.QCheckBox(self)
service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.vlServices.addWidget(checkbox)
checkbox.stateChanged.connect(
partial(self._service_selection_changed, service))
checkbox.setChecked(service in services_conf)
except ValueError:
logger.error("Something went wrong while trying to "
"load service %s" % (service,))
def _save_enabled_services(self, provider):
"""
SLOT
TRIGGERS:
self.ui.pbSaveServices.clicked
Saves the new enabled services settings to the configuration file.
:param provider: the provider config that we need to save.
:type provider: str
"""
services = list(self._selected_services)
self._settings.set_enabled_services(provider, services)
msg = self.tr(
"Services settings for provider '{0}' saved.".format(provider))
logger.debug(msg)
self._set_providers_services_status(msg, success=True)
def _get_provider_config(self, domain):
"""
Helper to return a valid Provider Config from the domain name.
:param domain: the domain name of the provider.
:type domain: str
:rtype: ProviderConfig or None if there is a problem loading the config
"""
provider_config = ProviderConfig()
provider_config_path = os.path.join(
"leap", "providers", domain, "provider.json")
if not provider_config.load(provider_config_path):
provider_config = None
return provider_config