Skip to content

Commit 00ce693

Browse files
authored
Show toast when manual device is not found (#4932)
1 parent e73db92 commit 00ce693

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/devices/bluetooth.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ void bluetooth::finished() {
236236
return;
237237
}
238238

239+
const QString manualDevice =
240+
settings.value(QZSettings::filter_device, QZSettings::default_filter_device).toString();
241+
if (!onlyDiscover && !gymModeEnabled() &&
242+
manualDevice.compare(QZSettings::default_filter_device, Qt::CaseInsensitive) != 0) {
243+
emit manualDeviceNotFound(manualDevice);
244+
}
245+
239246
QString heartRateBeltName =
240247
settings.value(QZSettings::heart_rate_belt_name, QZSettings::default_heart_rate_belt_name).toString();
241248
QString ftmsAccessoryName =

src/devices/bluetooth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ class bluetooth : public QObject, public SignalHandler {
387387
signals:
388388
void deviceConnected(QBluetoothDeviceInfo b);
389389
void deviceFound(QString name);
390+
void manualDeviceNotFound(QString name);
390391
void searchingStop();
391392
void ftmsAccessoryConnected(smartspin2k *d);
392393

src/homeform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,12 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) {
878878
connect(bluetoothManager, &bluetooth::bluetoothDeviceConnected, this, &homeform::bluetoothDeviceConnected);
879879
connect(bluetoothManager, &bluetooth::bluetoothDeviceDisconnected, this, &homeform::bluetoothDeviceDisconnected);
880880
connect(bluetoothManager, &bluetooth::deviceFound, this, &homeform::deviceFound);
881+
connect(bluetoothManager, &bluetooth::manualDeviceNotFound, this, [this](const QString &name) {
882+
setToastRequested(
883+
QStringLiteral("QZ is looking for %1. Please wake it up or change this device under the Manual Device "
884+
"setting in Advanced Settings.")
885+
.arg(name));
886+
});
881887
connect(bluetoothManager, &bluetooth::deviceConnected, this, &homeform::deviceConnected);
882888
connect(bluetoothManager, &bluetooth::ftmsAccessoryConnected, this, &homeform::ftmsAccessoryConnected);
883889
connect(bluetoothManager, &bluetooth::deviceConnected, this, &homeform::trainProgramSignals);

0 commit comments

Comments
 (0)