Exemplo n.º 1
0
 def __init__( self, parent, export_folders ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._export_folders_panel = ClientGUIListCtrl.BetterListCtrlPanel( self )
     
     self._export_folders = ClientGUIListCtrl.BetterListCtrl( self._export_folders_panel, CGLC.COLUMN_LIST_EXPORT_FOLDERS.ID, 6, self._ConvertExportFolderToListCtrlTuples, use_simple_delete = True, activation_callback = self._Edit )
     
     self._export_folders_panel.SetListCtrl( self._export_folders )
     
     self._export_folders_panel.AddButton( 'add', self._AddFolder )
     self._export_folders_panel.AddButton( 'edit', self._Edit, enabled_only_on_selection = True )
     self._export_folders_panel.AddDeleteButton()
     
     #
     
     self._export_folders.AddDatas( export_folders )
     
     self._export_folders.Sort()
     
     vbox = QP.VBoxLayout()
     
     intro = 'Here you can set the client to regularly export a certain query to a particular location.'
     
     QP.AddToLayout( vbox, ClientGUICommon.BetterStaticText(self,intro), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._export_folders_panel, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.widget().setLayout( vbox )
Exemplo n.º 2
0
 def __init__( self, parent, initial_dict: typing.Dict[ str, ClientParsing.StringMatch ], min_height = 10, key_name = 'key' ):
     
     QW.QWidget.__init__( self, parent )
     
     self._key_name = key_name
     
     listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel( self )
     
     column_types_to_name_overrides = { CGLC.COLUMN_LIST_KEY_TO_STRING_MATCH.KEY : self._key_name }
     
     self._listctrl = ClientGUIListCtrl.BetterListCtrl( listctrl_panel, CGLC.COLUMN_LIST_KEY_TO_STRING_MATCH.ID, min_height, self._ConvertDataToListCtrlTuples, use_simple_delete = True, activation_callback = self._Edit, column_types_to_name_overrides = column_types_to_name_overrides )
     
     listctrl_panel.SetListCtrl( self._listctrl )
     
     listctrl_panel.AddButton( 'add', self._Add )
     listctrl_panel.AddButton( 'edit', self._Edit, enabled_only_on_selection = True )
     listctrl_panel.AddDeleteButton()
     
     #
     
     self._listctrl.AddDatas( initial_dict.items() )
     
     self._listctrl.Sort()
     
     #
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.setLayout( vbox )
Exemplo n.º 3
0
    def __init__(self, parent):

        title = 'manage local upnp'

        ClientGUIDialogs.Dialog.__init__(self, parent, title)

        self._status_st = ClientGUICommon.BetterStaticText(self)

        listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl(
            listctrl_panel,
            CGLC.COLUMN_LIST_MANAGE_UPNP_MAPPINGS.ID,
            12,
            self._ConvertDataToListCtrlTuples,
            delete_key_callback=self._Remove,
            activation_callback=self._Edit)

        listctrl_panel.SetListCtrl(self._mappings_list_ctrl)

        listctrl_panel.AddButton('add custom mapping', self._Add)
        listctrl_panel.AddButton('edit mapping',
                                 self._Edit,
                                 enabled_only_on_selection=True)
        listctrl_panel.AddButton('remove mapping',
                                 self._Remove,
                                 enabled_only_on_selection=True)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._ok, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 760))

        QP.SetInitialSize(self, size_hint)

        #

        self._mappings = []

        self._mappings_list_ctrl.Sort()

        self._started_external_ip_fetch = False

        self._RefreshMappings()
Exemplo n.º 4
0
    def __init__(self,
                 parent,
                 favourite_searches_rows,
                 initial_search_row_to_edit=None):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._favourite_searches_panel = ClientGUIListCtrl.BetterListCtrlPanel(
            self)

        self._favourite_searches = ClientGUIListCtrl.BetterListCtrl(
            self._favourite_searches_panel,
            CGLC.COLUMN_LIST_FAVOURITE_SEARCHES.ID,
            20,
            self._ConvertRowToListCtrlTuples,
            use_simple_delete=True,
            activation_callback=self._EditFavouriteSearch)

        self._favourite_searches_panel.SetListCtrl(self._favourite_searches)

        self._favourite_searches_panel.AddButton('add',
                                                 self._AddNewFavouriteSearch)
        self._favourite_searches_panel.AddButton(
            'edit', self._EditFavouriteSearch, enabled_only_on_selection=True)
        self._favourite_searches_panel.AddDeleteButton()

        #

        self._favourite_searches.AddDatas(favourite_searches_rows)

        self._favourite_searches.Sort()

        #

        vbox = QP.VBoxLayout()

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

        self.widget().setLayout(vbox)

        if initial_search_row_to_edit is not None:

            HG.client_controller.CallLaterQtSafe(self, 0.5,
                                                 'add new favourite search',
                                                 self._AddNewFavouriteSearch,
                                                 initial_search_row_to_edit)
