Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor|Updater: Separated VersionInfo, UpdaterSettings
Also added UpdateAvailableDialog that will be shown after checking for available updates.
- Loading branch information
Showing
7 changed files
with
318 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
doomsday/engine/portable/src/updater/updateavailabledialog.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "updateavailabledialog.h" | ||
#include "versioninfo.h" | ||
#include <QHBoxLayout> | ||
#include <QVBoxLayout> | ||
#include <QDialogButtonBox> | ||
#include <QCheckBox> | ||
#include <QPushButton> | ||
#include <QFont> | ||
#include <QLabel> | ||
|
||
struct UpdateAvailableDialog::Instance | ||
{ | ||
UpdateAvailableDialog* self; | ||
|
||
QLabel* info; | ||
|
||
Instance(UpdateAvailableDialog* d) : self(d) | ||
{ | ||
QVBoxLayout* mainLayout = new QVBoxLayout(self); | ||
self->setLayout(mainLayout); | ||
//mainLayout->setMargin(12); | ||
|
||
info = new QLabel; | ||
info->setTextFormat(Qt::RichText); | ||
info->setText(QString("<span style=\"font-weight:bold; font-size:%1pt;\">You are up to date.</span>" | ||
"<p>The installed version %2 is the latest available stable build.") | ||
.arg(int(self->font().pointSize() * 1.2)) | ||
.arg(VersionInfo().asText())); | ||
|
||
QCheckBox* neverCheck = new QCheckBox("Never check for updates automatically"); | ||
|
||
QDialogButtonBox* bbox = new QDialogButtonBox; | ||
|
||
QPushButton* ok = bbox->addButton("Ok", QDialogButtonBox::AcceptRole); | ||
ok->setDefault(true); | ||
|
||
QPushButton* cfg = bbox->addButton("Settings...", QDialogButtonBox::ActionRole); | ||
cfg->setAutoDefault(false); | ||
cfg->setDefault(false); | ||
|
||
//QPushButton* whatsNew = bbox->addButton("What's new?", QDialogButtonBox::HelpRole); | ||
|
||
mainLayout->addWidget(info); | ||
mainLayout->addWidget(neverCheck); | ||
mainLayout->addWidget(bbox); | ||
} | ||
}; | ||
|
||
UpdateAvailableDialog::UpdateAvailableDialog(QWidget *parent) | ||
: QDialog(parent) | ||
{ | ||
d = new Instance(this); | ||
} | ||
|
||
UpdateAvailableDialog::~UpdateAvailableDialog() | ||
{ | ||
delete d; | ||
} |
19 changes: 19 additions & 0 deletions
19
doomsday/engine/portable/src/updater/updateavailabledialog.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef LIBDENG_UPDATEAVAILABLEDIALOG_H | ||
#define LIBDENG_UPDATEAVAILABLEDIALOG_H | ||
|
||
#include <QDialog> | ||
|
||
class UpdateAvailableDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit UpdateAvailableDialog(QWidget *parent = 0); | ||
~UpdateAvailableDialog(); | ||
|
||
private: | ||
struct Instance; | ||
Instance* d; | ||
}; | ||
|
||
#endif // LIBDENG_UPDATEAVAILABLEDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "updatersettings.h" | ||
#include "versioninfo.h" | ||
#include <QDateTime> | ||
#include <QSettings> | ||
#include <QDesktopServices> | ||
|
||
#define STK_FREQUENCY "updater/frequency" | ||
#define STK_CHANNEL "updater/channel" | ||
#define STK_LAST_CHECKED "updater/lastChecked" | ||
#define STK_ONLY_MANUAL "updater/onlyManually" | ||
#define STK_DELETE "updater/delete" | ||
#define STK_DOWNLOAD_PATH "updater/downloadPath" | ||
|
||
static de::String defaultDownloadPath() | ||
{ | ||
return QDesktopServices::storageLocation(QDesktopServices::TempLocation); | ||
} | ||
|
||
UpdaterSettings::UpdaterSettings() | ||
{} | ||
|
||
UpdaterSettings::Frequency UpdaterSettings::frequency() const | ||
{ | ||
return Frequency(QSettings().value(STK_FREQUENCY, Weekly).toInt()); | ||
} | ||
|
||
UpdaterSettings::Channel UpdaterSettings::channel() const | ||
{ | ||
return Channel(QSettings().value(STK_CHANNEL, | ||
QString(DOOMSDAY_RELEASE_TYPE) == "Stable"? Stable : Unstable).toInt()); | ||
} | ||
|
||
de::Time UpdaterSettings::lastCheckTime() const | ||
{ | ||
return QSettings().value(STK_LAST_CHECKED).toDateTime(); | ||
} | ||
|
||
bool UpdaterSettings::onlyCheckManually() const | ||
{ | ||
return QSettings().value(STK_ONLY_MANUAL, false).toBool(); | ||
} | ||
|
||
bool UpdaterSettings::deleteAfterUpdate() const | ||
{ | ||
return QSettings().value(STK_DELETE, true).toBool(); | ||
} | ||
|
||
bool UpdaterSettings::isDefaultDownloadPath() const | ||
{ | ||
de::String path = downloadPath(); | ||
return path == defaultDownloadPath(); | ||
} | ||
|
||
de::String UpdaterSettings::downloadPath() const | ||
{ | ||
return QSettings().value(STK_DOWNLOAD_PATH, defaultDownloadPath()).toString(); | ||
} | ||
|
||
void UpdaterSettings::setFrequency(UpdaterSettings::Frequency freq) | ||
{ | ||
QSettings().setValue(STK_FREQUENCY, int(freq)); | ||
} | ||
|
||
void UpdaterSettings::channel(UpdaterSettings::Channel channel) | ||
{ | ||
QSettings().setValue(STK_CHANNEL, int(channel)); | ||
} | ||
|
||
void UpdaterSettings::setLastCheckTime(const de::Time &time) | ||
{ | ||
QSettings().setValue(STK_LAST_CHECKED, time.asDateTime()); | ||
} | ||
|
||
void UpdaterSettings::setOnlyCheckManually(bool onlyManually) | ||
{ | ||
QSettings().setValue(STK_ONLY_MANUAL, onlyManually); | ||
} | ||
|
||
void UpdaterSettings::setDeleteAfterUpdate(bool deleteAfter) | ||
{ | ||
QSettings().setValue(STK_DELETE, deleteAfter); | ||
} | ||
|
||
void UpdaterSettings::setDownloadPath(de::String downloadPath) | ||
{ | ||
QSettings().setValue(STK_DOWNLOAD_PATH, downloadPath); | ||
} | ||
|
||
void UpdaterSettings::useDefaultDownloadPath() | ||
{ | ||
setDownloadPath(defaultDownloadPath()); | ||
} |
Oops, something went wrong.