コード例 #1
0
 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 )
コード例 #2
0
        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)
コード例 #3
0
    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)
コード例 #4
0
    def AddBitmapButton(self,
                        bitmap,
                        clicked_func,
                        tooltip=None,
                        enabled_only_on_selection=False,
                        enabled_only_on_single_selection=False,
                        enabled_check_func=None):

        button = ClientGUICommon.BetterBitmapButton(self, bitmap, clicked_func)

        if tooltip is not None:

            button.setToolTip(tooltip)

        self._AddButton(
            button,
            enabled_only_on_selection=enabled_only_on_selection,
            enabled_only_on_single_selection=enabled_only_on_single_selection,
            enabled_check_func=enabled_check_func)

        self._UpdateButtons()
コード例 #5
0
    def __init__(self, parent, call_mouse_buttons_primary_secondary,
                 all_shortcuts):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        help_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().help, self._ShowHelp)
        help_button.setToolTip('Show help regarding editing shortcuts.')

        self._call_mouse_buttons_primary_secondary = QW.QCheckBox(self)
        self._call_mouse_buttons_primary_secondary.setToolTip(
            'Useful if you swap your buttons around.')

        reserved_panel = ClientGUICommon.StaticBox(
            self, 'built-in hydrus shortcut sets')

        self._reserved_shortcuts = ClientGUIListCtrl.BetterListCtrl(
            reserved_panel,
            CGLC.COLUMN_LIST_SHORTCUT_SETS.ID,
            6,
            data_to_tuples_func=self._GetTuples,
            activation_callback=self._EditReserved)

        self._reserved_shortcuts.setMinimumSize(QC.QSize(320, 200))

        self._edit_reserved_button = ClientGUICommon.BetterButton(
            reserved_panel, 'edit', self._EditReserved)
        self._restore_defaults_button = ClientGUICommon.BetterButton(
            reserved_panel, 'restore defaults', self._RestoreDefaults)

        #

        custom_panel = ClientGUICommon.StaticBox(self, 'custom user sets')

        self._custom_shortcuts = ClientGUIListCtrl.BetterListCtrl(
            custom_panel,
            CGLC.COLUMN_LIST_SHORTCUT_SETS.ID,
            6,
            data_to_tuples_func=self._GetTuples,
            delete_key_callback=self._Delete,
            activation_callback=self._EditCustom)

        self._add_button = ClientGUICommon.BetterButton(
            custom_panel, 'add', self._Add)
        self._edit_custom_button = ClientGUICommon.BetterButton(
            custom_panel, 'edit', self._EditCustom)
        self._delete_button = ClientGUICommon.BetterButton(
            custom_panel, 'delete', self._Delete)

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

            custom_panel.hide()

        #

        self._call_mouse_buttons_primary_secondary.setChecked(
            call_mouse_buttons_primary_secondary)

        reserved_shortcuts = [
            shortcuts for shortcuts in all_shortcuts if shortcuts.GetName() in
            ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES
        ]
        custom_shortcuts = [
            shortcuts for shortcuts in all_shortcuts if shortcuts.GetName()
            not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES
        ]

        self._reserved_shortcuts.AddDatas(reserved_shortcuts)

        self._reserved_shortcuts.Sort()

        self._original_custom_names = set()

        for shortcuts in custom_shortcuts:

            self._custom_shortcuts.AddDatas((shortcuts, ))

            self._original_custom_names.add(shortcuts.GetName())

        self._custom_shortcuts.Sort()

        #

        rows = []

        rows.append(('Replace "left/right"-click with "primary/secondary": ',
                     self._call_mouse_buttons_primary_secondary))

        mouse_gridbox = ClientGUICommon.WrapInGrid(self, rows)

        #

        button_hbox = QP.HBoxLayout()

        QP.AddToLayout(button_hbox, self._edit_reserved_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._restore_defaults_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        reserved_panel.Add(self._reserved_shortcuts,
                           CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        reserved_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT)

        #

        button_hbox = QP.HBoxLayout()

        QP.AddToLayout(button_hbox, self._add_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._edit_custom_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._delete_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        custom_panel_message = 'Custom shortcuts are advanced. They apply to the media viewer and must be turned on to take effect.'

        st = ClientGUICommon.BetterStaticText(custom_panel,
                                              custom_panel_message)
        st.setWordWrap(True)

        custom_panel.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        custom_panel.Add(self._custom_shortcuts,
                         CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        custom_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, help_button, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, mouse_gridbox, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, reserved_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, custom_panel, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.widget().setLayout(vbox)

        self._call_mouse_buttons_primary_secondary.clicked.connect(
            self._UpdateMouseLabels)
コード例 #6
0
    def __init__(self, parent, manager, job_key: ClientThreading.JobKey):

        PopupWindow.__init__(self, parent, manager)

        self.setSizePolicy(QW.QSizePolicy.MinimumExpanding,
                           QW.QSizePolicy.Fixed)

        self._job_key = job_key

        vbox = QP.VBoxLayout()

        self._title = ClientGUICommon.BetterStaticText(self)
        self._title.setAlignment(QC.Qt.AlignHCenter | QC.Qt.AlignVCenter)

        font = self._title.font()
        font.setBold(True)
        self._title.setFont(font)

        popup_message_character_width = HG.client_controller.new_options.GetInteger(
            'popup_message_character_width')

        popup_char_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._title, popup_message_character_width)

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

            #QP.SetMinClientSize( self, ( wrap_width, -1 ) )
            self.setFixedWidth(popup_char_width)

        else:

            self.setMaximumWidth(popup_char_width)

        self._title.setWordWrap(True)
        self._title_ev = QP.WidgetEventFilter(self._title)
        self._title_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._title.hide()

        self._text_1 = ClientGUICommon.BetterStaticText(self)
        self._text_1.setWordWrap(True)
        self._text_1_ev = QP.WidgetEventFilter(self._text_1)
        self._text_1_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_1.hide()

        self._gauge_1 = ClientGUICommon.Gauge(self)
        self._gauge_1_ev = QP.WidgetEventFilter(self._gauge_1)
        self._gauge_1_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._gauge_1.setMinimumWidth(int(popup_char_width * 0.9))
        self._gauge_1.hide()

        self._text_2 = ClientGUICommon.BetterStaticText(self)
        self._text_2.setWordWrap(True)
        self._text_2_ev = QP.WidgetEventFilter(self._text_2)
        self._text_2_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_2.hide()

        self._gauge_2 = ClientGUICommon.Gauge(self)
        self._gauge_2_ev = QP.WidgetEventFilter(self._gauge_2)
        self._gauge_2_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._gauge_2.setMinimumWidth(int(popup_char_width * 0.9))
        self._gauge_2.hide()

        self._text_yes_no = ClientGUICommon.BetterStaticText(self)
        self._text_yes_no_ev = QP.WidgetEventFilter(self._text_yes_no)
        self._text_yes_no_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_yes_no.hide()

        self._yes = ClientGUICommon.BetterButton(self, 'yes', self._YesButton)
        self._yes.hide()

        self._no = ClientGUICommon.BetterButton(self, 'no', self._NoButton)
        self._no.hide()

        self._network_job_ctrl = ClientGUINetworkJobControl.NetworkJobControl(
            self)
        self._network_job_ctrl.hide()

        self._copy_to_clipboard_button = ClientGUICommon.BetterButton(
            self, 'copy to clipboard', self.CopyToClipboard)
        self._copy_to_clipboard_button_ev = QP.WidgetEventFilter(
            self._copy_to_clipboard_button)
        self._copy_to_clipboard_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._copy_to_clipboard_button.hide()

        self._show_files_button = ClientGUICommon.BetterButton(
            self, 'show files', self.ShowFiles)
        self._show_files_button_ev = QP.WidgetEventFilter(
            self._show_files_button)
        self._show_files_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._show_files_button.hide()

        self._user_callable_button = ClientGUICommon.BetterButton(
            self, 'run command', self.CallUserCallable)
        self._user_callable_button_ev = QP.WidgetEventFilter(
            self._user_callable_button)
        self._user_callable_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._user_callable_button.hide()

        self._show_tb_button = ClientGUICommon.BetterButton(
            self, 'show traceback', self.ShowTB)
        self._show_tb_button_ev = QP.WidgetEventFilter(self._show_tb_button)
        self._show_tb_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._show_tb_button.hide()

        self._tb_text = ClientGUICommon.BetterStaticText(self)
        self._tb_text_ev = QP.WidgetEventFilter(self._tb_text)
        self._tb_text_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._tb_text.setWordWrap(True)
        self._tb_text.hide()

        self._copy_tb_button = ClientGUICommon.BetterButton(
            self, 'copy traceback information', self.CopyTB)
        self._copy_tb_button_ev = QP.WidgetEventFilter(self._copy_tb_button)
        self._copy_tb_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._copy_tb_button.hide()

        self._pause_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().pause, self.PausePlay)
        self._pause_button_ev = QP.WidgetEventFilter(self._pause_button)
        self._pause_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._pause_button.hide()

        self._cancel_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().stop, self.Cancel)
        self._cancel_button_ev = QP.WidgetEventFilter(self._cancel_button)
        self._cancel_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._cancel_button.hide()

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._pause_button, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._cancel_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        yes_no_hbox = QP.HBoxLayout()

        QP.AddToLayout(yes_no_hbox, self._yes, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(yes_no_hbox, self._no, CC.FLAGS_CENTER_PERPENDICULAR)

        QP.AddToLayout(vbox, self._title, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._gauge_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._gauge_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_yes_no, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, yes_no_hbox)
        QP.AddToLayout(vbox, self._network_job_ctrl)
        QP.AddToLayout(vbox, self._copy_to_clipboard_button)
        QP.AddToLayout(vbox, self._show_files_button)
        QP.AddToLayout(vbox, self._user_callable_button)
        QP.AddToLayout(vbox, self._show_tb_button)
        QP.AddToLayout(vbox, self._tb_text)
        QP.AddToLayout(vbox, self._copy_tb_button)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)
