Fix build issues
This commit is contained in:
parent
3642b4f5f3
commit
a3e9ef2d1f
@ -56,6 +56,9 @@ Downloader::Downloader (QWidget* parent) : QWidget (parent)
|
|||||||
m_startTime = 0;
|
m_startTime = 0;
|
||||||
m_useCustomProcedures = false;
|
m_useCustomProcedures = false;
|
||||||
|
|
||||||
|
/* Set download directory */
|
||||||
|
m_downloadDir = QDir::homePath() + "/Downloads/";
|
||||||
|
|
||||||
/* Make the window look like a modal dialog */
|
/* Make the window look like a modal dialog */
|
||||||
setWindowIcon (QIcon());
|
setWindowIcon (QIcon());
|
||||||
setWindowFlags (Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
setWindowFlags (Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
@ -112,9 +115,14 @@ void Downloader::startDownload (const QUrl& url)
|
|||||||
m_ui->downloadLabel->setText (tr ("Downloading updates"));
|
m_ui->downloadLabel->setText (tr ("Downloading updates"));
|
||||||
m_ui->timeLabel->setText (tr ("Time remaining") + ": " + tr ("unknown"));
|
m_ui->timeLabel->setText (tr ("Time remaining") + ": " + tr ("unknown"));
|
||||||
|
|
||||||
|
/* Configure the network request */
|
||||||
|
QNetworkRequest request (url);
|
||||||
|
if (!m_userAgentString.isEmpty())
|
||||||
|
request.setRawHeader ("User-Agent", m_userAgentString.toUtf8());
|
||||||
|
|
||||||
/* Start download */
|
/* Start download */
|
||||||
|
m_reply = m_manager->get (request);
|
||||||
m_startTime = QDateTime::currentDateTime().toTime_t();
|
m_startTime = QDateTime::currentDateTime().toTime_t();
|
||||||
m_reply = m_manager->get (QNetworkRequest (url));
|
|
||||||
|
|
||||||
/* Ensure that downloads directory exists */
|
/* Ensure that downloads directory exists */
|
||||||
if (!m_downloadDir.exists())
|
if (!m_downloadDir.exists())
|
||||||
@ -146,6 +154,29 @@ void Downloader::setFileName (const QString& file)
|
|||||||
m_fileName = "QSU_Update.bin";
|
m_fileName = "QSU_Update.bin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the user-agent string used to communicate with the remote HTTP server
|
||||||
|
*/
|
||||||
|
void Downloader::setUserAgentString (const QString& agent)
|
||||||
|
{
|
||||||
|
m_userAgentString = agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Downloader::finished()
|
||||||
|
{
|
||||||
|
/* Rename file */
|
||||||
|
QFile::rename (m_downloadDir.filePath (m_fileName + PARTIAL_DOWN),
|
||||||
|
m_downloadDir.filePath (m_fileName));
|
||||||
|
|
||||||
|
/* Notify application */
|
||||||
|
emit downloadFinished (m_url, m_downloadDir.filePath (m_fileName));
|
||||||
|
|
||||||
|
/* Install the update */
|
||||||
|
m_reply->close();
|
||||||
|
installUpdate();
|
||||||
|
setVisible (false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the downloaded file.
|
* Opens the downloaded file.
|
||||||
* \note If the downloaded file is not found, then the function will alert the
|
* \note If the downloaded file is not found, then the function will alert the
|
||||||
@ -318,21 +349,6 @@ void Downloader::updateProgress (qint64 received, qint64 total)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::finished()
|
|
||||||
{
|
|
||||||
/* Rename file */
|
|
||||||
QFile::rename (m_downloadDir.filePath (m_fileName + PARTIAL_DOWN),
|
|
||||||
m_downloadDir.filePath (m_fileName));
|
|
||||||
|
|
||||||
/* Notify application */
|
|
||||||
emit downloadFinished (m_url, m_downloadDir.filePath (m_fileName));
|
|
||||||
|
|
||||||
/* Install the update */
|
|
||||||
m_reply->close();
|
|
||||||
installUpdate();
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses two time samples (from the current time and a previous sample) to
|
* Uses two time samples (from the current time and a previous sample) to
|
||||||
* calculate how many bytes have been downloaded.
|
* calculate how many bytes have been downloaded.
|
||||||
|
@ -65,28 +65,30 @@ public slots:
|
|||||||
void setUrlId (const QString& url);
|
void setUrlId (const QString& url);
|
||||||
void startDownload (const QUrl& url);
|
void startDownload (const QUrl& url);
|
||||||
void setFileName (const QString& file);
|
void setFileName (const QString& file);
|
||||||
|
void setUserAgentString (const QString& agent);
|
||||||
void setUseCustomInstallProcedures (const bool custom);
|
void setUseCustomInstallProcedures (const bool custom);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void finished();
|
||||||
void openDownload();
|
void openDownload();
|
||||||
void installUpdate();
|
void installUpdate();
|
||||||
void cancelDownload();
|
void cancelDownload();
|
||||||
void saveFile (qint64 received, qint64 total);
|
void saveFile (qint64 received, qint64 total);
|
||||||
void calculateSizes (qint64 received, qint64 total);
|
void calculateSizes (qint64 received, qint64 total);
|
||||||
void updateProgress (qint64 received, qint64 total);
|
void updateProgress (qint64 received, qint64 total);
|
||||||
void finished ();
|
|
||||||
void calculateTimeRemaining (qint64 received, qint64 total);
|
void calculateTimeRemaining (qint64 received, qint64 total);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal round (const qreal& input);
|
qreal round (const qreal& input);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDir m_downloadDir;
|
|
||||||
QString m_url;
|
QString m_url;
|
||||||
uint m_startTime;
|
uint m_startTime;
|
||||||
|
QDir m_downloadDir;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
Ui::Downloader* m_ui;
|
Ui::Downloader* m_ui;
|
||||||
QNetworkReply* m_reply;
|
QNetworkReply* m_reply;
|
||||||
|
QString m_userAgentString;
|
||||||
bool m_useCustomProcedures;
|
bool m_useCustomProcedures;
|
||||||
QNetworkAccessManager* m_manager;
|
QNetworkAccessManager* m_manager;
|
||||||
};
|
};
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 59 KiB |
Loading…
Reference in New Issue
Block a user