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