コード例 #1
0
    def __init__(self, parent, selectable_mimes):

        OptionsPanel.__init__(self, parent)

        self._selectable_mimes = set(selectable_mimes)

        self._mimes_to_checkboxes = {}
        self._general_mime_types_to_checkboxes = {}
        self._general_mime_types_to_buttons = {}

        general_mime_types = []

        general_mime_types.append(HC.GENERAL_IMAGE)
        general_mime_types.append(HC.GENERAL_ANIMATION)
        general_mime_types.append(HC.GENERAL_VIDEO)
        general_mime_types.append(HC.GENERAL_AUDIO)
        general_mime_types.append(HC.GENERAL_APPLICATION)

        gridbox = QP.GridLayout(cols=3)

        gridbox.setColumnStretch(2, 1)

        for general_mime_type in general_mime_types:

            mimes_in_type = self._GetMimesForGeneralMimeType(general_mime_type)

            if len(mimes_in_type) == 0:

                continue

            general_mime_checkbox = QW.QCheckBox(
                HC.mime_string_lookup[general_mime_type], self)
            general_mime_checkbox.clicked.connect(self.EventMimeGroupCheckbox)

            self._general_mime_types_to_checkboxes[
                general_mime_type] = general_mime_checkbox

            QP.AddToLayout(gridbox, general_mime_checkbox,
                           CC.FLAGS_CENTER_PERPENDICULAR)

            show_hide_button = ClientGUICommon.BetterButton(
                self, self.BUTTON_CURRENTLY_SHOWING, self._ButtonShowHide,
                general_mime_type)

            max_width = ClientGUIFunctions.ConvertTextToPixelWidth(
                show_hide_button, 5)

            show_hide_button.setMaximumWidth(max_width)

            self._general_mime_types_to_buttons[
                general_mime_type] = show_hide_button

            QP.AddToLayout(gridbox, show_hide_button,
                           CC.FLAGS_CENTER_PERPENDICULAR)

            vbox = QP.VBoxLayout()

            for mime in mimes_in_type:

                m_checkbox = QW.QCheckBox(HC.mime_string_lookup[mime], self)
                m_checkbox.clicked.connect(self.EventMimeCheckbox)

                self._mimes_to_checkboxes[mime] = m_checkbox

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

            QP.AddToLayout(gridbox, vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

        self.setLayout(gridbox)
コード例 #2
0
ファイル: ClientGUISearch.py プロジェクト: ReAnzu/hydrus
    def __init__(self, parent, predicate: ClientSearch.Predicate):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        predicate_type = predicate.GetType()

        self._predicates = []

        label = None
        editable_pred_panels = []
        static_pred_buttons = []

        recent_predicate_types = [predicate_type]

        if predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 0, 1, 0))), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 0, 7, 0))), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 1, 0, 0))), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemAgeDelta,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemModifiedDelta, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemModifiedDate,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH,
                ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 16, 9)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 9, 16)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 4, 3)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 1, 1)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1920)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 1080))),
                    forced_label='1080p'))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1280)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 720))),
                    forced_label='720p'))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 3840)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 2160))),
                    forced_label='4k'))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemHeight,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemWidth,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemRatio,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumPixels,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                        ('>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                        ('=', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                        ('=', 30)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                        ('=', 60)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemDuration,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemFramerate,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumFrames,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemFileService,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsExactURL, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsDomain, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsRegex, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsURLClass, predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO:

            recent_predicate_types = []

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
                        True), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
                        False), )))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemHash,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT:

            label = 'system:limit clips a large search result down to the given number of files. It is very useful for processing in smaller batches.'
            label += os.linesep * 2
            label += 'For all the simpler sorts (filesize, duration, etc...), it will select the n largest/smallest in the result set appropriate for that sort. For complicated sorts like tags, it will sample randomly.'

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 64), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 256), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 1024), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemLimit,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemMime,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
                        (None, '>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
                        (None, '=', 0)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumTags,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                        ('>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                        ('=', 0)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumNotes,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemHasNoteName,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumWords,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING:

            services_manager = HG.client_controller.services_manager

            ratings_services = services_manager.GetServices(
                (HC.LOCAL_RATING_LIKE, HC.LOCAL_RATING_NUMERICAL))

            if len(ratings_services) > 0:

                editable_pred_panels.append(
                    self._PredOKPanel(
                        self,
                        ClientGUIPredicatesMultiple.PanelPredicateSystemRating,
                        (predicate, )))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemSimilarTo,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemSize,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemTagAsNumber,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.
                        PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING,
                        False), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.
                        PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING,
                        True), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemDuplicateRelationships, predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemFileViewingStatsViews, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemFileViewingStatsViewtime, predicate))

        vbox = QP.VBoxLayout()

        if label is not None:

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

            st.setWordWrap(True)

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

        recent_predicates = []

        if len(recent_predicate_types) > 0:

            recent_predicates = HG.client_controller.new_options.GetRecentPredicates(
                recent_predicate_types)

            if len(recent_predicates) > 0:

                recent_predicates_box = ClientGUICommon.StaticBox(
                    self, 'recent')

                for recent_predicate in recent_predicates:

                    button = ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                        recent_predicates_box, self, (recent_predicate, ))

                    recent_predicates_box.Add(button,
                                              CC.FLAGS_EXPAND_PERPENDICULAR)

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

        for button in static_pred_buttons:

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

        for panel in editable_pred_panels:

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

        if len(static_pred_buttons) > 0 and len(editable_pred_panels) == 0:

            HG.client_controller.CallAfterQtSafe(
                static_pred_buttons[0], static_pred_buttons[0].setFocus,
                QC.Qt.OtherFocusReason)

        self.widget().setLayout(vbox)
コード例 #3
0
ファイル: ClientGUITime.py プロジェクト: HOZHENWAI/hydrus
    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_VCENTER)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'days'),
                           CC.FLAGS_VCENTER)

        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_VCENTER)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'hours'),
                           CC.FLAGS_VCENTER)

        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_VCENTER)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'minutes'),
                           CC.FLAGS_VCENTER)

        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_VCENTER)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'seconds'),
                           CC.FLAGS_VCENTER)

        if self._monthly_allowed:

            self._monthly = QW.QCheckBox(self)
            self._monthly.clicked.connect(self.EventChange)

            QP.AddToLayout(hbox, self._monthly, CC.FLAGS_VCENTER)
            QP.AddToLayout(
                hbox, ClientGUICommon.BetterStaticText(self, monthly_label),
                CC.FLAGS_VCENTER)

        self.setLayout(hbox)
