示例#1
0
 def _AddSomeDefaults( self, defaults_callable, add_callable ):
     
     defaults = defaults_callable()
     
     selected = False
     
     choice_tuples = [ ( default.GetName(), default, selected ) for default in defaults ]
     
     from hydrus.client.gui import ClientGUITopLevelWindowsPanels
     from hydrus.client.gui import ClientGUIScrolledPanelsEdit
     
     with ClientGUITopLevelWindowsPanels.DialogEdit( self, 'select the defaults to add' ) as dlg:
         
         panel = ClientGUIScrolledPanelsEdit.EditChooseMultiple( dlg, choice_tuples )
         
         dlg.SetPanel( panel )
         
         if dlg.exec() == QW.QDialog.Accepted:
             
             defaults_to_add = panel.GetValue()
             
             for default in defaults_to_add:
                 
                 add_callable( default )
                 
             
         
     
     self._listctrl.Sort()
def SelectFromList(win,
                   title,
                   choice_tuples,
                   value_to_select=None,
                   sort_tuples=True):

    with ClientGUITopLevelWindowsPanels.DialogEdit(win, title) as dlg:

        panel = ClientGUIScrolledPanelsEdit.EditSelectFromListPanel(
            dlg,
            choice_tuples,
            value_to_select=value_to_select,
            sort_tuples=sort_tuples)

        dlg.SetPanel(panel)

        if dlg.exec() == QW.QDialog.Accepted:

            result = panel.GetValue()

            return result

        else:

            raise HydrusExceptions.CancelledException('Dialog cancelled.')
def GetDeleteFilesJobs(win,
                       media,
                       default_reason,
                       suggested_file_service_key=None):

    title = 'Delete files?'

    with ClientGUITopLevelWindowsPanels.DialogEdit(
            win, title, frame_key='regular_center_dialog') as dlg:

        panel = ClientGUIScrolledPanelsEdit.EditDeleteFilesPanel(
            dlg,
            media,
            default_reason,
            suggested_file_service_key=suggested_file_service_key)

        dlg.SetPanel(panel)

        if panel.QuestionIsAlreadyResolved():

            (involves_physical_delete, jobs) = panel.GetValue()

            return (involves_physical_delete, jobs)

        if dlg.exec() == QW.QDialog.Accepted:

            (involves_physical_delete, jobs) = panel.GetValue()

            return (involves_physical_delete, jobs)

        else:

            raise HydrusExceptions.CancelledException('Dialog cancelled.')
示例#4
0
    def _SetTxtServices(self):

        services_manager = HG.client_controller.services_manager

        tag_services = services_manager.GetServices(HC.REAL_TAG_SERVICES)

        choice_tuples = [(service.GetName(), service.GetServiceKey(),
                          service.GetServiceKey()
                          in self._neighbouring_txt_tag_service_keys)
                         for service in tag_services]

        with ClientGUITopLevelWindowsPanels.DialogEdit(
                self, 'select tag services') as dlg:

            panel = ClientGUIScrolledPanelsEdit.EditChooseMultiple(
                dlg, choice_tuples)

            dlg.SetPanel(panel)

            if dlg.exec() == QW.QDialog.Accepted:

                self._neighbouring_txt_tag_service_keys = panel.GetValue()

                HG.client_controller.new_options.SetKeyList(
                    'default_neighbouring_txt_tag_service_keys',
                    self._neighbouring_txt_tag_service_keys)

        if len(self._neighbouring_txt_tag_service_keys) == 0:

            self._export_tag_txts.setChecked(False)

        self._UpdateTxtButton()
示例#5
0
def SelectFromListButtons(win, title, choice_tuples, message=''):

    if len(choice_tuples) == 1:

        ((text, data, tooltip), ) = choice_tuples

        return data

    with ClientGUITopLevelWindowsPanels.DialogEdit(win,
                                                   title,
                                                   hide_buttons=True) as dlg:

        panel = ClientGUIScrolledPanelsEdit.EditSelectFromListButtonsPanel(
            dlg, choice_tuples, message=message)

        dlg.SetPanel(panel)

        if dlg.exec() == QW.QDialog.Accepted:

            result = panel.GetValue()

            return result

        else:

            raise HydrusExceptions.CancelledException('Dialog cancelled.')
示例#6
0
def SelectMultipleFromList( win, title, choice_tuples ):
    
    with ClientGUITopLevelWindowsPanels.DialogEdit( win, title ) as dlg:
        
        panel = ClientGUIScrolledPanelsEdit.EditChooseMultiple( dlg, choice_tuples )
        
        dlg.SetPanel( panel )
        
        if dlg.exec() == QW.QDialog.Accepted:
            
            result = panel.GetValue()
            
            return result
            
        else:
            
            raise HydrusExceptions.CancelledException( 'Dialog cancelled.' )
示例#7
0
        def qt_code():

            title = 'subs test'

            with ClientGUITopLevelWindowsPanels.DialogEdit(None, title) as dlg:

                panel = ClientGUIScrolledPanelsEdit.EditSubscriptionsPanel(
                    dlg, [])

                dlg.SetPanel(panel)

                HG.test_controller.CallLaterQtSafe(dlg, 2, panel.Add)

                HG.test_controller.CallLaterQtSafe(dlg, 4, OKChildDialog,
                                                   panel)

                HG.test_controller.CallLaterQtSafe(dlg, 6, HitCancelButton,
                                                   dlg)

                result = dlg.exec()

                self.assertEqual(result, QW.QDialog.Rejected)
def EditFileNotes(win: QW.QWidget, media: ClientMedia.Media):

    names_to_notes = media.GetNotesManager().GetNamesToNotes()

    title = 'manage notes'

    with ClientGUITopLevelWindowsPanels.DialogEdit(win, title) as dlg:

        panel = ClientGUIScrolledPanelsEdit.EditFileNotesPanel(
            dlg, names_to_notes)

        dlg.SetPanel(panel)

        if dlg.exec() == QW.QDialog.Accepted:

            hash = media.GetHash()

            (names_to_notes, deletee_names) = panel.GetValue()

            content_updates = [
                HydrusData.ContentUpdate(HC.CONTENT_TYPE_NOTES,
                                         HC.CONTENT_UPDATE_SET,
                                         (hash, name, note))
                for (name, note) in names_to_notes.items()
            ]
            content_updates.extend([
                HydrusData.ContentUpdate(HC.CONTENT_TYPE_NOTES,
                                         HC.CONTENT_UPDATE_DELETE,
                                         (hash, name))
                for name in deletee_names
            ])

            service_keys_to_content_updates = {
                CC.LOCAL_NOTES_SERVICE_KEY: content_updates
            }

            HG.client_controller.Write('content_updates',
                                       service_keys_to_content_updates)