def __init__( self, parent ):
     
     Dialog.__init__( self, parent, 'how to set up the account?', position = 'center' )
     
     register_message = 'I want to initialise a new account with the server. I have a registration key (a key starting with \'r\').'
     
     self._register = QW.QPushButton( register_message, self )
     self._register.clicked.connect( self.EventRegister )
     
     setup_message = 'The account is already initialised; I just want to add it to this client. I have a normal access key.'
     
     self._setup = QW.QPushButton( setup_message, self )
     self._setup.clicked.connect( self.accept )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._register, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment('-or-', self, QC.Qt.AlignHCenter | QC.Qt.AlignVCenter ), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._setup, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     self._should_register = False
     
     HG.client_controller.CallAfterQtSafe( self._register, self._register.setFocus, QC.Qt.OtherFocusReason )
 def __init__( self, parent, external_port, protocol_type, internal_port, description, duration ):
     
     Dialog.__init__( self, parent, 'configure upnp mapping' )
     
     self._external_port = QP.MakeQSpinBox( self, min=0, max=65535 )
     
     self._protocol_type = ClientGUICommon.BetterChoice( self )
     self._protocol_type.addItem( 'TCP', 'TCP' )
     self._protocol_type.addItem( 'UDP', 'UDP' )
     
     self._internal_port = QP.MakeQSpinBox( self, min=0, max=65535 )
     self._description = QW.QLineEdit( self )
     self._duration = QP.MakeQSpinBox( self, min=0, max=86400 )
     
     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._external_port.setValue( external_port )
     
     if protocol_type == 'TCP': self._protocol_type.setCurrentIndex( 0 )
     elif protocol_type == 'UDP': self._protocol_type.setCurrentIndex( 1 )
     
     self._internal_port.setValue( internal_port )
     self._description.setText( description )
     self._duration.setValue( duration )
     
     #
     
     rows = []
     
     rows.append( ( 'external port: ', self._external_port ) )
     rows.append( ( 'protocol type: ', self._protocol_type ) )
     rows.append( ( 'internal port: ', self._internal_port ) )
     rows.append( ( 'description: ', self._description ) )
     rows.append( ( 'duration (0 = indefinite): ', self._duration ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     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()
     
     QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
     QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     HG.client_controller.CallAfterQtSafe( self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
    def __init__(self,
                 parent,
                 message,
                 title='Are you sure?',
                 yes_tuples=None,
                 no_label='no'):

        if yes_tuples is None:

            yes_tuples = [('yes', 'yes')]

        Dialog.__init__(self, parent, title, position='center')

        self._value = None

        yes_buttons = []

        for (label, data) in yes_tuples:

            yes_button = ClientGUICommon.BetterButton(self, label, self._DoYes,
                                                      data)
            yes_button.setObjectName('HydrusAccept')

            yes_buttons.append(yes_button)

        self._no = ClientGUICommon.BetterButton(self, no_label, self.done,
                                                QW.QDialog.Rejected)
        self._no.setObjectName('HydrusCancel')

        #

        hbox = QP.HBoxLayout()

        for yes_button in yes_buttons:

            QP.AddToLayout(hbox, yes_button, CC.FLAGS_CENTER_PERPENDICULAR)

        QP.AddToLayout(hbox, self._no, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        text = ClientGUICommon.BetterStaticText(self, message)
        text.setWordWrap(True)

        QP.AddToLayout(vbox, text, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 250))

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(yes_buttons[0],
                                             yes_buttons[0].setFocus,
                                             QC.Qt.OtherFocusReason)
Ejemplo n.º 4
0
    def __init__(self, parent):

        title = 'manage local upnp'

        ClientGUIDialogs.Dialog.__init__(self, parent, title)

        self._status_st = ClientGUICommon.BetterStaticText(self)

        listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl(
            listctrl_panel,
            CGLC.COLUMN_LIST_MANAGE_UPNP_MAPPINGS.ID,
            12,
            self._ConvertDataToListCtrlTuples,
            delete_key_callback=self._Remove,
            activation_callback=self._Edit)

        listctrl_panel.SetListCtrl(self._mappings_list_ctrl)

        listctrl_panel.AddButton('add custom mapping', self._Add)
        listctrl_panel.AddButton('edit mapping',
                                 self._Edit,
                                 enabled_only_on_selection=True)
        listctrl_panel.AddButton('remove mapping',
                                 self._Remove,
                                 enabled_only_on_selection=True)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._ok, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 760))

        QP.SetInitialSize(self, size_hint)

        #

        self._mappings = []

        self._mappings_list_ctrl.Sort()

        self._started_external_ip_fetch = False

        self._RefreshMappings()
 def __init__( self, parent, namespace = '', regex = '' ):
     
     Dialog.__init__( self, parent, 'configure quick namespace' )
     
     self._namespace = QW.QLineEdit( self )
     
     self._regex = QW.QLineEdit( self )
     
     self._shortcuts = ClientGUICommon.RegexButton( self )
     
     self._regex_intro_link = ClientGUICommon.BetterHyperLink( self, 'a good regex introduction', 'https://www.aivosto.com/vbtips/regex.html' )
     self._regex_practise_link = ClientGUICommon.BetterHyperLink( self, 'regex practice', 'https://regexr.com/3cvmf' )
     
     self._ok = QW.QPushButton( 'OK', self )
     self._ok.clicked.connect( self.EventOK )
     self._ok.setObjectName( 'HydrusAccept' )
     
     self._cancel = QW.QPushButton( 'Cancel', self )
     self._cancel.clicked.connect( self.reject )
     self._cancel.setObjectName( 'HydrusCancel' )
     
     #
 
     self._namespace.setText( namespace )
     self._regex.setText( regex )
     
     #
     
     control_box = QP.HBoxLayout()
     
     QP.AddToLayout( control_box, self._namespace, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( control_box, ClientGUICommon.BetterStaticText(self,':'), CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( control_box, self._regex, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     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()
     
     intro = r'Put the namespace (e.g. page) on the left.' + os.linesep + r'Put the regex (e.g. [1-9]+\d*(?=.{4}$)) on the right.' + os.linesep + r'All files will be tagged with "namespace:regex".'
     
     QP.AddToLayout( vbox, ClientGUICommon.BetterStaticText(self,intro), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, control_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     QP.AddToLayout( vbox, self._shortcuts, CC.FLAGS_ON_RIGHT )
     QP.AddToLayout( vbox, self._regex_intro_link, CC.FLAGS_ON_RIGHT )
     QP.AddToLayout( vbox, self._regex_practise_link, CC.FLAGS_ON_RIGHT )
     QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     HG.client_controller.CallAfterQtSafe( self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
 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)
Ejemplo n.º 7
0
    def __init__(self, key_type, keys):

        if key_type == 'registration': title = 'Registration Keys'
        elif key_type == 'access': title = 'Access Keys'

        # have to give it a parent so we won't get garbage collected, use the main gui
        ClientGUITopLevelWindows.Frame.__init__(
            self, HG.client_controller.gui,
            HG.client_controller.PrepStringForDisplay(title))

        self._key_type = key_type
        self._keys = keys

        #

        self._text_ctrl = QW.QPlainTextEdit(self)
        self._text_ctrl.setLineWrapMode(QW.QPlainTextEdit.NoWrap)
        self._text_ctrl.setReadOnly(True)

        self._save_to_file = QW.QPushButton('save to file', self)
        self._save_to_file.clicked.connect(self.EventSaveToFile)

        self._done = QW.QPushButton('done', self)
        self._done.clicked.connect(self.close)

        #

        if key_type == 'registration': prepend = 'r'
        else: prepend = ''

        self._text = os.linesep.join(
            [prepend + key.hex() for key in self._keys])

        self._text_ctrl.setPlainText(self._text)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._text_ctrl, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._save_to_file, CC.FLAGS_LONE_BUTTON)
        QP.AddToLayout(vbox, self._done, CC.FLAGS_LONE_BUTTON)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 500))
        size_hint.setHeight(max(size_hint.height(), 200))

        QP.SetInitialSize(self, size_hint)

        self.show()
    def __init__(self, parent, url_tree):

        Dialog.__init__(self, parent, 'select items')

        self._tree = QP.TreeWidgetWithInheritedCheckState(self)

        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')

        #

        (text_gumpf, name, size, children) = url_tree

        root_name = self._RenderItemName(name, size)

        root_item = QW.QTreeWidgetItem()
        root_item.setText(0, root_name)
        root_item.setCheckState(0, QC.Qt.Checked)
        self._tree.addTopLevelItem(root_item)

        self._AddDirectory(root_item, children)

        root_item.setExpanded(True)

        #

        button_hbox = QP.HBoxLayout()

        QP.AddToLayout(button_hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._cancel,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._tree, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, button_hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 640))
        size_hint.setHeight(max(size_hint.height(), 640))

        QP.SetInitialSize(self, size_hint)
Ejemplo n.º 9
0
 def __init__( self, parent ):
     
     title = 'manage local upnp'
     
     ClientGUIDialogs.Dialog.__init__( self, parent, title )
     
     self._status_st = ClientGUICommon.BetterStaticText( self )
     
     listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel( self )
     
     columns = [ ( 'description', -1 ), ( 'internal ip', 17 ), ( 'internal port', 7 ), ( 'external port', 7 ), ( 'prototcol', 5 ), ( 'lease', 12 ) ]
     
     self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl( listctrl_panel, 'manage_upnp_mappings', 12, 36, columns, self._ConvertDataToListCtrlTuples, delete_key_callback = self._Remove, activation_callback = self._Edit )
     
     listctrl_panel.SetListCtrl( self._mappings_list_ctrl )
     
     listctrl_panel.AddButton( 'add custom mapping', self._Add )
     listctrl_panel.AddButton( 'edit mapping', self._Edit, enabled_only_on_selection = True )
     listctrl_panel.AddButton( 'remove mapping', self._Remove, enabled_only_on_selection = True )
     
     self._ok = QW.QPushButton( 'ok', self )
     self._ok.clicked.connect( self.EventOK )
     self._ok.setObjectName( 'HydrusAccept' )
     
     #
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, self._ok, CC.FLAGS_LONE_BUTTON )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     size_hint.setWidth( max( size_hint.width(), 760 ) )
     
     QP.SetInitialSize( self, size_hint )
     
     #
     
     self._mappings = []
     
     self._mappings_list_ctrl.Sort( 0 )
     
     self._started_external_ip_fetch = False
     
     self._RefreshMappings()
