diff --git a/src/modules/localeq/CMakeLists.txt b/src/modules/localeq/CMakeLists.txt index ff5292f3a..280c95c62 100644 --- a/src/modules/localeq/CMakeLists.txt +++ b/src/modules/localeq/CMakeLists.txt @@ -6,6 +6,17 @@ if( DEBUG_TIMEZONES ) add_definitions( -DDEBUG_TIMEZONES ) endif() +find_package(Qt5Location CONFIG) +set_package_properties(Qt5Location PROPERTIES + DESCRIPTION "Used for rendering the map" + TYPE RUNTIME +) +find_package(Qt5Positioning CONFIG) +set_package_properties(Qt5Positioning PROPERTIES + DESCRIPTION "Used for GeoLocation and GeoCoding" + TYPE RUNTIME +) + # Because we're sharing sources with the regular locale module set( _locale ${CMAKE_CURRENT_SOURCE_DIR}/../locale ) diff --git a/src/modules/localeq/Map.qml b/src/modules/localeq/Map.qml new file mode 100644 index 000000000..023de6d1b --- /dev/null +++ b/src/modules/localeq/Map.qml @@ -0,0 +1,243 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Anke Boersma + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +import QtQuick 2.10 +import QtQuick.Controls 2.10 +import QtQuick.Window 2.14 +import QtQuick.Layouts 1.3 + +import org.kde.kirigami 2.7 as Kirigami + +import QtLocation 5.14 +import QtPositioning 5.14 + +Column { + width: parent.width + + //Needs to come from .conf/geoip + property var configCity: "New York" + property var configCountry: "USA" + property var configTimezone: "America/New York" + property var geoipCity: "" //"Amsterdam" + property var geoipCountry: "" //"Netherlands" + property var geoipTimezone: "" //"Europe/Amsterdam" + // vars that will stay once connected + property var cityName: (geoipCity != "") ? geoipCity : configCity + property var countryName: (geoipCountry != "") ? geoipCountry : configCountry + property var timeZone: (geoipTimezone != "") ? geoipTimezone : configTimezone + + function getIp() { + var xhr = new XMLHttpRequest + + xhr.onreadystatechange = function() { + if (xhr.readyState === XMLHttpRequest.DONE) { + var responseJSON = JSON.parse(xhr.responseText) + var tz = responseJSON.timezone + var ct = responseJSON.city + var cy = responseJSON.country + + tzText.text = "Timezone: " + tz + cityName = ct + countryName = cy + } + } + + // Define the target of the request + xhr.open("GET", "https://get.geojs.io/v1/ip/geo.json") + // Execute the request + xhr.send() + } + + function getTz() { + var xhr = new XMLHttpRequest + var latC = map.center.latitude + var lonC = map.center.longitude + + xhr.onreadystatechange = function() { + if (xhr.readyState === XMLHttpRequest.DONE) { + var responseJSON = JSON.parse(xhr.responseText) + var tz2 = responseJSON.timezoneId + + tzText.text = "Timezone: " + tz2 + } + } + + // Needs to move to localeq.conf, each distribution will need their own account + xhr.open("GET", "http://api.geonames.org/timezoneJSON?lat=" + latC + "&lng=" + lonC + "&username=SOME_USERNAME") + xhr.send() + } + + Rectangle { + width: parent.width + height: parent.height / 1.28 + + Plugin { + id: mapPlugin + name: "esri" // "esri", "here", "itemsoverlay", "mapbox", "mapboxgl", "osm" + } + + Map { + id: map + anchors.fill: parent + plugin: mapPlugin + activeMapType: supportedMapTypes[0] + //might be desirable to set zoom level configurable? + zoomLevel: 5 + bearing: 0 + tilt: 0 + copyrightsVisible : true + fieldOfView : 0 + + GeocodeModel { + id: geocodeModel + plugin: mapPlugin + autoUpdate: true + query: Address { + id: address + city: cityName + country: countryName + } + + onLocationsChanged: { + if (count == 1) { + map.center.latitude = get(0).coordinate.latitude + map.center.longitude = get(0).coordinate.longitude + } + } + } + + MapQuickItem { + id: marker + anchorPoint.x: image.width/4 + anchorPoint.y: image.height + coordinate: QtPositioning.coordinate( + map.center.latitude, + map.center.longitude) + //coordinate: QtPositioning.coordinate(40.730610, -73.935242) // New York + + sourceItem: Image { + id: image + width: 32 + height: 32 + source: "img/pin.svg" + } + } + + MouseArea { + acceptedButtons: Qt.LeftButton + anchors.fill: map + hoverEnabled: true + property var coordinate: map.toCoordinate(Qt.point(mouseX, mouseY)) + Label { + x: parent.mouseX - width + y: parent.mouseY - height - 5 + text: "%1, %2".arg( + parent.coordinate.latitude).arg(parent.coordinate.longitude) + } + + onClicked: { + marker.coordinate = coordinate + map.center.latitude = coordinate.latitude + map.center.longitude = coordinate.longitude + + getTz(); + + console.log(coordinate.latitude, coordinate.longitude) + } + } + } + + Column { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.bottomMargin: 5 + anchors.rightMargin: 10 + + MouseArea { + width: 32 + height:32 + cursorShape: Qt.PointingHandCursor + Image { + source: "img/plus.png" + anchors.centerIn: parent + width: 36 + height: 36 + } + + onClicked: map.zoomLevel++ + } + + MouseArea { + width: 32 + height:32 + cursorShape: Qt.PointingHandCursor + Image { + source: "img/minus.png" + anchors.centerIn: parent + width: 32 + height: 32 + } + + onClicked: map.zoomLevel-- + } + } + } + + Rectangle { + width: parent.width + height: 100 + anchors.horizontalCenter: parent.horizontalCenter + + Item { + id: location + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary + anchors.horizontalCenter: parent.horizontalCenter + + Rectangle { + anchors.centerIn: parent + width: 300 + height: 30 + color: Kirigami.Theme.backgroundColor + + Text { + id: tzText + text: tzText.text + //text: qsTr("Timezone: %1").arg(timeZone) + color: Kirigami.Theme.textColor + anchors.centerIn: parent + } + + Component.onCompleted: getIp(); + } + } + + Text { + anchors.top: location.bottom + anchors.topMargin: 20 + padding: 10 + width: parent.width + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + Kirigami.Theme.backgroundColor: Kirigami.Theme.backgroundColor + text: qsTr("Please select your preferred location on the map so the installer can suggest the locale + and timezone settings for you. You can fine-tune the suggested settings below. Search the map by dragging + to move and using the +/- buttons to zoom in/out or use mouse scrolling for zooming.") + } + } +} diff --git a/src/modules/localeq/Offline.qml b/src/modules/localeq/Offline.qml new file mode 100644 index 000000000..8e9d91280 --- /dev/null +++ b/src/modules/localeq/Offline.qml @@ -0,0 +1,80 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Anke Boersma + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +import QtQuick 2.10 +import QtQuick.Controls 2.10 +import QtQuick.Window 2.14 +import QtQuick.Layouts 1.3 + +import org.kde.kirigami 2.7 as Kirigami + +Column { + width: parent.width + + //Needs to come from localeq.conf + property var configTimezone: "America/New York" + + Rectangle { + width: parent.width + height: parent.height / 1.28 + + Image { + id: image + anchors.fill: parent + source: "img/worldmap.png" + width: parent.width + } + } + + Rectangle { + width: parent.width + height: 100 + anchors.horizontalCenter: parent.horizontalCenter + + Item { + id: location + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary + anchors.horizontalCenter: parent.horizontalCenter + + Rectangle { + anchors.centerIn: parent + width: 300 + height: 30 + color: Kirigami.Theme.backgroundColor + + Text { + text: qsTr("Timezone: %1").arg(configTimezone) + color: Kirigami.Theme.textColor + anchors.centerIn: parent + } + } + } + + Text { + anchors.top: location.bottom + anchors.topMargin: 20 + padding: 10 + width: parent.width + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + Kirigami.Theme.backgroundColor: Kirigami.Theme.backgroundColor + text: qsTr("To be able to select a timezone, make sure you are connected to the internet. Restart the installer after connecting. You can fine-tune Language and Locale settings below.") + } + } +} diff --git a/src/modules/localeq/i18n.qml b/src/modules/localeq/i18n.qml new file mode 100644 index 000000000..a806d0174 --- /dev/null +++ b/src/modules/localeq/i18n.qml @@ -0,0 +1,189 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Anke Boersma + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +import io.calamares.ui 1.0 + +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 + +import org.kde.kirigami 2.7 as Kirigami + +Item { + width: parent.width + height: parent.height + focus: true + MouseArea { + anchors.fill: parent + } + + //Needs to come from Locale config + property var confLang: "en_US.UTF8" + property var confLocale: "nl_NL.UTF8" + + Rectangle { + id: textArea + x: 28 + y: 14 + anchors.fill: parent + Kirigami.Theme.backgroundColor: Kirigami.Theme.backgroundColor + + Column { + id: languages + x: 130 + y: 40 + + Rectangle { + width: 250 + height: 140 + color: "#d3d3d3" + Text { + anchors.top: parent.top + width: 240 + wrapMode: Text.WordWrap + text: qsTr("

