Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/NavigationDelegate.qml
- This file was added.
1 | import QtQuick 2.9 | ||||
---|---|---|---|---|---|
2 | import QtQml.Models 2.2 | ||||
3 | import QtQuick.Controls 2.2 | ||||
4 | import QtQuick.Layouts 1.3 | ||||
5 | import Qt.WebSockets 1.0 | ||||
6 | import Qt.labs.settings 1.0 | ||||
7 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
8 | import org.kde.plasma.plasmoid 2.0 | ||||
9 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
10 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
11 | import QtWebKit 3.0 | ||||
12 | import QtWebKit.experimental 1.0 | ||||
13 | import QtGraphicalEffects 1.0 | ||||
14 | | ||||
15 | Rectangle { | ||||
16 | id: navMapDelegateItm | ||||
17 | height: units.gridUnit * 5 | ||||
18 | width: parent.width | ||||
19 | color: theme.backgroundColor | ||||
20 | | ||||
21 | function filterDirection(getInfo){ | ||||
22 | var keyleft = ["left","east"] | ||||
23 | var keyright = ["right", "west"] | ||||
24 | var keynorth = ["north", "Head"] | ||||
25 | var keyuturn = ["U-Turn", "u-turn"] | ||||
26 | var keyramp = ["ramp", "Ramp"] | ||||
27 | var keyarrive = ["Arrive", "arrive"] | ||||
28 | for (var i=0; i<keyleft.length; i++){ | ||||
29 | if (getInfo.indexOf(keyleft[i]) != -1) { | ||||
30 | navMapDirectionsImg.source = "../images/turnleft.png"; | ||||
31 | } | ||||
32 | else if (getInfo.indexOf(keyright[i]) != -1) { | ||||
33 | navMapDirectionsImg.source = "../images/turnright.png"; | ||||
34 | } | ||||
35 | else if (getInfo.indexOf(keynorth[i]) != -1) { | ||||
36 | navMapDirectionsImg.source = "../images/turnnorth.png"; | ||||
37 | } | ||||
38 | else if (getInfo.indexOf(keyuturn[i]) != -1) { | ||||
39 | navMapDirectionsImg.source = "../images/turnuturn.png"; | ||||
40 | } | ||||
41 | else if (getInfo.indexOf(keyramp[i]) != -1) { | ||||
42 | navMapDirectionsImg.source = "../images/turnramp.png"; | ||||
43 | } | ||||
44 | else if (getInfo.indexOf(keyarrive[i]) != -1) { | ||||
45 | navMapDirectionsImg.source = "../images/destination.png"; | ||||
46 | } | ||||
47 | } | ||||
48 | } | ||||
49 | | ||||
50 | Row { | ||||
51 | id: navMapRow | ||||
52 | spacing: 4 | ||||
53 | | ||||
54 | Image { | ||||
55 | id: navMapDirectionsImg | ||||
56 | width: 0 | ||||
57 | height: 64 | ||||
58 | visible: false | ||||
59 | anchors.margins: units.gridUnit * 2 | ||||
60 | } | ||||
61 | | ||||
62 | ColorOverlay{ | ||||
63 | anchors.top: navMapDirectionsImg.top | ||||
64 | anchors.bottom: navMapDirectionsImg.bottom | ||||
65 | width: 64 | ||||
66 | source: navMapDirectionsImg | ||||
67 | color: theme.linkColor | ||||
68 | } | ||||
69 | | ||||
70 | Rectangle { | ||||
71 | id: vertsepNav | ||||
72 | anchors.top: parent.top | ||||
73 | anchors.bottom: parent.bottom | ||||
74 | anchors.topMargin: units.gridUnit * 0.5 | ||||
75 | anchors.bottomMargin: units.gridUnit * 0.5 | ||||
76 | color: theme.linkColor | ||||
77 | width: 1 | ||||
78 | } | ||||
79 | | ||||
80 | Label { | ||||
81 | id: navMapDelegateItmLabel | ||||
82 | color: theme.textColor | ||||
83 | anchors.verticalCenter: parent.verticalCenter | ||||
84 | text: navInstruction | ||||
85 | Rectangle { | ||||
86 | anchors { | ||||
87 | left: parent.left | ||||
88 | right: parent.right | ||||
89 | bottom: parent.bottom | ||||
90 | bottomMargin: units.gridUnit * -0.2 | ||||
91 | } | ||||
92 | height: 1 | ||||
93 | color: theme.linkColor | ||||
94 | } | ||||
95 | onTextChanged: { | ||||
96 | filterDirection(navInstruction) | ||||
97 | } | ||||
98 | } | ||||
99 | } | ||||
100 | } | ||||
101 | |