Ejemplo n.º 10
0
    def __init__( self, parent ):
        
        Dialog.__init__( self, parent, 'select imageboard' )
        
        self._tree = QW.QTreeWidget( self )
        self._tree.itemActivated.connect( self.EventActivate )
        
        #
        
        all_imageboards = HG.client_controller.Read( 'imageboards' )
        
        root_item = QW.QTreeWidgetItem()
        root_item.setText( 0, 'all sites' )
        self._tree.addTopLevelItem( root_item )
        
        for ( site, imageboards ) in list(all_imageboards.items()):

            site_item = QW.QTreeWidgetItem()
            site_item.setText( 0, site )
            root_item.addChild( site_item )
            
            for imageboard in imageboards:
                
                name = imageboard.GetName()

                imageboard_item = QW.QTreeWidgetItem()
                imageboard_item.setText( 0, name )
                imageboard_item.setData( 0, QC.Qt.UserRole, imageboard )
                site_item.addChild( imageboard_item )
                
            
        
        root_item.setExpanded( True )
        
        #
        
        vbox = QP.VBoxLayout()
        
        QP.AddToLayout( vbox, self._tree, CC.FLAGS_EXPAND_BOTH_WAYS )
        
        self.setLayout( vbox )
        
        size_hint = self.sizeHint()
        
        size_hint.setWidth( max( size_hint.width(), 320 ) )
        size_hint.setHeight( max( size_hint.height(), 640 ) )
        
        QP.SetInitialSize( self, size_hint )
