def __init__(self, parent, shortcut, command, shortcuts_name): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) # self._shortcut_panel = ClientGUICommon.StaticBox(self, 'shortcut') self._shortcut = ShortcutWidget(self._shortcut_panel) self._command_panel = ClientGUICommon.StaticBox(self, 'command') self._command = ClientGUIApplicationCommand.ApplicationCommandWidget( self._command_panel, command, shortcuts_name) # self._shortcut.SetValue(shortcut) # self._shortcut_panel.Add(self._shortcut, CC.FLAGS_EXPAND_PERPENDICULAR) self._command_panel.Add(self._command, CC.FLAGS_EXPAND_BOTH_WAYS) hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._shortcut_panel, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, ClientGUICommon.BetterStaticText(self, '\u2192'), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._command_panel, CC.FLAGS_EXPAND_BOTH_WAYS) self.widget().setLayout(hbox)
def __init__(self, parent, service_key, subject_identifiers): Dialog.__init__(self, parent, 'modify account') self._service = HG.client_controller.services_manager.GetService( service_key) self._subject_identifiers = list(subject_identifiers) # self._account_info_panel = ClientGUICommon.StaticBox( self, 'account info') self._subject_text = QW.QLabel(self._account_info_panel) # self._account_types_panel = ClientGUICommon.StaticBox( self, 'account types') self._account_types = QW.QComboBox(self._account_types_panel) self._account_types_ok = QW.QPushButton('OK', self._account_types_panel) self._account_types_ok.clicked.connect(self.EventChangeAccountType) # self._expiration_panel = ClientGUICommon.StaticBox( self, 'change expiration') self._add_to_expires = QW.QComboBox(self._expiration_panel) self._add_to_expires_ok = QW.QPushButton('OK', self._expiration_panel) self._add_to_expires.clicked.connect(self.EventAddToExpires) self._set_expires = QW.QComboBox(self._expiration_panel) self._set_expires_ok = QW.QPushButton('OK', self._expiration_panel) self._set_expires_ok.clicked.connect(self.EventSetExpires) # self._ban_panel = ClientGUICommon.StaticBox(self, 'bans') self._ban = QW.QPushButton('ban user', self._ban_panel) self._ban.clicked.connect(self.EventBan) QP.SetBackgroundColour(self._ban, (255, 0, 0)) QP.SetForegroundColour(self._ban, (255, 255, 0)) self._superban = QW.QPushButton( 'ban user and delete every contribution they have ever made', self._ban_panel) self._superban.clicked.connect(self.EventSuperban) QP.SetBackgroundColour(self._superban, (255, 0, 0)) QP.SetForegroundColour(self._superban, (255, 255, 0)) self._exit = QW.QPushButton('Exit', self) self._exit.clicked.connect(self.reject) # if len(self._subject_identifiers) == 1: (subject_identifier, ) = self._subject_identifiers response = self._service.Request( HC.GET, 'account_info', {'subject_identifier': subject_identifier}) subject_string = str(response['account_info']) else: subject_string = 'modifying ' + HydrusData.ToHumanInt( len(self._subject_identifiers)) + ' accounts' self._subject_text.setText(subject_string) # response = self._service.Request(HC.GET, 'account_types') account_types = response['account_types'] for account_type in account_types: self._account_types.addItem(account_type.ConvertToString(), account_type) self._account_types.setCurrentIndex(0) # for (label, value) in HC.lifetimes: if value is not None: self._add_to_expires.addItem( label, value) # don't want 'add no limit' self._add_to_expires.setCurrentIndex(1) # three months for (label, value) in HC.lifetimes: self._set_expires.addItem(label, value) self._set_expires.setCurrentIndex(1) # three months # self._account_info_panel.Add(self._subject_text, CC.FLAGS_EXPAND_PERPENDICULAR) account_types_hbox = QP.HBoxLayout() QP.AddToLayout(account_types_hbox, self._account_types, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(account_types_hbox, self._account_types_ok, CC.FLAGS_CENTER_PERPENDICULAR) self._account_types_panel.Add(account_types_hbox, CC.FLAGS_EXPAND_PERPENDICULAR) add_to_expires_box = QP.HBoxLayout() QP.AddToLayout(add_to_expires_box, QW.QLabel('add to expires: ', self._expiration_panel), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(add_to_expires_box, self._add_to_expires, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(add_to_expires_box, self._add_to_expires_ok, CC.FLAGS_CENTER_PERPENDICULAR) set_expires_box = QP.HBoxLayout() QP.AddToLayout(set_expires_box, QW.QLabel('set expires to: ', self._expiration_panel), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(set_expires_box, self._set_expires, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(set_expires_box, self._set_expires_ok, CC.FLAGS_CENTER_PERPENDICULAR) self._expiration_panel.Add(add_to_expires_box, CC.FLAGS_EXPAND_PERPENDICULAR) self._expiration_panel.Add(set_expires_box, CC.FLAGS_EXPAND_PERPENDICULAR) self._ban_panel.Add(self._ban, CC.FLAGS_EXPAND_PERPENDICULAR) self._ban_panel.Add(self._superban, CC.FLAGS_EXPAND_PERPENDICULAR) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._account_info_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._account_types_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._expiration_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._ban_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._exit, CC.FLAGS_ON_RIGHT) self.setLayout(vbox) size_hint = self.sizeHint() QP.SetInitialSize(self, size_hint) HG.client_controller.CallAfterQtSafe(self._exit, self._exit.setFocus, QC.Qt.OtherFocusReason)
def __init__(self, parent, 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.') 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() # 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() # 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, reserved_panel, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(vbox, custom_panel, CC.FLAGS_EXPAND_BOTH_WAYS) 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() 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() HG.client_controller.CallAfterQtSafe(self._export, self._export.setFocus, QC.Qt.OtherFocusReason) self._paths.itemSelectionChanged.connect(self._RefreshTags) if do_export_and_then_quit: QP.CallAfter(self._DoExport, True)
def __init__(self, parent, export_folder: ClientExporting.ExportFolder): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) self._export_folder = export_folder (name, path, export_type, delete_from_client_after_export, file_search_context, run_regularly, period, phrase, self._last_checked, paused, run_now) = self._export_folder.ToTuple() self._path_box = ClientGUICommon.StaticBox(self, 'name and location') self._name = QW.QLineEdit(self._path_box) self._path = QP.DirPickerCtrl(self._path_box) # self._type_box = ClientGUICommon.StaticBox(self, 'type of export') self._type = ClientGUICommon.BetterChoice(self._type_box) self._type.addItem('regular', HC.EXPORT_FOLDER_TYPE_REGULAR) self._type.addItem('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE) self._delete_from_client_after_export = QW.QCheckBox(self._type_box) # self._query_box = ClientGUICommon.StaticBox(self, 'query to export') self._page_key = 'export folders placeholder' self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead( self._query_box, self._page_key, file_search_context, allow_all_known_files=False, force_system_everything=True) # self._period_box = ClientGUICommon.StaticBox(self, 'export period') self._period = ClientGUITime.TimeDeltaButton(self._period_box, min=3 * 60, days=True, hours=True, minutes=True) self._run_regularly = QW.QCheckBox(self._period_box) self._paused = QW.QCheckBox(self._period_box) self._run_now = QW.QCheckBox(self._period_box) # self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames') self._pattern = QW.QLineEdit(self._phrase_box) self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box) # self._name.setText(name) self._path.SetPath(path) self._type.SetValue(export_type) self._delete_from_client_after_export.setChecked( delete_from_client_after_export) self._period.SetValue(period) self._run_regularly.setChecked(run_regularly) self._paused.setChecked(paused) self._run_now.setChecked(run_now) self._pattern.setText(phrase) # rows = [] rows.append(('name: ', self._name)) rows.append(('folder path: ', self._path)) gridbox = ClientGUICommon.WrapInGrid(self._path_box, rows) self._path_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) # text = '''regular - try to export the files to the directory, overwriting if the filesize if different synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory If you select synchronise, be careful!''' st = ClientGUICommon.BetterStaticText(self._type_box, label=text) st.setWordWrap(True) self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR) self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR) rows = [] rows.append(('delete files from client after export: ', self._delete_from_client_after_export)) gridbox = ClientGUICommon.WrapInGrid(self._type_box, rows) self._type_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) self._query_box.Add(self._tag_autocomplete) self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR) rows = [] rows.append(('run regularly?: ', self._run_regularly)) rows.append(('paused: ', self._paused)) rows.append(('run on dialog ok: ', self._run_now)) gridbox = ClientGUICommon.WrapInGrid(self._period_box, rows) self._period_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) phrase_hbox = QP.HBoxLayout() QP.AddToLayout(phrase_hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(phrase_hbox, self._examples, CC.FLAGS_CENTER_PERPENDICULAR) self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(vbox, self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR) self.widget().setLayout(vbox) self._UpdateTypeDeleteUI() self._type.currentIndexChanged.connect(self._UpdateTypeDeleteUI) self._delete_from_client_after_export.clicked.connect( self.EventDeleteFilesAfterExport)
def __init__(self, parent, checker_options): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) help_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().help, self._ShowHelp) help_button.setToolTip('Show help regarding these checker options.') help_hbox = ClientGUICommon.WrapInText(help_button, self, 'help for this panel -->', QG.QColor(0, 0, 255)) from hydrus.client import ClientDefaults defaults_panel = ClientGUICommon.StaticBox(self, 'reasonable defaults') defaults_1 = ClientGUICommon.BetterButton( defaults_panel, 'thread', self.SetValue, ClientDefaults.GetDefaultCheckerOptions('thread')) defaults_2 = ClientGUICommon.BetterButton( defaults_panel, 'slow thread', self.SetValue, ClientDefaults.GetDefaultCheckerOptions('slow thread')) defaults_3 = ClientGUICommon.BetterButton( defaults_panel, 'faster tag subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions('fast tag subscription')) defaults_4 = ClientGUICommon.BetterButton( defaults_panel, 'medium tag/artist subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions('artist subscription')) defaults_5 = ClientGUICommon.BetterButton( defaults_panel, 'slower tag subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions('slow tag subscription')) # # add statictext or whatever that will update on any updates above to say 'given velocity of blah and last check at blah, next check in 5 mins' # or indeed this could just take the file_seed cache and last check of the caller, if there is one # this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins' # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity # min_unit_value = 0 max_unit_value = 1000 min_time_delta = 60 self._death_file_velocity = VelocityCtrl(self, min_unit_value, max_unit_value, min_time_delta, days=True, hours=True, minutes=True, per_phrase='in', unit='files') self._flat_check_period_checkbox = QW.QCheckBox(self) # if HG.client_controller.new_options.GetBoolean('advanced_mode'): never_faster_than_min = 1 never_slower_than_min = 1 flat_check_period_min = 1 else: never_faster_than_min = 30 never_slower_than_min = 600 flat_check_period_min = 180 self._reactive_check_panel = ClientGUICommon.StaticBox( self, 'reactive checking') self._intended_files_per_check = QP.MakeQSpinBox( self._reactive_check_panel, min=1, max=1000) self._never_faster_than = TimeDeltaCtrl(self._reactive_check_panel, min=never_faster_than_min, days=True, hours=True, minutes=True, seconds=True) self._never_slower_than = TimeDeltaCtrl(self._reactive_check_panel, min=never_slower_than_min, days=True, hours=True, minutes=True, seconds=True) # self._static_check_panel = ClientGUICommon.StaticBox( self, 'static checking') self._flat_check_period = TimeDeltaCtrl(self._static_check_panel, min=flat_check_period_min, days=True, hours=True, minutes=True, seconds=True) # self.SetValue(checker_options) # defaults_panel.Add(defaults_1, CC.FLAGS_EXPAND_PERPENDICULAR) defaults_panel.Add(defaults_2, CC.FLAGS_EXPAND_PERPENDICULAR) defaults_panel.Add(defaults_3, CC.FLAGS_EXPAND_PERPENDICULAR) defaults_panel.Add(defaults_4, CC.FLAGS_EXPAND_PERPENDICULAR) defaults_panel.Add(defaults_5, CC.FLAGS_EXPAND_PERPENDICULAR) # # rows = [] rows.append( ('intended new files per check: ', self._intended_files_per_check)) rows.append( ('never check faster than once per: ', self._never_faster_than)) rows.append( ('never check slower than once per: ', self._never_slower_than)) gridbox = ClientGUICommon.WrapInGrid(self._reactive_check_panel, rows) self._reactive_check_panel.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) # rows = [] rows.append(('check period: ', self._flat_check_period)) gridbox = ClientGUICommon.WrapInGrid(self._static_check_panel, rows) self._static_check_panel.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) # rows = [] rows.append(('stop checking if new files found falls below: ', self._death_file_velocity)) rows.append(('just check at a static, regular interval: ', self._flat_check_period_checkbox)) gridbox = ClientGUICommon.WrapInGrid(self, rows) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, help_hbox, CC.FLAGS_BUTTON_SIZER) QP.AddToLayout(vbox, defaults_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) if HG.client_controller.new_options.GetBoolean('advanced_mode'): label = 'As you are in advanced mode, these options have extremely low limits. This is intended only for testing and small scale private network tasks. Do not use very fast check times for real world use on public websites, as it is wasteful and rude, hydrus will be overloaded with high-CPU parsing work, and you may get your IP banned.' st = ClientGUICommon.BetterStaticText(self, label=label) st.setObjectName('HydrusWarning') st.setWordWrap(True) QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._reactive_check_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._static_check_panel, CC.FLAGS_EXPAND_PERPENDICULAR) self.widget().setLayout(vbox) # self._flat_check_period_checkbox.clicked.connect( self.EventFlatPeriodCheck)
def __init__(self, parent, predicate: ClientSearch.Predicate): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) predicate_type = predicate.GetType() self._predicates = [] label = None editable_pred_panels = [] static_pred_buttons = [] recent_predicate_types = [predicate_type] if predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE: static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ('<', 'delta', (0, 0, 1, 0))), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ('<', 'delta', (0, 0, 7, 0))), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ('<', 'delta', (0, 1, 0, 0))), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemAgeDelta, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemModifiedDelta, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemModifiedDate, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS: recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS ] static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ('=', 16, 9)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ('=', 9, 16)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ('=', 4, 3)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ('=', 1, 1)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1920)), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ('=', 1080))), forced_label='1080p')) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1280)), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ('=', 720))), forced_label='720p')) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 3840)), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ('=', 2160))), forced_label='4k')) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemHeight, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemWidth, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemRatio, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumPixels, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION: recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES ] static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ('>', 0)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ('=', 0)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ('=', 30)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ('=', 60)), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemDuration, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemFramerate, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumFrames, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemFileService, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemKnownURLsExactURL, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemKnownURLsDomain, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemKnownURLsRegex, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemKnownURLsURLClass, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO: recent_predicate_types = [] static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False), ))) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemHash, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT: label = 'system:limit clips a large search result down to the given number of files. It is very useful for processing in smaller batches.' label += os.linesep * 2 label += 'For all the simpler sorts (filesize, duration, etc...), it will select the n largest/smallest in the result set appropriate for that sort. For complicated sorts like tags, it will sample randomly.' static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 64), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 256), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 1024), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemLimit, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemMime, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS: static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, (None, '>', 0)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, (None, '=', 0)), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumTags, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES: recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME ] static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ('>', 0)), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ('=', 0)), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumNotes, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemHasNoteName, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumWords, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING: services_manager = HG.client_controller.services_manager ratings_services = services_manager.GetServices( (HC.LOCAL_RATING_LIKE, HC.LOCAL_RATING_NUMERICAL)) if len(ratings_services) > 0: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesMultiple.PanelPredicateSystemRating, (predicate, ))) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemSimilarTo, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemSize, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemTagAsNumber, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS: static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch. PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False), ))) static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, self, (ClientSearch.Predicate( ClientSearch. PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True), ))) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemDuplicateRelationships, predicate)) elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS: editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemFileViewingStatsViews, predicate)) editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle. PanelPredicateSystemFileViewingStatsViewtime, predicate)) vbox = QP.VBoxLayout() if label is not None: st = ClientGUICommon.BetterStaticText(self, label=label) st.setWordWrap(True) QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR) recent_predicates = [] if len(recent_predicate_types) > 0: recent_predicates = HG.client_controller.new_options.GetRecentPredicates( recent_predicate_types) if len(recent_predicates) > 0: recent_predicates_box = ClientGUICommon.StaticBox( self, 'recent') for recent_predicate in recent_predicates: button = ClientGUIPredicatesSingle.StaticSystemPredicateButton( recent_predicates_box, self, (recent_predicate, )) recent_predicates_box.Add(button, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, recent_predicates_box, CC.FLAGS_EXPAND_PERPENDICULAR) for button in static_pred_buttons: QP.AddToLayout(vbox, button, CC.FLAGS_EXPAND_PERPENDICULAR) for panel in editable_pred_panels: QP.AddToLayout(vbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR) if len(static_pred_buttons) > 0 and len(editable_pred_panels) == 0: HG.client_controller.CallAfterQtSafe( static_pred_buttons[0], static_pred_buttons[0].setFocus, QC.Qt.OtherFocusReason) self.widget().setLayout(vbox)