diff options
author | Tobias Markmann <tm@ayena.de> | 2016-11-11 11:28:53 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-11-11 13:50:52 (GMT) |
commit | 97c87cf3e9b5e150152898e7907577c3ca3fdd86 (patch) | |
tree | 17c23b1a10537261e0d1e662493cc4ddf137026c /Swift/QtUI/QtSwift.cpp | |
parent | 94ec9c25311f8d54519f045205d58526d885412a (diff) | |
download | swift-97c87cf3e9b5e150152898e7907577c3ca3fdd86.zip swift-97c87cf3e9b5e150152898e7907577c3ca3fdd86.tar.bz2 |
Add update channel configuration dialog to the about window
If software updates are enabled the about dialog will show
the currently configured update channel and provides a link
to a dialog to change the update channel.
Test-Information:
Builds on macOS 10.12.1, unit tests pass, and dialogs behave
as expected. Did not test Sparkle updating.
Change-Id: I05d5014f0d719ba9b2146c1e599db4f7fde80558
Diffstat (limited to 'Swift/QtUI/QtSwift.cpp')
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 3aff999..3f6ce8e 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -51,6 +51,7 @@ #include <Swift/QtUI/QtSystemTray.h> #include <Swift/QtUI/QtUIFactory.h> #include <Swift/QtUI/QtUISettingConstants.h> +#include <Swift/QtUI/SwiftUpdateFeeds.h> #if defined(SWIFTEN_PLATFORM_WINDOWS) #include <Swift/QtUI/WindowsNotifier.h> @@ -84,12 +85,6 @@ namespace Swift{ -#if defined(SWIFTEN_PLATFORM_MACOSX) -#define SWIFT_APPCAST_URL "https://swift.im/appcast/swift-mac-dev.xml" -#else -#define SWIFT_APPCAST_URL "" -#endif - po::options_description QtSwift::getOptionsDescription() { po::options_description result("Options"); result.add_options() @@ -141,6 +136,22 @@ void QtSwift::loadEmoticonsFile(const QString& fileName, std::map<std::string, s } } +const std::string& QtSwift::updateChannelToFeed(const std::string& channel) { + static const std::string invalidChannel; + if (channel == UpdateFeeds::StableChannel) { + return UpdateFeeds::StableAppcastFeed; + } + else if (channel == UpdateFeeds::TestingChannel) { + return UpdateFeeds::TestingAppcastFeed; + } + else if (channel == UpdateFeeds::DevelopmentChannel) { + return UpdateFeeds::DevelopmentAppcastFeed; + } + else { + return invalidChannel; + } +} + QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(nullptr), idleDetector_(&idleQuerier_, networkFactories_.getTimerFactory(), 1000) { QCoreApplication::setApplicationName(SWIFT_APPLICATION_NAME); QCoreApplication::setOrganizationName(SWIFT_ORGANIZATION_NAME); @@ -285,10 +296,18 @@ 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)) { - autoUpdater_ = autoUpdaterFactory.createAutoUpdater(SWIFT_APPCAST_URL); + 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(); + } + }); } } @@ -328,7 +347,7 @@ void QtSwift::handleAboutToQuit() { } void QtSwift::handleRecommendRestartToInstallUpdate() { - notifier_->showMessage(Notifier::SystemMessage, Q2PSTRING(tr("Swift Update Available")), Q2PSTRING(tr("Restart Swift now or later to update to the new Swift version")), "", [](){}); + notifier_->showMessage(Notifier::SystemMessage, Q2PSTRING(tr("Swift Update Available")), Q2PSTRING(tr("Restart Swift to update to the new Swift version.")), "", [](){}); } } |