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
def toUserButtonClicked(self): """ processing click() on the To User Mode button """ GlobalData().isAdmin = False ui.hideForm('AdminTopBar') ui.showForm('TopBar') return
def updatePicture( self, path ): pictureName = "" if GlobalData().isConnected: pictureName = path + 'logo.gif' else: pictureName = path + 'warning.png' self.logoPicture.setPixmap(QtGui.QPixmap(pictureName)) return
def mouseReleaseEvent( self, event ): """ go home """ ui.navigateHome() if GlobalData().isAdmin: ui.hideForm( 'TopBar' ) ui.showForm( 'AdminTopBar' ) return
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
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
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
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
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