Changeset View
Changeset View
Standalone View
Standalone View
src/imports/declarativedevice.cpp
Show All 16 Lines | |||||
17 | * Lesser General Public License for more details. | 17 | * Lesser General Public License for more details. | ||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include "declarativedevice.h" | 23 | #include "declarativedevice.h" | ||
24 | #include "declarativeadapter.h" | 24 | #include "declarativeadapter.h" | ||
25 | #include "declarativebattery.h" | ||||
25 | #include "declarativeinput.h" | 26 | #include "declarativeinput.h" | ||
26 | #include "declarativemediaplayer.h" | 27 | #include "declarativemediaplayer.h" | ||
27 | 28 | | |||
28 | #include <QStringList> | 29 | #include <QStringList> | ||
29 | 30 | | |||
30 | DeclarativeDevice::DeclarativeDevice(BluezQt::DevicePtr device, DeclarativeAdapter *adapter) | 31 | DeclarativeDevice::DeclarativeDevice(BluezQt::DevicePtr device, DeclarativeAdapter *adapter) | ||
31 | : QObject(adapter) | 32 | : QObject(adapter) | ||
32 | , m_device(device) | 33 | , m_device(device) | ||
33 | , m_adapter(adapter) | 34 | , m_adapter(adapter) | ||
35 | , m_battery(nullptr) | ||||
34 | , m_input(nullptr) | 36 | , m_input(nullptr) | ||
35 | , m_mediaPlayer(nullptr) | 37 | , m_mediaPlayer(nullptr) | ||
36 | { | 38 | { | ||
37 | connect(m_device.data(), &BluezQt::Device::nameChanged, this, &DeclarativeDevice::nameChanged); | 39 | connect(m_device.data(), &BluezQt::Device::nameChanged, this, &DeclarativeDevice::nameChanged); | ||
38 | connect(m_device.data(), &BluezQt::Device::friendlyNameChanged, this, &DeclarativeDevice::friendlyNameChanged); | 40 | connect(m_device.data(), &BluezQt::Device::friendlyNameChanged, this, &DeclarativeDevice::friendlyNameChanged); | ||
39 | connect(m_device.data(), &BluezQt::Device::remoteNameChanged, this, &DeclarativeDevice::remoteNameChanged); | 41 | connect(m_device.data(), &BluezQt::Device::remoteNameChanged, this, &DeclarativeDevice::remoteNameChanged); | ||
40 | connect(m_device.data(), &BluezQt::Device::deviceClassChanged, this, &DeclarativeDevice::deviceClassChanged); | 42 | connect(m_device.data(), &BluezQt::Device::deviceClassChanged, this, &DeclarativeDevice::deviceClassChanged); | ||
41 | connect(m_device.data(), &BluezQt::Device::typeChanged, this, &DeclarativeDevice::typeChanged); | 43 | connect(m_device.data(), &BluezQt::Device::typeChanged, this, &DeclarativeDevice::typeChanged); | ||
42 | connect(m_device.data(), &BluezQt::Device::appearanceChanged, this, &DeclarativeDevice::appearanceChanged); | 44 | connect(m_device.data(), &BluezQt::Device::appearanceChanged, this, &DeclarativeDevice::appearanceChanged); | ||
43 | connect(m_device.data(), &BluezQt::Device::iconChanged, this, &DeclarativeDevice::iconChanged); | 45 | connect(m_device.data(), &BluezQt::Device::iconChanged, this, &DeclarativeDevice::iconChanged); | ||
44 | connect(m_device.data(), &BluezQt::Device::pairedChanged, this, &DeclarativeDevice::pairedChanged); | 46 | connect(m_device.data(), &BluezQt::Device::pairedChanged, this, &DeclarativeDevice::pairedChanged); | ||
45 | connect(m_device.data(), &BluezQt::Device::trustedChanged, this, &DeclarativeDevice::trustedChanged); | 47 | connect(m_device.data(), &BluezQt::Device::trustedChanged, this, &DeclarativeDevice::trustedChanged); | ||
46 | connect(m_device.data(), &BluezQt::Device::blockedChanged, this, &DeclarativeDevice::blockedChanged); | 48 | connect(m_device.data(), &BluezQt::Device::blockedChanged, this, &DeclarativeDevice::blockedChanged); | ||
47 | connect(m_device.data(), &BluezQt::Device::legacyPairingChanged, this, &DeclarativeDevice::legacyPairingChanged); | 49 | connect(m_device.data(), &BluezQt::Device::legacyPairingChanged, this, &DeclarativeDevice::legacyPairingChanged); | ||
48 | connect(m_device.data(), &BluezQt::Device::rssiChanged, this, &DeclarativeDevice::rssiChanged); | 50 | connect(m_device.data(), &BluezQt::Device::rssiChanged, this, &DeclarativeDevice::rssiChanged); | ||
49 | connect(m_device.data(), &BluezQt::Device::connectedChanged, this, &DeclarativeDevice::connectedChanged); | 51 | connect(m_device.data(), &BluezQt::Device::connectedChanged, this, &DeclarativeDevice::connectedChanged); | ||
50 | connect(m_device.data(), &BluezQt::Device::uuidsChanged, this, &DeclarativeDevice::uuidsChanged); | 52 | connect(m_device.data(), &BluezQt::Device::uuidsChanged, this, &DeclarativeDevice::uuidsChanged); | ||
51 | connect(m_device.data(), &BluezQt::Device::modaliasChanged, this, &DeclarativeDevice::modaliasChanged); | 53 | connect(m_device.data(), &BluezQt::Device::modaliasChanged, this, &DeclarativeDevice::modaliasChanged); | ||
52 | connect(m_device.data(), &BluezQt::Device::mediaPlayerChanged, this, &DeclarativeDevice::updateMediaPlayer); | 54 | connect(m_device.data(), &BluezQt::Device::mediaPlayerChanged, this, &DeclarativeDevice::updateMediaPlayer); | ||
53 | connect(m_device.data(), &BluezQt::Device::inputChanged, this, &DeclarativeDevice::updateInput); | 55 | connect(m_device.data(), &BluezQt::Device::inputChanged, this, &DeclarativeDevice::updateInput); | ||
56 | connect(m_device.data(), &BluezQt::Device::batteryChanged, this, &DeclarativeDevice::updateBattery); | ||||
54 | 57 | | |||
55 | connect(m_device.data(), &BluezQt::Device::deviceRemoved, this, [this]() { | 58 | connect(m_device.data(), &BluezQt::Device::deviceRemoved, this, [this]() { | ||
56 | Q_EMIT deviceRemoved(this); | 59 | Q_EMIT deviceRemoved(this); | ||
57 | }); | 60 | }); | ||
58 | 61 | | |||
59 | connect(m_device.data(), &BluezQt::Device::deviceChanged, this, [this]() { | 62 | connect(m_device.data(), &BluezQt::Device::deviceChanged, this, [this]() { | ||
60 | Q_EMIT deviceChanged(this); | 63 | Q_EMIT deviceChanged(this); | ||
61 | }); | 64 | }); | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 161 | { | |||
159 | return m_device->uuids(); | 162 | return m_device->uuids(); | ||
160 | } | 163 | } | ||
161 | 164 | | |||
162 | QString DeclarativeDevice::modalias() const | 165 | QString DeclarativeDevice::modalias() const | ||
163 | { | 166 | { | ||
164 | return m_device->modalias(); | 167 | return m_device->modalias(); | ||
165 | } | 168 | } | ||
166 | 169 | | |||
170 | DeclarativeBattery *DeclarativeDevice::battery() const | ||||
171 | { | ||||
172 | return m_battery; | ||||
173 | } | ||||
174 | | ||||
167 | DeclarativeInput *DeclarativeDevice::input() const | 175 | DeclarativeInput *DeclarativeDevice::input() const | ||
168 | { | 176 | { | ||
169 | return m_input; | 177 | return m_input; | ||
170 | } | 178 | } | ||
171 | 179 | | |||
172 | DeclarativeMediaPlayer *DeclarativeDevice::mediaPlayer() const | 180 | DeclarativeMediaPlayer *DeclarativeDevice::mediaPlayer() const | ||
173 | { | 181 | { | ||
174 | return m_mediaPlayer; | 182 | return m_mediaPlayer; | ||
Show All 29 Lines | 211 | { | |||
204 | return m_device->pair(); | 212 | return m_device->pair(); | ||
205 | } | 213 | } | ||
206 | 214 | | |||
207 | BluezQt::PendingCall *DeclarativeDevice::cancelPairing() | 215 | BluezQt::PendingCall *DeclarativeDevice::cancelPairing() | ||
208 | { | 216 | { | ||
209 | return m_device->cancelPairing(); | 217 | return m_device->cancelPairing(); | ||
210 | } | 218 | } | ||
211 | 219 | | |||
220 | void DeclarativeDevice::updateBattery() | ||||
221 | { | ||||
222 | if (m_battery) { | ||||
223 | m_battery->deleteLater(); | ||||
224 | m_battery = nullptr; | ||||
225 | } | ||||
226 | | ||||
227 | if (m_device->battery()) { | ||||
228 | m_battery = new DeclarativeBattery(m_device->battery(), this); | ||||
229 | } | ||||
230 | | ||||
231 | Q_EMIT batteryChanged(m_battery); | ||||
232 | } | ||||
233 | | ||||
212 | void DeclarativeDevice::updateInput() | 234 | void DeclarativeDevice::updateInput() | ||
213 | { | 235 | { | ||
214 | if (m_input) { | 236 | if (m_input) { | ||
215 | m_input->deleteLater(); | 237 | m_input->deleteLater(); | ||
216 | m_input = nullptr; | 238 | m_input = nullptr; | ||
217 | } | 239 | } | ||
218 | 240 | | |||
219 | if (m_device->input()) { | 241 | if (m_device->input()) { | ||
Show All 19 Lines |