-
Notifications
You must be signed in to change notification settings - Fork 7
/
GasStation.qml
144 lines (137 loc) · 6.38 KB
/
GasStation.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.Notifications 1.0
Page {
id: stationPage
clip: true
allowedOrientations: Orientation.All
property string stationId: ""
property variant station: ({ })
SilicaFlickable {
anchors.fill: parent
anchors.topMargin: Theme.verticalPageMargin
anchors.bottomMargin: Theme.verticalPageMargin
contentHeight: stationDetails.height
id: page
PullDownMenu {
busy: selectedPlugin.stationBusy
enabled: selectedPlugin.supportsFavs
MenuItem {
text: ( isFav( stationId ) ? qsTr( "Unset as Favourite" ) : qsTr( "Set as Favourite" ) )
onClicked: ( isFav( stationId ) ? unsetFav : setFav )(stationId, station.stationName)
}
}
VerticalScrollDecorator {}
Image {
id: maptile
width: parent.width
height: Math.round(selectedPlugin.stationBusy?0:stationPage.height/2.5)
function getMapSource() {
var src = "https://api.mapbox.com/v4/mapbox."+(Theme.colorScheme == Theme.LightOnDark?"dark":"light")+"/pin-l-fuel+"
src += (Theme.highlightColor+"").replace("#","")
src += "("+station.stationAdress.longitude+","+station.stationAdress.latitude+")/"
src += station.stationAdress.longitude+","+station.stationAdress.latitude+",17/"
src += Math.min(1200,width)+"x"+Math.min(1200,height)+".png?access_token=pk.eyJ1Ijoic3BhcmtleXkiLCJhIjoiY2l0MzhxODdjMDBkNDJ0bzNoMWsyd2c1YyJ9.m-yBA1wgLm3Ps_PxQ1Oasg"
return src
}
onHeightChanged: if(!selectedPlugin.stationBusy && station.stationAdress && source != getMapSource() && height > 0 ) source = getMapSource()
Connections {
target: Theme
onColorSchemeChanged: maptile.source = maptile.getMapSource()
}
Rectangle {
color: Theme.highlightColor
anchors.fill: parent
opacity: Theme.highlightBackgroundOpacity
visible: addressContainer.pressed
}
opacity: addressContainer.pressed?Theme.highlightBackgroundOpacity:0
}
OpacityRampEffect {
sourceItem: maptile
direction: OpacityRamp.TopToBottom
offset: 0.75
slope: 1/(1-offset)
}
Column {
id: stationDetails
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width-2*Theme.horizontalPageMargin
PageHeader {
title: station.stationName?station.stationName:""
}
MouseArea {
height: address.paintedHeight + 2*Theme.paddingLarge
width: parent.width
onClicked: Qt.openUrlExternally( "geo:"+station.stationAdress.latitude+","+station.stationAdress.longitude )
onPressAndHold: {
Clipboard.text = station.stationAdress.latitude+","+station.stationAdress.longitude
clipborad_notification.publish()
}
Notification {
id: clipborad_notification
isTransient: true
previewSummary: qsTr("Coordinates Copied to Clipboard")
}
id: addressContainer
visible: !selectedPlugin.stationBusy
Label {
id: address
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: Theme.paddingLarge
anchors.right: ico.left
anchors.rightMargin: Theme.paddingLarge
truncationMode: TruncationMode.Fade
wrapMode: Text.WordWrap
//Adresse
text: typeof(station.stationAdress) == "object"? ( station.stationAdress.street+"\n"+station.stationAdress.county +(station.stationAdress.country?"\n"+station.stationAdress.country:"" ) ):typeof(station.stationAdress) == "string"?station.stationAdress:""
color: addressContainer.highlighted ? Theme.highlightColor : Theme.primaryColor
font.pixelSize: Theme.fontSizeSmall
verticalAlignment: Text.AlignVCenter
}
Image {
id: ico
source: "image://theme/icon-m-whereami?" + (addressContainer.down
? Theme.highlightColor
: Theme.primaryColor)
width: height
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: Theme.paddingLarge
}
}
Repeater {
model: station.content?station.content.length:0
delegate: Column {
width: stationDetails.width
property variant items: station.content[index]?station.content[index].items:[]
SectionHeader {
visible: station.content[index]?station.content[index].title!="":false
text: station.content[index]?qsTr(station.content[index].title):""
}
Repeater {
model: items.length
delegate: ListText {
Component.onCompleted: {
if( items[index].tf ) titlefade = items[index].tf
if( items[index].sz ) size = items[index].sz
}
width: stationDetails.width
anchors.horizontalCenter: parent.horizontalCenter
title: items[index].title
text: items[index].text?items[index].text:items[index].price+selectedPlugin.units.currency
}
}
}
}
}
}
BusyIndicator {
anchors.centerIn: parent
running: visible
size: BusyIndicatorSize.Large
visible: selectedPlugin.stationBusy
}
}