Skip to content

Commit

Permalink
Merge pull request #1247 from deXol/develop
Browse files Browse the repository at this point in the history
Fix progress bar for file upload
  • Loading branch information
limpkin authored Dec 4, 2024
2 parents 46c92a3 + 9cdc1c3 commit 56b3aff
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/FilesManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ FilesManagement::FilesManagement(QWidget *parent) :
ui->progressBarQuick->hide();

ui->labelConfirmRequest->hide();
ui->labelConfirmRequestTop->hide();

connect(ui->lineEditFilterFiles, &QLineEdit::textChanged, [=](const QString &t)
{
Expand Down Expand Up @@ -561,6 +562,7 @@ void FilesManagement::updateProgress(int total, int curr)
ui->progressBarTop->setValue(curr);
ui->progressBarQuick->setMaximum(total);
ui->progressBarQuick->setValue(curr);
ui->labelConfirmRequestTop->hide();
}

void FilesManagement::updateButtonsUI()
Expand Down Expand Up @@ -609,6 +611,8 @@ void FilesManagement::addUpdateFile(QString service, QString filename, QProgress
pbar->setMinimum(0);
pbar->setMaximum(0);
pbar->setValue(0);
ui->labelConfirmRequestTop->show();

pbar->show();
updateButtonsUI();

Expand All @@ -628,6 +632,7 @@ void FilesManagement::dataFileSent(const QString &service, bool success)
disconnect(wsClient, &WSClient::progressChanged, this, &FilesManagement::updateProgress);
ui->progressBar->hide();
ui->progressBarTop->hide();
ui->labelConfirmRequestTop->hide();
updateButtonsUI();
ui->lineEditFilename->clear();
ui->addFileServiceInput->clear();
Expand Down
36 changes: 24 additions & 12 deletions src/FilesManagement.ui
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,34 @@ border-right: none;
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>180</number>
</property>
<property name="rightMargin">
<number>180</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QProgressBar" name="progressBarTop">
<property name="value">
<number>24</number>
<widget class="QLabel" name="labelConfirmRequestTop">
<property name="text">
<string>Confirm the request on your device.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>180</number>
</property>
<property name="rightMargin">
<number>180</number>
</property>
<item>
<widget class="QProgressBar" name="progressBarTop">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -206,7 +220,6 @@ border-right: none;
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down Expand Up @@ -322,7 +335,6 @@ border-right: none;
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down
16 changes: 10 additions & 6 deletions src/MPDeviceBleImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,12 +1844,16 @@ void MPDeviceBleImpl::storeFileData(int current, AsyncJobs *jobs, const MPDevice

if (isFile)
{
QVariantMap cbData = {
{"total", currentNodeSize},
{"current", current + BLE_DATA_BLOCK_SIZE},
{"msg", "WORKING on setDataNodeCb"}
};
cbProgress(cbData);
// Do not send progress for 0, device confirmation is needed first
if (current != 0)
{
QVariantMap cbData = {
{"total", currentNodeSize},
{"current", current + BLE_DATA_BLOCK_SIZE},
{"msg", "WORKING on setDataNodeCb"}
};
cbProgress(cbData);
}
}
}

Expand Down

0 comments on commit 56b3aff

Please sign in to comment.