def __init__(self, parent: QW.QWidget, predicate: ClientSearch.Predicate):

        QW.QWidget.__init__(self, parent)

        from hydrus.client.gui.search import ClientGUIACDropdown

        if predicate.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER:

            raise Exception(
                'Launched an ORPredicateControl without an OR Pred!')

        predicates = predicate.GetValue()

        page_key = HydrusData.GenerateKey()

        file_search_context = ClientSearch.FileSearchContext(
            file_service_key=CC.LOCAL_FILE_SERVICE_KEY, predicates=predicates)

        self._search_control = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self,
            page_key,
            file_search_context,
            hide_favourites_edit_actions=True)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._search_control, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)
Exemple #2
0
 def __init__( self, parent: QW.QWidget ):
     
     QW.QWidget.__init__( self, parent )
     
     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._tag_value = QW.QLineEdit( self )
     self._tag_value.setReadOnly( True )
     
     default_location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext()
     
     self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.SetTags, default_location_context, CC.COMBINED_TAG_SERVICE_KEY )
     
     #
     
     services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_TAG, HC.TAG_REPOSITORY ) )
     
     for service in services:
         
         service_name = service.GetName()
         service_key = service.GetServiceKey()
         
         self._service_keys.addItem( service_name, service_key )
         
     
     self._tag_input.SetTagServiceKey( self._service_keys.GetValue() )
     
     #
     
     vbox = QP.VBoxLayout()
     
     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_SIZER_BOTH_WAYS )
     
     tag_hbox = QP.HBoxLayout()
     
     QP.AddToLayout( tag_hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH )
     QP.AddToLayout( tag_hbox, tag_sub_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
     
     QP.AddToLayout( vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, tag_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     self.setLayout( vbox )
     
     #
     
     self._service_keys.currentIndexChanged.connect( self._NewServiceKey )
Exemple #3
0
 def __init__( self, parent, service_key, tag_display_type, tags, message = '' ):
     
     Dialog.__init__( self, parent, 'input tags' )
     
     self._service_key = service_key
     
     self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove( self, service_key, tag_display_type )
     
     self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.EnterTags, 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)
Exemple #4
0
    def __init__(self, parent: QW.QWidget, predicate: ClientSearch.Predicate):

        QW.QWidget.__init__(self, parent)

        from hydrus.client.gui.search import ClientGUIACDropdown

        if predicate.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER:

            raise Exception(
                'Launched an ORPredicateControl without an OR Pred!')

        predicates = predicate.GetValue()

        page_key = HydrusData.GenerateKey()

        location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext(
        )

        file_search_context = ClientSearch.FileSearchContext(
            location_context=location_context, predicates=predicates)

        self._search_control = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self,
            page_key,
            file_search_context,
            hide_favourites_edit_actions=True)

        self._search_control.setMinimumWidth(
            ClientGUIFunctions.ConvertTextToPixelWidth(self._search_control,
                                                       64))

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._search_control, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        ClientGUIFunctions.SetFocusLater(self._search_control)
Exemple #5
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 = ClientGUIResultsSortCollect.MediaSortControl(self)
        self._media_collect = ClientGUIResultsSortCollect.MediaCollectControl(
            self, silent=True)

        page_key = HydrusData.GenerateKey()

        from hydrus.client.gui.search import ClientGUIACDropdown

        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)
Exemple #6
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)
Exemple #7
0
    def __init__(self,
                 parent,
                 service_key,
                 tag_display_type,
                 tags,
                 message=''):

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

        self._service_key = service_key

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

        default_location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext(
        )

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite(
            self,
            self.EnterTags,
            default_location_context,
            service_key,
            show_paste_button=True)

        self._tag_autocomplete.nullEntered.connect(self.OK)

        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)

        ClientGUIFunctions.SetFocusLater(self._tag_autocomplete)