2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (C) 2017 Konsulko Group
4 * Copyright (C) 2017 Toyota Motor Corporation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 import QtQuick.Layouts 1.1
21 import QtQuick.Controls 2.0
22 import AGL.Demo.Controls 1.0
33 onBandChanged: frequency = minimumFrequency
34 onStationFound: title = stationId
37 slider.value = frequency
41 property int connectionID
43 function slotReply(msg){
44 var jstr = JSON.stringify(msg)
45 console.log("radio: Json jstr:" + jstr)
46 var content = JSON.parse(jstr);
47 var verb = content.response.verb
48 var err = content.response.error
49 console.log("radio: verb: " + verb)
50 console.log("radio: content.response.error: " + err)
54 console.log("radio: replied by connect")
56 connectionID = content.response.mainConnectionID
57 console.log("radio: mainConnectionID is " + connectionID)
60 case "registerSource":
61 console.log("radio: replied by registerSource")
63 sourceID = content.response.sourceID
70 function slotEvent(event,msg){
71 var jstr = JSON.stringify(msg)
72 var content = JSON.parse(jstr);
73 var eventName = content.event
74 console.log("radio: event qml: event" + eventName + " msg: " + jstr)
77 case "soundmanager\/asyncSetSourceState":
78 console.log("radio: soundmanager\/asyncSetSourceState")
79 console.log("radio: my soundID:" + sourceID + "handle:" + content.data.handle + ",sourceID:" + content.data.sourceID + ",sourceState:" + content.data.sourceState)
80 if(sourceID == content.data.sourceID){
81 console.log("radio: call ackSetSourceState")
82 var arg = JSON.stringify({handle:content.data.handle, error:0})
83 smw.call("ackSetSourceState", arg)
84 switch(content.data.sourceState){
98 case "soundmanager\/asyncConnect":
99 // In reality, device shall be opened in this timing
100 if(connectionID == content.data.connectionID){
101 //radio.open_device()
104 case "soundmanager\/asyncDisconnect":
105 // In reality, device shall be closed in this timing
106 if(connectionID == content.data.connectionID){
107 // radio.close_device()
118 Layout.fillWidth: true
119 Layout.fillHeight: true
120 Layout.preferredHeight: 3
123 anchors.left: parent.left
124 anchors.right: parent.right
125 anchors.bottom: parent.bottom
126 fillMode: Image.PreserveAspectFit
127 source: './images/HMI_Radio_Equalizer.svg'
130 anchors.left: parent.left
131 anchors.right: parent.right
132 anchors.bottom: parent.bottom
142 anchors.margins: root.width * 0.02
144 Layout.fillWidth: true
145 Layout.fillHeight: true
149 source: './images/FM_Icons_FM.svg'
152 // offImage: './images/FM_Icons_FM.svg'
153 // onImage: './images/FM_Icons_AM.svg'
154 // onCheckedChanged: {
155 // radio.band = checked ? radio.amBand : radio.fmBand
156 // radio.frequency = radio.minimumFrequency
164 Layout.alignment: Layout.Center
165 text: radio.freq2str(radio.frequency)
166 horizontalAlignment: Label.AlignHCenter
167 verticalAlignment: Label.AlignVCenter
171 Layout.alignment: Layout.Center
173 horizontalAlignment: Label.AlignHCenter
174 verticalAlignment: Label.AlignVCenter
175 font.pixelSize: label.font.pixelSize * 0.6
181 Layout.fillWidth: true
182 from: radio.minimumFrequency
183 to: radio.maximumFrequency
184 stepSize: radio.frequencyStep
185 snapMode: Slider.SnapOnRelease
186 onValueChanged: radio.frequency = value
188 anchors.left: parent.left
189 anchors.bottom: parent.top
191 text: radio.freq2str(radio.minimumFrequency)
194 anchors.right: parent.right
195 anchors.bottom: parent.top
197 text: radio.freq2str(radio.maximumFrequency)
201 Layout.fillHeight: true
208 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
210 running: parent.pressed
211 triggeredOnStart: true
214 onTriggered: radio.tuneDown()
219 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
221 running: parent.pressed
222 triggeredOnStart: true
225 onTriggered: radio.tuneUp()
229 Item { Layout.fillWidth: true }
233 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
235 var JsonArg = JSON.stringify({sourceID:sourceID, sinkID:1})
237 smw.call("connect",JsonArg)
241 when: radio.state === radio.activeState
244 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
246 var JsonDisConArg = JSON.stringify({mainConnectionID:connectionID});
247 console.log(JsonDisConArg)
248 smw.call("disconnect",JsonDisConArg)
256 Item { Layout.fillWidth: true }
259 //Layout.fillWidth: true
264 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
266 running: parent.pressed
267 triggeredOnStart: true
270 onTriggered: radio.scanDown()
275 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
277 running: parent.pressed
278 triggeredOnStart: true
281 onTriggered: radio.scanUp()
290 Layout.fillWidth: true
291 Layout.fillHeight: true
292 Layout.preferredHeight: 2
295 anchors.leftMargin: 50
296 anchors.rightMargin: 50
298 header: Label { text: 'PRESETS'; opacity: 0.5 }
301 delegate: MouseArea {
302 width: ListView.view.width
303 height: ListView.view.height / 4
306 radio.band = model.modelData.band
307 radio.frequency = model.modelData.frequency
308 radio.title = model.modelData.title
314 source: './images/Radio_Active_Icon.svg'
317 Layout.fillWidth: true
319 Layout.fillWidth: true
323 Layout.fillWidth: true
324 text: radio.freq2str(model.frequency)
331 switch (model.modelData.band) {
333 return './images/FM_Icons_FM.svg'
335 return './images/FM_Icons_AM.svg'
344 Component.onCompleted: {
345 var JsonRegArg = JSON.stringify({appname:"radio"})
346 console.log(JsonRegArg)
347 smw.call("registerSource", JsonRegArg)