Exemplo n.º 5
0
 def __init__( self, parent, initial_dict: typing.Dict[ str, str ], min_height = 10, key_name = 'key', value_name = 'value', allow_add_delete = True, edit_keys = True ):
     
     QW.QWidget.__init__( self, parent )
     
     self._key_name = key_name
     self._value_name = value_name
     
     self._edit_keys = edit_keys
     
     listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel( self )
     
     use_simple_delete = allow_add_delete
     
     column_types_to_name_overrides = { CGLC.COLUMN_LIST_KEY_TO_VALUE.KEY : self._key_name }
     
     self._listctrl = ClientGUIListCtrl.BetterListCtrl( listctrl_panel, CGLC.COLUMN_LIST_KEY_TO_VALUE.ID, min_height, self._ConvertDataToListCtrlTuples, use_simple_delete = use_simple_delete, activation_callback = self._Edit, column_types_to_name_overrides = column_types_to_name_overrides )
     self._listctrl.columnListContentsChanged.connect( self.columnListContentsChanged )
     
     listctrl_panel.SetListCtrl( self._listctrl )
     
     if allow_add_delete:
         
         listctrl_panel.AddButton( 'add', self._Add )
         
     
     listctrl_panel.AddButton( 'edit', self._Edit, enabled_only_on_selection = True )
     
     if allow_add_delete:
         
         listctrl_panel.AddDeleteButton()
         
     
     #
     
     self._listctrl.AddDatas( list(initial_dict.items()) )
     
     self._listctrl.Sort()
     
     #
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.setLayout( vbox )
Exemplo n.º 6
0
    def __init__(self, parent, shortcuts: ClientGUIShortcuts.ShortcutSet):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._name = QW.QLineEdit(self)

        self._shortcuts_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._shortcuts = ClientGUIListCtrl.BetterListCtrl(
            self._shortcuts_panel,
            CGLC.COLUMN_LIST_SHORTCUTS.ID,
            20,
            data_to_tuples_func=self._ConvertSortTupleToPrettyTuple,
            delete_key_callback=self.RemoveShortcuts,
            activation_callback=self.EditShortcuts)

        self._shortcuts_panel.SetListCtrl(self._shortcuts)

        self._shortcuts_panel.AddImportExportButtons(
            (ClientGUIShortcuts.ShortcutSet, ),
            self._AddShortcutSet,
            custom_get_callable=self._GetSelectedShortcutSet,
            and_duplicate_button=False)

        tt = 'Click this to replicate the current selection of commands with "incremented" shortcuts. If you want to create a list of "set rating to 1, 2, 3" or "set tag" commands, use this.'

        self._shortcuts_panel.AddButton('special duplicate',
                                        self._SpecialDuplicate,
                                        enabled_only_on_selection=True,
                                        tooltip=tt)

        self._shortcuts.setMinimumSize(QC.QSize(360, 480))

        self._add = QW.QPushButton('add', self)
        self._add.clicked.connect(self.AddShortcut)

        self._edit = QW.QPushButton('edit', self)
        self._edit.clicked.connect(self.EditShortcuts)

        self._remove = QW.QPushButton('remove', self)
        self._remove.clicked.connect(self.RemoveShortcuts)

        #

        name = shortcuts.GetName()

        self._name.setText(name)

        self._this_is_custom = True

        if name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            self._this_is_custom = False

            self._name.setEnabled(False)

        self._shortcuts.AddDatas(shortcuts.GetShortcutsAndCommands())

        self._shortcuts.Sort()

        #

        action_buttons = QP.HBoxLayout()

        QP.AddToLayout(action_buttons, self._add,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._edit,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._remove,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        message = 'Please note the shortcut system does not support multiple commands per shortcut yet. If there are shortcut duplicates in this list, only one command will ever fire.'

        st = ClientGUICommon.BetterStaticText(self, label=message)

        st.setWordWrap(True)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox,
                       ClientGUICommon.WrapInText(self._name, self, 'name: '),
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if name in ClientGUIShortcuts.shortcut_names_to_descriptions:

            description_text = ClientGUIShortcuts.shortcut_names_to_descriptions[
                name]

            description = ClientGUICommon.BetterStaticText(
                self, description_text, description_text)

            description.setWordWrap(True)

            QP.AddToLayout(vbox, description, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._shortcuts_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, action_buttons, CC.FLAGS_ON_RIGHT)

        self.widget().setLayout(vbox)
    def __init__(self, parent, bandwidth_rules):

        ClientGUICommon.StaticBox.__init__(self, parent, 'bandwidth rules')

        listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        # example for later:
        '''
        def sort_call( desired_columns, rule ):
            
            ( bandwidth_type, time_delta, max_allowed ) = rule
            
            sort_time_delta = SafeNoneInt( time_delta )
            
            result = {}
            
            result[ CGLC.COLUMN_LIST_BANDWIDTH_RULES.MAX_ALLOWED ] = max_allowed
            result[ CGLC.COLUMN_LIST_BANDWIDTH_RULES.EVERY ] = sort_time_delta
            
            return result
            
        
        def display_call( desired_columns, rule ):
            
            ( bandwidth_type, time_delta, max_allowed ) = rule
            
            if bandwidth_type == HC.BANDWIDTH_TYPE_DATA:
                
                pretty_max_allowed = HydrusData.ToHumanBytes( max_allowed )
                
            elif bandwidth_type == HC.BANDWIDTH_TYPE_REQUESTS:
                
                pretty_max_allowed = '{} requests'.format( HydrusData.ToHumanInt( max_allowed ) )
                
            
            pretty_time_delta = HydrusData.TimeDeltaToPrettyTimeDelta( time_delta )
            
            result = {}
            
            result[ CGLC.COLUMN_LIST_BANDWIDTH_RULES.MAX_ALLOWED ] = pretty_max_allowed
            result[ CGLC.COLUMN_LIST_BANDWIDTH_RULES.EVERY ] = pretty_time_delta
            
            return result
            
'''

        self._listctrl = ClientGUIListCtrl.BetterListCtrl(
            listctrl_panel,
            CGLC.COLUMN_LIST_BANDWIDTH_RULES.ID,
            8,
            self._ConvertRuleToListCtrlTuples,
            use_simple_delete=True,
            activation_callback=self._Edit)

        listctrl_panel.SetListCtrl(self._listctrl)

        listctrl_panel.AddButton('add', self._Add)
        listctrl_panel.AddButton('edit',
                                 self._Edit,
                                 enabled_only_on_selection=True)
        listctrl_panel.AddDeleteButton()

        #

        self._listctrl.AddDatas(bandwidth_rules.GetRules())

        self._listctrl.Sort()

        #

        self.Add(listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
    def __init__(self, parent, shortcuts: ClientGUIShortcuts.ShortcutSet):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._name = QW.QLineEdit(self)

        self._shortcuts_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._shortcuts = ClientGUIListCtrl.BetterListCtrl(
            self._shortcuts_panel,
            CGLC.COLUMN_LIST_SHORTCUTS.ID,
            20,
            data_to_tuples_func=self._ConvertSortTupleToPrettyTuple,
            delete_key_callback=self.RemoveShortcuts,
            activation_callback=self.EditShortcuts)

        self._shortcuts_panel.SetListCtrl(self._shortcuts)

        self._shortcuts_panel.AddImportExportButtons(
            (ClientGUIShortcuts.ShortcutSet, ),
            self._AddShortcutSet,
            custom_get_callable=self._GetSelectedShortcutSet)

        self._shortcuts.setMinimumSize(QC.QSize(360, 480))

        self._add = QW.QPushButton('add', self)
        self._add.clicked.connect(self.AddShortcut)

        self._edit = QW.QPushButton('edit', self)
        self._edit.clicked.connect(self.EditShortcuts)

        self._remove = QW.QPushButton('remove', self)
        self._remove.clicked.connect(self.RemoveShortcuts)

        #

        name = shortcuts.GetName()

        self._name.setText(name)

        self._this_is_custom = True

        if name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            self._this_is_custom = False

            self._name.setEnabled(False)

        self._shortcuts.AddDatas(shortcuts)

        self._shortcuts.Sort()

        #

        action_buttons = QP.HBoxLayout()

        QP.AddToLayout(action_buttons, self._add,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._edit,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._remove,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox,
                       ClientGUICommon.WrapInText(self._name, self, 'name: '),
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if name in ClientGUIShortcuts.shortcut_names_to_descriptions:

            description_text = ClientGUIShortcuts.shortcut_names_to_descriptions[
                name]

            description = ClientGUICommon.BetterStaticText(
                self, description_text, description_text)

            description.setWordWrap(True)

            QP.AddToLayout(vbox, description, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._shortcuts_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, action_buttons, CC.FLAGS_ON_RIGHT)

        self.widget().setLayout(vbox)