Languages


+ The system locale setting affects the language and character set for some command line user interface elements. The current setting is %1.").arg(confLang) + font.pointSize: 10 + } + } + + Rectangle { + width: 250 + height: 300 + + ScrollView { + id: scroll1 + anchors.fill: parent + contentHeight: 800 + clip: true + + ListView { + id: list1 + focus: true + + // bogus entries, need to come from Locale config + model: ["en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8"] + + currentIndex: 1 + highlight: Rectangle { + color: Kirigami.Theme.highlightColor + } + delegate: Text { + text: modelData + + MouseArea { + hoverEnabled: true + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onEntered: { + color: "#0000ff" + } + onClicked: { + list1.currentIndex = index + confLang = list1.currentIndex + } + } + } + } + } + } + } + + Column { + id: i18n + x: 430 + y: 40 + + Rectangle { + width: 250 + height: 140 + color: "#d3d3d3" + Text { + anchors.top: parent.top + width: 240 + wrapMode: Text.WordWrap + text: qsTr("

Locales


+ The system locale setting affects the language and character set for some command line user interface elements. The current setting is %1.").arg(confLocale) + font.pointSize: 10 + } + } + + Rectangle { + width: 250 + height: 300 + + ScrollView { + id: scroll2 + anchors.fill: parent + contentHeight: 800 + clip: true + + ListView { + id: list2 + width: 180; height: 200 + focus: true + + // bogus entries, need to come from Locale config + model: ["en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8", "en_GB.UTF-8 UTF-8", "en_US.UTF-8 UTF-8 ", "nl_NL.UTF-8 UTF-8"] + + currentIndex: 2 + highlight: Rectangle { + color: Kirigami.Theme.highlightColor + } + delegate: Text { + text: modelData + + MouseArea { + hoverEnabled: true + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + list2.currentIndex = index + confLocale = list1.currentIndex + } + } + } + onCurrentItemChanged: console.debug(currentIndex) + } + } + } + + } + + ToolButton { + id: toolButton + x: 19 + y: 29 + width: 105 + height: 48 + text: qsTr("Back") + hoverEnabled: true + onClicked: load.source = "" + + Image { + id: image1 + x: 0 + y: 13 + width: 22 + height: 22 + source: "img/chevron-left-solid.svg" + fillMode: Image.PreserveAspectFit + } + } + } +} diff --git a/src/modules/localeq/img/chevron-left-solid.svg b/src/modules/localeq/img/chevron-left-solid.svg new file mode 100644 index 000000000..41061c287 --- /dev/null +++ b/src/modules/localeq/img/chevron-left-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/localeq/img/minus.png b/src/modules/localeq/img/minus.png new file mode 100644 index 000000000..be122dff2 Binary files /dev/null and b/src/modules/localeq/img/minus.png differ diff --git a/src/modules/localeq/img/pin.svg b/src/modules/localeq/img/pin.svg new file mode 100644 index 000000000..b4185d1af --- /dev/null +++ b/src/modules/localeq/img/pin.svg @@ -0,0 +1,60 @@ + +image/svg+xml + + \ No newline at end of file diff --git a/src/modules/localeq/img/plus.png b/src/modules/localeq/img/plus.png new file mode 100644 index 000000000..3bd5d832c Binary files /dev/null and b/src/modules/localeq/img/plus.png differ diff --git a/src/modules/localeq/img/worldmap.png b/src/modules/localeq/img/worldmap.png new file mode 100644 index 000000000..c5c181985 Binary files /dev/null and b/src/modules/localeq/img/worldmap.png differ diff --git a/src/modules/localeq/localeq.qml b/src/modules/localeq/localeq.qml index 0e00d1b1b..0abdebfc9 100644 --- a/src/modules/localeq/localeq.qml +++ b/src/modules/localeq/localeq.qml @@ -1,3 +1,22 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * Copyright 2020, Anke Boersma + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + import io.calamares.core 1.0 import io.calamares.ui 1.0 @@ -5,35 +24,77 @@ import QtQuick 2.10 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami -import QtGraphicalEffects 1.0 -RowLayout -{ - Rectangle { - width: parent.width / 3 - Layout.fillWidth: true - ColumnLayout { - id: regions - Repeater { - model: config.regionModel - Text { - text: label - } - } - } +Page { + width: 800 + height: 550 + + property var confLang: "American English" + property var confLocale: "Nederland" + //Needs to come from .conf/geoip + property var hasInternet: true + + Loader { + id: image + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width + height: parent.height / 1.28 + source: (hasInternet) ? "Map.qml" : "Offline.qml" } - Rectangle { - width: parent.width / 3 - Layout.fillWidth: true - ColumnLayout { - id: zones - ListView { - model: config.zonesModel - delegate: Text { - text: label + + RowLayout { + anchors.bottom: parent.bottom + anchors.bottomMargin : 20 + width: parent.width + + Kirigami.FormLayout { + id: lang + + GridLayout { + anchors { + left: parent.left + top: parent.top + right: parent.right + } + rowSpacing: Kirigami.Units.largeSpacing + columnSpacing: Kirigami.Units.largeSpacing + + Kirigami.Icon { + source: "application-x-gettext-translation" + Layout.fillHeight: true + Layout.maximumHeight: Kirigami.Units.iconSizes.medium + Layout.preferredWidth: height + } + ColumnLayout { + Label { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: qsTr("System language set to %1").arg(confLang) + } + Kirigami.Separator { + Layout.fillWidth: true + } + Label { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: qsTr("Numbers and dates locale set to %1").arg(confLocale) + } + } + Button { + Layout.alignment: Qt.AlignRight|Qt.AlignVCenter + Layout.columnSpan: 2 + text: qsTr("Change") + //onClicked: console.log("Adjust Language clicked"); + onClicked: { + onClicked: load.source = "i18n.qml" + } } } } + + } + Loader { + id:load + anchors.fill: parent } } - diff --git a/src/modules/localeq/localeq.qrc b/src/modules/localeq/localeq.qrc index e2bf12636..591b83452 100644 --- a/src/modules/localeq/localeq.qrc +++ b/src/modules/localeq/localeq.qrc @@ -1,47 +1,13 @@ - - ../locale/images/bg.png - ../locale/images/pin.png - ../locale/images/timezone_0.0.png - ../locale/images/timezone_1.0.png - ../locale/images/timezone_2.0.png - ../locale/images/timezone_3.0.png - ../locale/images/timezone_3.5.png - ../locale/images/timezone_4.0.png - ../locale/images/timezone_4.5.png - ../locale/images/timezone_5.0.png - ../locale/images/timezone_5.5.png - ../locale/images/timezone_5.75.png - ../locale/images/timezone_6.0.png - ../locale/images/timezone_6.5.png - ../locale/images/timezone_7.0.png - ../locale/images/timezone_8.0.png - ../locale/images/timezone_9.0.png - ../locale/images/timezone_9.5.png - ../locale/images/timezone_10.0.png - ../locale/images/timezone_10.5.png - ../locale/images/timezone_11.0.png - ../locale/images/timezone_11.5.png - ../locale/images/timezone_12.0.png - ../locale/images/timezone_12.75.png - ../locale/images/timezone_13.0.png - ../locale/images/timezone_-1.0.png - ../locale/images/timezone_-2.0.png - ../locale/images/timezone_-3.0.png - ../locale/images/timezone_-3.5.png - ../locale/images/timezone_-4.0.png - ../locale/images/timezone_-4.5.png - ../locale/images/timezone_-5.0.png - ../locale/images/timezone_-5.5.png - ../locale/images/timezone_-6.0.png - ../locale/images/timezone_-7.0.png - ../locale/images/timezone_-8.0.png - ../locale/images/timezone_-9.0.png - ../locale/images/timezone_-9.5.png - ../locale/images/timezone_-10.0.png - ../locale/images/timezone_-11.0.png - + i18n.qml localeq.qml + Map.qml + Offline.qml + img/minus.png + img/pin.svg + img/plus.png + img/chevron-left-solid.svg + img/worldmap.png