示例#1
0
文件: dialogs.py 项目: hj91/cspace
 def __init__(self, parent, permissions, closeCallback):
     QDialog.__init__(self, parent)
     self.ui = Ui_PermissionsDialog()
     self.ui.setupUi(self)
     self.permissions = permissions
     self.closeCallback = closeCallback
     self.ui.predefinedPermissions.setPlainText(
         self.permissions.getPredefinedPermissions())
     self.savedData = self.permissions.getUserPermissions()
     self.ui.permissions.setPlainText(self.savedData)
     self.ui.permissions.setToolTip(self.permissions.getHelpText())
     self.connect(self.ui.closeButton, SIGNAL('clicked()'), self.close)
示例#2
0
 def __init__( self, parent, permissions, closeCallback ) :
     QDialog.__init__( self, parent )
     self.ui = Ui_PermissionsDialog()
     self.ui.setupUi( self )
     self.permissions = permissions
     self.closeCallback = closeCallback
     self.ui.predefinedPermissions.setPlainText( self.permissions.getPredefinedPermissions() )
     self.savedData = self.permissions.getUserPermissions()
     self.ui.permissions.setPlainText( self.savedData )
     self.ui.permissions.setToolTip( self.permissions.getHelpText() )
     self.connect( self.ui.closeButton, SIGNAL('clicked()'), self.close )
示例#3
0
文件: dialogs.py 项目: hj91/cspace
class PermissionsDialog(QDialog):
    def __init__(self, parent, permissions, closeCallback):
        QDialog.__init__(self, parent)
        self.ui = Ui_PermissionsDialog()
        self.ui.setupUi(self)
        self.permissions = permissions
        self.closeCallback = closeCallback
        self.ui.predefinedPermissions.setPlainText(
            self.permissions.getPredefinedPermissions())
        self.savedData = self.permissions.getUserPermissions()
        self.ui.permissions.setPlainText(self.savedData)
        self.ui.permissions.setToolTip(self.permissions.getHelpText())
        self.connect(self.ui.closeButton, SIGNAL('clicked()'), self.close)

    def _updateUI(self):
        curData = unicode(self.ui.permissions.toPlainText()).encode('utf8')
        modified = curData != self.savedData
        self.ui.applyButton.setEnabled(modified)
        closeText = modified and '&Cancel' or '&Close'
        self.ui.closeButton.setText(closeText)

    @pyqtSignature('')
    def on_permissions_textChanged(self):
        self._updateUI()

    @pyqtSignature('')
    def on_applyButton_clicked(self):
        curData = unicode(self.ui.permissions.toPlainText()).encode('utf8')
        try:
            self.permissions.setUserPermissions(curData)
            self.ui.status.setText('<b>Permissions updated.</b>')
            self.permissions.savePermissions()
            self.savedData = curData
            self._updateUI()
            return
        except BadUserInRuleError, ue:
            line = ue.lineNumber
            errorMsg = 'Invalid user \'%s\'' % ue.user
        except BadServiceInRuleError, se:
            line = se.lineNumber
            errorMsg = 'Invalid service \'%s\'' % se.service
示例#4
0
class PermissionsDialog( QDialog ) :
    def __init__( self, parent, permissions, closeCallback ) :
        QDialog.__init__( self, parent )
        self.ui = Ui_PermissionsDialog()
        self.ui.setupUi( self )
        self.permissions = permissions
        self.closeCallback = closeCallback
        self.ui.predefinedPermissions.setPlainText( self.permissions.getPredefinedPermissions() )
        self.savedData = self.permissions.getUserPermissions()
        self.ui.permissions.setPlainText( self.savedData )
        self.ui.permissions.setToolTip( self.permissions.getHelpText() )
        self.connect( self.ui.closeButton, SIGNAL('clicked()'), self.close )

    def _updateUI( self ) :
        curData = unicode(self.ui.permissions.toPlainText()).encode( 'utf8' )
        modified = curData != self.savedData
        self.ui.applyButton.setEnabled( modified )
        closeText = modified and '&Cancel' or '&Close'
        self.ui.closeButton.setText( closeText )

    @pyqtSignature( '' )
    def on_permissions_textChanged( self ) :
        self._updateUI()

    @pyqtSignature( '' )
    def on_applyButton_clicked( self ) :
        curData = unicode(self.ui.permissions.toPlainText()).encode('utf8')
        try :
            self.permissions.setUserPermissions( curData )
            self.ui.status.setText( '<b>Permissions updated.</b>' )
            self.permissions.savePermissions()
            self.savedData = curData
            self._updateUI()
            return
        except BadUserInRuleError, ue :
            line = ue.lineNumber
            errorMsg = 'Invalid user \'%s\'' % ue.user
        except BadServiceInRuleError, se :
            line = se.lineNumber
            errorMsg = 'Invalid service \'%s\'' % se.service