| 1 |
/* |
| 2 |
* Copyright 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
*/ |
| 17 |
|
| 18 |
import QtQuick 2.0 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Lomiri.Components.ListItems 1.3 as ListItem |
| 21 |
|
| 22 |
/*! |
| 23 |
\brief An application to test locales on the device |
| 24 |
|
| 25 |
Demonstrates following: |
| 26 |
- ListItem |
| 27 |
- MainView |
| 28 |
- Label |
| 29 |
|
| 30 |
Uses: |
| 31 |
- Date() |
| 32 |
- Qt.locale |
| 33 |
*/ |
| 34 |
|
| 35 |
MainView { |
| 36 |
// objectName for functional testing purposes (autopilot-qt5) |
| 37 |
objectName: "mainView" |
| 38 |
|
| 39 |
// Note! applicationName needs to match the .desktop filename |
| 40 |
applicationName: "locale" |
| 41 |
|
| 42 |
/* |
| 43 |
This property enables the application to change orientation |
| 44 |
when the device is rotated. The default is false. |
| 45 |
*/ |
| 46 |
|
| 47 |
id: root |
| 48 |
width: units.gu(100) |
| 49 |
height: units.gu(75) |
| 50 |
automaticOrientation: true |
| 51 |
property string locale: view.currentItem.locale |
| 52 |
|
| 53 |
Page { |
| 54 |
id: page |
| 55 |
Item { |
| 56 |
id: chooser |
| 57 |
anchors { |
| 58 |
top: parent.top |
| 59 |
left: parent.left |
| 60 |
right: parent.right |
| 61 |
} |
| 62 |
height: parent.height/2 |
| 63 |
ListView { |
| 64 |
highlightFollowsCurrentItem: true |
| 65 |
id: view |
| 66 |
clip: true |
| 67 |
focus: true |
| 68 |
anchors.fill: parent |
| 69 |
model: [ |
| 70 |
"hu_HU", |
| 71 |
"he-IL", |
| 72 |
"en_US", |
| 73 |
"en_GB", |
| 74 |
"fi_FI", |
| 75 |
"de_DE", |
| 76 |
"ar_SA", |
| 77 |
"hi_IN", |
| 78 |
"zh_CN", |
| 79 |
"th_TH", |
| 80 |
"fr_FR", |
| 81 |
"nb_NO", |
| 82 |
"sv_SE" |
| 83 |
] |
| 84 |
delegate: ListItem.Standard { |
| 85 |
property string locale: modelData |
| 86 |
text: Qt.locale(modelData).name + " ("+ Qt.locale(modelData).nativeCountryName + "/" + Qt.locale(modelData).nativeLanguageName + ")" |
| 87 |
onClicked: view.currentIndex = index |
| 88 |
} |
| 89 |
highlight: Rectangle { |
| 90 |
height: units.gu(2) |
| 91 |
width: view.width |
| 92 |
color: theme.palette.selected.background |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
Rectangle { |
| 97 |
anchors { |
| 98 |
top: chooser.bottom |
| 99 |
topMargin: units.gu(0.5) |
| 100 |
leftMargin: units.gu(0.5) |
| 101 |
bottom: parent.bottom |
| 102 |
} |
| 103 |
color: theme.palette.normal.base |
| 104 |
width: parent.width |
| 105 |
Column { |
| 106 |
anchors.fill: parent |
| 107 |
spacing: units.gu(0.5) |
| 108 |
Label { |
| 109 |
textSize: Label.Large |
| 110 |
property var date: new Date() |
| 111 |
text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale)) |
| 112 |
} |
| 113 |
Label { |
| 114 |
textSize: Label.Large |
| 115 |
property var date: new Date() |
| 116 |
text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale)) |
| 117 |
} |
| 118 |
Label { |
| 119 |
textSize: Label.Large |
| 120 |
property var dow: Qt.locale(root.locale).firstDayOfWeek |
| 121 |
text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow) |
| 122 |
} |
| 123 |
Label { |
| 124 |
textSize: Label.Large |
| 125 |
property var num: 10023823 |
| 126 |
text: "Number: " + num.toLocaleString(Qt.locale(root.locale)) |
| 127 |
} |
| 128 |
Label { |
| 129 |
textSize: Label.Large |
| 130 |
property var num: 10023823 |
| 131 |
text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale)) |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
} |
| 136 |
} |