summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-02-10 18:17:11 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-04-13 14:54:23 +0000
commit8bd7914a78ec6f29ecb52995b0c0116f34d7a2d2 (patch)
tree924b4b6b7c9f706bc64093e89d4e6612a3edfeff /examples
parent037e0e93cf35282224dfd6ce899c7c8325f193fb (diff)
downloadqtlocation-8bd7914a78ec6f29ecb52995b0c0116f34d7a2d2.tar.gz
Replace language button in mapviewer example.
Move language button fuctionality to tools menu. Change-Id: I29c9aa2594113b93995788b9938602537a293b9f Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/location/mapviewer/Locale.qml84
-rw-r--r--examples/location/mapviewer/MainMenu.qml2
-rw-r--r--examples/location/mapviewer/content/map/MapComponent.qml54
-rw-r--r--examples/location/mapviewer/mapviewer.qml53
-rw-r--r--examples/location/mapviewer/mapviewerwrapper.qrc1
5 files changed, 98 insertions, 96 deletions
diff --git a/examples/location/mapviewer/Locale.qml b/examples/location/mapviewer/Locale.qml
new file mode 100644
index 00000000..55da3a24
--- /dev/null
+++ b/examples/location/mapviewer/Locale.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtPositioning 5.2
+import "forms"
+
+LocaleForm {
+
+ property string locale
+ signal selectLanguage(string language)
+ signal closeForm()
+
+ goButton.onClicked: {
+
+ if (!languageGroup.current) return
+
+ if (otherRadioButton.checked) {
+ selectLanguage(language.text)
+ } else {
+ selectLanguage(languageGroup.current.text)
+ }
+ }
+
+ clearButton.onClicked: {
+ language.text = ""
+ }
+
+ cancelButton.onClicked: {
+ closeForm()
+ }
+
+ Component.onCompleted: {
+ switch (locale) {
+ case "en":
+ enRadioButton.checked = true;
+ break
+ case "fr":
+ frRadioButton.checked = true;
+ break
+ default:
+ otherRadioButton.checked = true;
+ language.text = locale
+ break
+ }
+ }
+}
diff --git a/examples/location/mapviewer/MainMenu.qml b/examples/location/mapviewer/MainMenu.qml
index d930d727..b8af3b6b 100644
--- a/examples/location/mapviewer/MainMenu.qml
+++ b/examples/location/mapviewer/MainMenu.qml
@@ -119,6 +119,8 @@ MenuBar {
item = addItem("")
item.text = Qt.binding(function() { return isFollowMe ? qsTr("Stop following") : qsTr("Follow me")})
item.triggered.connect(function() {toggleMapState("FollowMe")})
+
+ addItem(qsTr("Language")).triggered.connect(function(){selectTool("Language")})
}
}
}
diff --git a/examples/location/mapviewer/content/map/MapComponent.qml b/examples/location/mapviewer/content/map/MapComponent.qml
index 8d159085..7694ddcb 100644
--- a/examples/location/mapviewer/content/map/MapComponent.qml
+++ b/examples/location/mapviewer/content/map/MapComponent.qml
@@ -151,6 +151,7 @@ Map {
anchorPoint.y: poiNokia.sourceItem.height * 1.5
}
+
Slider {
id: zoomSlider;
z: map.z + 3
@@ -170,48 +171,6 @@ Map {
}
}
- Button {
- id: languageButton
- text: "en"
- width: 30
- height: 30
- z: map.z + 2
- anchors.bottom: zoomSlider.top
- anchors.bottomMargin: 8
- anchors.right: zoomSlider.right
- onClicked: {
- map.state = "LanguageMenu"
- }
- }
-
- OwnControls.Menu {
- id:languageMenu
- horizontalOrientation: false
- autoWidth: true
- opacity: 0
- z: map.z + 4
- anchors.bottom: languageButton.top
- anchors.right: languageButton.left
- onClicked: {
- switch (button) {
- case "en":
- case "fr": {
- setLanguage(button);
- break;
- }
- case "Other": {
- map.requestLocale()
- }
- }
- map.state = ""
- }
- Component.onCompleted: {
- addItem("en")
- addItem("fr")
- addItem("Other")
- }
- }
-
//! [routemodel0]
property RouteQuery routeQuery: RouteQuery {}
@@ -976,13 +935,6 @@ Map {
return dist
}
- function setLanguage(lang) {
- map.plugin.locales = lang;
- if (map.plugin.locales.length > 0) {
- languageButton.text = map.plugin.locales[0];
- }
- }
-
// states of map
states: [
State {
@@ -1002,10 +954,6 @@ Map {
PropertyChanges { target: pointMenu; opacity: 1}
PropertyChanges { target: pointMenu; x: ((map.lastX + pointMenu.width > map.width) ? map.width - pointMenu.width : map.lastX)}
PropertyChanges { target: pointMenu; y: ((map.lastY + pointMenu.height > map.height - 40) ? map.height - pointMenu.height - 40 : map.lastY)}
- },
- State {
- name: "LanguageMenu"
- PropertyChanges { target: languageMenu; opacity: 1}
}
]
//! [end]
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml
index 74df5a54..ba906e85 100644
--- a/examples/location/mapviewer/mapviewer.qml
+++ b/examples/location/mapviewer/mapviewer.qml
@@ -42,7 +42,6 @@ import QtQuick 2.4
import QtQuick.Controls 1.3
import QtLocation 5.3
import QtPositioning 5.2
-import QtLocation.examples 5.0 as OwnControls
import "content/map"
ApplicationWindow {
@@ -135,6 +134,11 @@ ApplicationWindow {
properties: { "coordinate": fromCoordinate}})
stackView.currentItem.showPlace.connect(showPlace)
stackView.currentItem.closeForm.connect(closeForm)
+ } else if (tool === "Language") {
+ stackView.push({ item: Qt.resolvedUrl("Locale.qml") ,
+ properties: { "locale": map.plugin.locales[0]}})
+ stackView.currentItem.selectLanguage.connect(setLanguage)
+ stackView.currentItem.closeForm.connect(closeForm)
}
}
@@ -193,6 +197,11 @@ ApplicationWindow {
map.geocodeModel.query = geocode
map.geocodeModel.update()
}
+
+ function setLanguage(lang) {
+ map.plugin.locales = lang;
+ stackView.pop(page)
+ }
}
function showMessage(title,message,backPage) {
@@ -281,9 +290,6 @@ ApplicationWindow {
onRouteError: {\
showMessage(qsTr("Route Error"),qsTr("Unable to find a route for the given points"),page);\
}\
- onRequestLocale:{\
- page.state = "Locale";\
- }\
onShowGeocodeInfo:{\
showMessage(qsTr("Location"),geocodeMessage(),page);\
}\
@@ -426,45 +432,6 @@ ApplicationWindow {
color: "lightgrey"
z:2
}
-
- //=====================Dialogs=====================
-
- //Get new locale
- OwnControls.InputDialog {
- id: localeDialog
- title: "New Locale"
- z: backgroundRect.z + 2
-
- Component.onCompleted: {
- var obj = [["Language", ""]]
- setModel(obj)
- }
-
- onGoButtonClicked: {
- page.state = ""
- map.setLanguage(dialogModel.get(0).inputText.split(Qt.locale().groupSeparator));
- }
-
- onCancelButtonClicked: {
- page.state = ""
- }
- }
-
- //=====================States of page=====================
- states: [
- State {
- name : "Locale"
- PropertyChanges { target: localeDialog; opacity: 1 }
- }
- ]
-
- //=====================State-transition animations for page=====================
- transitions: [
- Transition {
- to: ""
- NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
- }
- ]
}
}
}
diff --git a/examples/location/mapviewer/mapviewerwrapper.qrc b/examples/location/mapviewer/mapviewerwrapper.qrc
index ba45e928..b5fcc9ac 100644
--- a/examples/location/mapviewer/mapviewerwrapper.qrc
+++ b/examples/location/mapviewer/mapviewerwrapper.qrc
@@ -24,5 +24,6 @@
<file>ReverseGeocode.qml</file>
<file>MapPopupMenu.qml</file>
<file>MarkerPopupMenu.qml</file>
+ <file>Locale.qml</file>
</qresource>
</RCC>