Ejemplo n.º 11
0
    def __init__(self, parent):

        Dialog.__init__(self,
                        parent,
                        'how to set up the account?',
                        position='center')

        register_message = 'I want to initialise a new account with the server. I have a registration token (a hexadecimal key starting with \'r\').'

        self._register = QW.QPushButton(register_message, self)
        self._register.clicked.connect(self.EventRegister)

        setup_message = 'The account is already initialised; I just want to add it to this client. I have a normal access key.'

        self._setup = QW.QPushButton(setup_message, self)
        self._setup.clicked.connect(self.accept)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._register, CC.FLAGS_EXPAND_PERPENDICULAR)

        st = ClientGUICommon.BetterStaticText(self, '-or-')

        st.setAlignment(QC.Qt.AlignCenter)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._setup, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        self._should_register = False

        ClientGUIFunctions.SetFocusLater(self._register)
    def __init__(self, parent, service_key, subject_identifiers):

        Dialog.__init__(self, parent, 'modify account')

        self._service = HG.client_controller.services_manager.GetService(
            service_key)
        self._subject_identifiers = list(subject_identifiers)

        #

        self._account_info_panel = ClientGUICommon.StaticBox(
            self, 'account info')

        self._subject_text = QW.QLabel(self._account_info_panel)

        #

        self._account_types_panel = ClientGUICommon.StaticBox(
            self, 'account types')

        self._account_types = QW.QComboBox(self._account_types_panel)

        self._account_types_ok = QW.QPushButton('OK',
                                                self._account_types_panel)
        self._account_types_ok.clicked.connect(self.EventChangeAccountType)

        #

        self._expiration_panel = ClientGUICommon.StaticBox(
            self, 'change expiration')

        self._add_to_expires = QW.QComboBox(self._expiration_panel)

        self._add_to_expires_ok = QW.QPushButton('OK', self._expiration_panel)
        self._add_to_expires.clicked.connect(self.EventAddToExpires)

        self._set_expires = QW.QComboBox(self._expiration_panel)

        self._set_expires_ok = QW.QPushButton('OK', self._expiration_panel)
        self._set_expires_ok.clicked.connect(self.EventSetExpires)

        #

        self._ban_panel = ClientGUICommon.StaticBox(self, 'bans')

        self._ban = QW.QPushButton('ban user', self._ban_panel)
        self._ban.clicked.connect(self.EventBan)
        QP.SetBackgroundColour(self._ban, (255, 0, 0))
        QP.SetForegroundColour(self._ban, (255, 255, 0))

        self._superban = QW.QPushButton(
            'ban user and delete every contribution they have ever made',
            self._ban_panel)
        self._superban.clicked.connect(self.EventSuperban)
        QP.SetBackgroundColour(self._superban, (255, 0, 0))
        QP.SetForegroundColour(self._superban, (255, 255, 0))

        self._exit = QW.QPushButton('Exit', self)
        self._exit.clicked.connect(self.reject)

        #

        if len(self._subject_identifiers) == 1:

            (subject_identifier, ) = self._subject_identifiers

            response = self._service.Request(
                HC.GET, 'account_info',
                {'subject_identifier': subject_identifier})

            subject_string = str(response['account_info'])

        else:

            subject_string = 'modifying ' + HydrusData.ToHumanInt(
                len(self._subject_identifiers)) + ' accounts'

        self._subject_text.setText(subject_string)

        #

        response = self._service.Request(HC.GET, 'account_types')

        account_types = response['account_types']

        for account_type in account_types:
            self._account_types.addItem(account_type.ConvertToString(),
                                        account_type)

        self._account_types.setCurrentIndex(0)

        #

        for (label, value) in HC.lifetimes:

            if value is not None:

                self._add_to_expires.addItem(
                    label, value)  # don't want 'add no limit'

        self._add_to_expires.setCurrentIndex(1)  # three months

        for (label, value) in HC.lifetimes:

            self._set_expires.addItem(label, value)

        self._set_expires.setCurrentIndex(1)  # three months

        #

        self._account_info_panel.Add(self._subject_text,
                                     CC.FLAGS_EXPAND_PERPENDICULAR)

        account_types_hbox = QP.HBoxLayout()

        QP.AddToLayout(account_types_hbox, self._account_types,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(account_types_hbox, self._account_types_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._account_types_panel.Add(account_types_hbox,
                                      CC.FLAGS_EXPAND_PERPENDICULAR)

        add_to_expires_box = QP.HBoxLayout()

        QP.AddToLayout(add_to_expires_box,
                       QW.QLabel('add to expires: ', self._expiration_panel),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(add_to_expires_box, self._add_to_expires,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(add_to_expires_box, self._add_to_expires_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        set_expires_box = QP.HBoxLayout()

        QP.AddToLayout(set_expires_box,
                       QW.QLabel('set expires to: ', self._expiration_panel),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(set_expires_box, self._set_expires,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(set_expires_box, self._set_expires_ok,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._expiration_panel.Add(add_to_expires_box,
                                   CC.FLAGS_EXPAND_PERPENDICULAR)
        self._expiration_panel.Add(set_expires_box,
                                   CC.FLAGS_EXPAND_PERPENDICULAR)

        self._ban_panel.Add(self._ban, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._ban_panel.Add(self._superban, CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox = QP.VBoxLayout()
        QP.AddToLayout(vbox, self._account_info_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._account_types_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._expiration_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._ban_panel, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._exit, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._exit, self._exit.setFocus,
                                             QC.Qt.OtherFocusReason)
    def __init__(self,
                 parent,
                 share_key,
                 name,
                 text,
                 timeout,
                 hashes,
                 new_share=False):

        Dialog.__init__(self, parent, 'configure local booru share')

        self._name = QW.QLineEdit(self)

        self._text = QW.QPlainTextEdit(self)
        self._text.setMinimumHeight(100)

        message = 'expires in'

        self._timeout_number = ClientGUICommon.NoneableSpinCtrl(
            self,
            message,
            none_phrase='no expiration',
            max=1000000,
            multiplier=1)

        self._timeout_multiplier = ClientGUICommon.BetterChoice(self)
        self._timeout_multiplier.addItem('minutes', 60)
        self._timeout_multiplier.addItem('hours', 60 * 60)
        self._timeout_multiplier.addItem('days', 60 * 60 * 24)

        self._copy_internal_share_link = QW.QPushButton(
            'copy internal share link', self)
        self._copy_internal_share_link.clicked.connect(
            self.EventCopyInternalShareURL)

        self._copy_external_share_link = QW.QPushButton(
            'copy external share link', self)
        self._copy_external_share_link.clicked.connect(
            self.EventCopyExternalShareURL)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.accept)
        self._ok.setObjectName('HydrusAccept')

        self._cancel = QW.QPushButton('cancel', self)
        self._cancel.clicked.connect(self.reject)
        self._cancel.setObjectName('HydrusCancel')

        #

        self._share_key = share_key
        self._name.setText(name)
        self._text.setPlainText(text)

        if timeout is None:

            self._timeout_number.SetValue(None)

            self._timeout_multiplier.SetValue(60)

        else:

            time_left = HydrusData.GetTimeDeltaUntilTime(timeout)

            if time_left < 60 * 60 * 12: time_value = 60
            elif time_left < 60 * 60 * 24 * 7: time_value = 60 * 60
            else: time_value = 60 * 60 * 24

            self._timeout_number.SetValue(time_left // time_value)

            self._timeout_multiplier.SetValue(time_value)

        self._hashes = hashes

        self._service = HG.client_controller.services_manager.GetService(
            CC.LOCAL_BOORU_SERVICE_KEY)

        internal_port = self._service.GetPort()

        if internal_port is None:

            self._copy_internal_share_link.setEnabled(False)
            self._copy_external_share_link.setEnabled(False)

        #

        rows = []

        rows.append(('share name: ', self._name))
        rows.append(('share text: ', self._text))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        timeout_box = QP.HBoxLayout()
        QP.AddToLayout(timeout_box, self._timeout_number,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(timeout_box, self._timeout_multiplier,
                       CC.FLAGS_EXPAND_BOTH_WAYS)

        link_box = QP.HBoxLayout()
        QP.AddToLayout(link_box, self._copy_internal_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(link_box, self._copy_external_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        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()

        intro = 'Sharing ' + HydrusData.ToHumanInt(len(
            self._hashes)) + ' files.'
        intro += os.linesep + 'Title and text are optional.'

        if new_share:
            intro += os.linesep + 'The link will not work until you ok this dialog.'

        QP.AddToLayout(vbox, ClientGUICommon.BetterStaticText(self, intro),
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, timeout_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, link_box, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 350))

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus,
                                             QC.Qt.OtherFocusReason)
    def __init__(self, parent, service_key):

        Dialog.__init__(self, parent, 'configure new accounts')

        self._service_key = service_key

        self._num = QP.MakeQSpinBox(self, min=1, max=10000, width=80)

        self._account_types = ClientGUICommon.BetterChoice(self)

        self._lifetime = ClientGUICommon.BetterChoice(self)

        self._ok = QW.QPushButton('OK', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        self._cancel = QW.QPushButton('Cancel', self)
        self._cancel.clicked.connect(self.reject)
        self._cancel.setObjectName('HydrusCancel')

        #

        self._num.setValue(1)

        service = HG.client_controller.services_manager.GetService(service_key)

        response = service.Request(HC.GET, 'account_types')

        account_types = response['account_types']

        for account_type in account_types:

            self._account_types.addItem(account_type.GetTitle(), account_type)

        self._account_types.setCurrentIndex(0)

        for (s, value) in HC.lifetimes:

            self._lifetime.addItem(s, value)

        self._lifetime.setCurrentIndex(3)  # one year

        #

        ctrl_box = QP.HBoxLayout()

        QP.AddToLayout(ctrl_box,
                       ClientGUICommon.BetterStaticText(self, 'generate'),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._num, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._account_types,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(
            ctrl_box,
            ClientGUICommon.BetterStaticText(self, 'accounts, to expire in'),
            CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._lifetime, CC.FLAGS_CENTER_PERPENDICULAR)

        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()

        QP.AddToLayout(vbox, ctrl_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus,
                                             QC.Qt.OtherFocusReason)
Ejemplo n.º 15
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)
    def __init__(self,
                 parent,
                 message,
                 default='',
                 placeholder=None,
                 allow_blank=False,
                 suggestions=None,
                 max_chars=None,
                 password_entry=False,
                 min_char_width=72):

        if suggestions is None:

            suggestions = []

        Dialog.__init__(self, parent, 'enter text', position='center')

        self._chosen_suggestion = None
        self._allow_blank = allow_blank
        self._max_chars = max_chars

        button_choices = []

        for text in suggestions:

            button_choices.append(
                ClientGUICommon.BetterButton(self, text, self.ButtonChoice,
                                             text))

        self._text = QW.QLineEdit(self)
        self._text.textChanged.connect(self.EventText)
        self._text.installEventFilter(
            ClientGUICommon.TextCatchEnterEventFilter(self._text,
                                                      self.EnterText))

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._text, min_char_width)

        self._text.setMinimumWidth(width)

        if password_entry:

            self._text.setEchoMode(QW.QLineEdit.Password)

        if self._max_chars is not None:

            self._text.setMaxLength(self._max_chars)

        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._text.setText(default)

        if placeholder is not None:

            self._text.setPlaceholderText(placeholder)

        if len(default) > 0:

            self._text.setSelection(0, len(default))

        self._CheckText()

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR)

        st_message = ClientGUICommon.BetterStaticText(self, message)
        st_message.setWordWrap(True)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, st_message, CC.FLAGS_EXPAND_PERPENDICULAR)

        for button in button_choices:

            QP.AddToLayout(vbox, button, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._text, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 250))

        QP.SetInitialSize(self, size_hint)
Ejemplo n.º 17
0
    def __init__(self, parent, media):

        self._hashes = set()

        for m in media:

            self._hashes.update(m.GetHashes())

        ClientGUIDialogs.Dialog.__init__(
            self,
            parent,
            'manage ratings for ' + HydrusData.ToHumanInt(len(self._hashes)) +
            ' files',
            position='topleft')

        #

        like_services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_RATING_LIKE, ))
        numerical_services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_RATING_NUMERICAL, ))

        self._panels = []

        if len(like_services) > 0:

            self._panels.append(self._LikePanel(self, like_services, media))

        if len(numerical_services) > 0:

            self._panels.append(
                self._NumericalPanel(self, numerical_services, media))

        self._apply = QW.QPushButton('apply', self)
        self._apply.clicked.connect(self.EventOK)
        self._apply.setObjectName('HydrusAccept')

        self._cancel = QW.QPushButton('cancel', self)
        self._cancel.clicked.connect(self.reject)
        self._cancel.setObjectName('HydrusCancel')

        #

        buttonbox = QP.HBoxLayout()

        QP.AddToLayout(buttonbox, self._apply, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(buttonbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        for panel in self._panels:

            QP.AddToLayout(vbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, buttonbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        #

        self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler(
            self, ['global', 'media'])