Attempt to fix the progress bar issue on Companion Read Firmware function (DFU mode)

This commit is contained in:
Bertrand Songis
2020-06-13 12:46:21 +02:00
parent 0541177224
commit 5198b9a8a7
4 changed files with 17 additions and 7 deletions
+14 -3
View File
@@ -134,15 +134,18 @@ void FlashProcess::onKillTimerElapsed()
#endif
}
void FlashProcess::analyseStandardOutput(const QString &text)
void FlashProcess::analyseStandardOutput(const QString & text)
{
// qDebug() << text;
currStdoutLine.append(text);
if (currStdoutLine.contains("size = ")) {
int pos = currStdoutLine.lastIndexOf("size = ");
QString temp = currStdoutLine.mid(pos+7);
pos = temp.lastIndexOf("\n");
int size = temp.left(pos).toInt();
progress->setMaximum(size/2048);
progress->setMaximum(size / 2048);
}
if (currStdoutLine.contains("\n")) {
int nlPos = currStdoutLine.lastIndexOf("\n");
@@ -168,7 +171,15 @@ void FlashProcess::analyseStandardOutput(const QString &text)
int end = text.indexOf("%");
if (start > 0) {
start += 9;
int value = text.mid(start, end-start).toInt();
int value = text.mid(start, end - start).toInt();
progress->setValue(value);
}
}
if (text.contains("Upload\t[")) {
int end = text.indexOf("%");
if (end > 0) {
int value = text.mid(end - 3, 3).toInt();
progress->setValue(value);
}
}