def _populate_services(self): """ Loads the services that the provider provides into the UI for the user to enable or disable. """ title = self.tr("Services by {0}").format( self._provider_details['domain']) self.ui.grpServices.setTitle(title) services = get_supported(self._provider_details['services']) for service in services: try: if service not in self._shown_services: checkbox = QtGui.QCheckBox(self) service_label = get_service_display_name(service) checkbox.setText(service_label) self.ui.serviceListLayout.addWidget(checkbox) checkbox.stateChanged.connect( partial(self._service_selection_changed, service)) checkbox.setChecked(True) self._shown_services.add(service) except ValueError: logger.error( self.tr("Something went wrong while trying to " "load service %s" % (service, )))
def _populate_services(self): """ Loads the services that the provider provides into the UI for the user to enable or disable. """ self.ui.grpServices.setTitle( self.tr("Services by {0}").format(self._provider_details['name'])) services = get_supported(self._provider_details['services']) for service in services: try: if service not in self._shown_services: checkbox = QtGui.QCheckBox(self) service_label = get_service_display_name(service) checkbox.setText(service_label) self.ui.serviceListLayout.addWidget(checkbox) checkbox.stateChanged.connect( partial(self._service_selection_changed, service)) checkbox.setChecked(True) self._shown_services.add(service) except ValueError: logger.error( self.tr("Something went wrong while trying to " "load service %s" % (service,)))
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, self._standalone) 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 test_supports_unknown_service(self): pc = self._provider_config config = copy.deepcopy(sample_config) config['services'] = ['unknown'] json_string = json.dumps(config) pc.load(data=json_string) self.assertFalse('unknown' in get_supported(pc.get_services()))
def get_supported_services(self, domain): """ Signal a list of supported services provided by the given provider. :param domain: the provider to get the services from. :type domain: str Signals: prov_get_supported_services -> list of unicode """ services = get_supported(self._get_services(domain)) self._signaler.signal( self._signaler.prov_get_supported_services, services)
def get_supported_services(self, domain): """ Signal a list of supported services provided by the given provider. :param domain: the provider to get the services from. :type domain: str Signals: prov_get_supported_services -> list of unicode """ services = get_supported(self._get_services(domain)) self._signaler.signal(self._signaler.prov_get_supported_services, services)