示例#1
0
    def mouseDoubleClickEvent( self, event ):
        """ Ask password and move to the admin mode """

        globalData = GlobalData()

        keyboard = ui.findForm( 'DigitKeyboard' )
        keyboard.hideInput = True
        keyboard.raise_()
        keyboard.exec_()

        if keyboard.cancelled:
            return

        debugMsg( "User input: " + keyboard.userInput )
        debugMsg( "Admin password: " + Settings().adminPassword )

        if keyboard.userInput != Settings().adminPassword:
            return


        ui.hideForm( 'TopBar' )
        ui.showForm( 'AdminTopBar' )

        globalData.isAdmin = True
        return
示例#2
0
    def toUserButtonClicked(self):
        """ processing click() on the To User Mode button """

        GlobalData().isAdmin = False
        ui.hideForm('AdminTopBar')
        ui.showForm('TopBar')
        return
示例#3
0
 def updatePicture( self, path ):
     pictureName = ""
     if GlobalData().isConnected:
         pictureName = path + 'logo.gif'
     else:
         pictureName = path + 'warning.png'
     self.logoPicture.setPixmap(QtGui.QPixmap(pictureName))
     return
示例#4
0
    def mouseReleaseEvent( self, event ):
        """ go home """

        ui.navigateHome()
        if GlobalData().isAdmin:
            ui.hideForm( 'TopBar' )
            ui.showForm( 'AdminTopBar' )
        return
示例#5
0
    def flushButtonClicked(self):
        """ processing click() on the Flush button """

        debugMsg("Sending a test notification")
        GlobalData().application.sendNotification("something")
        debugMsg("Sent")

        QtGui.QMessageBox.information(None, "Not implemented yet",
                                      "Not implemented yet")
        return
示例#6
0
    def __init__(self, path, parent=None, f=QtCore.Qt.WindowFlags()):
        QtGui.QWidget.__init__(self, parent, f)

        self.path = path
        self.setupUi(self, path)

        self.connect( GlobalData().application,
                      SIGNAL( "connectionStatus" ),
                      self.onConnectionChanged )
        return
示例#7
0
文件: ui.py 项目: gridl/ttkiosk
def navigateHome():
    """ return back to the home screen """

    global formsStack
    globalData = GlobalData()

    formsStack = []
    for key in kioskForms.keys():
        if key == 'DebugBar':
            continue
        theForm = kioskForms[key]
        if not key in globalData.startupForms:
            theForm.hide()
        else:
            theForm.show()
    return
示例#8
0
    def makeConnections(self):
        """ A collection of SIGNAL - SLOT connections """

        globalData = GlobalData()
        self.connect(self.restartButton, SIGNAL("clicked()"),
                     globalData.application, SLOT("quit()"))
        self.connect(self.showHostInfoButton, SIGNAL("clicked()"),
                     self.showHostInfoCkicked)
        self.connect(self.createEventButton, SIGNAL("clicked()"),
                     self.createEventButtonClicked)
        self.connect(self.toUserButton, SIGNAL("clicked()"),
                     self.toUserButtonClicked)
        self.connect(self.shutdownButton, SIGNAL("clicked()"),
                     self.shutdownButtonClicked)
        self.connect(self.flushButton, SIGNAL("clicked()"),
                     self.flushButtonClicked)
        return
示例#9
0
文件: ui.py 项目: gridl/ttkiosk
def applySingleLayout(path, startupForms, geometry):
    """ recursive function which parses a layout file """

    if not os.path.exists(path):
        raise Exception("Layout file '" + path + "' has not been found")

    globalData = GlobalData()
    # variables name -> value
    variables = {
        "WIDTH": str(globalData.screenWidth),
        "HEIGHT": str(globalData.screenHeight)
    }
    if utils.debug:
        variables["DEBUG"] = "1"
    else:
        variables["DEBUG"] = "0"

    f = open(path)
    for line in f:
        line = line.strip()
        if len(line) == 0:
            continue
        if line.startswith('#'):
            continue

        if line.upper().startswith('SET'):
            assignment = line[len('SET'):].strip()
            parts = assignment.split('=')
            if len(parts) != 2:
                raise Exception( "Unexpected line format: '" + line + \
                                 "' in file '" + path + "'" )
            varName = parts[0].strip()
            if variables.has_key(varName):
                raise Exception( "Variable '" + varName + \
                                 "' is defined twice in file '" + path + "'" )
            variables[varName] = substAndEvaluate(parts[1].strip(), variables)
            debugMsg( "Found variable '" + varName + \
                      "' in file '" + path + "'" )
            continue

        if line.upper().startswith('STARTUP'):
            parts = line.split()
            if len(parts) != 2:
                raise Exception( "Unexpected line format: '" + line + \
                                 "' in file '" + path + "'" )
            formName = parts[1].strip()
            if not kioskForms.has_key(formName):
                raise Exception( "Unknown startup form '" + formName + \
                                 "' in file '" + path + "'" )

            if not formName in startupForms:
                startupForms.append(formName)
                debugMsg("Found STARTUP form '" + formName + "'")
            continue

        if line.upper().startswith('INCLUDE'):
            parts = line.split()
            if len(parts) != 2:
                raise Exception( "Unexpected line format: '" + line + \
                                 "' in file '" + path + "'" )

            fileName = parts[1].strip()
            if fileName.startswith('/'):
                # absolute path
                if not os.path.exists(fileName):
                    raise Exception( "INCLUDE file '" + fileName + "' in '" + \
                                     path + "' has not been found" )
                applySingleLayout(fileName, startupForms, geometry)
                continue

            # relative path
            includedFileName = os.path.dirname(path) + '/' + fileName
            includedFileName = os.path.normpath(includedFileName)
            if not os.path.exists(includedFileName):
                raise Exception( "INCLUDE file '" + fileName + "' (" + \
                                 includedFileName + ") in '" + path + \
                                 "' has not been found" )
            applySingleLayout(includedFileName, startupForms, geometry)
            continue

        if line.upper().startswith('GEOMETRY'):
            arguments = line[len('GEOMETRY'):].strip()
            if len(arguments) == 0:
                raise Exception( "Unexpected line format: '" + line + \
                                 "' in file '" + path + "'" )
            formName = arguments.split()[0]
            if not kioskForms.has_key(formName):
                raise Exception( "Unknown form '" + formName + \
                                 "' geometry in file '" + path + "'" )
            if geometry.has_key(formName):
                raise Exception( "GEOMETRY for '" + formName + \
                                 "' has been defined twice.\nFirst: " + \
                                 geometry[formName][0] + "\nSecond: " + \
                                 path )

            arguments = arguments[len(formName):].strip()
            parts = arguments.split(',')
            if len(parts) != 4:
                raise Exception( "Unexpected line format: '" + line + \
                                 "' in file '" + path + "'" )

            globalData = GlobalData()
            for index in range(0, 4):
                parts[index] = int(substAndEvaluate(parts[index], variables))

            geometry[formName] = [path, parts[0], parts[1], parts[2], parts[3]]
            debugMsg("Found GEOMETRY for '" + formName + "'")
            continue

        raise Exception("Unexpected line '" + line + "' in " + path)

    f.close()
    return