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)

        expand_parents = False

        self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite(
            self, self.SetTags, expand_parents, CC.LOCAL_FILE_SERVICE_KEY,
            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)

        #

        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)
 def __init__( self, parent, service_key, tags, expand_parents = True, message = '', show_sibling_text = False ):
     
     Dialog.__init__( self, parent, 'input tags' )
     
     self._service_key = service_key
     
     self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove( self, service_key = service_key, show_sibling_text = show_sibling_text )
     
     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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)