def __init__(self, parent: QW.QWidget, service_key: bytes,
                 account_identifiers: typing.Collection[
                     HydrusNetwork.AccountIdentifier]):

        QW.QWidget.__init__(self, parent)

        self._service_key = service_key
        self._service = HG.client_controller.services_manager.GetService(
            self._service_key)
        self._account_identifiers = account_identifiers

        self._done_first_fetch = False
        self._accounts_loaded = False
        self._account_keys_to_accounts = {}
        self._account_keys_to_account_info = {}

        self._accounts_box = ClientGUICommon.StaticBox(self, 'accounts')

        self._status_st = ClientGUICommon.BetterStaticText(self._accounts_box)

        self._account_list = ClientGUICommon.BetterCheckBoxList(
            self._accounts_box)
        self._account_list.setSelectionMode(
            QW.QAbstractItemView.SingleSelection)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_list, (74, 6))

        self._account_list.setMinimumSize(min_width, min_height)

        self._account_info_box = QW.QTextEdit(self._accounts_box)
        self._account_info_box.setReadOnly(True)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_info_box, (16, 8))

        self._account_info_box.setMinimumHeight(min_height)

        self._copy_checked_account_keys_button = ClientGUICommon.BetterButton(
            self._accounts_box, 'copy checked account ids',
            self._CopyCheckedAccountKeys)

        #

        self._accounts_box.Add(self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._accounts_box.Add(self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._account_info_box,
                               CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._copy_checked_account_keys_button,
                               CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        #

        self._account_list.itemClicked.connect(self._AccountClicked)
    def __init__(self, parent: QW.QWidget,
                 location_context: ClientLocation.LocationContext,
                 all_known_files_allowed: bool,
                 only_local_file_domains_allowed: bool):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._original_location_context = location_context
        self._all_known_files_allowed = all_known_files_allowed
        self._only_local_file_domains_allowed = only_local_file_domains_allowed

        self._location_list = ClientGUICommon.BetterCheckBoxList(self)

        services = ClientLocation.GetPossibleFileDomainServicesInOrder(
            all_known_files_allowed, only_local_file_domains_allowed)

        for service in services:

            name = service.GetName()
            service_key = service.GetServiceKey()

            starts_checked = service_key in self._original_location_context.current_service_keys

            self._location_list.Append(
                name, (HC.CONTENT_STATUS_CURRENT, service_key),
                starts_checked=starts_checked)

        advanced_mode = HG.client_controller.new_options.GetBoolean(
            'advanced_mode')

        if advanced_mode and not only_local_file_domains_allowed:

            for service in services:

                name = service.GetName()
                service_key = service.GetServiceKey()

                if service_key in (CC.COMBINED_FILE_SERVICE_KEY,
                                   CC.TRASH_SERVICE_KEY):

                    continue

                starts_checked = service_key in self._original_location_context.deleted_service_keys

                self._location_list.Append(
                    'deleted from {}'.format(name),
                    (HC.CONTENT_STATUS_DELETED, service_key),
                    starts_checked=starts_checked)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._location_list,
                       CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

        self.widget().setLayout(vbox)

        self._location_list.checkBoxListChanged.connect(
            self._ClearSurplusServices)
Exemple #3
0
 def __init__( self, parent, api_permissions ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._original_api_permissions = api_permissions
     
     self._access_key = QW.QLineEdit()
     
     self._access_key.setReadOnly( True )
     
     width = ClientGUIFunctions.ConvertTextToPixelWidth( self._access_key, 66 )
     
     self.setMinimumWidth( width )
     
     self._name = QW.QLineEdit( self )
     
     self._basic_permissions = ClientGUICommon.BetterCheckBoxList( self )
     
     for permission in ClientAPI.ALLOWED_PERMISSIONS:
         
         self._basic_permissions.Append( ClientAPI.basic_permission_to_str_lookup[ permission ], permission )
         
     
     search_tag_filter = api_permissions.GetSearchTagFilter()
     
     message = 'The API will only permit searching for tags that pass through this filter.'
     message += os.linesep * 2
     message += 'If you want to allow all tags, just leave it as is, permitting everything. If you want to limit it to just one tag, such as "do waifu2x on this", set up a whitelist with only that tag allowed.'
     
     self._search_tag_filter = ClientGUITags.TagFilterButton( self, message, search_tag_filter, label_prefix = 'permitted tags: ' )
     
     #
     
     access_key = api_permissions.GetAccessKey()
     
     self._access_key.setText( access_key.hex() )
     
     name = api_permissions.GetName()
     
     self._name.setText( name )
     
     basic_permissions = api_permissions.GetBasicPermissions()
     
     self._basic_permissions.SetValue( basic_permissions )
     
     #
     
     rows = []
     
     rows.append( ( 'access key: ', self._access_key ) )
     rows.append( ( 'name: ', self._name ) )
     rows.append( ( 'permissions: ', self._basic_permissions) )
     rows.append( ( 'tag search permissions: ', self._search_tag_filter ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
     
     #
     
     self._UpdateEnabled()
     
     self._basic_permissions.checkBoxListChanged.connect( self._UpdateEnabled )