コード例 #4
0
    def __init__(self, parent, 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.')

        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()

        #

        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()

        #

        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, reserved_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, custom_panel, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.widget().setLayout(vbox)
コード例 #5
0
 def __init__( self, parent, message, default = '', placeholder = None, allow_blank = False, suggestions = None, max_chars = None, password_entry = False, min_char_width = 72 ):
     
     if suggestions is None:
         
         suggestions = []
         
     
     Dialog.__init__( self, parent, 'enter text', position = 'center' )
     
     self._chosen_suggestion = None
     self._allow_blank = allow_blank
     self._max_chars = max_chars
     
     button_choices =  []
     
     for text in suggestions:
         
         button_choices.append( ClientGUICommon.BetterButton( self, text, self.ButtonChoice, text ) )
         
     
     self._text = QW.QLineEdit( self )
     self._text.textChanged.connect( self.EventText )
     self._text.installEventFilter( ClientGUICommon.TextCatchEnterEventFilter( self._text, self.EnterText ) )
     
     width = ClientGUIFunctions.ConvertTextToPixelWidth( self._text, min_char_width )
     
     self._text.setMinimumWidth( width )
     
     if password_entry:
         
         self._text.setEchoMode( QW.QLineEdit.Password )
         
     
     if self._max_chars is not None:
         
         self._text.setMaxLength( self._max_chars )
         
     
     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._text.setText( default )
     
     if placeholder is not None:
         
         self._text.setPlaceholderText( placeholder )
         
     
     if len( default ) > 0:
         
         self._text.setSelection( 0, len( default ) )
         
     
     self._CheckText()
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR )
     
     st_message = ClientGUICommon.BetterStaticText( self, message )
     st_message.setWordWrap( True )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, st_message, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     for button in button_choices:
         
         QP.AddToLayout( vbox, button, CC.FLAGS_EXPAND_PERPENDICULAR )
         
     
     QP.AddToLayout( vbox, self._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 )
コード例 #6
0
    def __init__(self, parent, api_permissions):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._original_api_permissions = api_permissions

        self._access_key = QW.QLineEdit()

        self._access_key.setReadOnly(True)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._access_key, 66)

        self.setMinimumWidth(width)

        self._name = QW.QLineEdit(self)

        self._basic_permissions = QP.CheckListBox(self)

        for permission in ClientAPI.ALLOWED_PERMISSIONS:

            self._basic_permissions.Append(
                ClientAPI.basic_permission_to_str_lookup[permission],
                permission)

        search_tag_filter = api_permissions.GetSearchTagFilter()

        message = 'The API will only permit searching for tags that pass through this filter.'
        message += os.linesep * 2
        message += 'If you want to allow all tags, just leave it as is, permitting everything. If you want to limit it to just one tag, such as "do waifu2x on this", set up a whitelist with only that tag allowed.'

        self._search_tag_filter = ClientGUITags.TagFilterButton(
            self, message, search_tag_filter, label_prefix='permitted tags: ')

        #

        access_key = api_permissions.GetAccessKey()

        self._access_key.setText(access_key.hex())

        name = api_permissions.GetName()

        self._name.setText(name)

        basic_permissions = api_permissions.GetBasicPermissions()

        self._basic_permissions.SetCheckedData(basic_permissions)

        #

        rows = []

        rows.append(('access key: ', self._access_key))
        rows.append(('name: ', self._name))
        rows.append(('permissions: ', self._basic_permissions))
        rows.append(('tag search permissions: ', self._search_tag_filter))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self.widget().setLayout(vbox)

        #

        self._UpdateEnabled()

        self._basic_permissions.checkListBoxChanged.connect(
            self._UpdateEnabled)
コード例 #7
0
    def __init__(self, parent, existing_folders_to_names, foldername, name,
                 file_search_context, synchronised, media_sort, media_collect):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._existing_folders_to_names = existing_folders_to_names
        self._original_folder_and_name = (foldername, name)

        self._foldername = QW.QLineEdit(self)
        self._name = QW.QLineEdit(self)

        self._media_sort = ClientGUISearch.MediaSortControl(self)
        self._media_collect = ClientGUISearch.MediaCollectControl(self,
                                                                  silent=True)

        page_key = HydrusData.GenerateKey()

        from hydrus.client.gui import ClientGUIACDropdown
        from hydrus.client.gui import ClientGUIListBoxes

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self,
            page_key,
            file_search_context,
            media_sort_widget=self._media_sort,
            media_collect_widget=self._media_collect,
            synchronised=synchronised,
            hide_favourites_edit_actions=True)

        self._include_media_sort = QW.QCheckBox(self)
        self._include_media_collect = QW.QCheckBox(self)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._include_media_collect, 48)

        self._include_media_collect.setMinimumWidth(width)

        self._include_media_sort.stateChanged.connect(self._UpdateWidgets)
        self._include_media_collect.stateChanged.connect(self._UpdateWidgets)

        #

        if foldername is not None:

            self._foldername.setText(foldername)

        self._name.setText(name)

        if media_sort is not None:

            self._include_media_sort.setChecked(True)

            self._media_sort.SetSort(media_sort)

        if media_collect is not None:

            self._include_media_collect.setChecked(True)

            self._media_collect.SetCollect(media_collect)

        #

        rows = []

        rows.append(('folder (blank for none): ', self._foldername))
        rows.append(('name: ', self._name))

        top_gridbox = ClientGUICommon.WrapInGrid(self, rows)

        rows = []

        rows.append(('save sort: ', self._include_media_sort))
        rows.append(('sort: ', self._media_sort))
        rows.append(('save collect: ', self._include_media_collect))
        rows.append(('collect: ', self._media_collect))

        bottom_gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, top_gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tag_autocomplete,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, bottom_gridbox,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self.widget().setLayout(vbox)
コード例 #8
0
    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)
