def __init__( self, parent: QW.QWidget ): QW.QWidget.__init__( self, parent ) self._add_or_move_action = ClientGUICommon.BetterChoice( self ) self._add_or_move_action.addItem( 'add to', HC.CONTENT_UPDATE_ADD ) self._add_or_move_action.addItem( 'move to', HC.CONTENT_UPDATE_MOVE ) self._add_or_move_action.SetValue( HC.CONTENT_UPDATE_ADD ) self._service_keys = ClientGUICommon.BetterChoice( self ) # services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_FILE_DOMAIN, ) ) for service in services: service_name = service.GetName() service_key = service.GetServiceKey() self._service_keys.addItem( service_name, service_key ) # vbox = QP.VBoxLayout() ratings_numerical_hbox = QP.HBoxLayout() QP.AddToLayout( vbox, self._add_or_move_action, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._service_keys, CC.FLAGS_EXPAND_PERPENDICULAR ) self.setLayout( vbox )
def __init__(self, parent: QW.QWidget): QW.QWidget.__init__(self, parent) self._flip_or_set_action = ClientGUICommon.BetterChoice(self) self._flip_or_set_action.addItem('set', HC.CONTENT_UPDATE_SET) self._flip_or_set_action.addItem('flip on and off', HC.CONTENT_UPDATE_FLIP) self._flip_or_set_action.SetValue(HC.CONTENT_UPDATE_SET) self._service_keys = ClientGUICommon.BetterChoice(self) self._ratings_like_like = QW.QRadioButton('like', self) self._ratings_like_dislike = QW.QRadioButton('dislike', self) self._ratings_like_remove = QW.QRadioButton('remove rating', self) # services = HG.client_controller.services_manager.GetServices( (HC.LOCAL_RATING_LIKE, )) if len(services) == 0: self._service_keys.addItem( 'you have no like/dislike rating services', None) else: for service in services: service_name = service.GetName() service_key = service.GetServiceKey() self._service_keys.addItem(service_name, service_key) self._ratings_like_like.setChecked(True) # vbox = QP.VBoxLayout() ratings_like_hbox = QP.HBoxLayout() QP.AddToLayout(ratings_like_hbox, self._service_keys, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(ratings_like_hbox, self._ratings_like_like, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(ratings_like_hbox, self._ratings_like_dislike, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(ratings_like_hbox, self._ratings_like_remove, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, ratings_like_hbox, CC.FLAGS_EXPAND_PERPENDICULAR) self.setLayout(vbox) self._ratings_like_remove.toggled.connect(self._UpdateFlipAllowed)
def __init__( self, parent: QW.QWidget ): QW.QWidget.__init__( self, parent ) self._flip_or_set_action = ClientGUICommon.BetterChoice( self ) self._flip_or_set_action.addItem( 'set', HC.CONTENT_UPDATE_SET ) self._flip_or_set_action.addItem( 'flip on and off', HC.CONTENT_UPDATE_FLIP ) self._flip_or_set_action.SetValue( HC.CONTENT_UPDATE_SET ) self._service_keys = ClientGUICommon.BetterChoice( self ) self._tag_value = QW.QLineEdit( self ) self._tag_value.setReadOnly( True ) default_location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext() self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.SetTags, default_location_context, CC.COMBINED_TAG_SERVICE_KEY ) # services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_TAG, HC.TAG_REPOSITORY ) ) for service in services: service_name = service.GetName() service_key = service.GetServiceKey() self._service_keys.addItem( service_name, service_key ) self._tag_input.SetTagServiceKey( self._service_keys.GetValue() ) # vbox = QP.VBoxLayout() tag_sub_vbox = QP.VBoxLayout() QP.AddToLayout( tag_sub_vbox, self._tag_value, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( tag_sub_vbox, self._tag_input, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) tag_hbox = QP.HBoxLayout() QP.AddToLayout( tag_hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH ) QP.AddToLayout( tag_hbox, tag_sub_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) QP.AddToLayout( vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, tag_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) self.setLayout( vbox ) # self._service_keys.currentIndexChanged.connect( self._NewServiceKey )
def __init__( self, parent: QW.QWidget ): QW.QWidget.__init__( self, parent ) self._current_ratings_numerical_service = None self._flip_or_set_action = ClientGUICommon.BetterChoice( self ) self._flip_or_set_action.addItem( 'set', HC.CONTENT_UPDATE_SET ) self._flip_or_set_action.addItem( 'flip on and off', HC.CONTENT_UPDATE_FLIP ) self._flip_or_set_action.SetValue( HC.CONTENT_UPDATE_SET ) self._service_keys = ClientGUICommon.BetterChoice( self ) self._service_keys.currentIndexChanged.connect( self._UpdateSliderRange ) self._ratings_numerical_slider = QP.LabelledSlider( self ) self._ratings_numerical_remove = QW.QCheckBox( 'remove rating', self ) # services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_NUMERICAL, ) ) if len( services ) == 0: self._service_keys.addItem( 'you have no numerical rating services', None ) else: for service in services: service_name = service.GetName() service_key = service.GetServiceKey() self._service_keys.addItem( service_name, service_key ) self._UpdateSliderRange() # vbox = QP.VBoxLayout() ratings_numerical_hbox = QP.HBoxLayout() QP.AddToLayout( ratings_numerical_hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH ) QP.AddToLayout( ratings_numerical_hbox, self._ratings_numerical_slider, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( ratings_numerical_hbox, self._ratings_numerical_remove, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, ratings_numerical_hbox, CC.FLAGS_EXPAND_PERPENDICULAR ) self.setLayout( vbox ) self._ratings_numerical_remove.toggled.connect( self._UpdateFlipAllowed )
def __init__( self, parent, tag_filter: HydrusTags.TagFilter, tag_display_type: int ): ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) # message = 'Filter the tags you want to export here. Anything that passes this filter is exported.' self._tag_filter = ClientGUITags.TagFilterButton( self, message, tag_filter ) self._tag_display_type = ClientGUICommon.BetterChoice( self ) self._tag_display_type.addItem( 'with siblings and parents applied', ClientTags.TAG_DISPLAY_ACTUAL ) self._tag_display_type.addItem( 'as the tags are actually stored', ClientTags.TAG_DISPLAY_STORAGE ) # self._tag_display_type.SetValue( tag_display_type ) # vbox = QP.VBoxLayout() rows = [] rows.append( ( 'Tags to export: ', self._tag_filter ) ) rows.append( ( 'Type to export: ', self._tag_display_type ) ) gridbox = ClientGUICommon.WrapInGrid( self, rows ) QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) self.widget().setLayout( vbox )
def __init__( self, parent, external_port, protocol_type, internal_port, description, duration ): Dialog.__init__( self, parent, 'configure upnp mapping' ) self._external_port = QP.MakeQSpinBox( self, min=0, max=65535 ) self._protocol_type = ClientGUICommon.BetterChoice( self ) self._protocol_type.addItem( 'TCP', 'TCP' ) self._protocol_type.addItem( 'UDP', 'UDP' ) self._internal_port = QP.MakeQSpinBox( self, min=0, max=65535 ) self._description = QW.QLineEdit( self ) self._duration = QP.MakeQSpinBox( self, min=0, max=86400 ) self._ok = ClientGUICommon.BetterButton( self, 'OK', self.done, QW.QDialog.Accepted ) self._ok.setObjectName( 'HydrusAccept' ) self._cancel = QW.QPushButton( 'Cancel', self ) self._cancel.clicked.connect( self.reject ) self._cancel.setObjectName( 'HydrusCancel' ) # self._external_port.setValue( external_port ) if protocol_type == 'TCP': self._protocol_type.setCurrentIndex( 0 ) elif protocol_type == 'UDP': self._protocol_type.setCurrentIndex( 1 ) self._internal_port.setValue( internal_port ) self._description.setText( description ) self._duration.setValue( duration ) # rows = [] rows.append( ( 'external port: ', self._external_port ) ) rows.append( ( 'protocol type: ', self._protocol_type ) ) rows.append( ( 'internal port: ', self._internal_port ) ) rows.append( ( 'description: ', self._description ) ) rows.append( ( 'duration (0 = indefinite): ', self._duration ) ) gridbox = ClientGUICommon.WrapInGrid( self, rows ) b_box = QP.HBoxLayout() QP.AddToLayout( b_box, self._ok, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( b_box, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT ) self.setLayout( vbox ) size_hint = self.sizeHint() QP.SetInitialSize( self, size_hint ) HG.client_controller.CallAfterQtSafe( self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
def __init__(self, parent, initial_value=65536): QW.QWidget.__init__(self, parent) self._spin = QP.MakeQSpinBox(self, min=0, max=1048576) self._unit = ClientGUICommon.BetterChoice(self) self._unit.addItem('B', 1) self._unit.addItem('KB', 1024) self._unit.addItem('MB', 1024 * 1024) self._unit.addItem('GB', 1024 * 1024 * 1024) # self.SetValue(initial_value) # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._spin, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._unit, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(hbox) self._spin.valueChanged.connect(self._HandleValueChanged) self._unit.currentIndexChanged.connect(self._HandleValueChanged)
def __init__(self, parent: QW.QWidget, shortcuts_name: str): QW.QWidget.__init__(self, parent) if shortcuts_name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES: simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ shortcuts_name] else: simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ 'custom'] choices = sorted([(CAC.simple_enum_to_str_lookup[simple_type], simple_type) for simple_type in simple_types]) self._simple_actions = ClientGUICommon.BetterChoice(self) for (display_string, data) in choices: self._simple_actions.addItem(display_string, data) # vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._simple_actions, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) self.setLayout(vbox)
def __init__(self, parent: QW.QWidget): QW.QWidget.__init__(self, parent) self._service_keys = ClientGUICommon.BetterChoice(self) self._ratings_numerical_incdec = ClientGUICommon.BetterChoice(self) self._ratings_numerical_incdec.addItem( HC.content_update_string_lookup[HC.CONTENT_UPDATE_INCREMENT], HC.CONTENT_UPDATE_INCREMENT) self._ratings_numerical_incdec.addItem( HC.content_update_string_lookup[HC.CONTENT_UPDATE_DECREMENT], HC.CONTENT_UPDATE_DECREMENT) # services = HG.client_controller.services_manager.GetServices( (HC.LOCAL_RATING_NUMERICAL, )) if len(services) == 0: self._service_keys.addItem('you have no numerical rating services', None) else: for service in services: service_name = service.GetName() service_key = service.GetServiceKey() self._service_keys.addItem(service_name, service_key) # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH) QP.AddToLayout(hbox, self._ratings_numerical_incdec, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(hbox)
def __init__(self, parent, service_key, media, activate_callable): QW.QWidget.__init__(self, parent) self._service_key = service_key self._media = media self._last_fetched_tags = [] self._script_choice = ClientGUICommon.BetterChoice(self) self._script_choice.setEnabled(False) self._have_fetched = False self._fetch_button = ClientGUICommon.BetterButton( self, 'fetch tags', self.FetchTags) self._fetch_button.setEnabled(False) self._script_management = ClientGUIParsing.ScriptManagementControl( self) self._tags = ListBoxTagsSuggestionsFavourites(self, self._service_key, activate_callable, sort_tags=True) self._add_all = ClientGUICommon.BetterButton(self, 'add all', self._tags.ActivateAll) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._script_choice, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._fetch_button, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._script_management, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._add_all, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._tags, CC.FLAGS_EXPAND_BOTH_WAYS) self._SetTags([]) self.setLayout(vbox) self._FetchScripts() self._tags.mouseActivationOccurred.connect( self.mouseActivationOccurred)
def __init__(self, parent): QW.QWidget.__init__(self, parent) self._button = MouseShortcutButton(self) self._press_or_release = ClientGUICommon.BetterChoice(self) self._press_or_release.addItem( 'press', ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS) self._press_or_release.addItem( 'release', ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_RELEASE) layout = QP.HBoxLayout() QP.AddToLayout(layout, self._button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(layout, self._press_or_release, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(layout) self._press_or_release.currentIndexChanged.connect(self._NewChoice) self._button.valueChanged.connect(self._ButtonValueChanged)
def __init__(self, parent, share_key, name, text, timeout, hashes, new_share=False): Dialog.__init__(self, parent, 'configure local booru share') self._name = QW.QLineEdit(self) self._text = QW.QPlainTextEdit(self) self._text.setMinimumHeight(100) message = 'expires in' self._timeout_number = ClientGUICommon.NoneableSpinCtrl( self, message, none_phrase='no expiration', max=1000000, multiplier=1) self._timeout_multiplier = ClientGUICommon.BetterChoice(self) self._timeout_multiplier.addItem('minutes', 60) self._timeout_multiplier.addItem('hours', 60 * 60) self._timeout_multiplier.addItem('days', 60 * 60 * 24) self._copy_internal_share_link = QW.QPushButton( 'copy internal share link', self) self._copy_internal_share_link.clicked.connect( self.EventCopyInternalShareURL) self._copy_external_share_link = QW.QPushButton( 'copy external share link', self) self._copy_external_share_link.clicked.connect( self.EventCopyExternalShareURL) self._ok = QW.QPushButton('ok', self) self._ok.clicked.connect(self.accept) self._ok.setObjectName('HydrusAccept') self._cancel = QW.QPushButton('cancel', self) self._cancel.clicked.connect(self.reject) self._cancel.setObjectName('HydrusCancel') # self._share_key = share_key self._name.setText(name) self._text.setPlainText(text) if timeout is None: self._timeout_number.SetValue(None) self._timeout_multiplier.SetValue(60) else: time_left = HydrusData.GetTimeDeltaUntilTime(timeout) if time_left < 60 * 60 * 12: time_value = 60 elif time_left < 60 * 60 * 24 * 7: time_value = 60 * 60 else: time_value = 60 * 60 * 24 self._timeout_number.SetValue(time_left // time_value) self._timeout_multiplier.SetValue(time_value) self._hashes = hashes self._service = HG.client_controller.services_manager.GetService( CC.LOCAL_BOORU_SERVICE_KEY) internal_port = self._service.GetPort() if internal_port is None: self._copy_internal_share_link.setEnabled(False) self._copy_external_share_link.setEnabled(False) # rows = [] rows.append(('share name: ', self._name)) rows.append(('share text: ', self._text)) gridbox = ClientGUICommon.WrapInGrid(self, rows) timeout_box = QP.HBoxLayout() QP.AddToLayout(timeout_box, self._timeout_number, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(timeout_box, self._timeout_multiplier, CC.FLAGS_EXPAND_BOTH_WAYS) link_box = QP.HBoxLayout() QP.AddToLayout(link_box, self._copy_internal_share_link, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(link_box, self._copy_external_share_link, CC.FLAGS_CENTER_PERPENDICULAR) b_box = QP.HBoxLayout() QP.AddToLayout(b_box, self._ok, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(b_box, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR) vbox = QP.VBoxLayout() intro = 'Sharing ' + HydrusData.ToHumanInt(len( self._hashes)) + ' files.' intro += os.linesep + 'Title and text are optional.' if new_share: intro += os.linesep + 'The link will not work until you ok this dialog.' QP.AddToLayout(vbox, ClientGUICommon.BetterStaticText(self, intro), CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, timeout_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, link_box, CC.FLAGS_ON_RIGHT) QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT) self.setLayout(vbox) size_hint = self.sizeHint() size_hint.setWidth(max(size_hint.width(), 350)) QP.SetInitialSize(self, size_hint) ClientGUIFunctions.SetFocusLater(self._ok)
def __init__(self, parent, rule): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) self._bandwidth_type = ClientGUICommon.BetterChoice(self) self._bandwidth_type.addItem('data', HC.BANDWIDTH_TYPE_DATA) self._bandwidth_type.addItem('requests', HC.BANDWIDTH_TYPE_REQUESTS) self._bandwidth_type.currentIndexChanged.connect( self._UpdateEnabled) self._max_allowed_bytes = BytesControl(self) self._max_allowed_requests = QP.MakeQSpinBox(self, min=1, max=1048576) self._time_delta = ClientGUITime.TimeDeltaButton( self, min=1, days=True, hours=True, minutes=True, seconds=True, monthly_allowed=True) # (bandwidth_type, time_delta, max_allowed) = rule self._bandwidth_type.SetValue(bandwidth_type) self._time_delta.SetValue(time_delta) if bandwidth_type == HC.BANDWIDTH_TYPE_DATA: self._max_allowed_bytes.SetValue(max_allowed) else: self._max_allowed_requests.setValue(max_allowed) self._UpdateEnabled() # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._max_allowed_bytes, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._max_allowed_requests, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._bandwidth_type, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, ClientGUICommon.BetterStaticText(self, ' every '), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._time_delta, CC.FLAGS_CENTER_PERPENDICULAR) self.widget().setLayout(hbox)
def __init__( self, parent: QW.QWidget, service_key: bytes, subject_identifiers: typing.Collection[ HydrusNetwork.AccountIdentifier ] ): ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent ) self._service_key = service_key self._service = HG.client_controller.services_manager.GetService( service_key ) self._subject_identifiers = subject_identifiers self._account_types = [] # self._account_panel = ReviewAccountsPanel( self, service_key, subject_identifiers ) # self._message_panel = ClientGUICommon.StaticBox( self, 'message' ) self._message_text = QW.QLineEdit( self._message_panel ) self._set_message_button = ClientGUICommon.BetterButton( self._message_panel, 'set message', self._DoSetMessage ) # self._expiration_panel = ClientGUICommon.StaticBox( self, 'change expiration' ) self._add_to_expires = ClientGUICommon.BetterChoice( self._expiration_panel ) for ( label, value ) in HC.lifetimes: if value is not None: self._add_to_expires.addItem( label, value ) self._add_to_expires_button = ClientGUICommon.BetterButton( self._expiration_panel, 'ok', self._AddToExpires ) self._add_to_expires_button.SetYesNoText( 'Add time to account expiration?' ) self._set_expires = ClientGUICommon.BetterChoice( self._expiration_panel ) for ( label, value ) in HC.lifetimes: self._set_expires.addItem( label, value ) self._set_expires_button = ClientGUICommon.BetterButton( self._expiration_panel, 'ok', self._SetExpires ) self._set_expires_button.SetYesNoText( 'Set new account expiration?' ) # self._account_types_panel = ClientGUICommon.StaticBox( self, 'account types' ) self._account_types_choice = ClientGUICommon.BetterChoice( self._account_types_panel ) self._account_types_button = ClientGUICommon.BetterButton( self._account_types_panel, 'ok', self._DoAccountType ) self._account_types_button.SetYesNoText( 'Set new account type?' ) # self._ban_panel = ClientGUICommon.StaticBox( self, 'bans' ) self._ban_reason = QW.QLineEdit( self._ban_panel ) self._ban_expires = ClientGUICommon.BetterChoice( self._ban_panel ) for ( label, value ) in HC.lifetimes: self._ban_expires.addItem( label, value ) self._ban_button = ClientGUICommon.BetterButton( self._ban_panel, 'ban account', self._DoBan ) self._unban_button = ClientGUICommon.BetterButton( self._ban_panel, 'unban account', self._DoUnban ) self._unban_button.SetYesNoText( 'Unban the account(s)?' ) # self._add_to_expires.SetValue( 3 * 31 * 86400 ) # three months self._set_expires.SetValue( 3 * 31 * 86400 ) # three months # gridbox_rows = [] gridbox_rows.append( ( 'message:', self._message_text ) ) gridbox = ClientGUICommon.WrapInGrid( self._message_panel, gridbox_rows ) self._message_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) self._message_panel.Add( self._set_message_button, 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_button, 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_button, 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 ) account_types_hbox = QP.HBoxLayout() QP.AddToLayout( account_types_hbox, self._account_types_choice, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( account_types_hbox, self._account_types_button, CC.FLAGS_CENTER_PERPENDICULAR ) self._account_types_panel.Add( account_types_hbox, CC.FLAGS_EXPAND_PERPENDICULAR ) gridbox_rows = [] gridbox_rows.append( ( 'ban reason:', self._ban_reason ) ) gridbox_rows.append( ( 'ban expiration:', self._ban_expires ) ) gridbox = ClientGUICommon.WrapInGrid( self._ban_panel, gridbox_rows ) self._ban_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) self._ban_panel.Add( self._ban_button, CC.FLAGS_EXPAND_PERPENDICULAR ) self._ban_panel.Add( self._unban_button, CC.FLAGS_EXPAND_PERPENDICULAR ) vbox = QP.VBoxLayout() self._modification_status = ClientGUICommon.BetterStaticText( self ) QP.AddToLayout( vbox, self._modification_status, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._account_panel, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( vbox, self._message_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 ) self.widget().setLayout( vbox ) # self._account_panel.accountsFetchStarted.connect( self._DisableUIForRefresh ) self._account_panel.accountsFetchFinished.connect( self._EnableUIAfterRefresh ) # self._InitialiseAccountTypes() self._account_panel.RefreshAccounts()
def __init__( self, parent: QW.QWidget, service_type: int, account_type: HydrusNetwork.AccountType ): ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._account_type_key = account_type.GetAccountTypeKey() title = account_type.GetTitle() permissions = account_type.GetPermissions() bandwidth_rules = account_type.GetBandwidthRules() auto_create_velocity = account_type.GetAutoCreateAccountVelocity() self._auto_create_history = account_type.GetAutoCreateAccountHistory() self._title = QW.QLineEdit( self ) permission_choices = self._GeneratePermissionChoices( service_type ) self._permission_controls = [] self._permissions_panel = ClientGUICommon.StaticBox( self, 'permissions' ) gridbox_rows = [] for ( content_type, action_rows ) in permission_choices: choice_control = ClientGUICommon.BetterChoice( self._permissions_panel ) for ( label, action ) in action_rows: choice_control.addItem( label, (content_type, action) ) if content_type in permissions: selection_row = ( content_type, permissions[ content_type ] ) else: selection_row = ( content_type, None ) try: choice_control.SetValue( selection_row ) except: choice_control.SetValue( ( content_type, None ) ) self._permission_controls.append( choice_control ) gridbox_label = HC.content_type_string_lookup[ content_type ] gridbox_rows.append( ( gridbox_label, choice_control ) ) gridbox = ClientGUICommon.WrapInGrid( self._permissions_panel, gridbox_rows ) self._bandwidth_rules_control = ClientGUIControls.BandwidthRulesCtrl( self, bandwidth_rules ) self._auto_creation_box = ClientGUICommon.StaticBox( self, 'automatic account creation' ) min_unit_value = 0 max_unit_value = 65565 min_time_delta = 60 * 60 self._auto_create_velocity_control = ClientGUITime.VelocityCtrl( self._auto_creation_box, min_unit_value, max_unit_value, min_time_delta, days = True, hours = True, unit = 'accounts' ) self._auto_create_history_st = ClientGUICommon.BetterStaticText( self._auto_creation_box, label = 'initialising' ) # self._title.setText( title ) self._auto_create_velocity_control.SetValue( auto_create_velocity ) # intro = 'If you wish, you can allow new users to create their own accounts. They will be limited to a certain number over a particular time.' intro += os.linesep * 2 intro += 'Set to 0 to disable auto-creation.' st = ClientGUICommon.BetterStaticText( self._auto_creation_box, label = intro ) st.setWordWrap( True ) self._auto_creation_box.Add( st, CC.FLAGS_EXPAND_PERPENDICULAR ) self._auto_creation_box.Add( self._auto_create_history_st, CC.FLAGS_EXPAND_PERPENDICULAR ) self._auto_creation_box.Add( self._auto_create_velocity_control, CC.FLAGS_EXPAND_PERPENDICULAR ) t_hbox = ClientGUICommon.WrapInText( self._title, self, 'title: ' ) self._permissions_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, t_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) QP.AddToLayout( vbox, self._permissions_panel, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._bandwidth_rules_control, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._auto_creation_box, CC.FLAGS_EXPAND_PERPENDICULAR ) self.widget().setLayout( vbox ) # self._UpdateAutoCreationHistoryText() self._auto_create_velocity_control.velocityChanged.connect( self._UpdateAutoCreationHistoryText )
def __init__(self, parent, service_key): Dialog.__init__(self, parent, 'configure new accounts') self._service_key = service_key self._num = ClientGUICommon.BetterSpinBox(self, min=1, max=10000, width=80) self._account_types = ClientGUICommon.BetterChoice(self) self._lifetime = ClientGUICommon.BetterChoice(self) self._ok = QW.QPushButton('OK', self) self._ok.clicked.connect(self.EventOK) self._ok.setObjectName('HydrusAccept') self._cancel = QW.QPushButton('Cancel', self) self._cancel.clicked.connect(self.reject) self._cancel.setObjectName('HydrusCancel') # self._num.setValue(1) service = HG.client_controller.services_manager.GetService(service_key) response = service.Request(HC.GET, 'account_types') account_types = response['account_types'] for account_type in account_types: self._account_types.addItem(account_type.GetTitle(), account_type) self._account_types.setCurrentIndex(0) for (s, value) in HC.lifetimes: self._lifetime.addItem(s, value) self._lifetime.setCurrentIndex(3) # one year # ctrl_box = QP.HBoxLayout() QP.AddToLayout(ctrl_box, ClientGUICommon.BetterStaticText(self, 'generate'), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(ctrl_box, self._num, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(ctrl_box, self._account_types, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout( ctrl_box, ClientGUICommon.BetterStaticText(self, 'accounts, to expire in'), CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(ctrl_box, self._lifetime, CC.FLAGS_CENTER_PERPENDICULAR) b_box = QP.HBoxLayout() QP.AddToLayout(b_box, self._ok, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(b_box, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, ctrl_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT) self.setLayout(vbox) size_hint = self.sizeHint() QP.SetInitialSize(self, size_hint) ClientGUIFunctions.SetFocusLater(self._ok)
def __init__( self, parent: QW.QWidget, shortcuts_name: str ): QW.QWidget.__init__( self, parent ) if shortcuts_name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES: simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ shortcuts_name ] else: simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ 'custom' ] choices = sorted( [ ( CAC.simple_enum_to_str_lookup[ simple_type ], simple_type ) for simple_type in simple_types ] ) self._simple_actions = ClientGUICommon.BetterChoice( self ) for ( display_string, data ) in choices: self._simple_actions.addItem( display_string, data ) self._seek_panel = QW.QWidget( self ) choices = [ ( 'back', -1 ), ( 'forwards', 1 ) ] self._seek_direction = ClientGUICommon.BetterRadioBox( self._seek_panel, choices = choices ) self._seek_duration_s = ClientGUICommon.BetterSpinBox( self._seek_panel, max=3599, width = 60 ) self._seek_duration_ms = ClientGUICommon.BetterSpinBox( self._seek_panel, max=999, width = 60 ) # self._seek_duration_s.setValue( 5 ) self._seek_duration_ms.setValue( 0 ) self._seek_duration_s.value() * 1000 + self._seek_duration_ms.value() # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._seek_direction, CC.FLAGS_CENTER ) QP.AddToLayout( hbox, self._seek_duration_s, CC.FLAGS_CENTER ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText( self._seek_panel, label = 's' ), CC.FLAGS_CENTER ) QP.AddToLayout( hbox, self._seek_duration_ms, CC.FLAGS_CENTER ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText( self._seek_panel, label = 'ms' ), CC.FLAGS_CENTER ) hbox.addStretch( 1 ) self._seek_panel.setLayout( hbox ) # vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._simple_actions, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) QP.AddToLayout( vbox, self._seek_panel, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) self.setLayout( vbox ) self._simple_actions.currentIndexChanged.connect( self._UpdateControls ) self._UpdateControls()
def __init__(self, parent: QW.QWidget, command: CAC.ApplicationCommand, shortcuts_name: str): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) # is_custom_or_media = shortcuts_name not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES or shortcuts_name == 'media' self._panel_choice = ClientGUICommon.BetterChoice(self) self._panel_choice.addItem('simple command', self.PANEL_SIMPLE) if is_custom_or_media: self._panel_choice.addItem('tag command', self.PANEL_TAG) self._panel_choice.addItem('like/dislike rating command', self.PANEL_RATING_LIKE) self._panel_choice.addItem('numerical rating command', self.PANEL_RATING_NUMERICAL) self._panel_choice.addItem( 'numerical rating increment/decrement command', self.PANEL_RATING_NUMERICAL_INCDEC) else: self._panel_choice.hide() self._simple_sub_panel = SimpleSubPanel(self, shortcuts_name) self._tag_sub_panel = TagSubPanel(self) self._rating_like_sub_panel = RatingLikeSubPanel(self) self._rating_numerical_sub_panel = RatingNumericalSubPanel(self) self._rating_numerical_inc_dec_sub_panel = RatingNumericalIncDecSubPanel( self) # data = command.GetData() if command.IsSimpleCommand(): action = data self._simple_sub_panel.SetValue(action) self._panel_choice.SetValue(self.PANEL_SIMPLE) elif command.IsContentCommand(): service_key = command.GetContentServiceKey() if HG.client_controller.services_manager.ServiceExists( service_key): service = HG.client_controller.services_manager.GetService( service_key) action = command.GetContentAction() value = command.GetContentValue() else: QW.QMessageBox.warning( self, 'Warning', 'The service that this command relies upon no longer exists! This command will reset to a default form.' ) local_tag_services = list( HG.client_controller.services_manager.GetServices( (HC.LOCAL_TAG, ))) service = local_tag_services[0] service_key = service.GetServiceKey() action = HC.CONTENT_UPDATE_SET value = 'tag' service_type = service.GetServiceType() if service_type in HC.REAL_TAG_SERVICES: tag = value self._tag_sub_panel.SetValue(action, service_key, tag) self._panel_choice.SetValue(self.PANEL_TAG) elif service_type == HC.LOCAL_RATING_LIKE: rating = value self._rating_like_sub_panel.SetValue(action, service_key, rating) self._panel_choice.SetValue(self.PANEL_RATING_LIKE) elif service_type == HC.LOCAL_RATING_NUMERICAL: if action in (HC.CONTENT_UPDATE_SET, HC.CONTENT_UPDATE_FLIP): rating = value self._rating_numerical_sub_panel.SetValue( action, service_key, rating) self._panel_choice.SetValue(self.PANEL_RATING_NUMERICAL) elif action in (HC.CONTENT_UPDATE_INCREMENT, HC.CONTENT_UPDATE_DECREMENT): distance = 1 self._rating_numerical_inc_dec_sub_panel.SetValue( action, service_key, distance) self._panel_choice.SetValue( self.PANEL_RATING_NUMERICAL_INCDEC) # vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._panel_choice, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._simple_sub_panel, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._tag_sub_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._rating_like_sub_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._rating_numerical_sub_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._rating_numerical_inc_dec_sub_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) vbox.addStretch(1) self.widget().setLayout(vbox) self._UpdateVisibleControls() # self._panel_choice.currentIndexChanged.connect( self._UpdateVisibleControls)
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)