Skip to content

Commit 13afe21

Browse files
authored
Merge pull request #1137 from deXol/develop
[BLE] Improve NoBundle FW upload
2 parents c55121c + 3e9017c commit 13afe21

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/BleDev.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ void BleDev::keyPressEvent(QKeyEvent *event)
6969
{
7070
DeviceDetector::instance().shiftPressed();
7171
}
72+
if (event->key() == Qt::Key_Control)
73+
{
74+
DeviceDetector::instance().ctrlPressed();
75+
}
7276
}
7377

7478
void BleDev::keyReleaseEvent(QKeyEvent *event)
@@ -77,6 +81,10 @@ void BleDev::keyReleaseEvent(QKeyEvent *event)
7781
{
7882
DeviceDetector::instance().shiftReleased();
7983
}
84+
if (event->key() == Qt::Key_Control)
85+
{
86+
DeviceDetector::instance().ctrlReleased();
87+
}
8088
}
8189

8290
void BleDev::initUITexts()
@@ -179,11 +187,16 @@ void BleDev::on_btnFileBrowser_clicked()
179187
}
180188
QSettings s;
181189

190+
bool skipFilePwdCheck = wsClient->get_status() == Common::NoBundle &&
191+
DeviceDetector::instance().isCtrlPressed();
192+
182193
QString fileName = QFileDialog::getOpenFileName(this, tr("Select bundle file"),
183194
s.value("last_used_path/bundle_dir", QDir::homePath()).toString(),
184195
"*.img");
185196

197+
// Due to file selection dialog opened, release events are not catched
186198
DeviceDetector::instance().shiftReleased();
199+
DeviceDetector::instance().ctrlReleased();
187200

188201
if (fileName.isEmpty())
189202
{
@@ -211,8 +224,9 @@ void BleDev::on_btnFileBrowser_clicked()
211224
}
212225

213226
QString password = "";
214-
if (!checkBundleFilePassword(QFileInfo{file}, password))
227+
if (!skipFilePwdCheck && !checkBundleFilePassword(QFileInfo{file}, password))
215228
{
229+
qCritical() << "Invalid bundle file password";
216230
return;
217231
}
218232

src/DeviceDetector.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class DeviceDetector : public QObject
4040
void shiftPressed() { m_isShiftPressed = true; }
4141
void shiftReleased() { m_isShiftPressed = false; }
4242
bool isShiftPressed() const { return m_isShiftPressed; }
43+
void ctrlPressed() { m_isCtrlPressed = true; }
44+
void ctrlReleased() { m_isCtrlPressed = false; }
45+
bool isCtrlPressed() const { return m_isCtrlPressed; }
4346

4447
signals:
4548
void deviceChanged(Common::MPHwVersion newDevType);
@@ -53,6 +56,7 @@ public slots:
5356
bool m_isConnectedWithBluetooth = false;
5457
quint8 m_battery = 0;
5558
bool m_isShiftPressed = false;
59+
bool m_isCtrlPressed = false;
5660
};
5761

5862
#endif // DEVICEDETECTOR_H

src/MPDeviceBleImpl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ MPDeviceBleImpl::MPDeviceBleImpl(MessageProtocolBLE* mesProt, MPDevice *dev):
2323
MPCmd::CANCEL_USER_REQUEST,
2424
MPCmd::INFORM_LOCKED,
2525
MPCmd::INFORM_UNLOCKED,
26-
MPCmd::SET_DATE,
27-
MPCmd::GET_PLAT_INFO
26+
MPCmd::SET_DATE
2827
};
2928
}
3029

src/MainWindow.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,10 +2407,14 @@ void MainWindow::displayNotePage()
24072407
void MainWindow::keyPressEvent(QKeyEvent *event)
24082408
{
24092409
QMainWindow::keyPressEvent(event);
2410-
if (event->key() == Qt::Key_Control)
2410+
if (event->key() == Qt::Key_Shift)
24112411
{
24122412
DeviceDetector::instance().shiftPressed();
24132413
}
2414+
if (event->key() == Qt::Key_Control)
2415+
{
2416+
DeviceDetector::instance().ctrlPressed();
2417+
}
24142418
if (!ui->tutorialWidget->isTutorialFinished() && event->key() == Qt::Key_Escape)
24152419
{
24162420
ui->tutorialWidget->onExitClicked();
@@ -2420,10 +2424,14 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
24202424
void MainWindow::keyReleaseEvent(QKeyEvent *event)
24212425
{
24222426
QMainWindow::keyReleaseEvent(event);
2423-
if (event->key() == Qt::Key_Control)
2427+
if (event->key() == Qt::Key_Shift)
24242428
{
24252429
DeviceDetector::instance().shiftReleased();
24262430
}
2431+
if (event->key() == Qt::Key_Control)
2432+
{
2433+
DeviceDetector::instance().ctrlReleased();
2434+
}
24272435
}
24282436

24292437
void MainWindow::on_checkBoxBackupNotification_stateChanged(int)

0 commit comments

Comments
 (0)