예제 #1
0
    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 = QP.CheckListBox(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)
예제 #2
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 = QP.CheckListBox(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.SetCheckedData(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.checkListBoxChanged.connect(
            self._UpdateEnabled)