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/QtUpdateFeedSelectionDialog.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/QtUpdateFeedSelectionDialog.cpp')
-rw-r--r-- | Swift/QtUI/QtUpdateFeedSelectionDialog.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Swift/QtUI/QtUpdateFeedSelectionDialog.cpp b/Swift/QtUI/QtUpdateFeedSelectionDialog.cpp new file mode 100644 index 0000000..1f4058a --- /dev/null +++ b/Swift/QtUI/QtUpdateFeedSelectionDialog.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <Swift/QtUI/QtUpdateFeedSelectionDialog.h> + +#include <QComboBox> + +#include <Swift/Controllers/Settings/SettingsProvider.h> + +#include <Swift/QtUI/QtUISettingConstants.h> +#include <Swift/QtUI/SwiftUpdateFeeds.h> + +namespace Swift { + +QtUpdateFeedSelectionDialog::QtUpdateFeedSelectionDialog(SettingsProvider* settingsProvider) : QDialog(), settings_(settingsProvider) { + ui.setupUi(this); + + connect(ui.currentChannelComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [&] (int newIndex) { + setDescriptionForIndex(newIndex); + }); + + auto updateChannel = settings_->getSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL); + if (updateChannel == UpdateFeeds::StableChannel) { + ui.currentChannelComboBox->setCurrentIndex(0); + } + else if (updateChannel == UpdateFeeds::TestingChannel) { + ui.currentChannelComboBox->setCurrentIndex(1); + } + else if (updateChannel == UpdateFeeds::DevelopmentChannel) { + ui.currentChannelComboBox->setCurrentIndex(2); + } + + connect(this, &QDialog::accepted, [&]() { + auto newUpdateChannel = std::string(""); + switch (ui.currentChannelComboBox->currentIndex()) { + case 0: + newUpdateChannel = UpdateFeeds::StableChannel; + break; + case 1: + newUpdateChannel = UpdateFeeds::TestingChannel; + break; + case 2: + newUpdateChannel = UpdateFeeds::DevelopmentChannel; + break; + } + settings_->storeSetting(QtUISettingConstants::SOFTWARE_UPDATE_CHANNEL, newUpdateChannel); + }); + + setAttribute(Qt::WA_DeleteOnClose); +} + +void QtUpdateFeedSelectionDialog::setDescriptionForIndex(int index) { + switch (index) { + case 0: + ui.stableDescriptionLabel->show(); + ui.testingDescriptionLabel->hide(); + ui.developmentDescriptionLabel->hide(); + break; + case 1: + ui.stableDescriptionLabel->hide(); + ui.testingDescriptionLabel->show(); + ui.developmentDescriptionLabel->hide(); + break; + case 2: + ui.stableDescriptionLabel->hide(); + ui.testingDescriptionLabel->hide(); + ui.developmentDescriptionLabel->show(); + break; + default: + ui.stableDescriptionLabel->hide(); + ui.testingDescriptionLabel->hide(); + ui.developmentDescriptionLabel->hide(); + break; + } + setFixedSize(sizeHint()); +} + + + +} |