Skip to content

Commit

Permalink
Updater: "What's new" button and accept/reject buttons
Browse files Browse the repository at this point in the history
The buttons in the notification dialog now function as expected.
The change log is opened in the native browser when the "What's
new" button is pressed.
  • Loading branch information
skyjake committed May 26, 2012
1 parent fc32d35 commit 02691e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/updater.cpp
Expand Up @@ -115,7 +115,7 @@ struct Updater::Instance
<< latestPackageUri << latestLogUri;

// Is this newer than what we're running?
UpdateAvailableDialog* dlg = new UpdateAvailableDialog(latestVersion);
UpdateAvailableDialog* dlg = new UpdateAvailableDialog(latestVersion, latestLogUri);

dlg->exec();

Expand Down
18 changes: 16 additions & 2 deletions doomsday/engine/portable/src/updater/updateavailabledialog.cpp
Expand Up @@ -2,6 +2,8 @@
#include "updatersettings.h"
#include "versioninfo.h"
#include <de/Log>
#include <QUrl>
#include <QDesktopServices>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDialogButtonBox>
Expand All @@ -15,6 +17,7 @@ struct UpdateAvailableDialog::Instance
UpdateAvailableDialog* self;
QLabel* info;
VersionInfo latestVersion;
de::String changeLog;

Instance(UpdateAvailableDialog* d) : self(d)
{
Expand All @@ -28,7 +31,7 @@ struct UpdateAvailableDialog::Instance
de::String channel = UpdaterSettings().channel() == UpdaterSettings::Stable? "stable" : "unstable";
bool askUpgrade = false;

if(!(latestVersion > currentVersion))
if(latestVersion > currentVersion)
{
askUpgrade = true;
info->setText(QString("<span style=\"font-weight:bold; font-size:%1pt;\">"
Expand Down Expand Up @@ -58,11 +61,14 @@ struct UpdateAvailableDialog::Instance
if(!askUpgrade)
{
QPushButton* ok = bbox->addButton("Ok", QDialogButtonBox::AcceptRole);
QObject::connect(ok, SIGNAL(clicked()), self, SLOT(accept()));
}
else
{
QPushButton* yes = bbox->addButton("Download and install", QDialogButtonBox::YesRole);
QPushButton* no = bbox->addButton("Not now", QDialogButtonBox::NoRole);
QObject::connect(yes, SIGNAL(clicked()), self, SLOT(accept()));
QObject::connect(no, SIGNAL(clicked()), self, SLOT(reject()));
}

QPushButton* cfg = bbox->addButton("Settings...", QDialogButtonBox::ActionRole);
Expand All @@ -71,6 +77,7 @@ struct UpdateAvailableDialog::Instance
if(askUpgrade)
{
QPushButton* whatsNew = bbox->addButton("What's new?", QDialogButtonBox::HelpRole);
QObject::connect(whatsNew, SIGNAL(clicked()), self, SLOT(showWhatsNew()));
whatsNew->setAutoDefault(false);
}

Expand All @@ -80,11 +87,13 @@ struct UpdateAvailableDialog::Instance
}
};

UpdateAvailableDialog::UpdateAvailableDialog(const VersionInfo& latestVersion, QWidget *parent)
UpdateAvailableDialog::UpdateAvailableDialog(const VersionInfo& latestVersion, de::String changeLogUri,
QWidget *parent)
: QDialog(parent)
{
d = new Instance(this);
d->latestVersion = latestVersion;
d->changeLog = changeLogUri;
}

UpdateAvailableDialog::~UpdateAvailableDialog()
Expand All @@ -97,3 +106,8 @@ void UpdateAvailableDialog::neverCheckToggled(bool set)
LOG_DEBUG("Never check for updates: %b") << set;
UpdaterSettings().setOnlyCheckManually(set);
}

void UpdateAvailableDialog::showWhatsNew()
{
QDesktopServices::openUrl(QUrl(d->changeLog));
}
4 changes: 3 additions & 1 deletion doomsday/engine/portable/src/updater/updateavailabledialog.h
Expand Up @@ -9,11 +9,13 @@ class UpdateAvailableDialog : public QDialog
Q_OBJECT

public:
explicit UpdateAvailableDialog(const VersionInfo& latestVersion, QWidget *parent = 0);
explicit UpdateAvailableDialog(const VersionInfo& latestVersion,
de::String changeLogUri, QWidget *parent = 0);
~UpdateAvailableDialog();

public slots:
void neverCheckToggled(bool);
void showWhatsNew();

private:
struct Instance;
Expand Down

0 comments on commit 02691e2

Please sign in to comment.