Exemplo n.º 1
0
 def __init__(self, parent, contact, profile, updateNameCallback,
              closeCallback):
     QDialog.__init__(self, parent)
     self.ui = Ui_ContactInfoDialog()
     self.ui.setupUi(self)
     self.contact = contact
     self.profile = profile
     self.updateNameCallback = updateNameCallback
     self.closeCallback = closeCallback
     self.ui.name.setText(self.contact.name)
     pemPublicKey = self.contact.publicKey.toPEM_PublicKey()
     self.ui.publicKey.setPlainText(pemPublicKey)
     self.connect(self.ui.name, SIGNAL('textChanged(const QString&)'),
                  self._onNameChanged)
     self.connect(self.ui.name, SIGNAL('returnPressed()'),
                  self._onNameReturn)
     self.connect(self.ui.updateNameButton, SIGNAL('clicked()'),
                  self._onUpdateNameClicked)
     self._updateUI()
Exemplo n.º 2
0
 def __init__( self, parent, contact, profile,
         updateNameCallback, closeCallback ) :
     QDialog.__init__( self, parent )
     self.ui = Ui_ContactInfoDialog()
     self.ui.setupUi( self )
     self.contact = contact
     self.profile = profile
     self.updateNameCallback = updateNameCallback
     self.closeCallback = closeCallback
     self.ui.name.setText( self.contact.name )
     pemPublicKey = self.contact.publicKey.toPEM_PublicKey()
     self.ui.publicKey.setPlainText( pemPublicKey )
     self.connect( self.ui.name,
             SIGNAL('textChanged(const QString&)'),
             self._onNameChanged )
     self.connect( self.ui.name, SIGNAL('returnPressed()'),
             self._onNameReturn )
     self.connect( self.ui.updateNameButton, SIGNAL('clicked()'),
             self._onUpdateNameClicked )
     self._updateUI()
Exemplo n.º 3
0
class ContactInfoDialog( QDialog ) :
    def __init__( self, parent, contact, profile,
            updateNameCallback, closeCallback ) :
        QDialog.__init__( self, parent )
        self.ui = Ui_ContactInfoDialog()
        self.ui.setupUi( self )
        self.contact = contact
        self.profile = profile
        self.updateNameCallback = updateNameCallback
        self.closeCallback = closeCallback
        self.ui.name.setText( self.contact.name )
        pemPublicKey = self.contact.publicKey.toPEM_PublicKey()
        self.ui.publicKey.setPlainText( pemPublicKey )
        self.connect( self.ui.name,
                SIGNAL('textChanged(const QString&)'),
                self._onNameChanged )
        self.connect( self.ui.name, SIGNAL('returnPressed()'),
                self._onNameReturn )
        self.connect( self.ui.updateNameButton, SIGNAL('clicked()'),
                self._onUpdateNameClicked )
        self._updateUI()

    def _showError( self, msg ) :
        QMessageBox.critical( self, 'Error', msg )

    def _updateUI( self ) :
        curName = unicode(self.ui.name.text()).encode('utf8')
        nameChanged = (curName != self.contact.name)
        self.ui.updateNameButton.setEnabled( curName != self.contact.name )

    def _onNameChanged( self, text ) :
        self._updateUI()

    def _onNameReturn( self ) :
        self.ui.updateNameButton.click()

    def _onUpdateNameClicked( self ) :
        newName = unicode(self.ui.name.text()).encode('utf8')
        assert newName != self.contact.name
        if not isValidUserName(newName) :
            self._showError( 'Only lowercase alphabets(a-z), ' +
                    'digits(0-9), and underscore(\'_\') are allowed ' +
                    'in the contact name.' )
            self.ui.name.setFocus()
            self.ui.name.selectAll()
            return
        existing = self.profile.getContactByName( newName )
        if existing :
            self._showError( 'The new name is already present in ' +
                    'your contact list.\n' +
                    'Please choose a different name.' )
            self.ui.name.setFocus()
            self.ui.name.selectAll()
            return
        self.updateNameCallback( newName )
        self._updateUI()

    def done( self, r ) :
        QDialog.done( self, r )
        self.close()

    def closeEvent( self, ev ) :
        self.closeCallback()
        delaygc( self )
        QDialog.closeEvent( self, ev )
Exemplo n.º 4
0
class ContactInfoDialog(QDialog):
    def __init__(self, parent, contact, profile, updateNameCallback,
                 closeCallback):
        QDialog.__init__(self, parent)
        self.ui = Ui_ContactInfoDialog()
        self.ui.setupUi(self)
        self.contact = contact
        self.profile = profile
        self.updateNameCallback = updateNameCallback
        self.closeCallback = closeCallback
        self.ui.name.setText(self.contact.name)
        pemPublicKey = self.contact.publicKey.toPEM_PublicKey()
        self.ui.publicKey.setPlainText(pemPublicKey)
        self.connect(self.ui.name, SIGNAL('textChanged(const QString&)'),
                     self._onNameChanged)
        self.connect(self.ui.name, SIGNAL('returnPressed()'),
                     self._onNameReturn)
        self.connect(self.ui.updateNameButton, SIGNAL('clicked()'),
                     self._onUpdateNameClicked)
        self._updateUI()

    def _showError(self, msg):
        QMessageBox.critical(self, 'Error', msg)

    def _updateUI(self):
        curName = unicode(self.ui.name.text()).encode('utf8')
        nameChanged = (curName != self.contact.name)
        self.ui.updateNameButton.setEnabled(curName != self.contact.name)

    def _onNameChanged(self, text):
        self._updateUI()

    def _onNameReturn(self):
        self.ui.updateNameButton.click()

    def _onUpdateNameClicked(self):
        newName = unicode(self.ui.name.text()).encode('utf8')
        assert newName != self.contact.name
        if not isValidUserName(newName):
            self._showError('Only lowercase alphabets(a-z), ' +
                            'digits(0-9), and underscore(\'_\') are allowed ' +
                            'in the contact name.')
            self.ui.name.setFocus()
            self.ui.name.selectAll()
            return
        existing = self.profile.getContactByName(newName)
        if existing:
            self._showError('The new name is already present in ' +
                            'your contact list.\n' +
                            'Please choose a different name.')
            self.ui.name.setFocus()
            self.ui.name.selectAll()
            return
        self.updateNameCallback(newName)
        self._updateUI()

    def done(self, r):
        QDialog.done(self, r)
        self.close()

    def closeEvent(self, ev):
        self.closeCallback()
        delaygc(self)
        QDialog.closeEvent(self, ev)