Ejemplo n.º 1
0
def open_settings_dialog(context, editor):
    """
    Open Settings dialog
    :param context: shared properties in application
    :param editor: object of CodeEditor class
    :return: None
    """
    SettingsDialog(context, editor)
Ejemplo n.º 2
0
 def on_settings_dialog(self):
     d = SettingsDialog(self, self)
     self.connect(d, QtCore.SIGNAL("refresh_settings"), self.on_refresh_settings)
     if d.exec_():
         self.on_refresh_settings()
Ejemplo n.º 3
0
 def on_settings_dialog(self):
     d = SettingsDialog(self, self)
     self.connect(d, QtCore.SIGNAL("refresh_settings"),
                  self.on_refresh_settings)
     if d.exec_():
         self.on_refresh_settings()
Ejemplo n.º 4
0
 def settingsPopup(self):
     """Show settings dialog
     """
     self.dialog = SettingsDialog(self)
     self.dialog.exec_()
Ejemplo n.º 5
0
class LoginDialog(QtGui.QDialog):
    """Login Dialog Class
    """

    def __init__(self, svcHttp):
        """Default constructor
        """
        # Setup GUI
        QtGui.QDialog.__init__(self)
        self.setWindowTitle("RadPlanBio - Login")
        appIconPath =':/images/rpb-icon.jpg'
        appIcon = QtGui.QIcon()
        appIcon.addPixmap(QtGui.QPixmap(appIconPath))
        self.setWindowIcon(appIcon)

        toolBarButtonSize = 15

        configIconPath =':/images/config.png'
        configIcon = QtGui.QIcon(configIconPath)
        configIcon.addPixmap(QtGui.QPixmap(configIcon))

        # Config button
        self.btnConfig = QtGui.QPushButton()
        self.btnConfig.setIcon(configIcon)
        self.btnConfig.setToolTip("Configuration")
        self.btnConfig.setIconSize(QtCore.QSize(toolBarButtonSize, toolBarButtonSize))
        self.btnConfig.setMinimumWidth(toolBarButtonSize)
        self.btnConfig.clicked.connect(self.settingsPopup)

        # Dialog layout root
        rootLayout = QtGui.QVBoxLayout(self)

        # Login grid
        loginLayout = QtGui.QGridLayout()
        loginLayout.setSpacing(10)
        rootLayout.addLayout(loginLayout)

        # Connection
        lblConnection = QtGui.QLabel("Connection:")
        self.txtConnection = QtGui.QLineEdit()
        self.txtConnection.setText(ConfigDetails().rpbHost + "/" + ConfigDetails().rpbApplication)
        self.txtConnection.setMinimumWidth(300)
        self.txtConnection.setDisabled(True)

        # User label
        lblUsername = QtGui.QLabel("Username:"******"Password:"******"Login")
        self.btnLogin.setIcon(loginIcon)
        self.btnLogin.setToolTip("Login")
        self.btnLogin.setIconSize(QtCore.QSize(toolBarButtonSize, toolBarButtonSize))
        self.btnLogin.clicked.connect(self.handleLogin)

        # Add to connection layout
        loginLayout.addWidget(lblConnection, 0, 0)
        loginLayout.addWidget(self.txtConnection, 0, 1)
        loginLayout.addWidget(self.btnConfig, 0, 2)

        loginLayout.addWidget(lblUsername, 1, 0)
        loginLayout.addWidget(self.txtUsername, 1, 1, 1, 2)

        loginLayout.addWidget(lblPassword, 2, 0)
        loginLayout.addWidget(self.txtPassword, 2, 1, 1, 2)

        loginLayout.addWidget(self.btnLogin, 3, 1, 1, 2)

        self.txtUsername.setFocus()

        # Services
        self.svcHttp = svcHttp

        # ViewModel
        self.userName = ""
        self.password = ""

##     ##    ###    ##    ## ########  ##       ######## ########   ######  
##     ##   ## ##   ###   ## ##     ## ##       ##       ##     ## ##    ## 
##     ##  ##   ##  ####  ## ##     ## ##       ##       ##     ## ##       
######### ##     ## ## ## ## ##     ## ##       ######   ########   ######  
##     ## ######### ##  #### ##     ## ##       ##       ##   ##         ## 
##     ## ##     ## ##   ### ##     ## ##       ##       ##    ##  ##    ## 
##     ## ##     ## ##    ## ########  ######## ######## ##     ##  ###### 
    
    def handleLogin(self):
        """Send authenticate user message to site server
        """
        username = str(self.txtUsername.text())
        password = str(self.txtPassword.text())
        passwordHash = hashlib.sha1(password).hexdigest()

        try:
            successfull = False
            successfull = self.svcHttp.authenticateUser(username, passwordHash)

            if successfull:
                UserDetails().username = username
                UserDetails().clearpass = password
                UserDetails().password = passwordHash
                self.accept()
            else:
                QtGui.QMessageBox.warning(self, "Error", "Wrong username or password.")
        except:
            QtGui.QMessageBox.warning(self, "Error", "Cannot communicate with the server, no network connection or the server is not running.")


    def settingsPopup(self):
        """Show settings dialog
        """
        self.dialog = SettingsDialog(self)
        self.dialog.exec_()
Ejemplo n.º 6
0
 def show_settings(self):
     dialog = SettingsDialog()
     dialog.exec_()