Skip to content

Commit

Permalink
Merge pull request #1137 from deXol/develop
Browse files Browse the repository at this point in the history
[BLE] Improve NoBundle FW upload
  • Loading branch information
limpkin authored Feb 1, 2023
2 parents c55121c + 3e9017c commit 13afe21
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/BleDev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ void BleDev::keyPressEvent(QKeyEvent *event)
{
DeviceDetector::instance().shiftPressed();
}
if (event->key() == Qt::Key_Control)
{
DeviceDetector::instance().ctrlPressed();
}
}

void BleDev::keyReleaseEvent(QKeyEvent *event)
Expand All @@ -77,6 +81,10 @@ void BleDev::keyReleaseEvent(QKeyEvent *event)
{
DeviceDetector::instance().shiftReleased();
}
if (event->key() == Qt::Key_Control)
{
DeviceDetector::instance().ctrlReleased();
}
}

void BleDev::initUITexts()
Expand Down Expand Up @@ -179,11 +187,16 @@ void BleDev::on_btnFileBrowser_clicked()
}
QSettings s;

bool skipFilePwdCheck = wsClient->get_status() == Common::NoBundle &&
DeviceDetector::instance().isCtrlPressed();

QString fileName = QFileDialog::getOpenFileName(this, tr("Select bundle file"),
s.value("last_used_path/bundle_dir", QDir::homePath()).toString(),
"*.img");

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

if (fileName.isEmpty())
{
Expand Down Expand Up @@ -211,8 +224,9 @@ void BleDev::on_btnFileBrowser_clicked()
}

QString password = "";
if (!checkBundleFilePassword(QFileInfo{file}, password))
if (!skipFilePwdCheck && !checkBundleFilePassword(QFileInfo{file}, password))
{
qCritical() << "Invalid bundle file password";
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/DeviceDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class DeviceDetector : public QObject
void shiftPressed() { m_isShiftPressed = true; }
void shiftReleased() { m_isShiftPressed = false; }
bool isShiftPressed() const { return m_isShiftPressed; }
void ctrlPressed() { m_isCtrlPressed = true; }
void ctrlReleased() { m_isCtrlPressed = false; }
bool isCtrlPressed() const { return m_isCtrlPressed; }

signals:
void deviceChanged(Common::MPHwVersion newDevType);
Expand All @@ -53,6 +56,7 @@ public slots:
bool m_isConnectedWithBluetooth = false;
quint8 m_battery = 0;
bool m_isShiftPressed = false;
bool m_isCtrlPressed = false;
};

#endif // DEVICEDETECTOR_H
3 changes: 1 addition & 2 deletions src/MPDeviceBleImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ MPDeviceBleImpl::MPDeviceBleImpl(MessageProtocolBLE* mesProt, MPDevice *dev):
MPCmd::CANCEL_USER_REQUEST,
MPCmd::INFORM_LOCKED,
MPCmd::INFORM_UNLOCKED,
MPCmd::SET_DATE,
MPCmd::GET_PLAT_INFO
MPCmd::SET_DATE
};
}

Expand Down
12 changes: 10 additions & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,10 +2407,14 @@ void MainWindow::displayNotePage()
void MainWindow::keyPressEvent(QKeyEvent *event)
{
QMainWindow::keyPressEvent(event);
if (event->key() == Qt::Key_Control)
if (event->key() == Qt::Key_Shift)
{
DeviceDetector::instance().shiftPressed();
}
if (event->key() == Qt::Key_Control)
{
DeviceDetector::instance().ctrlPressed();
}
if (!ui->tutorialWidget->isTutorialFinished() && event->key() == Qt::Key_Escape)
{
ui->tutorialWidget->onExitClicked();
Expand All @@ -2420,10 +2424,14 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
QMainWindow::keyReleaseEvent(event);
if (event->key() == Qt::Key_Control)
if (event->key() == Qt::Key_Shift)
{
DeviceDetector::instance().shiftReleased();
}
if (event->key() == Qt::Key_Control)
{
DeviceDetector::instance().ctrlReleased();
}
}

void MainWindow::on_checkBoxBackupNotification_stateChanged(int)
Expand Down

0 comments on commit 13afe21

Please sign in to comment.