コード例 #9
0
    def __init__(self, parent, service_key, subject_identifiers):

        Dialog.__init__(self, parent, 'modify account')

        self._service = HG.client_controller.services_manager.GetService(
            service_key)
        self._subject_identifiers = list(subject_identifiers)

        #

        self._account_info_panel = ClientGUICommon.StaticBox(
            self, 'account info')

        self._subject_text = QW.QLabel(self._account_info_panel)

        #

        self._account_types_panel = ClientGUICommon.StaticBox(
            self, 'account types')

        self._account_types = QW.QComboBox(self._account_types_panel)

        self._account_types_ok = QW.QPushButton('OK',
                                                self._account_types_panel)
        self._account_types_ok.clicked.connect(self.EventChangeAccountType)

        #

        self._expiration_panel = ClientGUICommon.StaticBox(
            self, 'change expiration')

        self._add_to_expires = QW.QComboBox(self._expiration_panel)

        self._add_to_expires_ok = QW.QPushButton('OK', self._expiration_panel)
        self._add_to_expires.clicked.connect(self.EventAddToExpires)

        self._set_expires = QW.QComboBox(self._expiration_panel)

        self._set_expires_ok = QW.QPushButton('OK', self._expiration_panel)
        self._set_expires_ok.clicked.connect(self.EventSetExpires)

        #

        self._ban_panel = ClientGUICommon.StaticBox(self, 'bans')

        self._ban = QW.QPushButton('ban user', self._ban_panel)
        self._ban.clicked.connect(self.EventBan)
        QP.SetBackgroundColour(self._ban, (255, 0, 0))
        QP.SetForegroundColour(self._ban, (255, 255, 0))

        self._superban = QW.QPushButton(
            'ban user and delete every contribution they have ever made',
            self._ban_panel)
        self._superban.clicked.connect(self.EventSuperban)
        QP.SetBackgroundColour(self._superban, (255, 0, 0))
        QP.SetForegroundColour(self._superban, (255, 255, 0))

        self._exit = QW.QPushButton('Exit', self)
        self._exit.clicked.connect(self.reject)

        #

        if len(self._subject_identifiers) == 1:

            (subject_identifier, ) = self._subject_identifiers

            response = self._service.Request(
                HC.GET, 'account_info',
                {'subject_identifier': subject_identifier})

            subject_string = str(response['account_info'])

        else:

            subject_string = 'modifying ' + HydrusData.ToHumanInt(
                len(self._subject_identifiers)) + ' accounts'

        self._subject_text.setText(subject_string)

        #

        response = self._service.Request(HC.GET, 'account_types')

        account_types = response['account_types']

        for account_type in account_types:
            self._account_types.addItem(account_type.ConvertToString(),
                                        account_type)

        self._account_types.setCurrentIndex(0)

        #

        for (label, value) in HC.lifetimes:

            if value is not None:

                self._add_to_expires.addItem(
                    label, value)  # don't want 'add no limit'

        self._add_to_expires.setCurrentIndex(1)  # three months

        for (label, value) in HC.lifetimes:

            self._set_expires.addItem(label, value)

        self._set_expires.setCurrentIndex(1)  # three months

        #

        self._account_info_panel.Add(self._subject_text,
                                     CC.FLAGS_EXPAND_PERPENDICULAR)

        account_types_hbox = QP.HBoxLayout()

        QP.AddToLayout(account_types_hbox, self._account_types,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(account_types_hbox, self._account_types_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._account_types_panel.Add(account_types_hbox,
                                      CC.FLAGS_EXPAND_PERPENDICULAR)

        add_to_expires_box = QP.HBoxLayout()

        QP.AddToLayout(add_to_expires_box,
                       QW.QLabel('add to expires: ', self._expiration_panel),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(add_to_expires_box, self._add_to_expires,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(add_to_expires_box, self._add_to_expires_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        set_expires_box = QP.HBoxLayout()

        QP.AddToLayout(set_expires_box,
                       QW.QLabel('set expires to: ', self._expiration_panel),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(set_expires_box, self._set_expires,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(set_expires_box, self._set_expires_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._expiration_panel.Add(add_to_expires_box,
                                   CC.FLAGS_EXPAND_PERPENDICULAR)
        self._expiration_panel.Add(set_expires_box,
                                   CC.FLAGS_EXPAND_PERPENDICULAR)

        self._ban_panel.Add(self._ban, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._ban_panel.Add(self._superban, CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox = QP.VBoxLayout()
        QP.AddToLayout(vbox, self._account_info_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._account_types_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._expiration_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._ban_panel, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._exit, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._exit, self._exit.setFocus,
                                             QC.Qt.OtherFocusReason)
コード例 #10
0
    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)
コード例 #11
0
    def __init__(self,
                 parent,
                 service_key,
                 tags,
                 expand_parents=True,
                 message=''):

        Dialog.__init__(self, parent, 'input tags')

        self._service_key = service_key

        self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove(
            self, service_key=service_key)

        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)
コード例 #12
0
    def __init__(self,
                 parent,
                 share_key,
                 name,
                 text,
                 timeout,
                 hashes,
                 new_share=False):

        Dialog.__init__(self, parent, 'configure local booru share')

        self._name = QW.QLineEdit(self)

        self._text = QW.QPlainTextEdit(self)
        self._text.setMinimumHeight(100)

        message = 'expires in'

        self._timeout_number = ClientGUICommon.NoneableSpinCtrl(
            self,
            message,
            none_phrase='no expiration',
            max=1000000,
            multiplier=1)

        self._timeout_multiplier = ClientGUICommon.BetterChoice(self)
        self._timeout_multiplier.addItem('minutes', 60)
        self._timeout_multiplier.addItem('hours', 60 * 60)
        self._timeout_multiplier.addItem('days', 60 * 60 * 24)

        self._copy_internal_share_link = QW.QPushButton(
            'copy internal share link', self)
        self._copy_internal_share_link.clicked.connect(
            self.EventCopyInternalShareURL)

        self._copy_external_share_link = QW.QPushButton(
            'copy external share link', self)
        self._copy_external_share_link.clicked.connect(
            self.EventCopyExternalShareURL)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.accept)
        self._ok.setObjectName('HydrusAccept')

        self._cancel = QW.QPushButton('cancel', self)
        self._cancel.clicked.connect(self.reject)
        self._cancel.setObjectName('HydrusCancel')

        #

        self._share_key = share_key
        self._name.setText(name)
        self._text.setPlainText(text)

        if timeout is None:

            self._timeout_number.SetValue(None)

            self._timeout_multiplier.SetValue(60)

        else:

            time_left = HydrusData.GetTimeDeltaUntilTime(timeout)

            if time_left < 60 * 60 * 12: time_value = 60
            elif time_left < 60 * 60 * 24 * 7: time_value = 60 * 60
            else: time_value = 60 * 60 * 24

            self._timeout_number.SetValue(time_left // time_value)

            self._timeout_multiplier.SetValue(time_value)

        self._hashes = hashes

        self._service = HG.client_controller.services_manager.GetService(
            CC.LOCAL_BOORU_SERVICE_KEY)

        internal_port = self._service.GetPort()

        if internal_port is None:

            self._copy_internal_share_link.setEnabled(False)
            self._copy_external_share_link.setEnabled(False)

        #

        rows = []

        rows.append(('share name: ', self._name))
        rows.append(('share text: ', self._text))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        timeout_box = QP.HBoxLayout()
        QP.AddToLayout(timeout_box, self._timeout_number,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(timeout_box, self._timeout_multiplier,
                       CC.FLAGS_EXPAND_BOTH_WAYS)

        link_box = QP.HBoxLayout()
        QP.AddToLayout(link_box, self._copy_internal_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(link_box, self._copy_external_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        b_box = QP.HBoxLayout()
        QP.AddToLayout(b_box, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(b_box, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        intro = 'Sharing ' + HydrusData.ToHumanInt(len(
            self._hashes)) + ' files.'
        intro += os.linesep + 'Title and text are optional.'

        if new_share:
            intro += os.linesep + 'The link will not work until you ok this dialog.'

        QP.AddToLayout(vbox, ClientGUICommon.BetterStaticText(self, intro),
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, timeout_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, link_box, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 350))

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus,
                                             QC.Qt.OtherFocusReason)
コード例 #13
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 += ' - {}'.format(
                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)
コード例 #14
0
    def __init__(self, parent, service_key, media, activate_callable):

        QW.QWidget.__init__(self, parent)

        self._service_key = service_key
        self._media = media

        self._new_options = HG.client_controller.new_options

        layout_mode = self._new_options.GetNoneableString(
            'suggested_tags_layout')

        self._notebook = None

        if layout_mode == 'notebook':

            self._notebook = ClientGUICommon.BetterNotebook(self)

            panel_parent = self._notebook

        else:

            panel_parent = self

        panels = []

        self._favourite_tags = None

        favourites = HG.client_controller.new_options.GetSuggestedTagsFavourites(
            self._service_key)

        if len(favourites) > 0:

            self._favourite_tags = FavouritesTagsPanel(panel_parent,
                                                       service_key, media,
                                                       activate_callable)

            panels.append(('favourites', self._favourite_tags))

        self._related_tags = None

        if self._new_options.GetBoolean('show_related_tags') and len(
                media) == 1:

            self._related_tags = RelatedTagsPanel(panel_parent, service_key,
                                                  media, activate_callable)

            panels.append(('related', self._related_tags))

        self._file_lookup_script_tags = None

        if self._new_options.GetBoolean(
                'show_file_lookup_script_tags') and len(media) == 1:

            self._file_lookup_script_tags = FileLookupScriptTagsPanel(
                panel_parent, service_key, media, activate_callable)

            panels.append(
                ('file lookup scripts', self._file_lookup_script_tags))

        self._recent_tags = None

        if self._new_options.GetNoneableInteger('num_recent_tags') is not None:

            self._recent_tags = RecentTagsPanel(panel_parent, service_key,
                                                media, activate_callable)

            panels.append(('recent', self._recent_tags))

        hbox = QP.HBoxLayout()

        if layout_mode == 'notebook':

            for (name, panel) in panels:

                self._notebook.addTab(panel, name)

            QP.AddToLayout(hbox, self._notebook, CC.FLAGS_EXPAND_BOTH_WAYS)

        elif layout_mode == 'columns':

            for (name, panel) in panels:

                QP.AddToLayout(hbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.setLayout(hbox)

        if len(panels) == 0:

            self.hide()
コード例 #15
0
    def __init__(self, parent, export_folder: ClientExporting.ExportFolder):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._export_folder = export_folder

        (name, path, export_type, delete_from_client_after_export,
         file_search_context, run_regularly, period, phrase,
         self._last_checked, paused, run_now) = self._export_folder.ToTuple()

        self._path_box = ClientGUICommon.StaticBox(self, 'name and location')

        self._name = QW.QLineEdit(self._path_box)

        self._path = QP.DirPickerCtrl(self._path_box)

        #

        self._type_box = ClientGUICommon.StaticBox(self, 'type of export')

        self._type = ClientGUICommon.BetterChoice(self._type_box)
        self._type.addItem('regular', HC.EXPORT_FOLDER_TYPE_REGULAR)
        self._type.addItem('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE)

        self._delete_from_client_after_export = QW.QCheckBox(self._type_box)

        #

        self._query_box = ClientGUICommon.StaticBox(self, 'query to export')

        self._page_key = 'export folders placeholder'

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self._query_box,
            self._page_key,
            file_search_context,
            allow_all_known_files=False,
            force_system_everything=True)

        #

        self._period_box = ClientGUICommon.StaticBox(self, 'export period')

        self._period = ClientGUITime.TimeDeltaButton(self._period_box,
                                                     min=3 * 60,
                                                     days=True,
                                                     hours=True,
                                                     minutes=True)

        self._run_regularly = QW.QCheckBox(self._period_box)

        self._paused = QW.QCheckBox(self._period_box)

        self._run_now = QW.QCheckBox(self._period_box)

        #

        self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = QW.QLineEdit(self._phrase_box)

        self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box)

        #

        self._name.setText(name)

        self._path.SetPath(path)

        self._type.SetValue(export_type)

        self._delete_from_client_after_export.setChecked(
            delete_from_client_after_export)

        self._period.SetValue(period)

        self._run_regularly.setChecked(run_regularly)

        self._paused.setChecked(paused)

        self._run_now.setChecked(run_now)

        self._pattern.setText(phrase)

        #

        rows = []

        rows.append(('name: ', self._name))
        rows.append(('folder path: ', self._path))

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

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

        #

        text = '''regular - try to export the files to the directory, overwriting if the filesize if different

synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory

If you select synchronise, be careful!'''

        st = ClientGUICommon.BetterStaticText(self._type_box, label=text)
        st.setWordWrap(True)

        self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('delete files from client after export: ',
                     self._delete_from_client_after_export))

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

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

        self._query_box.Add(self._tag_autocomplete)

        self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('run regularly?: ', self._run_regularly))
        rows.append(('paused: ', self._paused))
        rows.append(('run on dialog ok: ', self._run_now))

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

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

        phrase_hbox = QP.HBoxLayout()

        QP.AddToLayout(phrase_hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(phrase_hbox, self._examples,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        self._UpdateTypeDeleteUI()

        self._type.currentIndexChanged.connect(self._UpdateTypeDeleteUI)
        self._delete_from_client_after_export.clicked.connect(
            self.EventDeleteFilesAfterExport)
コード例 #16
0
    def __init__(self, parent):

        title = 'manage local upnp'

        ClientGUIDialogs.Dialog.__init__(self, parent, title)

        self._status_st = ClientGUICommon.BetterStaticText(self)

        self._mappings_listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(
            self)

        self._mappings_list = ClientGUIListCtrl.BetterListCtrl(
            self._mappings_listctrl_panel,
            CGLC.COLUMN_LIST_MANAGE_UPNP_MAPPINGS.ID,
            12,
            self._ConvertDataToListCtrlTuples,
            delete_key_callback=self._Remove,
            activation_callback=self._Edit)

        self._mappings_listctrl_panel.SetListCtrl(self._mappings_list)

        self._mappings_listctrl_panel.AddButton('add custom mapping',
                                                self._Add)
        self._mappings_listctrl_panel.AddButton(
            'edit mapping', self._Edit, enabled_only_on_single_selection=True)
        self._mappings_listctrl_panel.AddButton('remove mapping',
                                                self._Remove,
                                                enabled_only_on_selection=True)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._mappings_listctrl_panel,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._ok, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 760))

        QP.SetInitialSize(self, size_hint)

        #

        self._mappings_lookup = set()

        self._mappings_list.Sort()

        self._external_ip = None

        self._started_external_ip_fetch = False

        self._RefreshMappings()
コード例 #17
0
    def __init__(self, parent, flat_media, do_export_and_then_quit=False):

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        new_options = HG.client_controller.new_options

        self._media_to_paths = {}
        self._existing_filenames = set()
        self._last_phrase_used = ''
        self._last_dir_used = ''

        self._tags_box = ClientGUIListBoxes.StaticBoxSorterForListBoxTags(
            self, 'files\' tags')

        services_manager = HG.client_controller.services_manager

        self._neighbouring_txt_tag_service_keys = services_manager.FilterValidServiceKeys(
            new_options.GetKeyList(
                'default_neighbouring_txt_tag_service_keys'))

        t = ClientGUIListBoxes.ListBoxTagsMedia(self._tags_box,
                                                ClientTags.TAG_DISPLAY_ACTUAL,
                                                include_counts=True)

        self._tags_box.SetTagsBox(t)

        self._tags_box.setMinimumSize(QC.QSize(220, 300))

        self._paths = ClientGUIListCtrl.BetterListCtrl(
            self,
            CGLC.COLUMN_LIST_EXPORT_FILES.ID,
            24,
            self._ConvertDataToListCtrlTuples,
            use_simple_delete=True)

        self._paths.Sort()

        self._export_path_box = ClientGUICommon.StaticBox(self, 'export path')

        self._directory_picker = QP.DirPickerCtrl(self._export_path_box)
        self._directory_picker.dirPickerChanged.connect(self._RefreshPaths)

        self._open_location = QW.QPushButton('open this location',
                                             self._export_path_box)
        self._open_location.clicked.connect(self.EventOpenLocation)

        self._filenames_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = QW.QLineEdit(self._filenames_box)

        self._update = QW.QPushButton('update', self._filenames_box)
        self._update.clicked.connect(self._RefreshPaths)

        self._examples = ClientGUICommon.ExportPatternButton(
            self._filenames_box)

        self._delete_files_after_export = QW.QCheckBox(
            'delete files from client after export?', self)
        self._delete_files_after_export.setObjectName('HydrusWarning')

        self._export_symlinks = QW.QCheckBox('EXPERIMENTAL: export symlinks',
                                             self)
        self._export_symlinks.setObjectName('HydrusWarning')

        text = 'This will export all the files\' tags, newline separated, into .txts beside the files themselves.'

        self._export_tag_txts_services_button = ClientGUICommon.BetterButton(
            self, 'set .txt services', self._SetTxtServices)

        self._export_tag_txts = QW.QCheckBox('export tags to .txt files?',
                                             self)
        self._export_tag_txts.setToolTip(text)
        self._export_tag_txts.clicked.connect(self.EventExportTagTxtsChanged)

        self._export = QW.QPushButton('export', self)
        self._export.clicked.connect(self._DoExport)

        #

        export_path = ClientExporting.GetExportPath()

        self._directory_picker.SetPath(export_path)

        phrase = new_options.GetString('export_phrase')

        self._pattern.setText(phrase)

        if len(self._neighbouring_txt_tag_service_keys) > 0:

            self._export_tag_txts.setChecked(True)

        self._paths.SetData(list(enumerate(flat_media)))

        self._delete_files_after_export.setChecked(
            HG.client_controller.new_options.GetBoolean(
                'delete_files_after_export'))
        self._delete_files_after_export.clicked.connect(
            self.EventDeleteFilesChanged)

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

            self._export_symlinks.setVisible(False)

        #

        top_hbox = QP.HBoxLayout()

        QP.AddToLayout(top_hbox, self._tags_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(top_hbox, self._paths, CC.FLAGS_EXPAND_BOTH_WAYS)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._directory_picker, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._open_location,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._export_path_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._update, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._examples, CC.FLAGS_CENTER_PERPENDICULAR)

        self._filenames_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        txt_hbox = QP.HBoxLayout()

        QP.AddToLayout(txt_hbox, self._export_tag_txts_services_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(txt_hbox, self._export_tag_txts,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, top_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        QP.AddToLayout(vbox, self._export_path_box,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._filenames_box,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._delete_files_after_export,
                       CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, self._export_symlinks, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, txt_hbox, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, self._export, CC.FLAGS_ON_RIGHT)

        self.widget().setLayout(vbox)

        self._RefreshTags()

        self._UpdateTxtButton()

        HG.client_controller.CallAfterQtSafe(self._export,
                                             self._export.setFocus,
                                             QC.Qt.OtherFocusReason)

        self._paths.itemSelectionChanged.connect(self._RefreshTags)

        if do_export_and_then_quit:

            QP.CallAfter(self._DoExport, True)
コード例 #18
0
    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)
コード例 #19
0
    def __init__(self, parent, manager, job_key):

        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 = ClientGUIControls.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._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._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)
コード例 #20
0
    def __init__(self, parent: QW.QWidget, command: CAC.ApplicationCommand,
                 shortcuts_name: str):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        #

        is_custom_or_media = shortcuts_name not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES or shortcuts_name == 'media'

        self._panel_choice = ClientGUICommon.BetterChoice(self)

        self._panel_choice.addItem('simple command', self.PANEL_SIMPLE)

        if is_custom_or_media:

            self._panel_choice.addItem('tag command', self.PANEL_TAG)
            self._panel_choice.addItem('like/dislike rating command',
                                       self.PANEL_RATING_LIKE)
            self._panel_choice.addItem('numerical rating command',
                                       self.PANEL_RATING_NUMERICAL)
            self._panel_choice.addItem(
                'numerical rating increment/decrement command',
                self.PANEL_RATING_NUMERICAL_INCDEC)

        else:

            self._panel_choice.hide()

        self._simple_sub_panel = SimpleSubPanel(self, shortcuts_name)

        self._tag_sub_panel = TagSubPanel(self)

        self._rating_like_sub_panel = RatingLikeSubPanel(self)

        self._rating_numerical_sub_panel = RatingNumericalSubPanel(self)

        self._rating_numerical_inc_dec_sub_panel = RatingNumericalIncDecSubPanel(
            self)

        #

        data = command.GetData()

        if command.IsSimpleCommand():

            action = data

            self._simple_sub_panel.SetValue(action)

            self._panel_choice.SetValue(self.PANEL_SIMPLE)

        elif command.IsContentCommand():

            service_key = command.GetContentServiceKey()

            if HG.client_controller.services_manager.ServiceExists(
                    service_key):

                service = HG.client_controller.services_manager.GetService(
                    service_key)

                action = command.GetContentAction()
                value = command.GetContentValue()

            else:

                QW.QMessageBox.warning(
                    self, 'Warning',
                    'The service that this command relies upon no longer exists! This command will reset to a default form.'
                )

                local_tag_services = list(
                    HG.client_controller.services_manager.GetServices(
                        (HC.LOCAL_TAG, )))

                service = local_tag_services[0]

                service_key = service.GetServiceKey()
                action = HC.CONTENT_UPDATE_SET
                value = 'tag'

            service_type = service.GetServiceType()

            if service_type in HC.REAL_TAG_SERVICES:

                tag = value

                self._tag_sub_panel.SetValue(action, service_key, tag)

                self._panel_choice.SetValue(self.PANEL_TAG)

            elif service_type == HC.LOCAL_RATING_LIKE:

                rating = value

                self._rating_like_sub_panel.SetValue(action, service_key,
                                                     rating)

                self._panel_choice.SetValue(self.PANEL_RATING_LIKE)

            elif service_type == HC.LOCAL_RATING_NUMERICAL:

                if action in (HC.CONTENT_UPDATE_SET, HC.CONTENT_UPDATE_FLIP):

                    rating = value

                    self._rating_numerical_sub_panel.SetValue(
                        action, service_key, rating)

                    self._panel_choice.SetValue(self.PANEL_RATING_NUMERICAL)

                elif action in (HC.CONTENT_UPDATE_INCREMENT,
                                HC.CONTENT_UPDATE_DECREMENT):

                    distance = 1

                    self._rating_numerical_inc_dec_sub_panel.SetValue(
                        action, service_key, distance)

                    self._panel_choice.SetValue(
                        self.PANEL_RATING_NUMERICAL_INCDEC)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._panel_choice, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._simple_sub_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tag_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_like_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_numerical_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_numerical_inc_dec_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        vbox.addStretch(1)

        self.widget().setLayout(vbox)

        self._UpdateVisibleControls()

        #

        self._panel_choice.currentIndexChanged.connect(
            self._UpdateVisibleControls)
コード例 #21
0
    def __init__(self, parent, command, shortcuts_name):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._current_ratings_like_service = None
        self._current_ratings_numerical_service = None

        #

        is_custom_or_media = shortcuts_name not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES or shortcuts_name == 'media'

        self._command_type_choice = ClientGUICommon.BetterChoice(self)

        self._command_type_choice.addItem('simple command',
                                          self.COMMAND_TYPE_PANEL_SIMPLE)

        if is_custom_or_media:

            self._command_type_choice.addItem('tag command',
                                              self.COMMAND_TYPE_PANEL_TAG)
            self._command_type_choice.addItem(
                'like/dislike rating command',
                self.COMMAND_TYPE_PANEL_RATING_LIKE)
            self._command_type_choice.addItem(
                'numerical rating command',
                self.COMMAND_TYPE_PANEL_RATING_NUMERICAL)
            self._command_type_choice.addItem(
                'numerical rating increment/decrement command',
                self.COMMAND_TYPE_PANEL_RATING_NUMERICAL_INCDEC)

        else:

            self._command_type_choice.hide()

        if shortcuts_name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            choices = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[
                shortcuts_name]

        else:

            choices = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[
                'custom']

        choices = list(choices)

        choices.sort()

        self._simple_actions = QW.QComboBox(self)
        self._simple_actions.addItems(choices)

        #

        self._flip_or_set_action = ClientGUICommon.BetterChoice(self)

        self._flip_or_set_action.addItem('set', HC.CONTENT_UPDATE_SET)
        self._flip_or_set_action.addItem('flip on and off',
                                         HC.CONTENT_UPDATE_FLIP)

        self._flip_or_set_action.SetValue(HC.CONTENT_UPDATE_SET)

        #

        self._tag_panel = QW.QWidget(self)

        self._tag_service_keys = QW.QComboBox(self._tag_panel)

        self._tag_value = QW.QLineEdit()
        self._tag_value.setReadOnly(True)

        expand_parents = False

        self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite(
            self._tag_panel, self.SetTags, expand_parents,
            CC.LOCAL_FILE_SERVICE_KEY, CC.COMBINED_TAG_SERVICE_KEY)

        #

        self._ratings_like_panel = QW.QWidget(self)

        self._ratings_like_service_keys = QW.QComboBox(
            self._ratings_like_panel)
        self._ratings_like_service_keys.currentIndexChanged.connect(
            self._SetActions)
        self._ratings_like_like = QW.QRadioButton('like',
                                                  self._ratings_like_panel)
        self._ratings_like_dislike = QW.QRadioButton('dislike',
                                                     self._ratings_like_panel)
        self._ratings_like_remove = QW.QRadioButton('remove rating',
                                                    self._ratings_like_panel)

        #

        self._ratings_numerical_panel = QW.QWidget(self)

        self._ratings_numerical_service_keys = QW.QComboBox(
            self._ratings_numerical_panel)
        self._ratings_numerical_service_keys.currentIndexChanged.connect(
            self._SetActions)
        self._ratings_numerical_slider = QP.LabelledSlider(
            self._ratings_numerical_panel)
        self._ratings_numerical_remove = QW.QCheckBox(
            'remove rating', self._ratings_numerical_panel)

        #

        self._ratings_numerical_incdec_panel = QW.QWidget(self)

        self._ratings_numerical_incdec_service_keys = QW.QComboBox(
            self._ratings_numerical_incdec_panel)

        self._ratings_numerical_incdec = ClientGUICommon.BetterChoice(
            self._ratings_numerical_incdec_panel)

        self._ratings_numerical_incdec.addItem(
            HC.content_update_string_lookup[HC.CONTENT_UPDATE_INCREMENT],
            HC.CONTENT_UPDATE_INCREMENT)
        self._ratings_numerical_incdec.addItem(
            HC.content_update_string_lookup[HC.CONTENT_UPDATE_DECREMENT],
            HC.CONTENT_UPDATE_DECREMENT)

        #

        services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_TAG, HC.TAG_REPOSITORY, HC.LOCAL_RATING_LIKE,
             HC.LOCAL_RATING_NUMERICAL))

        for service in services:

            service_name = service.GetName()
            service_key = service.GetServiceKey()

            service_type = service.GetServiceType()

            if service_type in HC.REAL_TAG_SERVICES:

                self._tag_service_keys.addItem(service_name, service_key)

            elif service_type == HC.LOCAL_RATING_LIKE:

                self._ratings_like_service_keys.addItem(
                    service_name, service_key)

            elif service_type == HC.LOCAL_RATING_NUMERICAL:

                self._ratings_numerical_service_keys.addItem(
                    service_name, service_key)
                self._ratings_numerical_incdec_service_keys.addItem(
                    service_name, service_key)

        self._SetActions()

        #

        command_type = command.GetCommandType()
        data = command.GetData()

        if command_type == CC.APPLICATION_COMMAND_TYPE_SIMPLE:

            action = data

            QP.SetStringSelection(self._simple_actions, action)

            self._command_type_choice.SetValue(self.COMMAND_TYPE_PANEL_SIMPLE)

        else:

            (service_key, content_type, action, value) = data

            if HG.client_controller.services_manager.ServiceExists(
                    service_key):

                self._service = HG.client_controller.services_manager.GetService(
                    service_key)

            else:

                QW.QMessageBox.warning(
                    self, 'Warning',
                    'The service that this command relies upon no longer exists! This command will reset to a default form.'
                )

                local_tag_services = list(
                    HG.client_controller.services_manager.GetServices(
                        (HC.LOCAL_TAG, )))

                self._service = local_tag_services[0]

                content_type = HC.CONTENT_TYPE_MAPPINGS
                action = HC.CONTENT_UPDATE_SET

                value = 'tag'

            service_name = self._service.GetName()
            service_type = self._service.GetServiceType()

            self._flip_or_set_action.SetValue(action)

            if service_type in HC.REAL_TAG_SERVICES:

                QP.SetStringSelection(self._tag_service_keys, service_name)

                self._tag_value.setText(value)

                self._command_type_choice.SetValue(self.COMMAND_TYPE_PANEL_TAG)

            elif service_type == HC.LOCAL_RATING_LIKE:

                QP.SetStringSelection(self._ratings_like_service_keys,
                                      service_name)

                self._SetActions()

                if value is None:

                    self._ratings_like_remove.setChecked(True)

                elif value == True:

                    self._ratings_like_like.setChecked(True)

                elif value == False:

                    self._ratings_like_dislike.setChecked(True)

                self._command_type_choice.SetValue(
                    self.COMMAND_TYPE_PANEL_RATING_LIKE)

            elif service_type == HC.LOCAL_RATING_NUMERICAL:

                if action in (HC.CONTENT_UPDATE_SET, HC.CONTENT_UPDATE_FLIP):

                    QP.SetStringSelection(self._ratings_numerical_service_keys,
                                          service_name)

                    self._SetActions()

                    if value is None:

                        self._ratings_numerical_remove.setChecked(True)

                    else:

                        num_stars = self._current_ratings_numerical_service.GetNumStars(
                        )

                        slider_value = int(round(value * num_stars))

                        self._ratings_numerical_slider.SetValue(slider_value)

                    self._command_type_choice.SetValue(
                        self.COMMAND_TYPE_PANEL_RATING_NUMERICAL)

                elif action in (HC.CONTENT_UPDATE_INCREMENT,
                                HC.CONTENT_UPDATE_DECREMENT):

                    QP.SetStringSelection(
                        self._ratings_numerical_incdec_service_keys,
                        service_name)

                    self._ratings_numerical_incdec.SetValue(action)

                    self._command_type_choice.SetValue(
                        self.COMMAND_TYPE_PANEL_RATING_NUMERICAL_INCDEC)

        #

        tag_sub_vbox = QP.VBoxLayout()

        QP.AddToLayout(tag_sub_vbox, self._tag_value,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(tag_sub_vbox, self._tag_input,
                       CC.FLAGS_EXPAND_BOTH_WAYS)

        tag_hbox = QP.HBoxLayout()

        QP.AddToLayout(tag_hbox, self._tag_service_keys,
                       CC.FLAGS_EXPAND_DEPTH_ONLY)
        QP.AddToLayout(tag_hbox, tag_sub_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

        self._tag_panel.setLayout(tag_hbox)

        ratings_like_hbox = QP.HBoxLayout()

        QP.AddToLayout(ratings_like_hbox, self._ratings_like_service_keys,
                       CC.FLAGS_EXPAND_DEPTH_ONLY)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_like,
                       CC.FLAGS_VCENTER)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_dislike,
                       CC.FLAGS_VCENTER)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_remove,
                       CC.FLAGS_VCENTER)

        self._ratings_like_panel.setLayout(ratings_like_hbox)

        ratings_numerical_hbox = QP.HBoxLayout()

        QP.AddToLayout(ratings_numerical_hbox,
                       self._ratings_numerical_service_keys,
                       CC.FLAGS_EXPAND_DEPTH_ONLY)
        QP.AddToLayout(ratings_numerical_hbox, self._ratings_numerical_slider,
                       CC.FLAGS_VCENTER)
        QP.AddToLayout(ratings_numerical_hbox, self._ratings_numerical_remove,
                       CC.FLAGS_VCENTER)

        self._ratings_numerical_panel.setLayout(ratings_numerical_hbox)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._ratings_numerical_incdec_service_keys,
                       CC.FLAGS_EXPAND_DEPTH_ONLY)
        QP.AddToLayout(hbox, self._ratings_numerical_incdec, CC.FLAGS_VCENTER)

        self._ratings_numerical_incdec_panel.setLayout(hbox)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._command_type_choice,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._simple_actions,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._flip_or_set_action,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tag_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._ratings_like_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._ratings_numerical_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._ratings_numerical_incdec_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, QW.QWidget(self), CC.FLAGS_EXPAND_BOTH_WAYS)

        self.widget().setLayout(vbox)

        self._UpdateVisibleControls()

        #

        self._command_type_choice.currentIndexChanged.connect(
            self._UpdateVisibleControls)
コード例 #22
0
    def __init__(self, parent):

        title = 'manage local upnp'

        ClientGUIDialogs.Dialog.__init__(self, parent, title)

        self._status_st = ClientGUICommon.BetterStaticText(self)

        listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        columns = [('description', -1), ('internal ip', 17),
                   ('internal port', 7), ('external port', 7),
                   ('prototcol', 5), ('lease', 12)]

        self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl(
            listctrl_panel,
            'manage_upnp_mappings',
            12,
            36,
            columns,
            self._ConvertDataToListCtrlTuples,
            delete_key_callback=self._Remove,
            activation_callback=self._Edit)

        listctrl_panel.SetListCtrl(self._mappings_list_ctrl)

        listctrl_panel.AddButton('add custom mapping', self._Add)
        listctrl_panel.AddButton('edit mapping',
                                 self._Edit,
                                 enabled_only_on_selection=True)
        listctrl_panel.AddButton('remove mapping',
                                 self._Remove,
                                 enabled_only_on_selection=True)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._ok, CC.FLAGS_LONE_BUTTON)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 760))

        QP.SetInitialSize(self, size_hint)

        #

        self._mappings = []

        self._mappings_list_ctrl.Sort(0)

        self._started_external_ip_fetch = False

        self._RefreshMappings()
コード例 #23
0
    def __init__(self, parent, shortcuts: ClientGUIShortcuts.ShortcutSet):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._name = QW.QLineEdit(self)

        self._shortcuts_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._shortcuts = ClientGUIListCtrl.BetterListCtrl(
            self._shortcuts_panel,
            CGLC.COLUMN_LIST_SHORTCUTS.ID,
            20,
            data_to_tuples_func=self._ConvertSortTupleToPrettyTuple,
            delete_key_callback=self.RemoveShortcuts,
            activation_callback=self.EditShortcuts)

        self._shortcuts_panel.SetListCtrl(self._shortcuts)

        self._shortcuts_panel.AddImportExportButtons(
            (ClientGUIShortcuts.ShortcutSet, ),
            self._AddShortcutSet,
            custom_get_callable=self._GetSelectedShortcutSet)

        self._shortcuts.setMinimumSize(QC.QSize(360, 480))

        self._add = QW.QPushButton('add', self)
        self._add.clicked.connect(self.AddShortcut)

        self._edit = QW.QPushButton('edit', self)
        self._edit.clicked.connect(self.EditShortcuts)

        self._remove = QW.QPushButton('remove', self)
        self._remove.clicked.connect(self.RemoveShortcuts)

        #

        name = shortcuts.GetName()

        self._name.setText(name)

        self._this_is_custom = True

        if name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            self._this_is_custom = False

            self._name.setEnabled(False)

        self._shortcuts.AddDatas(shortcuts)

        self._shortcuts.Sort()

        #

        action_buttons = QP.HBoxLayout()

        QP.AddToLayout(action_buttons, self._add,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._edit,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._remove,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox,
                       ClientGUICommon.WrapInText(self._name, self, 'name: '),
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if name in ClientGUIShortcuts.shortcut_names_to_descriptions:

            description_text = ClientGUIShortcuts.shortcut_names_to_descriptions[
                name]

            description = ClientGUICommon.BetterStaticText(
                self, description_text, description_text)

            description.setWordWrap(True)

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

        QP.AddToLayout(vbox, self._shortcuts_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, action_buttons, CC.FLAGS_ON_RIGHT)

        self.widget().setLayout(vbox)
コード例 #24
0
ファイル: ClientGUITime.py プロジェクト: HOZHENWAI/hydrus
    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)
コード例 #25
0
 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 )
