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.')
示例#3
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.')
示例#4
0
def GetYesYesNo( win, message, title = 'Are you sure?', yes_tuples = None, no_label = 'no' ):
    
    with ClientGUITopLevelWindowsPanels.DialogCustomButtonQuestion( win, title ) as dlg:
        
        panel = ClientGUIScrolledPanelsButtonQuestions.QuestionYesYesNoPanel( dlg, message, yes_tuples = yes_tuples, no_label = no_label )
        
        dlg.SetPanel( panel )
        
        if dlg.exec() == QW.QDialog.Accepted:
            
            return panel.GetValue()
            
        else:
            
            raise HydrusExceptions.CancelledException( 'Dialog cancelled.' )
示例#5
0
def EditPredicates(
    widget: QW.QWidget, predicates: typing.Collection[ClientSearch.Predicate]
) -> typing.List[ClientSearch.Predicate]:

    (editable_predicates,
     non_editable_predicates) = GetEditablePredicates(predicates)

    window = widget.window()

    from hydrus.client.gui import ClientGUITopLevelWindowsPanels

    if len(editable_predicates) == 1 and editable_predicates[0].IsInvertible():

        result = list(non_editable_predicates)
        result.append(editable_predicates[0].GetInverseCopy())

        return result

    elif len(editable_predicates) > 0:

        title = 'edit predicates'

        if len(editable_predicates) == 1:

            if list(editable_predicates)[0].GetType(
            ) == ClientSearch.PREDICATE_TYPE_OR_CONTAINER:

                title = 'edit OR predicate'

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

            panel = EditPredicatesPanel(dlg, predicates)

            dlg.SetPanel(panel)

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

                edited_predicates = panel.GetValue()

                HG.client_controller.new_options.PushRecentPredicates(
                    edited_predicates)

                result = list(non_editable_predicates)
                result.extend(edited_predicates)

                return result

    raise HydrusExceptions.CancelledException()
示例#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.' )