def __init__( self, parent, namespace = '', regex = '' ): Dialog.__init__( self, parent, 'configure quick namespace' ) self._namespace = QW.QLineEdit( self ) self._regex = QW.QLineEdit( self ) self._shortcuts = ClientGUICommon.RegexButton( self ) self._regex_intro_link = ClientGUICommon.BetterHyperLink( self, 'a good regex introduction', 'https://www.aivosto.com/vbtips/regex.html' ) self._regex_practise_link = ClientGUICommon.BetterHyperLink( self, 'regex practice', 'https://regexr.com/3cvmf' ) 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._namespace.setText( namespace ) self._regex.setText( regex ) # control_box = QP.HBoxLayout() QP.AddToLayout( control_box, self._namespace, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( control_box, ClientGUICommon.BetterStaticText(self,':'), CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( control_box, self._regex, CC.FLAGS_EXPAND_BOTH_WAYS ) 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 = r'Put the namespace (e.g. page) on the left.' + os.linesep + r'Put the regex (e.g. [1-9]+\d*(?=.{4}$)) on the right.' + os.linesep + r'All files will be tagged with "namespace:regex".' QP.AddToLayout( vbox, ClientGUICommon.BetterStaticText(self,intro), CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, control_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) QP.AddToLayout( vbox, self._shortcuts, CC.FLAGS_ON_RIGHT ) QP.AddToLayout( vbox, self._regex_intro_link, CC.FLAGS_ON_RIGHT ) QP.AddToLayout( vbox, self._regex_practise_link, CC.FLAGS_ON_RIGHT ) 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 ): QW.QFrame.__init__( self, parent ) self.setFrameStyle( QW.QFrame.Box | QW.QFrame.Raised ) self._network_job = None self._auto_override_bandwidth_rules = False self._left_text = ClientGUICommon.BetterStaticText( self, ellipsize_end = True ) self._right_text = ClientGUICommon.BetterStaticText( self ) self._right_text.setAlignment( QC.Qt.AlignRight | QC.Qt.AlignVCenter ) self._last_right_min_width = 0 self._gauge = ClientGUICommon.Gauge( self ) self._cog_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().cog, self._ShowCogMenu ) self._cancel_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().stop, self.Cancel ) self._error_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().dump_fail, self._ShowErrorMenu ) self._error_button.setToolTip( 'Click here to see the last job\'s error.' ) self._error_button.hide() self._error_text = None # self._Update() # st_hbox = QP.HBoxLayout() QP.AddToLayout( st_hbox, self._left_text, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( st_hbox, self._right_text, CC.FLAGS_CENTER_PERPENDICULAR ) left_vbox = QP.VBoxLayout() QP.AddToLayout( left_vbox, st_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) QP.AddToLayout( left_vbox, self._gauge, CC.FLAGS_EXPAND_BOTH_WAYS ) hbox = QP.HBoxLayout() QP.AddToLayout( hbox, left_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS ) QP.AddToLayout( hbox, self._cog_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._cancel_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._error_button, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox )
def _GetButtonBox(self): buttonbox = QP.HBoxLayout() QP.AddToLayout(buttonbox, self._close) return buttonbox
def __init__( self, parent, min_unit_value, max_unit_value, min_time_delta, days = False, hours = False, minutes = False, seconds = False, per_phrase = 'per', unit = None ): QW.QWidget.__init__( self, parent ) self._num = QP.MakeQSpinBox( self, min=min_unit_value, max=max_unit_value, width = 60 ) self._times = TimeDeltaCtrl( self, min = min_time_delta, days = days, hours = hours, minutes = minutes, seconds = seconds ) # hbox = QP.HBoxLayout( margin = 0 ) QP.AddToLayout( hbox, self._num, CC.FLAGS_CENTER_PERPENDICULAR ) mid_text = per_phrase if unit is not None: mid_text = '{} {}'.format( unit, mid_text ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,mid_text), CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._times, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox )
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: 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, initial_value=65536, none_label='no limit'): QW.QWidget.__init__(self, parent) self._bytes = BytesControl(self) self._none_checkbox = QW.QCheckBox(none_label, self) # self.SetValue(initial_value) # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._bytes, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._none_checkbox, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(hbox) # self._none_checkbox.clicked.connect(self._UpdateEnabled) self._bytes.valueChanged.connect(self._HandleValueChanged) self._none_checkbox.clicked.connect(self._HandleValueChanged)
def __init__(self, parent, message, yes_label='yes', no_label='no'): ClientGUIScrolledPanels.ResizingScrolledPanel.__init__(self, parent) self._yes = ClientGUICommon.BetterButton(self, yes_label, self.parentWidget().done, QW.QDialog.Accepted) self._yes.setObjectName('HydrusAccept') self._yes.setText(yes_label) self._no = ClientGUICommon.BetterButton(self, no_label, self.parentWidget().done, QW.QDialog.Rejected) self._no.setObjectName('HydrusCancel') self._no.setText(no_label) # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._yes) QP.AddToLayout(hbox, self._no) vbox = QP.VBoxLayout() text = ClientGUICommon.BetterStaticText(self, message) text.setWordWrap(True) QP.AddToLayout(vbox, text) QP.AddToLayout(vbox, hbox, CC.FLAGS_BUTTON_SIZER) self.widget().setLayout(vbox) HG.client_controller.CallAfterQtSafe(self._yes, self._yes.setFocus, QC.Qt.OtherFocusReason)
def __init__(self, parent, predicate_panel_class, predicate): QW.QWidget.__init__(self, parent) self._defaults_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().star, self._DefaultsMenu) self._defaults_button.setToolTip('Set a new default.') self._predicate_panel = predicate_panel_class(self, predicate) self._parent = parent self._ok = QW.QPushButton('ok', self) self._ok.clicked.connect(self._DoOK) self._ok.setObjectName('HydrusAccept') hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._defaults_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._predicate_panel, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS) QP.AddToLayout(hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(hbox) HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
def __init__( self, parent, controller, read_only, can_generate_more_pages, page_key = None ): QW.QFrame.__init__( self, parent ) self.setFrameStyle( QW.QFrame.Box | QW.QFrame.Raised ) self._controller = controller self._read_only = read_only self._can_generate_more_pages = can_generate_more_pages self._page_key = page_key self._gallery_seed_log = None self._log_summary_st = ClientGUICommon.BetterStaticText( self, ellipsize_end = True ) self._gallery_seed_log_button = GallerySeedLogButton( self, self._controller, self._read_only, self._can_generate_more_pages, self._GetGallerySeedLog ) # self._Update() # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._log_summary_st, CC.FLAGS_VCENTER_EXPAND_DEPTH_ONLY ) QP.AddToLayout( hbox, self._gallery_seed_log_button, CC.FLAGS_VCENTER ) self.setLayout( hbox ) # HG.client_controller.gui.RegisterUIUpdateWindow( self )
def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ): QW.QWidget.__init__( self, parent ) self._service_key = service_key service = HG.client_controller.services_manager.GetService( self._service_key ) name = service.GetName() name_st = ClientGUICommon.BetterStaticText( self, name ) name_st.setAlignment( QC.Qt.AlignLeft | QC.Qt.AlignVCenter ) self._rated_checkbox = QW.QCheckBox( 'rated', self ) self._not_rated_checkbox = QW.QCheckBox( 'not rated', self ) self._rating_control = ClientGUIRatings.RatingLikeDialog( self, service_key ) # if predicate is not None: value = predicate.GetValue() if value is not None: ( operator, rating, service_key ) = value if rating == 'rated': self._rated_checkbox.setChecked( True ) elif rating == 'not rated': self._not_rated_checkbox.setChecked( True ) else: if rating == 0: self._rating_control.SetRatingState( ClientRatings.DISLIKE ) else: self._rating_control.SetRatingState( ClientRatings.LIKE ) # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, name_st, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( hbox, self._rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._not_rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._rating_control, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox )
def __init__( self, parent, message, yes_label = 'yes', no_label = 'no' ): ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent ) self._yes = ClientGUICommon.BetterButton( self, yes_label, self.parentWidget().done, QW.QDialog.Accepted ) self._yes.setObjectName( 'HydrusAccept' ) self._yes.setText( yes_label ) self._no = ClientGUICommon.BetterButton( self, no_label, self.parentWidget().done, QW.QDialog.Rejected ) self._no.setObjectName( 'HydrusCancel' ) self._no.setText( no_label ) # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._yes ) QP.AddToLayout( hbox, self._no ) vbox = QP.VBoxLayout() text = ClientGUICommon.BetterStaticText( self, message ) text.setWordWrap( True ) QP.AddToLayout( vbox, text ) QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT ) self.widget().setLayout( vbox ) ClientGUIFunctions.SetFocusLater( self._yes )
def __init__( self, parent, service_type, account_types ): self._service_type = service_type self._original_account_types = account_types ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._deletee_account_type_keys_to_new_account_type_keys = {} self._account_types_listctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_ACCOUNT_TYPES.ID, 20, self._ConvertAccountTypeToTuples, delete_key_callback = self._Delete, activation_callback = self._Edit ) self._add_button = ClientGUICommon.BetterButton( self, 'add', self._Add ) self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit ) self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete ) self._account_types_listctrl.AddDatas( self._original_account_types ) hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._edit_button, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, self._account_types_listctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT ) self.widget().setLayout( vbox )
def __init__( self, parent, label ): ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent ) self._commit = ClientGUICommon.BetterButton( self, 'commit', self.parentWidget().done, QW.QDialog.Accepted ) self._commit.setObjectName( 'HydrusAccept' ) self._forget = ClientGUICommon.BetterButton( self, 'forget', self.parentWidget().done, QW.QDialog.Rejected ) self._forget.setObjectName( 'HydrusCancel' ) def cancel_callback( parent ): parent.SetCancelled( True ) parent.done( QW.QDialog.Rejected ) self._back = ClientGUICommon.BetterButton( self, 'back to filtering', cancel_callback, parent ) hbox = QP.HBoxLayout() QP.AddToLayout( hbox, self._commit, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( hbox, self._forget, CC.FLAGS_EXPAND_BOTH_WAYS ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment( label, self, QC.Qt.AlignVCenter | QC.Qt.AlignHCenter ), CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment( '-or-', self, QC.Qt.AlignVCenter | QC.Qt.AlignHCenter ), CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._back, CC.FLAGS_EXPAND_PERPENDICULAR ) self.widget().setLayout( vbox ) ClientGUIFunctions.SetFocusLater( self._commit )
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: 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, add_callable, allow_empty_input=False): self._add_callable = add_callable self._allow_empty_input = allow_empty_input QW.QWidget.__init__(self, parent) self._text_input = QW.QLineEdit(self) self._text_input.installEventFilter( ClientGUICommon.TextCatchEnterEventFilter(self._text_input, self.EnterText)) self._paste_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().paste, self._Paste) self._paste_button.setToolTip( 'Paste multiple inputs from the clipboard. Assumes the texts are newline-separated.' ) self.setFocusProxy(self._text_input) # hbox = QP.HBoxLayout() QP.AddToLayout(hbox, self._text_input, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(hbox, self._paste_button, CC.FLAGS_CENTER_PERPENDICULAR) self.setLayout(hbox)
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, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ): QW.QWidget.__init__( self, parent ) self._service_key = service_key service = HG.client_controller.services_manager.GetService( self._service_key ) name = service.GetName() name_st = ClientGUICommon.BetterStaticText( self, name ) name_st.setAlignment( QC.Qt.AlignLeft | QC.Qt.AlignVCenter ) self._rated_checkbox = QW.QCheckBox( 'rated', self ) self._not_rated_checkbox = QW.QCheckBox( 'not rated', self ) self._operator = QP.RadioBox( self, choices = [ '>', '<', '=', CC.UNICODE_ALMOST_EQUAL_TO ] ) self._rating_control = ClientGUIRatings.RatingNumericalDialog( self, service_key ) self._operator.Select( 2 ) # if predicate is not None: value = predicate.GetValue() if value is not None: ( operator, rating, service_key ) = value if rating == 'rated': self._rated_checkbox.setChecked( True ) elif rating == 'not rated': self._not_rated_checkbox.setChecked( True ) else: self._operator.SetStringSelection( operator ) self._rating_control.SetRating( rating ) # hbox = QP.HBoxLayout() QP.AddToLayout( hbox, name_st, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( hbox, self._rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._not_rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._operator, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, self._rating_control, CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox )
def __init__( self, parent, min = 1, days = False, hours = False, minutes = False, seconds = False, monthly_allowed = False, monthly_label = 'monthly' ): QW.QWidget.__init__( self, parent ) self._min = min self._show_days = days self._show_hours = hours self._show_minutes = minutes self._show_seconds = seconds self._monthly_allowed = monthly_allowed hbox = QP.HBoxLayout( margin = 0 ) if self._show_days: self._days = QP.MakeQSpinBox( self, min=0, max=3653, width = 50 ) self._days.valueChanged.connect( self.EventChange ) QP.AddToLayout( hbox, self._days, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'days'), CC.FLAGS_CENTER_PERPENDICULAR ) if self._show_hours: self._hours = QP.MakeQSpinBox( self, min=0, max=23, width = 45 ) self._hours.valueChanged.connect( self.EventChange ) QP.AddToLayout( hbox, self._hours, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'hours'), CC.FLAGS_CENTER_PERPENDICULAR ) if self._show_minutes: self._minutes = QP.MakeQSpinBox( self, min=0, max=59, width = 45 ) self._minutes.valueChanged.connect( self.EventChange ) QP.AddToLayout( hbox, self._minutes, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'minutes'), CC.FLAGS_CENTER_PERPENDICULAR ) if self._show_seconds: self._seconds = QP.MakeQSpinBox( self, min=0, max=59, width = 45 ) self._seconds.valueChanged.connect( self.EventChange ) QP.AddToLayout( hbox, self._seconds, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'seconds'), CC.FLAGS_CENTER_PERPENDICULAR ) if self._monthly_allowed: self._monthly = QW.QCheckBox( self ) self._monthly.clicked.connect( self.EventChange ) QP.AddToLayout( hbox, self._monthly, CC.FLAGS_CENTER_PERPENDICULAR ) QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,monthly_label), CC.FLAGS_CENTER_PERPENDICULAR ) self.setLayout( hbox )
def _GetButtonBox(self): buttonbox = QP.HBoxLayout() QP.AddToLayout(buttonbox, self._apply) QP.AddToLayout(buttonbox, self._cancel) return buttonbox
def __init__(self, parent, message, title='Are you sure?', yes_tuples=None, no_label='no'): if yes_tuples is None: yes_tuples = [('yes', 'yes')] Dialog.__init__(self, parent, title, position='center') self._value = None yes_buttons = [] for (label, data) in yes_tuples: yes_button = ClientGUICommon.BetterButton(self, label, self._DoYes, data) yes_button.setObjectName('HydrusAccept') yes_buttons.append(yes_button) self._no = ClientGUICommon.BetterButton(self, no_label, self.done, QW.QDialog.Rejected) self._no.setObjectName('HydrusCancel') # hbox = QP.HBoxLayout() for yes_button in yes_buttons: QP.AddToLayout(hbox, yes_button, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(hbox, self._no, CC.FLAGS_CENTER_PERPENDICULAR) vbox = QP.VBoxLayout() text = ClientGUICommon.BetterStaticText(self, message) text.setWordWrap(True) QP.AddToLayout(vbox, text, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT) self.setLayout(vbox) size_hint = self.sizeHint() size_hint.setWidth(max(size_hint.width(), 250)) QP.SetInitialSize(self, size_hint) HG.client_controller.CallAfterQtSafe(yes_buttons[0], yes_buttons[0].setFocus, QC.Qt.OtherFocusReason)
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._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, service_key, tags, expand_parents = True, message = '', show_sibling_text = False ): Dialog.__init__( self, parent, 'input tags' ) self._service_key = service_key self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove( self, service_key = service_key, show_sibling_text = show_sibling_text ) self._expand_parents = expand_parents self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.EnterTags, self._expand_parents, CC.LOCAL_FILE_SERVICE_KEY, service_key, null_entry_callable = self.OK, show_paste_button = True ) 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._tags.SetTags( tags ) # 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() if message != '': st = ClientGUICommon.BetterStaticText( self, message ) st.setWordWrap( True ) QP.AddToLayout( vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._tags, CC.FLAGS_EXPAND_BOTH_WAYS ) QP.AddToLayout( vbox, self._tag_autocomplete ) QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT ) self.setLayout( vbox ) size_hint = self.sizeHint() size_hint.setWidth( max( size_hint.width(), 300 ) ) QP.SetInitialSize( self, size_hint ) HG.client_controller.CallAfterQtSafe( self._tag_autocomplete, self._tag_autocomplete.setFocus, QC.Qt.OtherFocusReason)
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, url_tree): Dialog.__init__(self, parent, 'select items') self._tree = QP.TreeWidgetWithInheritedCheckState(self) 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') # (text_gumpf, name, size, children) = url_tree root_name = self._RenderItemName(name, size) root_item = QW.QTreeWidgetItem() root_item.setText(0, root_name) root_item.setCheckState(0, QC.Qt.Checked) self._tree.addTopLevelItem(root_item) self._AddDirectory(root_item, children) root_item.setExpanded(True) # button_hbox = QP.HBoxLayout() QP.AddToLayout(button_hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR) QP.AddToLayout(button_hbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR) vbox = QP.VBoxLayout() QP.AddToLayout(vbox, self._tree, CC.FLAGS_EXPAND_BOTH_WAYS) QP.AddToLayout(vbox, button_hbox, CC.FLAGS_ON_RIGHT) self.setLayout(vbox) size_hint = self.sizeHint() size_hint.setWidth(max(size_hint.width(), 640)) size_hint.setHeight(max(size_hint.height(), 640)) QP.SetInitialSize(self, size_hint)
def __init__( self, parent ): QW.QWidget.__init__( self, parent ) self._vbox = QP.VBoxLayout() self._buttonbox = QP.HBoxLayout() self._listctrl = None self._permitted_object_types = [] self._import_add_callable = lambda x: None self._custom_get_callable = None self._button_infos = []