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 )
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 )
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()
def __init__( self, parent, controller, read_only, can_generate_more_pages, gallery_seed_log ): ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._controller = controller self._read_only = read_only self._can_generate_more_pages = can_generate_more_pages self._gallery_seed_log = gallery_seed_log self._text = ClientGUICommon.BetterStaticText( self, 'initialising' ) # add index control row here, hide it if needed and hook into showing/hiding and postsizechangedevent on gallery_seed add/remove self._list_ctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_GALLERY_SEED_LOG.ID, 30, self._ConvertGallerySeedToListCtrlTuples ) # self._list_ctrl.AddDatas( self._gallery_seed_log.GetGallerySeeds() ) self._list_ctrl.Sort() # vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._text, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._list_ctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) self.widget().setLayout( vbox ) self._list_ctrl.AddMenuCallable( self._GetListCtrlMenu ) self._controller.sub( self, 'NotifyGallerySeedsUpdated', 'gallery_seed_log_gallery_seeds_updated' ) QP.CallAfter( self._UpdateText )
def __init__( self, parent, service_type, account_types ): self._service_type = service_type self._original_account_types = account_types ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._deletee_account_type_keys_to_new_account_type_keys = {} self._account_types_listctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_ACCOUNT_TYPES.ID, 20, self._ConvertAccountTypeToTuples, delete_key_callback = self._Delete, activation_callback = self._Edit ) self._add_button = ClientGUICommon.BetterButton( self, 'add', self._Add ) self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit ) self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete ) self._account_types_listctrl.AddDatas( self._original_account_types ) hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._edit_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._account_types_listctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT ) self.widget().setLayout( vbox )
def __init__( self, parent, controller, file_seed_cache ): ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._controller = controller self._file_seed_cache = file_seed_cache self._text = ClientGUICommon.BetterStaticText( self, 'initialising' ) # add index control row here, hide it if needed and hook into showing/hiding and postsizechangedevent on file_seed add/remove self._list_ctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_FILE_SEED_CACHE.ID, 30, self._ConvertFileSeedToListCtrlTuples, activation_callback = self._ShowSelectionInNewPage, delete_key_callback = self._DeleteSelected ) # self._list_ctrl.AddDatas( self._file_seed_cache.GetFileSeeds() ) self._list_ctrl.Sort() # vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._text, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._list_ctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) self.widget().setLayout( vbox ) self._list_ctrl.AddMenuCallable( self._GetListCtrlMenu ) self._controller.sub( self, 'NotifyFileSeedsUpdated', 'file_seed_cache_file_seeds_updated' ) QP.CallAfter( self._UpdateText )
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)
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 )
def _ConvertFileSeedToListCtrlTuples(self, file_seed): try: file_seed_index = self._file_seed_cache.GetFileSeedIndex(file_seed) pretty_file_seed_index = HydrusData.ToHumanInt(file_seed_index) except: file_seed_index = '--' pretty_file_seed_index = '--' file_seed_data = file_seed.file_seed_data status = file_seed.status added = file_seed.created modified = file_seed.modified source_time = file_seed.source_time note = file_seed.note pretty_file_seed_data = str(file_seed_data) pretty_status = CC.status_string_lookup[status] pretty_added = ClientData.TimestampToPrettyTimeDelta(added) pretty_modified = ClientData.TimestampToPrettyTimeDelta(modified) if source_time is None: pretty_source_time = 'unknown' else: pretty_source_time = ClientData.TimestampToPrettyTimeDelta( source_time) sort_source_time = ClientGUIListCtrl.SafeNoneInt(source_time) pretty_note = note.split(os.linesep)[0] display_tuple = (pretty_file_seed_index, pretty_file_seed_data, pretty_status, pretty_added, pretty_modified, pretty_source_time, pretty_note) sort_tuple = (file_seed_index, file_seed_data, status, added, modified, sort_source_time, note) return (display_tuple, sort_tuple)
def __init__( self, parent, service_key ): self._clientside_admin_service = HG.client_controller.services_manager.GetService( service_key ) ClientGUIScrolledPanels.ManagePanel.__init__( self, parent ) self._deletee_service_keys = [] self._services_listctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_SERVICES.ID, 20, data_to_tuples_func = self._ConvertServiceToTuples, delete_key_callback = self._Delete, activation_callback = self._Edit ) menu_items = [] menu_items.append( ( 'normal', 'tag repository', 'Create a new tag repository.', self._AddTagRepository ) ) menu_items.append( ( 'normal', 'file repository', 'Create a new file repository.', self._AddFileRepository ) ) self._add_button = ClientGUIMenuButton.MenuButton( self, 'add', menu_items ) self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit ) self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete ) # response = self._clientside_admin_service.Request( HC.GET, 'services' ) serverside_services = response[ 'services' ] self._services_listctrl.AddDatas( serverside_services ) #self._services_listctrl.SortListItems( 0 ) # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._edit_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._services_listctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT ) self.widget().setLayout( vbox )
def _ConvertRuleToListCtrlTuples(self, rule): (bandwidth_type, time_delta, max_allowed) = rule pretty_time_delta = HydrusData.TimeDeltaToPrettyTimeDelta(time_delta) if bandwidth_type == HC.BANDWIDTH_TYPE_DATA: pretty_max_allowed = HydrusData.ToHumanBytes(max_allowed) elif bandwidth_type == HC.BANDWIDTH_TYPE_REQUESTS: pretty_max_allowed = HydrusData.ToHumanInt( max_allowed) + ' requests' sort_time_delta = ClientGUIListCtrl.SafeNoneInt(time_delta) sort_tuple = (max_allowed, sort_time_delta) display_tuple = (pretty_max_allowed, pretty_time_delta) return (display_tuple, sort_tuple)
def __init__(self, parent, call_mouse_buttons_primary_secondary, all_shortcuts): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) help_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().help, self._ShowHelp) help_button.setToolTip('Show help regarding editing shortcuts.') self._call_mouse_buttons_primary_secondary = QW.QCheckBox(self) self._call_mouse_buttons_primary_secondary.setToolTip( 'Useful if you swap your buttons around.') reserved_panel = ClientGUICommon.StaticBox( self, 'built-in hydrus shortcut sets') self._reserved_shortcuts = ClientGUIListCtrl.BetterListCtrl( reserved_panel, CGLC.COLUMN_LIST_SHORTCUT_SETS.ID, 6, data_to_tuples_func=self._GetTuples, activation_callback=self._EditReserved) self._reserved_shortcuts.setMinimumSize(QC.QSize(320, 200)) self._edit_reserved_button = ClientGUICommon.BetterButton( reserved_panel, 'edit', self._EditReserved) self._restore_defaults_button = ClientGUICommon.BetterButton( reserved_panel, 'restore defaults', self._RestoreDefaults) # custom_panel = ClientGUICommon.StaticBox(self, 'custom user sets') self._custom_shortcuts = ClientGUIListCtrl.BetterListCtrl( custom_panel, CGLC.COLUMN_LIST_SHORTCUT_SETS.ID, 6, data_to_tuples_func=self._GetTuples, delete_key_callback=self._Delete, activation_callback=self._EditCustom) self._add_button = ClientGUICommon.BetterButton( custom_panel, 'add', self._Add) self._edit_custom_button = ClientGUICommon.BetterButton( custom_panel, 'edit', self._EditCustom) self._delete_button = ClientGUICommon.BetterButton( custom_panel, 'delete', self._Delete) if not HG.client_controller.new_options.GetBoolean('advanced_mode'): custom_panel.hide() # self._call_mouse_buttons_primary_secondary.setChecked( call_mouse_buttons_primary_secondary) reserved_shortcuts = [ shortcuts for shortcuts in all_shortcuts if shortcuts.GetName() in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES ] custom_shortcuts = [ shortcuts for shortcuts in all_shortcuts if shortcuts.GetName() not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES ] self._reserved_shortcuts.AddDatas(reserved_shortcuts) self._reserved_shortcuts.Sort() self._original_custom_names = set() for shortcuts in custom_shortcuts: self._custom_shortcuts.AddDatas((shortcuts, )) self._original_custom_names.add(shortcuts.GetName()) self._custom_shortcuts.Sort() # rows = [] rows.append(('Replace "left/right"-click with "primary/secondary": ', self._call_mouse_buttons_primary_secondary)) mouse_gridbox = ClientGUICommon.WrapInGrid(self, rows) # button_hbox = QP.HBoxLayout() QP.AddToLayout(button_hbox, self._edit_reserved_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(button_hbox, self._restore_defaults_button, CC.FLAGS_CENTER_PERPENDICULAR) reserved_panel.Add(self._reserved_shortcuts, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) reserved_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT) # button_hbox = QP.HBoxLayout() QP.AddToLayout(button_hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(button_hbox, self._edit_custom_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(button_hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR) custom_panel_message = 'Custom shortcuts are advanced. They apply to the media viewer and must be turned on to take effect.' st = ClientGUICommon.BetterStaticText(custom_panel, custom_panel_message) st.setWordWrap(True) custom_panel.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR) custom_panel.Add(self._custom_shortcuts, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) custom_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT) # vbox = QP.VBoxLayout() QP.AddToLayout(vbox, help_button, CC.FLAGS_ON_RIGHT) QP.AddToLayout(vbox, mouse_gridbox, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, reserved_panel, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(vbox, custom_panel, CC.FLAGS_EXPAND_BOTH_WAYS) self.widget().setLayout(vbox) self._call_mouse_buttons_primary_secondary.clicked.connect( self._UpdateMouseLabels)
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)
def __init__(self, parent, flat_media, do_export_and_then_quit=False): ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent) new_options = HG.client_controller.new_options self._media_to_paths = {} self._existing_filenames = set() self._last_phrase_used = '' self._last_dir_used = '' self._tags_box = ClientGUIListBoxes.StaticBoxSorterForListBoxTags( self, 'files\' tags') services_manager = HG.client_controller.services_manager self._neighbouring_txt_tag_service_keys = services_manager.FilterValidServiceKeys( new_options.GetKeyList( 'default_neighbouring_txt_tag_service_keys')) t = ClientGUIListBoxes.ListBoxTagsMedia(self._tags_box, ClientTags.TAG_DISPLAY_ACTUAL, include_counts=True) self._tags_box.SetTagsBox(t) self._tags_box.setMinimumSize(QC.QSize(220, 300)) self._paths = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_EXPORT_FILES.ID, 24, self._ConvertDataToListCtrlTuples, use_simple_delete=True) self._paths.Sort() self._export_path_box = ClientGUICommon.StaticBox(self, 'export path') self._directory_picker = QP.DirPickerCtrl(self._export_path_box) self._directory_picker.dirPickerChanged.connect(self._RefreshPaths) self._open_location = QW.QPushButton('open this location', self._export_path_box) self._open_location.clicked.connect(self.EventOpenLocation) self._filenames_box = ClientGUICommon.StaticBox(self, 'filenames') self._pattern = QW.QLineEdit(self._filenames_box) self._update = QW.QPushButton('update', self._filenames_box) self._update.clicked.connect(self._RefreshPaths) self._examples = ClientGUICommon.ExportPatternButton( self._filenames_box) self._delete_files_after_export = QW.QCheckBox( 'delete files from client after export?', self) self._delete_files_after_export.setObjectName('HydrusWarning') self._export_symlinks = QW.QCheckBox('EXPERIMENTAL: export symlinks', self) self._export_symlinks.setObjectName('HydrusWarning') text = 'This will export all the files\' tags, newline separated, into .txts beside the files themselves.' self._export_tag_txts_services_button = ClientGUICommon.BetterButton( self, 'set .txt services', self._SetTxtServices) self._export_tag_txts = QW.QCheckBox('export tags to .txt files?', self) self._export_tag_txts.setToolTip(text) self._export_tag_txts.clicked.connect(self.EventExportTagTxtsChanged) self._export = QW.QPushButton('export', self) self._export.clicked.connect(self._DoExport) # export_path = ClientExporting.GetExportPath() if export_path is not None: self._directory_picker.SetPath(export_path) phrase = new_options.GetString('export_phrase') self._pattern.setText(phrase) if len(self._neighbouring_txt_tag_service_keys) > 0: self._export_tag_txts.setChecked(True) self._paths.SetData(list(enumerate(flat_media))) self._delete_files_after_export.setChecked( HG.client_controller.new_options.GetBoolean( 'delete_files_after_export')) self._delete_files_after_export.clicked.connect( self.EventDeleteFilesChanged) if not HG.client_controller.new_options.GetBoolean('advanced_mode'): self._export_symlinks.setVisible(False) # top_hbox = QP.HBoxLayout() QP.AddToLayout(top_hbox, self._tags_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(top_hbox, self._paths, CC.FLAGS_EXPAND_BOTH_WAYS) hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._directory_picker, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(hbox, self._open_location, CC.FLAGS_CENTER_PERPENDICULAR) self._export_path_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(hbox, self._update, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._examples, CC.FLAGS_CENTER_PERPENDICULAR) self._filenames_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) txt_hbox = QP.HBoxLayout() QP.AddToLayout(txt_hbox, self._export_tag_txts_services_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(txt_hbox, self._export_tag_txts, CC.FLAGS_CENTER_PERPENDICULAR) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, top_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) QP.AddToLayout(vbox, self._export_path_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._filenames_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._delete_files_after_export, CC.FLAGS_ON_RIGHT) QP.AddToLayout(vbox, self._export_symlinks, CC.FLAGS_ON_RIGHT) QP.AddToLayout(vbox, txt_hbox, CC.FLAGS_ON_RIGHT) QP.AddToLayout(vbox, self._export, CC.FLAGS_ON_RIGHT) self.widget().setLayout(vbox) self._RefreshTags() self._UpdateTxtButton() ClientGUIFunctions.SetFocusLater(self._export) self._paths.itemSelectionChanged.connect(self._RefreshTags) if do_export_and_then_quit: HG.client_controller.CallAfterQtSafe( self, 'doing export before dialog quit', self._DoExport, True)