2 * Copyright (C) 2017 Konsulko Group
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "mastervolume.h"
21 MasterVolume::MasterVolume(QObject* parent) :
25 VehicleSignalsConfig vsConfig("homescreen");
26 m_vs = new VehicleSignals(vsConfig);
29 QObject::connect(m_vs, &VehicleSignals::connected, this, &MasterVolume::onConnected);
35 MasterVolume::~MasterVolume()
40 qint32 MasterVolume::getVolume() const
45 void MasterVolume::setVolume(quint32 volume)
47 if (m_volume == volume)
53 m_vs->set("Vehicle.Cabin.Infotainment.Media.Volume", volume, true);
56 void MasterVolume::updateVolume(QString value)
59 quint32 volume = value.toUInt(&ok);
61 volume = qBound(0U, volume, 100U);
62 if (m_volume != volume) {
69 void MasterVolume::onConnected()
74 QObject::connect(m_vs, &VehicleSignals::getSuccessResponse, this, &MasterVolume::onGetSuccessResponse);
75 QObject::connect(m_vs, &VehicleSignals::signalNotification, this, &MasterVolume::onSignalNotification);
77 m_vs->subscribe("Vehicle.Cabin.Infotainment.Media.Volume");
78 m_vs->get("Vehicle.Cabin.Infotainment.Media.Volume");
81 void MasterVolume::onGetSuccessResponse(QString path, QString value, QString timestamp)
83 if (path == "Vehicle.Cabin.Infotainment.Media.Volume") {
89 void MasterVolume::onSignalNotification(QString path, QString value, QString timestamp)
91 if (path == "Vehicle.Cabin.Infotainment.Media.Volume")