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, 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 __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, 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 )
Пример #5
0
        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, payload_objs):

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        self._payload_objs = payload_objs

        self._directory_picker = QP.DirPickerCtrl(self)

        dp_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._directory_picker, 52)

        self._directory_picker.setMinimumWidth(dp_width)

        self._width = QP.MakeQSpinBox(self, min=100, max=4096)

        self._export = ClientGUICommon.BetterButton(self, 'export',
                                                    self.Export)

        #

        last_png_export_dir = HG.client_controller.new_options.GetNoneableString(
            'last_png_export_dir')

        if last_png_export_dir is not None:

            self._directory_picker.SetPath(last_png_export_dir)

        self._width.setValue(512)

        self._Update()

        #

        rows = []

        rows.append(('export path: ', self._directory_picker))
        rows.append(('png width: ', self._width))
        rows.append(('', self._export))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        self.widget().setLayout(gridbox)

        self._directory_picker.dirPickerChanged.connect(self._Update)
Пример #7
0
 def __init__( self, parent: QW.QWidget, name: str, port: int, dictionary ):
     
     ClientGUICommon.StaticBox.__init__( self, parent, 'basic information' )
     
     self._name = QW.QLineEdit( self )
     self._port = QP.MakeQSpinBox( self, min=1, max=65535 )
     self._upnp_port = ClientGUICommon.NoneableSpinCtrl( self, 'external upnp port', none_phrase = 'do not forward port', min = 1, max = 65535 )
     
     self._bandwidth_tracker_st = ClientGUICommon.BetterStaticText( self )
     
     #
     
     self._name.setText( name )
     self._port.setValue( port )
     
     upnp_port = dictionary[ 'upnp_port' ]
     
     self._upnp_port.SetValue( upnp_port )
     
     bandwidth_tracker = dictionary[ 'bandwidth_tracker' ]
     
     bandwidth_text = bandwidth_tracker.GetCurrentMonthSummary()
     
     self._bandwidth_tracker_st.setText( bandwidth_text )
     
     #
     
     rows = []
     
     rows.append( ( 'name: ', self._name ) )
     rows.append( ( 'port: ', self._port ) )
     rows.append( ( 'upnp port: ', self._upnp_port ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     self.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     self.Add( self._bandwidth_tracker_st, CC.FLAGS_EXPAND_PERPENDICULAR )
    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)
Пример #9
0
 def __init__( self, parent, payload_obj, title = None, description = None, payload_description = None ):
     
     ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )
     
     self._payload_obj = payload_obj
     
     self._filepicker = QP.FilePickerCtrl( self, wildcard = 'PNG (*.png)' )
     self._filepicker.SetSaveMode( True )
     
     flp_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._filepicker, 64 )
     
     self._filepicker.setMinimumWidth( flp_width )
     
     self._title = QW.QLineEdit( self )
     
     self._payload_description = QW.QLineEdit( self )
     
     self._text = QW.QLineEdit( self )
     
     self._width = QP.MakeQSpinBox( self, min=100, max=4096 )
     
     self._export = ClientGUICommon.BetterButton( self, 'export', self.Export )
     
     #
     
     if payload_description is None:
         
         ( payload_description, payload_bytes ) = ClientSerialisable.GetPayloadDescriptionAndBytes( self._payload_obj )
         
     else:
         
         payload_bytes = ClientSerialisable.GetPayloadBytes( self._payload_obj )
         
         payload_description += ' - ' + HydrusData.ToHumanBytes( len( payload_bytes ) )
         
     
     self._payload_description.setText( payload_description )
     
     self._payload_description.setEnabled( False )
     
     self._width.setValue( 512 )
     
     last_png_export_dir = HG.client_controller.new_options.GetNoneableString( 'last_png_export_dir' )
     
     if title is not None:
         
         name = title
         
     elif isinstance( self._payload_obj, HydrusSerialisable.SerialisableBaseNamed ):
         
         name = self._payload_obj.GetName()
         
     else:
         
         name = payload_description
         
     
     self._title.setText( name )
     
     if description is not None:
         
         self._text.setText( description )
         
     
     if last_png_export_dir is not None:
         
         filename = name + '.png'
         
         filename = HydrusPaths.SanitizeFilename( filename )
         
         path = os.path.join( last_png_export_dir, filename )
         
         self._filepicker.SetPath( path )
         
     
     self._Update()
     
     #
     
     rows = []
     
     rows.append( ( 'export path: ', self._filepicker ) )
     rows.append( ( 'title: ', self._title ) )
     rows.append( ( 'payload description: ', self._payload_description ) )
     rows.append( ( 'your description (optional): ', self._text ) )
     rows.append( ( 'png width: ', self._width ) )
     rows.append( ( '', self._export ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     self.widget().setLayout( gridbox )
     
     self._filepicker.filePickerChanged.connect( self._Update )
     self._title.textChanged.connect( self._Update )
Пример #10
0
    def __init__(self, parent, checker_options):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        help_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().help, self._ShowHelp)
        help_button.setToolTip('Show help regarding these checker options.')

        help_hbox = ClientGUICommon.WrapInText(help_button, self,
                                               'help for this panel -->',
                                               QG.QColor(0, 0, 255))

        from hydrus.client import ClientDefaults

        defaults_panel = ClientGUICommon.StaticBox(self, 'reasonable defaults')

        defaults_1 = ClientGUICommon.BetterButton(
            defaults_panel, 'thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('thread'))
        defaults_2 = ClientGUICommon.BetterButton(
            defaults_panel, 'slow thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow thread'))
        defaults_3 = ClientGUICommon.BetterButton(
            defaults_panel, 'faster tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('fast tag subscription'))
        defaults_4 = ClientGUICommon.BetterButton(
            defaults_panel, 'medium tag/artist subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('artist subscription'))
        defaults_5 = ClientGUICommon.BetterButton(
            defaults_panel, 'slower tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow tag subscription'))

        #

        # add statictext or whatever that will update on any updates above to say 'given velocity of blah and last check at blah, next check in 5 mins'
        # or indeed this could just take the file_seed cache and last check of the caller, if there is one
        # this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins'
        # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity

        #

        min_unit_value = 0
        max_unit_value = 1000
        min_time_delta = 60

        self._death_file_velocity = VelocityCtrl(self,
                                                 min_unit_value,
                                                 max_unit_value,
                                                 min_time_delta,
                                                 days=True,
                                                 hours=True,
                                                 minutes=True,
                                                 per_phrase='in',
                                                 unit='files')

        self._flat_check_period_checkbox = QW.QCheckBox(self)

        #

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            never_faster_than_min = 1
            never_slower_than_min = 1

            flat_check_period_min = 1

        else:

            never_faster_than_min = 30
            never_slower_than_min = 600

            flat_check_period_min = 180

        self._reactive_check_panel = ClientGUICommon.StaticBox(
            self, 'reactive checking')

        self._intended_files_per_check = QP.MakeQSpinBox(
            self._reactive_check_panel, min=1, max=1000)

        self._never_faster_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_faster_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        self._never_slower_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_slower_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        #

        self._static_check_panel = ClientGUICommon.StaticBox(
            self, 'static checking')

        self._flat_check_period = TimeDeltaCtrl(self._static_check_panel,
                                                min=flat_check_period_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        #

        self.SetValue(checker_options)

        #

        defaults_panel.Add(defaults_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_3, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_4, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_5, CC.FLAGS_EXPAND_PERPENDICULAR)

        #

        #

        rows = []

        rows.append(
            ('intended new files per check: ', self._intended_files_per_check))
        rows.append(
            ('never check faster than once per: ', self._never_faster_than))
        rows.append(
            ('never check slower than once per: ', self._never_slower_than))

        gridbox = ClientGUICommon.WrapInGrid(self._reactive_check_panel, rows)

        self._reactive_check_panel.Add(gridbox,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('check period: ', self._flat_check_period))

        gridbox = ClientGUICommon.WrapInGrid(self._static_check_panel, rows)

        self._static_check_panel.Add(gridbox,
                                     CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('stop checking if new files found falls below: ',
                     self._death_file_velocity))
        rows.append(('just check at a static, regular interval: ',
                     self._flat_check_period_checkbox))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, help_hbox, CC.FLAGS_BUTTON_SIZER)
        QP.AddToLayout(vbox, defaults_panel, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            label = 'As you are in advanced mode, these options have extremely low limits. This is intended only for testing and small scale private network tasks. Do not use very fast check times for real world use on public websites, as it is wasteful and rude, hydrus will be overloaded with high-CPU parsing work, and you may get your IP banned.'

            st = ClientGUICommon.BetterStaticText(self, label=label)
            st.setObjectName('HydrusWarning')

            st.setWordWrap(True)

            QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._reactive_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._static_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        #

        self._flat_check_period_checkbox.clicked.connect(
            self.EventFlatPeriodCheck)
Пример #11
0
    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 = QP.MakeQSpinBox(self._seek_panel,
                                                max=3599,
                                                width=60)
        self._seek_duration_ms = QP.MakeQSpinBox(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()
Пример #12
0
    def __init__(self, parent, checker_options):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        help_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().help, self._ShowHelp)
        help_button.setToolTip('Show help regarding these checker options.')

        help_hbox = ClientGUICommon.WrapInText(
            help_button,
            self,
            'help for this panel -->',
            object_name='HydrusIndeterminate')

        from hydrus.client import ClientDefaults

        defaults_panel = ClientGUICommon.StaticBox(self, 'reasonable defaults')

        defaults_1 = ClientGUICommon.BetterButton(
            defaults_panel, 'thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('thread'))
        defaults_2 = ClientGUICommon.BetterButton(
            defaults_panel, 'slow thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow thread'))
        defaults_3 = ClientGUICommon.BetterButton(
            defaults_panel, 'faster tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('fast tag subscription'))
        defaults_4 = ClientGUICommon.BetterButton(
            defaults_panel, 'medium tag/artist subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('artist subscription'))
        defaults_5 = ClientGUICommon.BetterButton(
            defaults_panel, 'slower tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow tag subscription'))

        #

        # add statictext or whatever that will update on any updates above to say 'given velocity of blah and last check at blah, next check in 5 mins'
        # or indeed this could just take the file_seed cache and last check of the caller, if there is one
        # this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins'
        # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity

        #

        min_unit_value = 0
        max_unit_value = 1000
        min_time_delta = 60

        self._death_file_velocity = VelocityCtrl(self,
                                                 min_unit_value,
                                                 max_unit_value,
                                                 min_time_delta,
                                                 days=True,
                                                 hours=True,
                                                 minutes=True,
                                                 per_phrase='in',
                                                 unit='files')

        self._flat_check_period_checkbox = QW.QCheckBox(self)

        #

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            never_faster_than_min = 1
            never_slower_than_min = 1

            flat_check_period_min = 1

        else:

            never_faster_than_min = 30
            never_slower_than_min = 600

            flat_check_period_min = 180

        self._reactive_check_panel = ClientGUICommon.StaticBox(
            self, 'reactive checking')

        self._intended_files_per_check = QP.MakeQSpinBox(
            self._reactive_check_panel, min=1, max=1000)
        self._intended_files_per_check.setToolTip(
            'How many new files you want the checker to find on each check. If a source is producing about 2 files a day, and this is set to 6, you will probably get a check every three days. You probably want this to be a low number, like 1-4.'
        )

        self._never_faster_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_faster_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)
        self._never_faster_than.setToolTip(
            'Even if the download source produces many new files, the checker will never ask for a check more often than this. This is a safety measure.'
        )

        self._never_slower_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_slower_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)
        self._never_slower_than.setToolTip(
            'Even if the download source slows down significantly, the checker will make sure it checks at least this often anyway, just to catch a future wave in time.'
        )

        #

        self._static_check_panel = ClientGUICommon.StaticBox(
            self, 'static checking')

        self._flat_check_period = TimeDeltaCtrl(self._static_check_panel,
                                                min=flat_check_period_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)
        self._flat_check_period.setToolTip(
            'Always use the same check delay. It is based on the time the last check completed, not the time the last check was due. If you want once a day with no skips, try setting this to 23 hours.'
        )

        #

        self.SetValue(checker_options)

        #

        defaults_panel.Add(defaults_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_3, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_4, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_5, CC.FLAGS_EXPAND_PERPENDICULAR)

        #

        #

        label = 'This checks more or less frequently based on how fast the download source is producing new files.'

        st = ClientGUICommon.BetterStaticText(self._reactive_check_panel,
                                              label=label)

        st.setWordWrap(True)

        rows = []

        rows.append(
            ('intended new files per check: ', self._intended_files_per_check))
        rows.append(
            ('never check faster than once per: ', self._never_faster_than))
        rows.append(
            ('never check slower than once per: ', self._never_slower_than))

        gridbox = ClientGUICommon.WrapInGrid(self._reactive_check_panel, rows)

        self._reactive_check_panel.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._reactive_check_panel.Add(gridbox,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('check period: ', self._flat_check_period))

        gridbox = ClientGUICommon.WrapInGrid(self._static_check_panel, rows)

        self._static_check_panel.Add(gridbox,
                                     CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('stop checking if new files found falls below: ',
                     self._death_file_velocity))
        rows.append(('just check at a static, regular interval: ',
                     self._flat_check_period_checkbox))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, help_hbox, CC.FLAGS_EXPAND_PERPENDICULAR)

        label = 'If you do not understand this panel, use the buttons! The defaults are fine for most purposes!'

        st = ClientGUICommon.BetterStaticText(self._reactive_check_panel,
                                              label=label)

        st.setWordWrap(True)
        st.setObjectName('HydrusWarning')

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, defaults_panel, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            label = 'As you are in advanced mode, these options have extremely low limits. This is intended only for testing and small scale private network tasks. Do not use very fast check times for real world use on public websites, as it is wasteful and rude, hydrus will be overloaded with high-CPU parsing work, and you may get your IP banned.'

            st = ClientGUICommon.BetterStaticText(self, label=label)
            st.setObjectName('HydrusWarning')

            st.setWordWrap(True)

            QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._reactive_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._static_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox.addStretch(1)

        self.widget().setLayout(vbox)

        #

        self._flat_check_period_checkbox.clicked.connect(
            self.EventFlatPeriodCheck)