Ejemplo n.º 1
0
    def AddMenuButton(self,
                      label,
                      menu_items,
                      enabled_only_on_selection=False,
                      enabled_check_func=None):

        button = ClientGUIMenuButton.MenuButton(self, label, menu_items)

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

        self._UpdateButtons()
Ejemplo n.º 2
0
 def __init__( self, parent, service_key ):
     
     self._clientside_admin_service = HG.client_controller.services_manager.GetService( service_key )
     
     ClientGUIScrolledPanels.ManagePanel.__init__( self, parent )
     
     self._deletee_service_keys = []
     
     self._services_listctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_SERVICES.ID, 20, data_to_tuples_func = self._ConvertServiceToTuples, delete_key_callback = self._Delete, activation_callback = self._Edit )
     
     menu_items = []
     
     menu_items.append( ( 'normal', 'tag repository', 'Create a new tag repository.', self._AddTagRepository ) )
     menu_items.append( ( 'normal', 'file repository', 'Create a new file repository.', self._AddFileRepository ) )
     
     self._add_button = ClientGUIMenuButton.MenuButton( self, 'add', menu_items )
     
     self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit )
     
     self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete )
     
     #
     
     response = self._clientside_admin_service.Request( HC.GET, 'services' )
     
     serverside_services = response[ 'services' ]
     
     self._services_listctrl.AddDatas( serverside_services )
     
     #self._services_listctrl.SortListItems( 0 )
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._edit_button, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._services_listctrl, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT )
     
     self.widget().setLayout( vbox )
    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.º 4
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)