QSimpleUpdater
A simple auto-updater system for Qt applications
|
Implements an integrated file downloader with a nice UI. More...
#include <Downloader.h>
Public Slots | |
void | startDownload (const QUrl &url) |
void | setUseCustomInstallProcedures (const bool &custom) |
Signals | |
void | downloadFinished (const QString &url, const QString &filepath) |
Public Member Functions | |
Downloader (QWidget *parent=0) | |
bool | useCustomInstallProcedures () const |
Private Slots | |
void | openDownload () |
void | installUpdate () |
void | cancelDownload () |
void | onDownloadFinished () |
void | calculateSizes (qint64 received, qint64 total) |
void | updateProgress (qint64 received, qint64 total) |
void | calculateTimeRemaining (qint64 received, qint64 total) |
Private Member Functions | |
qreal | round (const qreal &input) |
Private Attributes | |
uint | m_startTime |
QString | m_filePath |
Ui::Downloader * | m_ui |
QNetworkReply * | m_reply |
bool | m_useCustomProcedures |
QNetworkAccessManager * | m_manager |
Implements an integrated file downloader with a nice UI.
|
privateslot |
Calculates the appropiate size units (bytes, KB or MB) for the received data and the total download size. Then, this function proceeds to update the dialog controls/UI.
References round().
Referenced by updateProgress().
|
privateslot |
Uses two time samples (from the current time and a previous sample) to calculate how many bytes have been downloaded.
Then, this function proceeds to calculate the appropiate units of time (hours, minutes or seconds) and constructs a user-friendly string, which is displayed in the dialog.
Referenced by updateProgress().
|
privateslot |
Prompts the user if he/she wants to cancel the download and cancels the download if the user agrees to do that.
|
privateslot |
Instructs the OS to open the downloaded file.
useCustomInstallProcedures()
returns true
, the function will not instruct the OS to open the downloaded file. You can use the signals fired by the QSimpleUpdater
to install the update with your own implementations/code. References openDownload(), and useCustomInstallProcedures().
Referenced by onDownloadFinished().
|
privateslot |
Writes the downloaded data to a temp. directory and updates the UI controls.
References installUpdate().
Referenced by startDownload().
|
privateslot |
Opens the downloaded file.
Referenced by installUpdate().
|
private |
Rounds the given input to two decimal places
Referenced by calculateSizes().
|
slot |
If the custom parameter is set to true
, then the Downloader
will not attempt to open the downloaded file.
Use the signals fired by the QSimpleUpdater
to implement your own install procedures.
Referenced by Updater::setUseCustomInstallProcedures().
|
slot |
Begins downloading the file at the given url
References onDownloadFinished(), and updateProgress().
Referenced by Updater::setUpdateAvailable().
|
privateslot |
Uses the received and total parameters to get the download progress and update the progressbar value on the dialog.
References calculateSizes(), and calculateTimeRemaining().
Referenced by startDownload().
bool Downloader::useCustomInstallProcedures | ( | ) | const |
Returns true
if the updater shall not intervene when the download has finished (you can use the QSimpleUpdater
signals to know when the download is completed).
Referenced by installUpdate(), and Updater::useCustomInstallProcedures().