(removed extra braces) |
|||
| Line 1: | Line 1: | ||
Code snippet that draws ui and shows GPS data and accuracy, also with GPS on/off switch if one wants to conserve power. | Code snippet that draws ui and shows GPS data and accuracy, also with GPS on/off switch if one wants to conserve power. | ||
| + | * Made by: Ossipena | ||
| + | * Modified by: Venemo | ||
| + | |||
| + | == main.qml == | ||
<pre> | <pre> | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
import QtQuick 1.1 | import QtQuick 1.1 | ||
import com.nokia.meego 1.0 | import com.nokia.meego 1.0 | ||
| Line 14: | Line 11: | ||
PageStackWindow { | PageStackWindow { | ||
id: appWindow | id: appWindow | ||
| + | initialPage: mainPage | ||
| - | MainPage {id: mainPage} | + | MainPage { |
| - | + | id: mainPage | |
| - | + | } | |
| - | + | ||
ToolBarLayout { | ToolBarLayout { | ||
id: commonTools | id: commonTools | ||
visible: true | visible: true | ||
| + | parent: appWindow.pageStack.currentPage | ||
| - | + | Button { | |
| - | + | ||
text: "View trackings" | text: "View trackings" | ||
height: parent.height | height: parent.height | ||
| - | |||
| - | |||
| - | |||
} | } | ||
| - | + | ToolIcon { | |
| - | ToolIcon { platformIconId: "toolbar-view-menu"; | + | platformIconId: "toolbar-view-menu"; |
| - | + | ||
| - | + | ||
| - | + | ||
} | } | ||
| - | |||
} | } | ||
| - | |||
} | } | ||
| + | </pre> | ||
| + | == MainPage.qml == | ||
| - | + | <pre> | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
import QtQuick 1.1 | import QtQuick 1.1 | ||
| - | import com.meego 1.0 | + | import com.nokia.meego 1.0 |
import Qt 4.7 | import Qt 4.7 | ||
import QtMobility.location 1.1 | import QtMobility.location 1.1 | ||
| Line 58: | Line 43: | ||
id: mainPage | id: mainPage | ||
tools: commonTools | tools: commonTools | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
function printableMethod(method) { | function printableMethod(method) { | ||
if (method == PositionSource.SatellitePositioningMethod) | if (method == PositionSource.SatellitePositioningMethod) | ||
| Line 76: | Line 55: | ||
return "source error"; | return "source error"; | ||
} | } | ||
| + | |||
| + | //init GPS etc | ||
| + | PositionSource { | ||
| + | id: positionSource | ||
| + | updateInterval: 1000 | ||
| + | //active: false | ||
| + | active: gpsswitch.checked | ||
| + | } | ||
| + | |||
Grid { | Grid { | ||
id: positiondata | id: positiondata | ||
| Line 84: | Line 72: | ||
columns: 2 | columns: 2 | ||
spacing: 5 | spacing: 5 | ||
| - | + | ||
Text { | Text { | ||
id:latitudelabel | id:latitudelabel | ||
| Line 136: | Line 124: | ||
} | } | ||
} | } | ||
| - | + | Item { | |
| - | + | id: switchrow | |
| - | + | width: 300 | |
| - | + | anchors.top: positiondata.bottom | |
| - | + | anchors.left: positiondata.left | |
| - | + | anchors.topMargin: 50 | |
| - | + | ||
// Switch for power saving: toggle gps on/off | // Switch for power saving: toggle gps on/off | ||
Text { | Text { | ||
| Line 155: | Line 143: | ||
anchors.left: switchtext.right | anchors.left: switchtext.right | ||
anchors.leftMargin: 50 | anchors.leftMargin: 50 | ||
| - | + | } | |
} | } | ||
} | } | ||
| - | |||
| - | |||
| - | |||
</pre> | </pre> | ||
Code snippet that draws ui and shows GPS data and accuracy, also with GPS on/off switch if one wants to conserve power.
import QtQuick 1.1
import com.nokia.meego 1.0
PageStackWindow {
id: appWindow
initialPage: mainPage
MainPage {
id: mainPage
}
ToolBarLayout {
id: commonTools
visible: true
parent: appWindow.pageStack.currentPage
Button {
text: "View trackings"
height: parent.height
}
ToolIcon {
platformIconId: "toolbar-view-menu";
}
}
}
import QtQuick 1.1
import com.nokia.meego 1.0
import Qt 4.7
import QtMobility.location 1.1
Page {
id: mainPage
tools: commonTools
function printableMethod(method) {
if (method == PositionSource.SatellitePositioningMethod)
return "Satellite";
else if (method == PositionSource.NoPositioningMethod)
return "Not available";
else if (method == PositionSouce.NonSatellitePositioningMethod)
return "Non-satellite";
else if (method == PositionSource.AllPositioningMethods)
return "All/multiple"
return "source error";
}
//init GPS etc
PositionSource {
id: positionSource
updateInterval: 1000
//active: false
active: gpsswitch.checked
}
Grid {
id: positiondata
anchors.top: parent.top
anchors.topMargin: 50
anchors.left: parent.left
anchors.leftMargin: 10
columns: 2
spacing: 5
Text {
id:latitudelabel
font.pointSize: 32
text: "Latitude:"
}
Text {
id: latitudetext
font.pointSize: 32
text: positionSource.position.coordinate.latitude
}
Text {
id:longitudelabel
font.pointSize: 32
text: "Longitude: "
}
Text {
id: longitudetext
font.pointSize: 32
text: positionSource.position.coordinate.longitude
}
Text{
id:accuracylabel1
font.pointSize: 16
text: "Horizontal accuracy:"
}
Text{
id: horiz_accuracy
font.pointSize: 16
text: positionSource.position.horizontalAccuracy
}
Text {
id:heightlabel
font.pointSize: 32
text: "Height: "
}
Text {
id: heighttext
font.pointSize: 32
text: positionSource.position.coordinate.altitude
}
Text{
id:accuracylabel2
font.pointSize: 16
text: "Altitude accuracy:"
}
Text{
id: vert_accuracy
font.pointSize: 16
text: positionSource.position.verticalAccuracy
}
}
Item {
id: switchrow
width: 300
anchors.top: positiondata.bottom
anchors.left: positiondata.left
anchors.topMargin: 50
// Switch for power saving: toggle gps on/off
Text {
id:switchtext
anchors.left: parent.left
font.pointSize: 32
text: gpsswitch.checked ? "GPS ON" : "GPS OFF"
}
Switch {
id: gpsswitch
checked: false
anchors.left: switchtext.right
anchors.leftMargin: 50
}
}
}