Skip to content

Commit

Permalink
Merge pull request #274 from FashionFreedom/SeamlyME_Progress
Browse files Browse the repository at this point in the history
show and check progress from SeamlyME and prevent 2 downloads at the …
  • Loading branch information
slspencer committed Jul 26, 2020
2 parents 8f6f732 + 9e90703 commit 976095e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/app/seamlyme/dialogs/dialogaboutseamlyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ DialogAboutSeamlyMe::DialogAboutSeamlyMe(QWidget *parent)
FontPointSize(ui->label_Legal_Stuff, 11);
FontPointSize(ui->label_SeamlyMe_Built, 11);
FontPointSize(ui->label_QT_Version, 11);

ui->downloadProgress->hide();
ui->downloadProgress->setValue(0);
connect(FvUpdater::sharedUpdater(), SIGNAL(setProgress(int)), this, SLOT(setProgressValue(int)));
}

//---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -162,3 +166,17 @@ void DialogAboutSeamlyMe::RetranslateUi()

ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR));
}

void DialogAboutSeamlyMe::setProgressValue(int val) {
if (!ui->downloadProgress->isVisible()){
ui->downloadProgress->show();
ui->pushButtonCheckUpdate->setDisabled(true);
}
ui->downloadProgress->setValue(val);
if (val == 100){
ui->downloadProgress->hide();
ui->downloadProgress->setValue(0);
ui->pushButtonCheckUpdate->setDisabled(false);
}
}

3 changes: 3 additions & 0 deletions src/app/seamlyme/dialogs/dialogaboutseamlyme.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class DialogAboutSeamlyMe : public QDialog
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;

public slots:
void setProgressValue(int val);

private:
Q_DISABLE_COPY(DialogAboutSeamlyMe)
Ui::DialogAboutSeamlyMe *ui;
Expand Down
19 changes: 19 additions & 0 deletions src/app/seamlyme/dialogs/dialogaboutseamlyme.ui
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,25 @@
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="downloadProgress">
<property name="value">
<number>25</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="format">
<string>Downloading installer %p% complete</string>
</property>
</widget>
</item>
</layout>
</item>
Expand Down
2 changes: 1 addition & 1 deletion src/app/seamlyme/mapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
}
else
{
if (type != QtDebugMsg)
if (type != QtDebugMsg && type != QtWarningMsg)
{
abort(); // be NOISY unless overridden!
}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/fervor/fvupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,14 @@ void FvUpdater::startDownloadFile(QUrl url, QString name) {
downloadDir.mkdir(m_releaseName);
downloadDir.cd(m_releaseName);
auto downloadedFile = new QFile(downloadDir.filePath(name), this);
if(downloadedFile->exists() && !downloadedFile->remove()){
showErrorDialog(tr("Unable to get exclusive access to file \n%1\nPossibly the file is already being downloaded.").arg(downloadDir.filePath(name)), false);
return;
}
bool isOpen = downloadedFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
if (!isOpen) {
showErrorDialog(tr("Unable to open file\n%1\nfor writing").arg(downloadDir.filePath(name)), false);
return;
}
connect(m_reply.data(), &QNetworkReply::readyRead, this, [this, downloadedFile]() {
// this slot gets called every time the QNetworkReply has new data.
Expand Down

0 comments on commit 976095e

Please sign in to comment.