123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- /*
- * Copyright (c) 2011 Nokia Corporation.
- */
- import QtQuick 1.1
- import QtMobility.serviceframework 1.1
- import QtMobility.systeminfo 1.2
- import QtMultimediaKit 1.1
- import CustomItems 1.0
- import "JavaScript.js" as JavaScript
- Rectangle {
- id: main
- width: 360; height: 640
- anchors.fill: parent
- color: "black"
- // WhoWhereDaemon service
- property variant daemonService: 0
- // ContactsView
- property variant contactsView: 0
- // InfoView
- property variant infoView: 0
- // Show/hide ContactsView
- function showContacts(enable)
- {
- if (enable) {
- // Create ContactsView dynamically
- if (!contactsView) {
- var component = Qt.createComponent("qrc:/ContactsView.qml");
- if (component.status == Component.Ready) {
- contactsView = component.createObject(main);
- }
- }
- water.pauseWater(true);
- contactsView.show();
- } else {
- // Hide ContactsView
- if (contactsView) {
- water.pauseWater(false);
- contactsView.opacity = 0;
- }
- }
- }
- // Show/hide InfoView
- function showInfo(enable)
- {
- if (enable) {
- water.setWaterUpdateSpeed(200);
- // Create InfoView dynamically
- if (!infoView) {
- var component = Qt.createComponent("qrc:/InfoView.qml");
- if (component.status == Component.Ready) {
- infoView = component.createObject(main);
- }
- }
- infoView.opacity = 1;
- } else {
- // Hide ContactsView
- if (infoView) {
- infoView.opacity = 0;
- water.setWaterUpdateSpeed(80);
- }
- }
- }
- // Application start sound
- Audio {
- id: playMusic
- source: appFolder + "13564__acclivity__GullsByTheSea.wav"
- volume: 0.4
- }
- // QtMobility Service FW
- // Connect WhoWhereDaemon Service
- Service {
- id: daemonServiceId
- interfaceName: "com.nokia.qt.examples.qwhowheredaemon"
- Component.onCompleted: {
- main.daemonService = daemonServiceId.serviceObject;
- console.log(daemonServiceId.serviceName);
- if (daemonServiceId.valid) {
- console.log("Service valid");
- // Read values form Daemot to UI
- if(JavaScript.isDaemonEnabled()) {
- onOffSwitch.state = "on";
- }
- if (JavaScript.isGpsRunningEnabled()) {
- console.log("gps running");
- gpsSwitch.state = "on";
- }
- knobDial.value = JavaScript.getGpsAccuracy();
- } else {
- console.log("Service NOT valid!");
- }
- }
- }
- // Listening device profile (silent or not)
- DeviceInfo {
- id: deviceInfo
- }
- Component.onCompleted: {
- audioTimer.restart();
- }
- Timer {
- id: audioTimer
- interval: 3000
- repeat: false
- onTriggered: {
- splashScreen.opacity = 0;
- water.opacity = 1;
- if (deviceInfo.currentProfile != 1){
- playMusic.play();
- }
- }
- }
- // Water background
- WaterItem {
- id:water
- anchors.fill: parent
- opacity: 0;
- }
- // Application background paper
- Image {
- id: background
- anchors.fill: parent
- anchors.centerIn: parent
- anchors.topMargin: 40
- anchors.bottomMargin: 40
- anchors.leftMargin: 10
- anchors.rightMargin: 10
- fillMode: Image.PreserveAspectFit
- source: "qrc:/images/back_portrait.png"
- smooth: true
- }
- // Gps icon
- GpsIcon {
- width: 50
- height: 50
- x: 5
- y: 5
- }
- // Exit
- Button {
- id: exit
- buttonId: 1
- width: 50
- height: 50
- x: parent.width - width - 5
- y: 5
- onBtnClicked: {
- Qt.quit();
- }
- }
- // Main content
- Item {
- id: mainContent
- anchors.fill: background
- smooth: true
- property int rowHeight: background.height * 0.105
- property int colWidth: background.width * 0.28
- // 1. row ---------------------------------------------------------
- Image {
- id: logo
- anchors.top: mainContent.top
- anchors.left: mainContent.left
- anchors.leftMargin: 10
- anchors.topMargin: background.height * 0.05
- width: mainContent.rowHeight * 2.2
- height: mainContent.rowHeight * 2.2
- fillMode: Image.PreserveAspectFit
- source: "qrc:/images/logo.png"
- smooth: true
- }
- Button {
- id: info
- buttonId: 2
- anchors.top: mainContent.top
- anchors.right: mainContent.right
- anchors.rightMargin: 40
- anchors.topMargin: background.height * 0.1
- width: mainContent.colWidth
- height: mainContent.rowHeight
- onBtnClicked: {
- main.showInfo(true);
- }
- }
- // 2. row --------------------------------------------------------
- Text {
- anchors.top: logo.bottom
- anchors.right: logo.right
- anchors.topMargin: 15
- color:"black"
- font.pointSize: 6
- text:"Server activated"
- smooth: true
- }
- Switch {
- id: onOffSwitch
- anchors.top: logo.bottom
- anchors.left: info.left
- anchors.topMargin: 5
- width: mainContent.colWidth
- height: mainContent.rowHeight
- onSwitched: {
- JavaScript.enableDaemon(on);
- }
- }
- // 3. row --------------------------------------------------------
- Text {
- anchors.top: onOffSwitch.bottom
- anchors.right: logo.right
- anchors.topMargin: 15
- color:"black"
- font.pointSize: 6
- text:"GPS always on"
- smooth: true
- }
- Switch {
- id: gpsSwitch
- anchors.top: onOffSwitch.bottom
- anchors.left: info.left
- anchors.topMargin: 5
- width: mainContent.colWidth
- height: mainContent.rowHeight
- }
- Connections {
- target:gpsSwitch
- onSwitched: {
- JavaScript.keepGpsRunning(on);
- }
- }
- // 4. row --------------------------------------------------------
- Text {
- anchors.top: gpsSwitch.bottom
- anchors.right: logo.right
- anchors.topMargin: 20
- color:"black"
- font.pointSize: 6
- text:"GPS accuracy"
- smooth: true
- }
- KnobDial {
- id: knobDial
- anchors.top: gpsSwitch.bottom
- anchors.left: info.left
- anchors.topMargin: 10
- width: mainContent.rowHeight
- height: mainContent.rowHeight
- }
- // 5. row --------------------------------------------------------
- Text {
- id: sendTxt
- anchors.top: knobDial.bottom
- anchors.right: logo.right
- anchors.topMargin: 20
- color:"black"
- font.pointSize: 6
- text:"Send location to..."
- smooth: true
- }
- Button {
- id: contactBtn
- buttonId: 3
- anchors.top: knobDial.bottom
- anchors.left: info.left
- anchors.topMargin: 10
- width: mainContent.colWidth
- height: mainContent.rowHeight
- onBtnClicked: {
- showContacts(true);
- }
- }
- // WhoWhereDaemon log screen
- DaemonLog {
- id: logScreen
- anchors.top: contactBtn.bottom
- anchors.topMargin: 10
- anchors.horizontalCenter: parent.horizontalCenter
- width: background.width - 70
- height: mainContent.rowHeight * 1.4
- }
- }
- MouseArea {
- id: mainMouseArea
- anchors.fill: parent
- onPressed: {
- // Note: need to handle onPressed() for
- // igonore MouseArea
- showContacts(false);
- showInfo(false);
- mouse.accepted = false;
- }
- }
- // Spalsh screen
- Rectangle {
- id:splashScreen
- anchors.fill: parent
- color: "black"
- Image {
- anchors.fill: parent
- source: "qrc:/images/back_portrait.png"
- smooth: true
- }
- Image {
- anchors.centerIn: parent
- fillMode: Image.PreserveAspectFit
- source: "qrc:/images/logo.png"
- smooth: true
- }
- }
- }
|