コード例 #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 = 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)
コード例 #2
0
    def minimumSizeHint(self):

        width = 0

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        width += self._min_last_section_size

        width += self.frameWidth() * 2

        if self._forced_height_num_chars is None:

            min_num_rows = 4

        else:

            min_num_rows = self._forced_height_num_chars

        # + 2 for header and * 1.25 for magic
        (width_gumpf, height) = ClientGUIFunctions.ConvertTextToPixels(
            self, (20, int((min_num_rows + 2) * 1.25)))

        min_size_hint = QC.QSize(width, height)

        return min_size_hint
コード例 #3
0
 def __init__( self, parent: QW.QWidget, service_key: bytes, accounts: typing.Collection[ HydrusNetwork.Account ] ):
     
     ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )
     
     self._service_key = service_key
     self._service = HG.client_controller.services_manager.GetService( self._service_key )
     self._accounts = accounts
     
     self._accounts_box = ClientGUICommon.StaticBox( self, 'accounts' )
     
     self._account_list = ClientGUIListBoxes.BetterQListWidget( self._accounts_box )
     self._account_list.setSelectionMode( QW.QListWidget.ExtendedSelection )
     
     ( min_width, min_height ) = ClientGUIFunctions.ConvertTextToPixels( self._account_list, ( 74, 16 ) )
     
     self._account_list.setMinimumSize( min_width, min_height )
     
     modify_button = ClientGUICommon.BetterButton( self._accounts_box, 'modify selected', self._ModifyAccounts )
     
     #
     
     my_admin_account_key = self._service.GetAccount().GetAccountKey()
     
     accounts.sort( key = lambda a: ( a.GetAccountType().GetTitle(), a.GetAccountKey().hex() ) )
     
     for account in accounts:
         
         item = QW.QListWidgetItem()
         
         account_key = account.GetAccountKey()
         
         text = account.GetSingleLineTitle()
         
         if account_key == my_admin_account_key:
             
             text = 'THIS IS YOU: {}'.format( text )
             
         
         item.setText( text )
         
         item.setData( QC.Qt.UserRole, account )
         
         self._account_list.addItem( item )
         
     
     #
     
     self._accounts_box.Add( self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, modify_button, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
     
     #
     
     self._account_list.itemDoubleClicked.connect( self._ModifyAccounts )
コード例 #4
0
ファイル: ClientGUIListCtrl.py プロジェクト: HOZHENWAI/hydrus
 def GrowShrinkColumnsHeight( self, ideal_rows ):
     
     # +2 for the header row and * 1.25 for magic rough text-to-rowheight conversion
     
     existing_min_width = self.minimumWidth()
     
     ( width_gumpf, ideal_client_height ) = ClientGUIFunctions.ConvertTextToPixels( self, ( 20, int( ( ideal_rows + 2 ) * 1.25 ) ) )
     
     QP.SetMinClientSize( self, ( existing_min_width, ideal_client_height ) )
コード例 #5
0
    def _GetRowHeightEstimate(self):

        if self.topLevelItemCount() > 0:

            height = self.rowHeight(self.indexFromItem(self.topLevelItem(0)))

        else:

            (width_gumpf,
             height) = ClientGUIFunctions.ConvertTextToPixels(self, (20, 1))

        return height
コード例 #6
0
    def sizeHint(self):

        # still have an issue here where if the list gets populated with a bunch of stuff and hence gets a vertical scrollbar, it doesn't account for that
        # something like change this to viewportSizehint and/or doing updateGeometry on add data, if that isn't already done when scrollbars added?

        width = 0

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        #

        # we use the last value saved to options for this column. not what it currently is, but what user saw last
        # this might be from a few milliseconds ago, or last time dialog was open. main thing is this is a _sensible_ value for this column, to inform panels and so on

        last_column_type = self._column_list_status.GetColumnTypes()[-1]

        last_column_chars = self._column_list_status.GetColumnWidth(
            last_column_type)

        main_tlw = HG.client_controller.GetMainTLW()

        width += ClientGUIFunctions.ConvertTextToPixelWidth(
            main_tlw, last_column_chars)

        #

        width += self.frameWidth() * 2

        if self._forced_height_num_chars is None:

            num_rows = self._initial_height_num_chars

        else:

            num_rows = self._forced_height_num_chars

        # + 2 for header and * 1.25 for magic
        (width_gumpf, height) = ClientGUIFunctions.ConvertTextToPixels(
            self, (20, int((num_rows + 2) * 1.25)))

        size_hint = QC.QSize(width, height)

        return size_hint