Skip to content

Commit

Permalink
Compound set of UI changes as per version 0.0.1 of https://openrepos.…
Browse files Browse the repository at this point in the history
…net/content/pichlo/patch-alternative-ui-pure-maps

I have a local copy with a full history of how I got here but, being a Git newbie, have no idea how to merge it while preserving the history of both, so I am starting from a given snapshot in time.
  • Loading branch information
pepichle committed Oct 15, 2018
1 parent 46e1e96 commit 0a117fe
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 658 deletions.
8 changes: 5 additions & 3 deletions poor/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def read_gpx(path):
file=sys.stderr)
raise # Exception
return x, y

def read_json(path):
"""Read data from JSON file at `path`."""
try:
Expand Down Expand Up @@ -515,8 +515,10 @@ def round_distance(meters, n=2):

def siground(x, n):
"""Round `x` to `n` significant digits."""
mult = 10**(n - math.floor(math.log10(x)) - 1)
return round(x * mult) / mult
mult = 10**(n - 1)
if x < mult:
return round(x * mult) / mult
return round(x)

@contextlib.contextmanager
def silent(*exceptions, tb=False):
Expand Down
11 changes: 1 addition & 10 deletions qml/AttributionButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ import Sailfish.Silica 1.0
IconButton {
id: attributionButton
anchors.left: parent.left
anchors.top: navigationBlock.bottom
anchors.top: app.portrait ? narrativeLabel.bottom : parent.top
height: icon.height
icon.height: icon.sourceSize.height
icon.smooth: false
icon.source: app.getIcon("icons/attribution/default")
icon.width: icon.sourceSize.width
states: [
State {
when: !app.portrait && navigationBlockLandscapeLeftShield.height > 0
AnchorChanges {
target: attributionButton
anchors.top: navigationBlockLandscapeLeftShield.bottom
}
}
]
width: icon.width
z: 500

Expand Down
21 changes: 1 addition & 20 deletions qml/CenterButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,12 @@ import Sailfish.Silica 1.0
IconButton {
id: button
anchors.right: parent.right
anchors.top: navigationSign.bottom
anchors.verticalCenter: attributionButton.verticalCenter
height: icon.height
icon.height: icon.sourceSize.height
icon.smooth: false
icon.source: app.getIcon("icons/center")
icon.width: icon.sourceSize.width
states: [
State {
when: app.mode !== modes.explore && app.portrait
AnchorChanges {
target: button
anchors.right: undefined
anchors.horizontalCenter: northArrow.horizontalCenter
}
},
State {
when: app.mode !== modes.explore && !app.portrait
AnchorChanges {
target: button
anchors.right: northArrow.left
anchors.top: undefined
anchors.verticalCenter: northArrow.verticalCenter
}
}
]
width: icon.width
z: 500

Expand Down
32 changes: 23 additions & 9 deletions qml/Map.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import "js/util.js" as Util

MapboxMap {
id: map
anchors.fill: parent
anchors.right: parent.right
anchors.bottom: parent.bottom
cacheDatabaseDefaultPath: true
cacheDatabaseStoreSettings: false
center: QtPositioning.coordinate(49, 13)
Expand All @@ -40,8 +41,27 @@ MapboxMap {
pixelRatio: Theme.pixelRatio * 1.5
zoomLevel: 4.0

states: [
State {
when: app.portrait
AnchorChanges {
target: map
anchors.top: navigationBlock.bottom
anchors.left: parent.left
}
},
State {
when: !app.portrait
AnchorChanges {
target: map
anchors.top: parent.top
anchors.left: navigationBlock.right
}
}
]

// Token for Mapbox.com-hosted maps, i.e. sources with mapbox:// URLs.
accessToken: "#MAPBOX_KEY#"
accessToken: "pk.eyJ1IjoicmluaWd1cyIsImEiOiJjamxiMWF2N3gxNDI4M2ttdHNsYWxoOGFyIn0.0znRguypZfUcijqfBFyP3g"

property bool autoCenter: false
property bool autoRotate: false
Expand Down Expand Up @@ -142,11 +162,6 @@ MapboxMap {
onHeightChanged: map.updateMargins();
}

Connections {
target: navigationInfoBlock
onHeightChanged: map.updateMargins();
}

Connections {
target: poiPanel
onHeightChanged: map.updateMargins();
Expand Down Expand Up @@ -219,7 +234,7 @@ MapboxMap {

function _addPoi(poi) {
if (hasPoi(poi)) return false; // avoid duplicates
// Add new POI marker to the map.
// Add new POI marker to the map.
map.pois.push({
"address": poi.address || "",
"bookmarked": poi.bookmarked || false,
Expand Down Expand Up @@ -673,7 +688,6 @@ MapboxMap {
// Calculate new margins and set them for the map.
var header = navigationBlock && navigationBlock.height > 0 ? navigationBlock.height : map.height*0.05;
var footer = !app.poiActive && app.mode === modes.explore && menuButton ? (map.height-menuButton.y) : 0;
footer += !app.poiActive && (app.mode === modes.navigate || app.mode === modes.followMe) && app.portrait && navigationInfoBlock ? navigationInfoBlock.height : 0;
footer += !app.poiActive && (app.mode === modes.navigate || app.mode === modes.followMe) && streetName ? streetName.height : 0
footer += app.poiActive && poiPanel ? poiPanel.height : 0
footer = Math.min(footer, map.height / 2.0);
Expand Down
2 changes: 1 addition & 1 deletion qml/MenuButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IconButton {
icon.source: app.getIcon("icons/menu")
icon.width: icon.sourceSize.width
width: icon.width
visible: app.mode === modes.explore && !app.poiActive
visible: !app.poiActive
z: 900
onClicked: app.showMenu();
}
16 changes: 8 additions & 8 deletions qml/Meters.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import "js/util.js" as Util

Item {
id: meters
anchors.right: northArrow.left
anchors.rightMargin: Theme.paddingSmall
anchors.verticalCenter: northArrow.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingLarge
height: labels.implicitHeight
opacity: 0.9
width: parent.width
visible: app.mode === modes.explore && !app.poiActive
visible: !app.poiActive
z: 400

Text {
Expand Down Expand Up @@ -71,7 +72,7 @@ Item {
if (app.conf.units === "american") {
labels.text = " %1\n %2".arg(app.tr("mph")).arg(app.tr("ft"))
if (gps.position.speedValid)
lines[0] = Math.round(gps.position.speed * 2.23694);
lines[0] = Util.siground(gps.position.speed * 2.23694, 2);
if (gps.position.horizontalAccuracyValid)
lines[1] = Util.siground(gps.position.horizontalAccuracy * 3.28084, 2);
lines[1] = "\u2300 %1".arg(lines[1]);
Expand All @@ -81,7 +82,7 @@ Item {
} else if (app.conf.units === "british") {
labels.text = " %1\n %2".arg(app.tr("mph")).arg(app.tr("yd"))
if (gps.position.speedValid)
lines[0] = Math.round(gps.position.speed * 2.23694);
lines[0] = Util.siground(gps.position.speed * 2.23694, 2);
if (gps.position.horizontalAccuracyValid)
lines[1] = Util.siground(gps.position.horizontalAccuracy * 1.09361, 2);
lines[1] = "\u2300 %1".arg(lines[1]);
Expand All @@ -91,7 +92,7 @@ Item {
} else {
labels.text = " %1\n %2".arg(app.tr("km/h")).arg(app.tr("m"))
if (gps.position.speedValid)
lines[0] = Math.round(gps.position.speed * 3.6);
lines[0] = Util.siground(gps.position.speed * 3.6, 2);
if (gps.position.horizontalAccuracyValid)
lines[1] = Util.siground(gps.position.horizontalAccuracy, 2);
lines[1] = "\u2300 %1".arg(lines[1]);
Expand All @@ -100,5 +101,4 @@ Item {

}
}

}
75 changes: 75 additions & 0 deletions qml/NarrativeLabel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* -*- coding: utf-8-unix -*-
*
* Copyright (C) 2014 Osmo Salomaa, 2018 Rinigus
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.0
import Sailfish.Silica 1.0

import "js/util.js" as Util

Rectangle {
id: block
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
width: notify
? (app.portrait ? app.screenWidth : app.screenHeight)
: 0
height: notify ? narrativeLabelText.height : 0
radius: app.portrait ? 0 : Theme.paddingMedium
color: app.styler.blockBg

property bool notify: app.navigationStatus.notify
property string narrative: app.navigationStatus.narrative
property var street: app.navigationStatus.street

Label {
id: narrativeLabelText
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.leftMargin: Theme.paddingLarge
anchors.rightMargin: Theme.paddingLarge
color: Theme.primaryColor
font.pixelSize: streetNameShown ? Theme.fontSizeExtraLarge : Theme.fontSizeMedium
height: text ? implicitHeight + Theme.paddingMedium : 0
maximumLineCount: streetNameShown ? 1 : 2
truncationMode: TruncationMode.Fade
text: block.notify
? (app.navigationPageSeen
? (block.street ? streetName : block.narrative)
: app.tr("Tap to review maneuvers or begin navigating"))
: ""
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap

property bool streetNameShown: block.notify && app.navigationPageSeen && block.street
property string streetName: {
var s = "";
for (var i in block.street) {
if (s != "") s += "; "
s += block.street[i];
}
return s;
}
}

MouseArea {
anchors.fill: parent
onClicked: app.showNavigationPages();
}
}
Loading

0 comments on commit 0a117fe

Please sign in to comment.