Skip to content

Commit

Permalink
Updater: Closing the download dialog
Browse files Browse the repository at this point in the history
The dialog is deleted and the installation should begin if everything
finished successfully.
  • Loading branch information
skyjake committed Jun 1, 2012
1 parent 927846a commit 4db3aaf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/updater.h
Expand Up @@ -42,6 +42,7 @@ class Updater : public QObject

public slots:
void gotReply(QNetworkReply*);
void downloadCompleted(int result);

private:
struct Instance;
Expand Down
32 changes: 28 additions & 4 deletions doomsday/engine/portable/src/updater.cpp
Expand Up @@ -62,12 +62,13 @@ struct Updater::Instance
{
Updater* self;
QNetworkAccessManager* network;
DownloadDialog* download;

VersionInfo latestVersion;
QString latestPackageUri;
QString latestLogUri;

Instance(Updater* up) : self(up)
Instance(Updater* up) : self(up), network(0), download(0)
{
network = new QNetworkAccessManager(self);
}
Expand Down Expand Up @@ -121,11 +122,22 @@ struct Updater::Instance
if(dlg.exec())
{
LOG_MSG("Download and install.");
DownloadDialog* downDlg = new DownloadDialog(latestPackageUri);
downDlg->show();
// The dialog will delete itself.
download = new DownloadDialog(latestPackageUri);
QObject::connect(download, SIGNAL(finished(int)), self, SLOT(downloadCompleted(int)));
download->show();
}
}

/**
* Start the installation process using the provided distribution package.
* The engine is shut down gracefully (game is always autosaved first).
*
* @param distribPackagePath File path of the distribution package.
*/
void startInstall(de::String distribPackagePath)
{

}
};

Updater::Updater(QObject *parent) : QObject(parent)
Expand All @@ -146,6 +158,18 @@ void Updater::gotReply(QNetworkReply* reply)
d->handleReply(reply);
}

void Updater::downloadCompleted(int result)
{
if(result == DownloadDialog::Accepted)
{
d->startInstall(d->download->downloadedFilePath());
}

// The download dialgo can be dismissed now.
d->download->deleteLater();
d->download = 0;
}

void Updater_Init(void)
{
updater = new Updater;
Expand Down

0 comments on commit 4db3aaf

Please sign in to comment.