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) expand_parents = False self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.SetTags, expand_parents, CC.LOCAL_FILE_SERVICE_KEY, 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) # 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)
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, 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, 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_VCENTER) QP.AddToLayout(hbox, self._max_allowed_requests, CC.FLAGS_VCENTER) QP.AddToLayout(hbox, self._bandwidth_type, CC.FLAGS_VCENTER) QP.AddToLayout(hbox, ClientGUICommon.BetterStaticText(self, ' every '), CC.FLAGS_VCENTER) QP.AddToLayout(hbox, self._time_delta, CC.FLAGS_VCENTER) self.widget().setLayout(hbox)
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, management_controller = None ): QW.QWidget.__init__( self, parent ) self._management_controller = management_controller self._sort_type = ( 'system', CC.SORT_FILES_BY_FILESIZE ) self._sort_type_button = ClientGUICommon.BetterButton( self, 'sort', self._SortTypeButtonClick ) self._sort_order_choice = ClientGUICommon.BetterChoice( self ) type_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._sort_type_button, 14 ) self._sort_type_button.setMinimumWidth( type_width ) asc_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._sort_order_choice, 14 ) self._sort_order_choice.setMinimumWidth( asc_width ) self._sort_order_choice.addItem( '', CC.SORT_ASC ) self._UpdateSortTypeLabel() self._UpdateAscLabels() # hbox = QP.HBoxLayout( margin = 0 ) QP.AddToLayout( hbox, self._sort_type_button, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( hbox, self._sort_order_choice, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox ) HG.client_controller.sub( self, 'ACollectHappened', 'a_collect_happened' ) HG.client_controller.sub( self, 'BroadcastSort', 'do_page_sort' ) if self._management_controller is not None and self._management_controller.HasVariable( 'media_sort' ): media_sort = self._management_controller.GetVariable( 'media_sort' ) try: self.SetSort( media_sort ) except: default_sort = ClientMedia.MediaSort( ( 'system', CC.SORT_FILES_BY_FILESIZE ), CC.SORT_ASC ) self.SetSort( default_sort ) self._sort_order_choice.currentIndexChanged.connect( self.EventSortAscChoice )
def __init__( self, parent, management_controller = None, silent = False ): QW.QWidget.__init__( self, parent ) # this is trash, rewrite it to deal with the media_collect object, not the management controller self._management_controller = management_controller if self._management_controller is not None and self._management_controller.HasVariable( 'media_collect' ): self._media_collect = self._management_controller.GetVariable( 'media_collect' ) else: self._media_collect = HG.client_controller.new_options.GetDefaultCollect() self._silent = silent self._collect_comboctrl = QP.CollectComboCtrl( self, self._media_collect ) self._collect_unmatched = ClientGUICommon.BetterChoice( self ) width = ClientGUIFunctions.ConvertTextToPixelWidth( self._collect_unmatched, 19 ) self._collect_unmatched.setMinimumWidth( width ) self._collect_unmatched.addItem( 'collect unmatched', True ) self._collect_unmatched.addItem( 'leave unmatched', False ) # self._collect_unmatched.SetValue( self._media_collect.collect_unmatched ) # hbox = QP.HBoxLayout( margin = 0 ) QP.AddToLayout( hbox, self._collect_comboctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( hbox, self._collect_unmatched, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox ) # self._UpdateLabel() self._collect_unmatched.currentIndexChanged.connect( self.CollectValuesChanged ) self._collect_comboctrl.itemChanged.connect( self.CollectValuesChanged ) HG.client_controller.sub( self, 'SetCollectFromPage', 'set_page_collect' )
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) HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
def __init__(self, parent, service_key): Dialog.__init__(self, parent, 'configure new accounts') self._service_key = service_key self._num = QP.MakeQSpinBox(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) HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
def __init__(self, parent, command, shortcuts_name): ClientGUIScrolledPanels.EditPanel.__init__(self, parent) self._current_ratings_like_service = None self._current_ratings_numerical_service = None # is_custom_or_media = shortcuts_name not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES or shortcuts_name == 'media' self._command_type_choice = ClientGUICommon.BetterChoice(self) self._command_type_choice.addItem('simple command', self.COMMAND_TYPE_PANEL_SIMPLE) if is_custom_or_media: self._command_type_choice.addItem('tag command', self.COMMAND_TYPE_PANEL_TAG) self._command_type_choice.addItem( 'like/dislike rating command', self.COMMAND_TYPE_PANEL_RATING_LIKE) self._command_type_choice.addItem( 'numerical rating command', self.COMMAND_TYPE_PANEL_RATING_NUMERICAL) self._command_type_choice.addItem( 'numerical rating increment/decrement command', self.COMMAND_TYPE_PANEL_RATING_NUMERICAL_INCDEC) else: self._command_type_choice.hide() if shortcuts_name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES: choices = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ shortcuts_name] else: choices = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[ 'custom'] choices = list(choices) choices.sort() self._simple_actions = QW.QComboBox(self) self._simple_actions.addItems(choices) # 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._tag_panel = QW.QWidget(self) self._tag_service_keys = QW.QComboBox(self._tag_panel) self._tag_value = QW.QLineEdit() self._tag_value.setReadOnly(True) expand_parents = False self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self._tag_panel, self.SetTags, expand_parents, CC.LOCAL_FILE_SERVICE_KEY, CC.COMBINED_TAG_SERVICE_KEY) # self._ratings_like_panel = QW.QWidget(self) self._ratings_like_service_keys = QW.QComboBox( self._ratings_like_panel) self._ratings_like_service_keys.currentIndexChanged.connect( self._SetActions) self._ratings_like_like = QW.QRadioButton('like', self._ratings_like_panel) self._ratings_like_dislike = QW.QRadioButton('dislike', self._ratings_like_panel) self._ratings_like_remove = QW.QRadioButton('remove rating', self._ratings_like_panel) # self._ratings_numerical_panel = QW.QWidget(self) self._ratings_numerical_service_keys = QW.QComboBox( self._ratings_numerical_panel) self._ratings_numerical_service_keys.currentIndexChanged.connect( self._SetActions) self._ratings_numerical_slider = QP.LabelledSlider( self._ratings_numerical_panel) self._ratings_numerical_remove = QW.QCheckBox( 'remove rating', self._ratings_numerical_panel) # self._ratings_numerical_incdec_panel = QW.QWidget(self) self._ratings_numerical_incdec_service_keys = QW.QComboBox( self._ratings_numerical_incdec_panel) self._ratings_numerical_incdec = ClientGUICommon.BetterChoice( self._ratings_numerical_incdec_panel) 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_TAG, HC.TAG_REPOSITORY, HC.LOCAL_RATING_LIKE, HC.LOCAL_RATING_NUMERICAL)) for service in services: service_name = service.GetName() service_key = service.GetServiceKey() service_type = service.GetServiceType() if service_type in HC.REAL_TAG_SERVICES: self._tag_service_keys.addItem(service_name, service_key) elif service_type == HC.LOCAL_RATING_LIKE: self._ratings_like_service_keys.addItem( service_name, service_key) elif service_type == HC.LOCAL_RATING_NUMERICAL: self._ratings_numerical_service_keys.addItem( service_name, service_key) self._ratings_numerical_incdec_service_keys.addItem( service_name, service_key) self._SetActions() # command_type = command.GetCommandType() data = command.GetData() if command_type == CC.APPLICATION_COMMAND_TYPE_SIMPLE: action = data QP.SetStringSelection(self._simple_actions, action) self._command_type_choice.SetValue(self.COMMAND_TYPE_PANEL_SIMPLE) else: (service_key, content_type, action, value) = data if HG.client_controller.services_manager.ServiceExists( service_key): self._service = HG.client_controller.services_manager.GetService( service_key) 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, ))) self._service = local_tag_services[0] content_type = HC.CONTENT_TYPE_MAPPINGS action = HC.CONTENT_UPDATE_SET value = 'tag' service_name = self._service.GetName() service_type = self._service.GetServiceType() self._flip_or_set_action.SetValue(action) if service_type in HC.REAL_TAG_SERVICES: QP.SetStringSelection(self._tag_service_keys, service_name) self._tag_value.setText(value) self._command_type_choice.SetValue(self.COMMAND_TYPE_PANEL_TAG) elif service_type == HC.LOCAL_RATING_LIKE: QP.SetStringSelection(self._ratings_like_service_keys, service_name) self._SetActions() if value is None: self._ratings_like_remove.setChecked(True) elif value == True: self._ratings_like_like.setChecked(True) elif value == False: self._ratings_like_dislike.setChecked(True) self._command_type_choice.SetValue( self.COMMAND_TYPE_PANEL_RATING_LIKE) elif service_type == HC.LOCAL_RATING_NUMERICAL: if action in (HC.CONTENT_UPDATE_SET, HC.CONTENT_UPDATE_FLIP): QP.SetStringSelection(self._ratings_numerical_service_keys, service_name) self._SetActions() if value is None: self._ratings_numerical_remove.setChecked(True) else: num_stars = self._current_ratings_numerical_service.GetNumStars( ) slider_value = int(round(value * num_stars)) self._ratings_numerical_slider.SetValue(slider_value) self._command_type_choice.SetValue( self.COMMAND_TYPE_PANEL_RATING_NUMERICAL) elif action in (HC.CONTENT_UPDATE_INCREMENT, HC.CONTENT_UPDATE_DECREMENT): QP.SetStringSelection( self._ratings_numerical_incdec_service_keys, service_name) self._ratings_numerical_incdec.SetValue(action) self._command_type_choice.SetValue( self.COMMAND_TYPE_PANEL_RATING_NUMERICAL_INCDEC) # 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_BOTH_WAYS) tag_hbox = QP.HBoxLayout() QP.AddToLayout(tag_hbox, self._tag_service_keys, CC.FLAGS_EXPAND_DEPTH_ONLY) QP.AddToLayout(tag_hbox, tag_sub_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) self._tag_panel.setLayout(tag_hbox) ratings_like_hbox = QP.HBoxLayout() QP.AddToLayout(ratings_like_hbox, self._ratings_like_service_keys, CC.FLAGS_EXPAND_DEPTH_ONLY) QP.AddToLayout(ratings_like_hbox, self._ratings_like_like, CC.FLAGS_VCENTER) QP.AddToLayout(ratings_like_hbox, self._ratings_like_dislike, CC.FLAGS_VCENTER) QP.AddToLayout(ratings_like_hbox, self._ratings_like_remove, CC.FLAGS_VCENTER) self._ratings_like_panel.setLayout(ratings_like_hbox) ratings_numerical_hbox = QP.HBoxLayout() QP.AddToLayout(ratings_numerical_hbox, self._ratings_numerical_service_keys, CC.FLAGS_EXPAND_DEPTH_ONLY) QP.AddToLayout(ratings_numerical_hbox, self._ratings_numerical_slider, CC.FLAGS_VCENTER) QP.AddToLayout(ratings_numerical_hbox, self._ratings_numerical_remove, CC.FLAGS_VCENTER) self._ratings_numerical_panel.setLayout(ratings_numerical_hbox) hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._ratings_numerical_incdec_service_keys, CC.FLAGS_EXPAND_DEPTH_ONLY) QP.AddToLayout(hbox, self._ratings_numerical_incdec, CC.FLAGS_VCENTER) self._ratings_numerical_incdec_panel.setLayout(hbox) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._command_type_choice, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._simple_actions, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR) QP.AddToLayout(vbox, self._tag_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._ratings_like_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._ratings_numerical_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, self._ratings_numerical_incdec_panel, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR) QP.AddToLayout(vbox, QW.QWidget(self), CC.FLAGS_EXPAND_BOTH_WAYS) self.widget().setLayout(vbox) self._UpdateVisibleControls() # self._command_type_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)
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)