From 6359d7d23f4137a35dfd241a0daa22c6a885e426 Mon Sep 17 00:00:00 2001 From: Silarn Date: Sun, 6 May 2018 17:21:35 -0500 Subject: Fixes for downloads and installs --- src/installationmanager.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 27c83787..b7ec3d68 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -95,9 +95,6 @@ InstallationManager::InstallationManager() if (!m_ArchiveHandler->isValid()) { throw MyException(getErrorString(m_ArchiveHandler->getLastError())); } - - connect(this, SIGNAL(progressUpdate(float)), this, (SLOT(doProgressUpdate(float))), Qt::QueuedConnection); - connect(this, SIGNAL(progressUpdate(const QString)), this, (SLOT(doProgressFileUpdate(const QString))), Qt::QueuedConnection); } InstallationManager::~InstallationManager() @@ -203,9 +200,12 @@ bool InstallationManager::unpackSingleFile(const QString &fileName) ); }); do { - ::Sleep(50); + if (m_Progress != m_InstallationProgress->value()) + m_InstallationProgress->setValue(m_Progress); + if (m_ProgressFile != m_InstallationProgress->labelText()) + m_InstallationProgress->setLabelText(m_ProgressFile); QCoreApplication::processEvents(); - } while (!future.isFinished()); + } while (!future.isFinished() || m_InstallationProgress->isVisible()); bool res = future.result(); return res; @@ -301,9 +301,12 @@ QStringList InstallationManager::extractFiles(const QStringList &filesOrig, bool ); }); do { - ::Sleep(50); + if (m_Progress != m_InstallationProgress->value()) + m_InstallationProgress->setValue(m_Progress); + if (m_ProgressFile != m_InstallationProgress->labelText()) + m_InstallationProgress->setLabelText(m_ProgressFile); QCoreApplication::processEvents(); - } while (!future.isFinished()); + } while (!future.isFinished() || m_InstallationProgress->isVisible()); if (!future.result()) { throw MyException(QString("extracting failed (%1)").arg(m_ArchiveHandler->getLastError())); } @@ -430,21 +433,9 @@ DirectoryTree::Node *InstallationManager::getSimpleArchiveBase(DirectoryTree *da void InstallationManager::updateProgress(float percentage) -{ - emit progressUpdate(percentage); -} - - -void InstallationManager::updateProgressFile(QString const &fileName) -{ - emit progressUpdate(fileName); -} - - -void InstallationManager::doProgressUpdate(float percentage) { if (m_InstallationProgress != nullptr) { - m_InstallationProgress->setValue(static_cast(percentage * 100.0)); + m_Progress = static_cast(percentage * 100.0); if (m_InstallationProgress->wasCanceled()) { m_ArchiveHandler->cancel(); @@ -453,11 +444,10 @@ void InstallationManager::doProgressUpdate(float percentage) } } -void InstallationManager::doProgressFileUpdate(QString const fileName) + +void InstallationManager::updateProgressFile(QString const &fileName) { - if (m_InstallationProgress != nullptr) { - m_InstallationProgress->setLabelText(fileName); - } + m_ProgressFile = fileName; } @@ -610,7 +600,10 @@ bool InstallationManager::doInstall(GuessedValue &modName, QString game ); }); do { - ::Sleep(50); + if (m_Progress != m_InstallationProgress->value()) + m_InstallationProgress->setValue(m_Progress); + if (m_ProgressFile != m_InstallationProgress->labelText()) + m_InstallationProgress->setLabelText(m_ProgressFile); QCoreApplication::processEvents(); } while (!future.isFinished()); if (!future.result()) { -- cgit v1.3.1