def __init__(self, parent, management_controller=None, silent=False):

        QW.QWidget.__init__(self, parent)

        # this is trash, rewrite it to deal with the media_collect object, not the management controller

        self._management_controller = management_controller

        if self._management_controller is not None and self._management_controller.HasVariable(
                'media_collect'):

            self._media_collect = self._management_controller.GetVariable(
                'media_collect')

        else:

            self._media_collect = HG.client_controller.new_options.GetDefaultCollect(
            )

        self._silent = silent

        self._collect_comboctrl = QP.CollectComboCtrl(self,
                                                      self._media_collect)

        choice_tuples = [('collect unmatched', True),
                         ('leave unmatched', False)]

        self._collect_unmatched = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._collect_unmatched, 19)

        self._collect_unmatched.setMinimumWidth(width)

        #

        self._collect_unmatched.SetValue(self._media_collect.collect_unmatched)

        #

        hbox = QP.HBoxLayout(margin=0)

        QP.AddToLayout(hbox, self._collect_comboctrl,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._collect_unmatched,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)

        #

        self._UpdateLabel()

        self._collect_unmatched.valueChanged.connect(self.CollectValuesChanged)
        self._collect_comboctrl.itemChanged.connect(self.CollectValuesChanged)

        self._collect_comboctrl.installEventFilter(self)

        HG.client_controller.sub(self, 'SetCollectFromPage',
                                 'set_page_collect')
Ejemplo n.º 2
0
    def __init__(self,
                 parent: QW.QWidget,
                 tag_sort: ClientTagSorting.TagSort,
                 show_siblings=False):

        QW.QWidget.__init__(self, parent)

        choice_tuples = [
            (ClientTagSorting.sort_type_str_lookup[sort_type], sort_type)
            for sort_type in (ClientTagSorting.SORT_BY_HUMAN_TAG,
                              ClientTagSorting.SORT_BY_HUMAN_SUBTAG,
                              ClientTagSorting.SORT_BY_COUNT)
        ]

        self._sort_type = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        choice_tuples = [('a-z', CC.SORT_ASC), ('z-a', CC.SORT_DESC)]

        self._sort_order_text = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        choice_tuples = [('most first', CC.SORT_DESC),
                         ('fewest first', CC.SORT_ASC)]

        self._sort_order_count = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        self._show_siblings = show_siblings

        choice_tuples = [('siblings', True), ('tags', False)]

        self._use_siblings = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        choice_tuples = [('no grouping', ClientTagSorting.GROUP_BY_NOTHING),
                         ('group namespace',
                          ClientTagSorting.GROUP_BY_NAMESPACE)]

        self._group_by = ClientGUIMenuButton.MenuChoiceButton(
            self, choice_tuples)

        #

        self.SetValue(tag_sort)

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._sort_type, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._sort_order_text,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._sort_order_count,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._use_siblings, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._group_by, CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)

        #

        self._sort_type.valueChanged.connect(
            self._UpdateControlsAfterSortTypeChanged)

        self._sort_type.valueChanged.connect(self._HandleValueChanged)
        self._sort_order_text.valueChanged.connect(self._HandleValueChanged)
        self._sort_order_count.valueChanged.connect(self._HandleValueChanged)
        self._use_siblings.valueChanged.connect(self._HandleValueChanged)
        self._group_by.valueChanged.connect(self._HandleValueChanged)
    def __init__(self, parent, management_controller=None):

        QW.QWidget.__init__(self, parent)

        self._management_controller = management_controller

        self._sort_type = ('system', CC.SORT_FILES_BY_FILESIZE)

        self._sort_type_button = ClientGUICommon.BetterButton(
            self, 'sort', self._SortTypeButtonClick)
        self._sort_tag_display_type_button = ClientGUIMenuButton.MenuChoiceButton(
            self, [])
        self._sort_order_choice = ClientGUIMenuButton.MenuChoiceButton(
            self, [])

        type_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._sort_type_button, 14)

        self._sort_type_button.setMinimumWidth(type_width)

        tdt_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._sort_tag_display_type_button, 8)

        self._sort_tag_display_type_button.setMinimumWidth(tdt_width)

        asc_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._sort_order_choice, 14)

        self._sort_order_choice.setMinimumWidth(asc_width)

        self._UpdateSortTypeLabel()
        self._UpdateAscDescLabelsAndDefault()

        #

        hbox = QP.HBoxLayout(margin=0)

        QP.AddToLayout(hbox, self._sort_type_button, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._sort_tag_display_type_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._sort_order_choice,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)

        HG.client_controller.sub(self, 'ACollectHappened',
                                 'a_collect_happened')
        HG.client_controller.sub(self, 'BroadcastSort', 'do_page_sort')

        if self._management_controller is not None and self._management_controller.HasVariable(
                'media_sort'):

            media_sort = self._management_controller.GetVariable('media_sort')

            try:

                self.SetSort(media_sort)

            except:

                default_sort = ClientMedia.MediaSort(
                    ('system', CC.SORT_FILES_BY_FILESIZE), CC.SORT_ASC)

                self.SetSort(default_sort)

        self._sort_tag_display_type_button.valueChanged.connect(
            self.EventTagDisplayTypeChoice)
        self._sort_order_choice.valueChanged.connect(self.EventSortAscChoice)