コード例 #26
0
ファイル: ClientGUIControls.py プロジェクト: ReAnzu/hydrus
        def __init__(self, parent, rule):

            ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

            self._bandwidth_type = ClientGUICommon.BetterChoice(self)

            self._bandwidth_type.addItem('data', HC.BANDWIDTH_TYPE_DATA)
            self._bandwidth_type.addItem('requests',
                                         HC.BANDWIDTH_TYPE_REQUESTS)

            self._bandwidth_type.currentIndexChanged.connect(
                self._UpdateEnabled)

            self._max_allowed_bytes = BytesControl(self)
            self._max_allowed_requests = QP.MakeQSpinBox(self,
                                                         min=1,
                                                         max=1048576)

            self._time_delta = ClientGUITime.TimeDeltaButton(
                self,
                min=1,
                days=True,
                hours=True,
                minutes=True,
                seconds=True,
                monthly_allowed=True)

            #

            (bandwidth_type, time_delta, max_allowed) = rule

            self._bandwidth_type.SetValue(bandwidth_type)

            self._time_delta.SetValue(time_delta)

            if bandwidth_type == HC.BANDWIDTH_TYPE_DATA:

                self._max_allowed_bytes.SetValue(max_allowed)

            else:

                self._max_allowed_requests.setValue(max_allowed)

            self._UpdateEnabled()

            #

            hbox = QP.HBoxLayout()

            QP.AddToLayout(hbox, self._max_allowed_bytes,
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox, self._max_allowed_requests,
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox, self._bandwidth_type,
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, ' every '),
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox, self._time_delta,
                           CC.FLAGS_CENTER_PERPENDICULAR)

            self.widget().setLayout(hbox)