Skip to content

Commit d011a2c

Browse files
committed
Gear implementations: Even out the version string management
Also a few other places mixing up string types
1 parent 910571b commit d011a2c

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/gearimplementations/GearDigitail.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GearDigitail::Private {
3535
GearDigitail* q{nullptr};
3636
DeviceModel * parentModel{nullptr};
3737

38-
QLatin1String version{"(unknown)"};
38+
QString version = QLatin1String{"(unknown)"};
3939
QString currentCall;
4040
int batteryLevel{-1};
4141

@@ -120,7 +120,7 @@ class GearDigitail::Private {
120120
if (tailStateCharacteristicUuid == characteristic.uuid()) {
121121
if (currentCall == QLatin1String("VER")) {
122122
q->reloadCommands();
123-
version = QLatin1String{newValue};
123+
version = QString::fromUtf8(newValue);
124124
Q_EMIT q->versionChanged(version);
125125
batteryTimer.start();
126126
q->sendMessage(QLatin1String{"BATT"});
@@ -202,7 +202,7 @@ class GearDigitail::Private {
202202
void characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
203203
{
204204
qDebug() << q->name() << q->deviceID() << "Characteristic written:" << characteristic.uuid() << newValue;
205-
currentCall = QLatin1String{newValue};
205+
currentCall = QString::fromUtf8(newValue);
206206
Q_EMIT q->currentCallChanged(currentCall);
207207
}
208208
};

src/gearimplementations/GearEars.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GearEars::Private {
4242
GearEars* q{nullptr};
4343
DeviceModel * parentModel{nullptr};
4444

45-
QLatin1String version{"(unknown)"};
45+
QString version = QLatin1String{"(unknown)"};
4646
int batteryLevel{-1};
4747
bool micsSwapped{false};
4848
ListenMode listenMode{ListenModeOff};
@@ -196,8 +196,8 @@ class GearEars::Private {
196196
}
197197
else if (stateResult[0] == QLatin1String{"VER"}) {
198198
q->reloadCommands();
199-
version = QLatin1String(newValue);
200-
Q_EMIT q->versionChanged(QString::fromUtf8(newValue));
199+
version = QString::fromUtf8(newValue);
200+
Q_EMIT q->versionChanged(version);
201201
Q_EMIT q->supportedTiltEventsChanged();
202202
q->setListenMode(listenMode);
203203
if (q->deviceInfo.name() == QLatin1String{"EarGear"}) {

src/gearimplementations/GearFlutterWings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GearFlutterWings::Private {
4242
DeviceModel * parentModel{nullptr};
4343

4444
QHash<QString, QString> knownFirmwareMessages;
45-
QLatin1String version{"(unknown)"};
45+
QString version = QLatin1String{"(unknown)"};
4646
int batteryLevel{-1};
4747

4848
QString currentCall;
@@ -159,15 +159,15 @@ class GearFlutterWings::Private {
159159
}
160160
else if (stateResult[0] == QLatin1String{"VER"}) {
161161
q->reloadCommands();
162-
version = QLatin1String{newValue};
162+
version = QString::fromUtf8(newValue);
163163
Q_EMIT q->versionChanged(version);
164164
q->setKnownFirmwareMessage(knownFirmwareMessages.value(version, QLatin1String{}));
165165
pingTimer.start();
166166
if (firmwareProgress > -1) {
167167
if (otaVersion == q->manuallyLoadedOtaVersion()) {
168168
// We have no idea whether the update succeeded, tell the user they need to check themselves
169169
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a firmware update with an unknown outcome", "Reboot Completed"), i18nc("Message shown to the user after a reboot following a manual firmware upload", "The reboot following the firmware upload has completed and we have connected back to the device. The gear now reports %1, and we hope that is what you expected.", version));
170-
} else if (otaVersion == QLatin1String{newValue}) {
170+
} else if (otaVersion == QString::fromUtf8(newValue)) {
171171
// successful update get!
172172
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a successful firmware upgrade", "Upgrade Successful"), i18nc("Message shown to the user when a firmware update completed successfully", "Congratulations, your gear has been successfully updated to version %1!", version));
173173
} else {
@@ -263,7 +263,7 @@ class GearFlutterWings::Private {
263263
}
264264
} else {
265265
qDebug() << q->name() << q->deviceID() << "Characteristic written:" << characteristic.uuid() << newValue;
266-
currentCall = QLatin1String{newValue};
266+
currentCall = QString::fromUtf8(newValue);
267267
Q_EMIT q->currentCallChanged(currentCall);
268268
}
269269
}

src/gearimplementations/GearMitail.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class GearMitail::Private {
4848
DeviceModel * parentModel{nullptr};
4949

5050
QHash<QString, QString> knownFirmwareMessages;
51-
QLatin1String version{"(unknown)"};
51+
QString version = QLatin1String{"(unknown)"};
5252
int batteryLevel{-1};
5353

5454
QString currentCall;
@@ -165,15 +165,15 @@ class GearMitail::Private {
165165
}
166166
else if (stateResult[0] == QLatin1String{"VER"}) {
167167
q->reloadCommands();
168-
version = QLatin1String{newValue};
168+
version = QString::fromUtf8(newValue);
169169
Q_EMIT q->versionChanged(version);
170170
q->setKnownFirmwareMessage(knownFirmwareMessages.value(version, QLatin1String{}));
171171
pingTimer.start();
172172
if (firmwareProgress > -1) {
173173
if (otaVersion == q->manuallyLoadedOtaVersion()) {
174174
// We have no idea whether the update succeeded, tell the user they need to check themselves
175175
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a firmware update with an unknown outcome", "Reboot Completed"), i18nc("Message shown to the user after a reboot following a manual firmware upload", "The reboot following the firmware upload has completed and we have connected back to the device. The gear now reports %1, and we hope that is what you expected.", version));
176-
} else if (otaVersion == QLatin1String{newValue}) {
176+
} else if (otaVersion == QString::fromUtf8(newValue)) {
177177
// successful update get!
178178
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a successful firmware upgrade", "Upgrade Successful"), i18nc("Message shown to the user when a firmware update completed successfully", "Congratulations, your gear has been successfully updated to version %1!", version));
179179
} else {

src/gearimplementations/GearMitailMini.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GearMitailMini::Private {
4343
DeviceModel * parentModel{nullptr};
4444

4545
QHash<QString, QString> knownFirmwareMessages;
46-
QLatin1String version{"(unknown)"};
46+
QString version = QLatin1String{"(unknown)"};
4747
int batteryLevel{-1};
4848

4949
QString currentCall;
@@ -160,15 +160,15 @@ class GearMitailMini::Private {
160160
}
161161
else if (stateResult[0] == QLatin1String{"VER"}) {
162162
q->reloadCommands();
163-
version = QLatin1String{newValue};
163+
version = QString::fromUtf8(newValue);
164164
Q_EMIT q->versionChanged(version);
165165
q->setKnownFirmwareMessage(knownFirmwareMessages.value(version, QLatin1String{}));
166166
pingTimer.start();
167167
if (firmwareProgress > -1) {
168168
if (otaVersion == q->manuallyLoadedOtaVersion()) {
169169
// We have no idea whether the update succeeded, tell the user they need to check themselves
170170
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a firmware update with an unknown outcome", "Reboot Completed"), i18nc("Message shown to the user after a reboot following a manual firmware upload", "The reboot following the firmware upload has completed and we have connected back to the device. The gear now reports %1, and we hope that is what you expected.", version));
171-
} else if (otaVersion == QLatin1String{newValue}) {
171+
} else if (otaVersion == QString::fromUtf8(newValue)) {
172172
// successful update get!
173173
q->deviceBlockingMessage(i18nc("Title of the message box shown to the user upon a successful firmware upgrade", "Upgrade Successful"), i18nc("Message shown to the user when a firmware update completed successfully", "Congratulations, your gear has been successfully updated to version %1!", version));
174174
} else {
@@ -264,7 +264,7 @@ class GearMitailMini::Private {
264264
}
265265
} else {
266266
qDebug() << q->name() << q->deviceID() << "Characteristic written:" << characteristic.uuid() << newValue;
267-
currentCall = QLatin1String{newValue};
267+
currentCall = QString::fromUtf8(newValue);
268268
Q_EMIT q->currentCallChanged(currentCall);
269269
}
270270
}

0 commit comments

Comments
 (0)