コード例 #7
0
 def __init__( self, parent, media ):
     
     self._hashes = set()
     
     for m in media:
         
         self._hashes.update( m.GetHashes() )
         
     
     CAC.ApplicationCommandProcessorMixin.__init__( self )
     ClientGUIDialogs.Dialog.__init__( self, parent, 'manage ratings for ' + HydrusData.ToHumanInt( len( self._hashes ) ) + ' files', position = 'topleft' )
     
     #
     
     like_services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_LIKE, ) )
     numerical_services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_NUMERICAL, ) )
     
     self._panels = []
     
     if len( like_services ) > 0:
         
         self._panels.append( self._LikePanel( self, like_services, media ) )
         
     
     if len( numerical_services ) > 0:
         
         self._panels.append( self._NumericalPanel( self, numerical_services, media ) )
         
     
     self._copy_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().copy, self._Copy )
     self._copy_button.setToolTip( 'Copy ratings to the clipboard.' )
     
     self._paste_button = ClientGUICommon.BetterBitmapButton( self, CC.global_pixmaps().paste, self._Paste )
     self._paste_button.setToolTip( 'Paste ratings from the clipboard.' )
     
     self._apply = QW.QPushButton( 'apply', self )
     self._apply.clicked.connect( self.EventOK )
     self._apply.setObjectName( 'HydrusAccept' )
     
     self._cancel = QW.QPushButton( 'cancel', self )
     self._cancel.clicked.connect( self.reject )
     self._cancel.setObjectName( 'HydrusCancel' )
     
     #
     
     vbox = QP.VBoxLayout()
     
     for panel in self._panels:
         
         QP.AddToLayout( vbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR )
         
     
     buttonbox = QP.HBoxLayout()
     
     QP.AddToLayout( buttonbox, self._copy_button, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( buttonbox, self._paste_button, CC.FLAGS_CENTER_PERPENDICULAR )
     
     QP.AddToLayout( vbox, buttonbox, CC.FLAGS_ON_RIGHT )
     
     buttonbox = QP.HBoxLayout()
     
     QP.AddToLayout( buttonbox, self._apply, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( buttonbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR )
     
     QP.AddToLayout( vbox, buttonbox, CC.FLAGS_ON_RIGHT )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     #
     
     self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler( self, [ 'global', 'media' ] )
コード例 #8
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)
コード例 #9
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_ON_RIGHT)
        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)