summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-02-21 13:27:42 (GMT)
committerTobias Markmann <tm@ayena.de>2017-02-22 11:15:00 (GMT)
commit996ca9ecf4f226a033d161419f11e715a3f892c3 (patch)
treee332db1edf3e9ea2282814154473e3a5e57d362d /Swift/QtUI/QtSwift.cpp
parenteea861301be0bf3e3f5db6cfc3cada38d133fef2 (diff)
downloadswift-996ca9ecf4f226a033d161419f11e715a3f892c3.zip
swift-996ca9ecf4f226a033d161419f11e715a3f892c3.tar.bz2
Improve Swift about window regarding auto update UX
The dialog will automatically initiate a check for updates when opened. It will show the current state of the auto updater backend, e.g. whether it is downloading or already at the latest version. This also fixes update channel selection being shown on Windows and Linux. Test-Information: Ran Swift and opening the dialog shows a short progress bar indicating it checking for updates. Afterwards it shows that it is already running the latest version, which is sensible for a dev build. Change-Id: Ie08cd2a8852e468d6007122604b532fedc24bcfe
Diffstat (limited to 'Swift/QtUI/QtSwift.cpp')
-rw-r--r--Swift/QtUI/QtSwift.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index ee21c4f..b61147d 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -242,113 +242,126 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
notifier_ = new WindowsNotifier(SWIFT_APPLICATION_NAME, applicationPathProvider_->getResourcePath("/images/logo-icon-32.png"), systemTray->getQSystemTrayIcon());
#elif defined(SWIFTEN_PLATFORM_LINUX)
notifier_ = new FreeDesktopNotifier(SWIFT_APPLICATION_NAME);
#elif defined(SWIFTEN_PLATFORM_MACOSX)
notifier_ = new NotificationCenterNotifier();
#else
notifier_ = new NullNotifier();
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
dock_ = new MacOSXDock(&cocoaApplication_);
#else
dock_ = new NullDock();
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
uriHandler_ = new QtURIHandler();
#elif defined(SWIFTEN_PLATFORM_WIN32)
uriHandler_ = new NullURIHandler();
#else
uriHandler_ = new QtDBUSURIHandler();
#endif
statusCache_ = new StatusCache(applicationPathProvider_);
if (splitter_) {
splitter_->show();
}
+ PlatformAutoUpdaterFactory autoUpdaterFactory;
+ if (autoUpdaterFactory.isSupported() && settingsHierachy_->getSetting(QtUISettingConstants::ENABLE_SOFTWARE_UPDATES)
+ && !settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL).empty()) {
+ autoUpdater_ = autoUpdaterFactory.createAutoUpdater(updateChannelToFeed(settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL)));
+ autoUpdater_->checkForUpdates();
+ autoUpdater_->onUpdateStateChanged.connect(boost::bind(&QtSwift::handleAutoUpdaterStateChanged, this, _1));
+
+ settingsHierachy_->onSettingChanged.connect([&](const std::string& path) {
+ if (path == QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL.getKey()) {
+ autoUpdater_->setAppcastFeed(updateChannelToFeed(settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL)));
+ autoUpdater_->checkForUpdates();
+ }
+ });
+ }
+
for (int i = 0; i < numberOfAccounts; i++) {
if (i > 0) {
// Don't add the first tray (see note above)
systemTrays_.push_back(new QtSystemTray());
}
- QtUIFactory* uiFactory = new QtUIFactory(settingsHierachy_, qtSettings_, tabs_, splitter_, systemTrays_[i], chatWindowFactory_, networkFactories_.getTimerFactory(), statusCache_, startMinimized, !emoticons.empty(), enableAdHocCommandOnJID);
+ QtUIFactory* uiFactory = new QtUIFactory(settingsHierachy_, qtSettings_, tabs_, splitter_, systemTrays_[i], chatWindowFactory_, networkFactories_.getTimerFactory(), statusCache_, autoUpdater_, startMinimized, !emoticons.empty(), enableAdHocCommandOnJID);
uiFactories_.push_back(uiFactory);
MainController* mainController = new MainController(
&clientMainThreadCaller_,
&networkFactories_,
uiFactory,
settingsHierachy_,
systemTrays_[i],
soundPlayer_,
storagesFactory_,
certificateStorageFactory_,
dock_,
notifier_,
uriHandler_,
&idleDetector_,
emoticons,
options.count("latency-debug") > 0);
mainControllers_.push_back(mainController);
}
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(handleAboutToQuit()));
-
- PlatformAutoUpdaterFactory autoUpdaterFactory;
- if (autoUpdaterFactory.isSupported() && settingsHierachy_->getSetting(QtUISettingConstants::ENABLE_SOFTWARE_UPDATES)
- && !settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL).empty()) {
- autoUpdater_ = autoUpdaterFactory.createAutoUpdater(updateChannelToFeed(settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL)));
- autoUpdater_->checkForUpdates();
- autoUpdater_->onSuggestRestartToUserToUpdate.connect(boost::bind(&QtSwift::handleRecommendRestartToInstallUpdate, this));
-
- settingsHierachy_->onSettingChanged.connect([&](const std::string& path) {
- if (path == QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL.getKey()) {
- autoUpdater_->setAppcastFeed(updateChannelToFeed(settingsHierachy_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL)));
- autoUpdater_->checkForUpdates();
- }
- });
- }
}
QtSwift::~QtSwift() {
delete autoUpdater_;
for (auto* factory : uiFactories_) {
delete factory;
}
for (auto* controller : mainControllers_) {
delete controller;
}
delete notifier_;
for (auto* tray : systemTrays_) {
delete tray;
}
delete tabs_;
delete chatWindowFactory_;
delete splitter_;
delete settingsHierachy_;
delete qtSettings_;
delete xmlSettings_;
delete statusCache_;
delete uriHandler_;
delete dock_;
delete soundPlayer_;
delete certificateStorageFactory_;
delete storagesFactory_;
delete applicationPathProvider_;
}
void QtSwift::handleAboutToQuit() {
#if defined(SWIFTEN_PLATFORM_MACOSX)
// This is required so Sparkle knows about the application shutting down
// and can update the application in background.
CocoaUIHelpers::sendCocoaApplicationWillTerminateNotification();
#endif
}
-void QtSwift::handleRecommendRestartToInstallUpdate() {
- notifier_->showMessage(Notifier::SystemMessage, Q2PSTRING(tr("Swift Update Available")), Q2PSTRING(tr("Restart Swift to update to the new Swift version.")), "", [](){});
+void QtSwift::handleAutoUpdaterStateChanged(AutoUpdater::State updatedState) {
+ switch (updatedState) {
+ case AutoUpdater::State::NotCheckedForUpdatesYet:
+ break;
+ case AutoUpdater::State::CheckingForUpdate:
+ break;
+ case AutoUpdater::State::DownloadingUpdate:
+ break;
+ case AutoUpdater::State::ErrorCheckingForUpdate:
+ break;
+ case AutoUpdater::State::NoUpdateAvailable:
+ break;
+ case AutoUpdater::State::RestartToInstallUpdate:
+ notifier_->showMessage(Notifier::SystemMessage, Q2PSTRING(tr("Swift Update Available")), Q2PSTRING(tr("Restart Swift to update to the new Swift version.")), "", [](){});
+ }
}
}