diff options
author | Tobias Markmann <tm@ayena.de> | 2017-02-21 13:27:42 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-02-22 11:15:00 (GMT) |
commit | 996ca9ecf4f226a033d161419f11e715a3f892c3 (patch) | |
tree | e332db1edf3e9ea2282814154473e3a5e57d362d /Swift/QtUI/QtSwift.cpp | |
parent | eea861301be0bf3e3f5db6cfc3cada38d133fef2 (diff) | |
download | swift-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.cpp | 49 |
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 @@ -269,12 +269,27 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa 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_, @@ -295,21 +310,6 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa } 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() { @@ -347,8 +347,21 @@ void QtSwift::handleAboutToQuit() { #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.")), "", [](){}); + } } } |