From 67f927c3f60164b90f8822690fbcb2270efc31a4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 9 Dec 2017 19:56:32 +0100 Subject: [PATCH] Ref T203, moved distribution info component to update info component * adjusted components like launcher etc. * deleted CDistributionInfoComponent * CUpdateInfoComponent uses TUpdateInfo/CUpdateInfo * UI adjustments --- .../components/distributioninfocomponent.cpp | 196 ----------------- .../components/downloadandinstalldialog.cpp | 12 +- .../components/downloadandinstalldialog.ui | 12 +- .../components/updateinfocomponent.cpp | 204 ++++++++++++++++++ ...ninfocomponent.h => updateinfocomponent.h} | 50 +++-- ...nfocomponent.ui => updateinfocomponent.ui} | 101 ++++----- src/blackgui/guiapplication.cpp | 6 +- src/swiftlauncher/swiftlauncher.cpp | 19 +- src/swiftlauncher/swiftlauncher.h | 5 +- src/swiftlauncher/swiftlauncher.ui | 6 +- 10 files changed, 317 insertions(+), 294 deletions(-) delete mode 100644 src/blackgui/components/distributioninfocomponent.cpp create mode 100644 src/blackgui/components/updateinfocomponent.cpp rename src/blackgui/components/{distributioninfocomponent.h => updateinfocomponent.h} (54%) rename src/blackgui/components/{distributioninfocomponent.ui => updateinfocomponent.ui} (53%) diff --git a/src/blackgui/components/distributioninfocomponent.cpp b/src/blackgui/components/distributioninfocomponent.cpp deleted file mode 100644 index 35f2cc976..000000000 --- a/src/blackgui/components/distributioninfocomponent.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* Copyright (C) 2017 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "distributioninfocomponent.h" -#include "ui_distributioninfocomponent.h" -#include "installxswiftbusdialog.h" -#include "blackgui/guiapplication.h" -#include "blackmisc/network/networkutils.h" -#include "blackmisc/db/distributionlist.h" -#include "blackmisc/logmessage.h" -#include "blackconfig/buildconfig.h" - -using namespace BlackConfig; -using namespace BlackCore::Application; -using namespace BlackMisc; -using namespace BlackMisc::Db; -using namespace BlackMisc::Network; - -namespace BlackGui -{ - namespace Components - { - CDistributionInfoComponent::CDistributionInfoComponent(QWidget *parent) : - QFrame(parent), - ui(new Ui::CDistributionInfoComponent) - { - ui->setupUi(this); - ui->lbl_NewVersionUrl->setTextFormat(Qt::RichText); - ui->lbl_NewVersionUrl->setTextInteractionFlags(Qt::TextBrowserInteraction); - ui->lbl_NewVersionUrl->setOpenExternalLinks(true); - - // use version signal as trigger for completion - const CDistributionList distributions = m_distributionsInfo.get(); - if (!distributions.isEmpty()) { this->changedDistributionInfo(); } - - connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::requestLoadOfSetup); - connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::installXSwiftBusDialog); - } - - CDistributionInfoComponent::~CDistributionInfoComponent() - { } - - bool CDistributionInfoComponent::isNewVersionAvailable() const - { - const QStringList channelPlatform = m_distributionSetting.get(); - Q_ASSERT_X(channelPlatform.size() == 2, Q_FUNC_INFO, "wrong setting"); - const QVersionNumber vCurrentChannelPlatform = m_distributionsInfo.get().getQVersionForChannelAndPlatform(channelPlatform); - if (vCurrentChannelPlatform.isNull() || vCurrentChannelPlatform.segmentCount() < 4) return false; - const QVersionNumber vCurrent = CBuildConfig::getVersion(); - return (vCurrentChannelPlatform > vCurrent); - } - - void CDistributionInfoComponent::requestLoadOfSetup() - { - if (sGui && !ui->le_LatestVersion->text().isEmpty()) - { - const CStatusMessageList msgs(sGui->requestReloadOfSetupAndVersion()); - CLogMessage::preformatted(msgs); - if (msgs.isSuccess()) - { - ui->le_LatestVersion->setText(""); - } - } - } - - void CDistributionInfoComponent::changedDistributionInfo() - { - this->channelChanged(); - ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl()); - - // emit via digest signal - m_dsDistributionAvailable.inputSignal(); - } - - void CDistributionInfoComponent::installXSwiftBusDialog() - { - if (!m_installXSwiftBusDialog) - { - m_installXSwiftBusDialog.reset(new CInstallXSwiftBusDialog(this)); - m_installXSwiftBusDialog->setModal(true); - } - m_installXSwiftBusDialog->show(); - } - - void CDistributionInfoComponent::saveSettings() - { - const QString channel = ui->cb_Channels->currentText(); - const QString currentPlatform = ui->cb_Platforms->currentText(); - const QStringList settings({ channel, currentPlatform }); - const CStatusMessage m = m_distributionSetting.setAndSave(settings); - if (m.isFailure()) - { - CLogMessage(this).preformatted(m); - } - } - - void CDistributionInfoComponent::channelChanged() - { - const CDistributionList distributions(m_distributionsInfo.get()); - const QStringList channels = distributions.getChannels().toList(); - const QStringList channelPlatformSetting = m_distributionSetting.get(); // channel / platform - Q_ASSERT_X(channelPlatformSetting.size() == 2, Q_FUNC_INFO, "Settings"); - - // default value - QString channel = ui->cb_Channels->currentText(); - if (channel.isEmpty()) { channel = channelPlatformSetting.front(); } - if (channel.isEmpty() && !channels.isEmpty()) { channel = channels.front(); } - - // channels (will be connected below) - ui->cb_Channels->disconnect(); - ui->cb_Platforms->disconnect(); - ui->cb_Channels->clear(); - ui->cb_Channels->insertItems(0, channels); - if (!channel.isEmpty()) { ui->cb_Channels->setCurrentText(channel); } - - // current distribution - const CDistribution currentDistribution = distributions.findByChannelOrDefault(channel); - const QStringList platforms = currentDistribution.getPlatforms(); - m_currentDistribution = currentDistribution; - ui->le_CurrentVersion->setText(CBuildConfig::getVersionString()); - - // platforms - QString platform = ui->cb_Platforms->currentText(); - if (platform.isEmpty()) { platform = channelPlatformSetting.last(); } - if (platform.isEmpty() || !platforms.contains(platform)) { platform = currentDistribution.guessMyPlatform(); } - - ui->cb_Platforms->clear(); - ui->cb_Platforms->insertItems(0, platforms); - if (!platform.isEmpty()) { ui->cb_Platforms->setCurrentText(platform); } - - // platform dependent stuff - this->platformChanged(); - connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::channelChanged); - connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::platformChanged); - } - - void CDistributionInfoComponent::platformChanged() - { - this->saveSettings(); - - // defaults - ui->le_LatestVersion->clear(); - ui->lbl_NewVersionInfo->setText("Nothing new"); - ui->lbl_NewVersionInfo->setStyleSheet("background-color: green"); - ui->lbl_NewVersionUrl->clear(); - m_newVersionAvailable.clear(); - - const QString currentPlatform = this->getSelectedOrGuessedPlatform(); - if (!currentPlatform.isEmpty()) - { - const QVersionNumber latestVersion = m_currentDistribution.getQVersion(currentPlatform); - const QString latestVersionStr = m_currentDistribution.getVersionString(currentPlatform); - ui->le_LatestVersion->setText(latestVersionStr); - ui->le_LatestVersion->setToolTip(""); - - CFailoverUrlList downloadUrls(m_currentDistribution.getDownloadUrls()); - const CUrl downloadUrl(downloadUrls.obtainNextUrl()); - const bool newer = CBuildConfig::getVersion() < latestVersion; - if (newer) - { - ui->lbl_NewVersionInfo->setText("New version!"); - ui->lbl_NewVersionInfo->setToolTip("New version '" + latestVersionStr + "'"); - ui->lbl_NewVersionInfo->setStyleSheet("background-color: red"); - m_newVersionAvailable = latestVersionStr; - } - - if (!downloadUrl.isEmpty()) - { - const QString urlStr(downloadUrl.toQString()); - const QString hl(" %2"); - ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, currentPlatform)); - ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform)); - } - - emit selectionChanged(); - } - } - - QString CDistributionInfoComponent::getSelectedOrGuessedPlatform() const - { - QString p = ui->cb_Platforms->currentText(); - if (p.isEmpty()) - { - const CDistributionList distributions = m_distributionsInfo.get(); - p = distributions.findByChannelOrDefault(ui->cb_Channels->currentText()).guessMyPlatform(); - } - return p; - } - } // ns -} // ns diff --git a/src/blackgui/components/downloadandinstalldialog.cpp b/src/blackgui/components/downloadandinstalldialog.cpp index 0cff5b940..b947b85a4 100644 --- a/src/blackgui/components/downloadandinstalldialog.cpp +++ b/src/blackgui/components/downloadandinstalldialog.cpp @@ -27,7 +27,7 @@ namespace BlackGui ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText(" Download and install "); ui->cb_DontShowAgain->setChecked(!m_setting.get()); this->selectionChanged(); - connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged); + connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged); connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CDownloadAndInstallDialog::onDontShowAgain); } @@ -36,16 +36,16 @@ namespace BlackGui bool CDownloadAndInstallDialog::isNewVersionAvailable() const { - const bool newVersion = ui->comp_DistributionInfo->isNewVersionAvailable(); + const bool newVersion = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable(); return newVersion; } int CDownloadAndInstallDialog::exec() { const int r = QDialog::exec(); - if (r != QDialog::Accepted) return r; - if (!ui->comp_DistributionInfo->isNewVersionAvailable()) { return QDialog::Rejected; } - const CDistribution distribution = ui->comp_DistributionInfo->getCurrentDistribution(); + if (r != QDialog::Accepted) { return r; } + if (!ui->comp_UpdateInfo->isNewPilotClientVersionAvailable()) { return QDialog::Rejected; } + const CDistribution distribution = ui->comp_UpdateInfo->getCurrentDistribution(); if (!distribution.hasDownloadUrls()) { return QDialog::Rejected; } // in future, start download and close application @@ -68,7 +68,7 @@ namespace BlackGui void CDownloadAndInstallDialog::selectionChanged() { - const bool nv = ui->comp_DistributionInfo->isNewVersionAvailable(); + const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable(); ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setEnabled(nv); } diff --git a/src/blackgui/components/downloadandinstalldialog.ui b/src/blackgui/components/downloadandinstalldialog.ui index f3d80c15e..cf294dee9 100644 --- a/src/blackgui/components/downloadandinstalldialog.ui +++ b/src/blackgui/components/downloadandinstalldialog.ui @@ -7,13 +7,13 @@ 0 0 400 - 150 + 200 400 - 130 + 200 @@ -36,7 +36,7 @@ 4 - + 0 @@ -52,7 +52,7 @@ 9 - 0 + 9 9 @@ -84,9 +84,9 @@ - BlackGui::Components::CDistributionInfoComponent + BlackGui::Components::CUpdateInfoComponent QFrame -
blackgui/components/distributioninfocomponent.h
+
blackgui/components/updateinfocomponent.h
1
diff --git a/src/blackgui/components/updateinfocomponent.cpp b/src/blackgui/components/updateinfocomponent.cpp new file mode 100644 index 000000000..44a2faa09 --- /dev/null +++ b/src/blackgui/components/updateinfocomponent.cpp @@ -0,0 +1,204 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "updateinfocomponent.h" +#include "ui_updateinfocomponent.h" +#include "installxswiftbusdialog.h" +#include "blackgui/guiapplication.h" +#include "blackmisc/network/networkutils.h" +#include "blackmisc/db/distributionlist.h" +#include "blackmisc/logmessage.h" +#include "blackconfig/buildconfig.h" + +#include + +using namespace BlackConfig; +using namespace BlackCore::Application; +using namespace BlackMisc; +using namespace BlackMisc::Db; +using namespace BlackMisc::Network; + +namespace BlackGui +{ + namespace Components + { + CUpdateInfoComponent::CUpdateInfoComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CUpdateInfoComponent) + { + ui->setupUi(this); + Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui"); + + connect(sGui, &CGuiApplication::updateInfoAvailable, this, &CUpdateInfoComponent::changedUpdateInfo); + connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CUpdateInfoComponent::requestLoadOfSetup); + connect(ui->pb_DownloadXSwiftBus, &QPushButton::pressed, this, &CUpdateInfoComponent::downloadXSwiftBusDialog); + connect(ui->pb_DownloadInstaller, &QPushButton::pressed, this, &CUpdateInfoComponent::downloadInstallerDialog); + + // use version signal as trigger for completion + if (!m_updateInfo.get().isEmpty()) { this->changedUpdateInfo(); } + } + + CUpdateInfoComponent::~CUpdateInfoComponent() + { } + + CArtifact CUpdateInfoComponent::getLatestAvailablePilotClientArtifactForSelection() const + { + const CUpdateInfo info = m_updateInfo.get(); + const CPlatform p = this->getSelectedOrDefaultPlatform(); + const CDistribution d = this->getSelectedOrDefaultDistribution(); + const CArtifact a = info.getArtifactsPilotClient().findByDistributionAndPlatform(d, p, true).getLatestArtifactOrDefault(); + return a; + } + + bool CUpdateInfoComponent::isNewPilotClientVersionAvailable() const + { + const QStringList settings = m_updateSettings.get(); + Q_ASSERT_X(settings.size() == 2, Q_FUNC_INFO, "wrong setting"); + const QString channel = settings.front(); + if (channel.isEmpty()) { return false; } + + const CUpdateInfo info = m_updateInfo.get(); + const CDistribution d = info.getDistributions().findFirstByChannelOrDefault(channel); + const QVersionNumber vCurrentChannelPlatform = info.getArtifactsPilotClient().findByDistribution(d).getLatestQVersion(); + const QVersionNumber vCurrent = CBuildConfig::getVersion(); + if (vCurrentChannelPlatform.isNull()) { return false; } + return (vCurrentChannelPlatform > vCurrent); + } + + void CUpdateInfoComponent::requestLoadOfSetup() + { + if (!sGui) { return; } + const CStatusMessageList msgs(sGui->requestReloadOfSetupAndVersion()); + CLogMessage::preformatted(msgs); + } + + void CUpdateInfoComponent::changedUpdateInfo() + { + ui->lbl_CurrentVersionDisplay->setText(CBuildConfig::getVersionString()); + + const CUpdateInfo updateInfo(m_updateInfo.get()); + const QStringList settings = m_updateSettings.get(); + Q_ASSERT_X(settings.size() == 2, Q_FUNC_INFO, "Settings"); + + const CPlatformSet platforms = updateInfo.getArtifactsPilotClient().getPlatforms(); + CDistributionList distributions = updateInfo.getArtifactsPilotClient().getDistributions(); + distributions.sortByStability(Qt::DescendingOrder); + + int i = 0; + ui->cb_Platforms->disconnect(); + ui->cb_Platforms->clear(); + for (const CPlatform &platform : platforms) + { + ui->cb_Platforms->insertItem(i++, platform.toPixmap(), platform.getPlatformName()); + } + if (platforms.contains(settings.last())) { ui->cb_Platforms->setCurrentText(settings.last()); } + else if (platforms.contains(CPlatform::currentPlatform().getPlatformName())) { ui->cb_Platforms->setCurrentText(CPlatform::currentPlatform().getPlatformName()); } + + i = 0; + ui->cb_Channels->disconnect(); + ui->cb_Channels->clear(); + for (const CDistribution &distribution : distributions) + { + ui->cb_Channels->insertItem(i++, distribution.getRestrictionIcon().toPixmap(), distribution.getChannel()); + } + if (distributions.containsChannel(settings.front())) { ui->cb_Channels->setCurrentText(settings.front()); } + + this->uiSelectionChanged(); + connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CUpdateInfoComponent::platformChanged); + connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CUpdateInfoComponent::channelChanged); + + // emit via digest signal + m_dsDistributionAvailable.inputSignal(); + } + + void CUpdateInfoComponent::downloadXSwiftBusDialog() + { + if (!m_installXSwiftBusDialog) + { + m_installXSwiftBusDialog.reset(new CInstallXSwiftBusDialog(this)); + m_installXSwiftBusDialog->setModal(true); + } + + const QString current = ui->cb_ArtifactsXsb->currentText(); + m_installXSwiftBusDialog->setDefaultDownloadName(current); + m_installXSwiftBusDialog->show(); + } + + void CUpdateInfoComponent::saveSettings() + { + const QString channel = this->getSelectedOrDefaultDistribution().getChannel(); + const QString platform = this->getSelectedOrDefaultPlatform().getPlatformName(); + const QStringList settings({ channel, platform }); + const CStatusMessage m = m_updateSettings.setAndSave(settings); + if (m.isFailure()) + { + CLogMessage(this).preformatted(m); + } + } + + void CUpdateInfoComponent::channelChanged() + { + this->uiSelectionChanged(); + } + + void CUpdateInfoComponent::platformChanged() + { + this->uiSelectionChanged(); + } + + void CUpdateInfoComponent::uiSelectionChanged() + { + const CDistribution selectedDistribution(this->getSelectedOrDefaultDistribution()); + const CPlatform selectedPlatform(this->getSelectedOrDefaultPlatform()); + + const CUpdateInfo updateInfo(m_updateInfo.get()); + const CArtifactList artifactsPilotClient = updateInfo.getArtifactsPilotClient().findByDistributionAndPlatform(selectedDistribution, selectedPlatform, true); + const CArtifactList artifactsXsb = updateInfo.getArtifactsXsb().findByDistributionAndPlatform(selectedDistribution, selectedPlatform, true); + + const QStringList sortedPilotClientVersions = artifactsPilotClient.getSortedVersions(); + ui->cb_ArtifactsPilotClient->clear(); + ui->cb_ArtifactsPilotClient->insertItems(0, sortedPilotClientVersions); + ui->pb_DownloadInstaller->setEnabled(!artifactsPilotClient.isEmpty()); + + const QStringList sortedXsbVersions = artifactsXsb.getSortedVersions(); + ui->cb_ArtifactsXsb->clear(); + ui->cb_ArtifactsXsb->insertItems(0, sortedXsbVersions); + ui->pb_DownloadXSwiftBus->setEnabled(!artifactsXsb.isEmpty()); + + const bool newer = this->isNewPilotClientVersionAvailable(); + ui->lbl_StatusInfo->setText(newer ? "New version available" : "Nothing new"); + ui->lbl_StatusInfo->setStyleSheet(newer ? + "background-color: green; color: white;" : + "background-color: red; color: white;"); + + this->saveSettings(); + emit this->selectionChanged(); + } + + const CPlatform &CUpdateInfoComponent::getSelectedOrDefaultPlatform() const + { + const QStringList settings = m_updateSettings.get(); // channel / platform + QString p = ui->cb_Platforms->currentText(); + if (p.isEmpty()) { p = settings.last(); } + if (p.isEmpty()) { p = CPlatform::currentPlatform().getPlatformName(); } + return CPlatform::stringToPlatformObject(p); + } + + const CDistribution CUpdateInfoComponent::getSelectedOrDefaultDistribution() const + { + const QStringList settings = m_updateSettings.get(); // channel / platform + QString c = ui->cb_Channels->currentText(); + if (c.isEmpty()) { c = settings.first(); } + const CUpdateInfo updateInfo(m_updateInfo.get()); + return c.isEmpty() ? + updateInfo.getDistributions().getMostStableOrDefault() : + updateInfo.getDistributions().findFirstByChannelOrDefault(c); + } + } // ns +} // ns diff --git a/src/blackgui/components/distributioninfocomponent.h b/src/blackgui/components/updateinfocomponent.h similarity index 54% rename from src/blackgui/components/distributioninfocomponent.h rename to src/blackgui/components/updateinfocomponent.h index d2623cfa9..4f1366d92 100644 --- a/src/blackgui/components/distributioninfocomponent.h +++ b/src/blackgui/components/updateinfocomponent.h @@ -9,17 +9,17 @@ //! \file -#ifndef BLACKGUI_COMPONENTS_DISTRIBUTIONINFOCOMPONENT_H -#define BLACKGUI_COMPONENTS_DISTRIBUTIONINFOCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_UPDATEINFOCOMPONENT_H +#define BLACKGUI_COMPONENTS_UPDATEINFOCOMPONENT_H -#include "blackcore/application/distributionsettings.h" +#include "blackcore/application/updatesettings.h" #include "blackgui/blackguiexport.h" -#include "blackmisc/db/distributionlist.h" +#include "blackmisc/db/updateinfo.h" #include "blackmisc/settingscache.h" #include "blackmisc/digestsignal.h" #include -namespace Ui { class CDistributionInfoComponent; } +namespace Ui { class CUpdateInfoComponent; } namespace BlackGui { namespace Components @@ -27,49 +27,47 @@ namespace BlackGui class CInstallXSwiftBusDialog; /** - * Update info (distributions etc.) + * Update info (distributions, artifacts etc.) */ - class BLACKGUI_EXPORT CDistributionInfoComponent : public QFrame + class BLACKGUI_EXPORT CUpdateInfoComponent : public QFrame { Q_OBJECT public: //! Ctor - explicit CDistributionInfoComponent(QWidget *parent = nullptr); + explicit CUpdateInfoComponent(QWidget *parent = nullptr); //! Dtor - virtual ~CDistributionInfoComponent(); + virtual ~CUpdateInfoComponent(); //! Is there a new version available return version, else empty string - QString getNewAvailableVersionForSelection() const { return m_newVersionAvailable; } + BlackMisc::Db::CArtifact getLatestAvailablePilotClientArtifactForSelection() const; //! Is there a new version available? - bool isNewVersionAvailable() const; + bool isNewPilotClientVersionAvailable() const; //! Current distribution - BlackMisc::Db::CDistribution getCurrentDistribution() { return m_currentDistribution; } + BlackMisc::Db::CDistribution getCurrentDistribution() const { return this->getSelectedOrDefaultDistribution(); } signals: - //! Distribution info loaded - void distributionInfoAvailable(); + //! Update info loaded + void updateInfoAvailable(); //! New platfrom or channel void selectionChanged(); private: - QScopedPointer ui; + QScopedPointer ui; QScopedPointer m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus - QString m_newVersionAvailable; //!< new version number if any - BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution - BlackMisc::CDataReadOnly m_distributionsInfo { this, &CDistributionInfoComponent::changedDistributionInfo }; //!< version cache - BlackMisc::CSetting m_distributionSetting { this }; //!< channel/platform selected - BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::distributionInfoAvailable, 10000, 2 }; + BlackMisc::CDataReadOnly m_updateInfo { this, &CUpdateInfoComponent::changedUpdateInfo }; //!< version cache + BlackMisc::CSetting m_updateSettings { this }; //!< channel/platform selected + BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CUpdateInfoComponent::updateInfoAvailable, 15000, 2 }; //! Load latest version void requestLoadOfSetup(); //! Loaded latest version - void changedDistributionInfo(); + void changedUpdateInfo(); //! Channel has been changed void channelChanged(); @@ -77,14 +75,20 @@ namespace BlackGui //! Platform changed void platformChanged(); + //! Selection changed + void uiSelectionChanged(); + //! Install XSwiftBus dialog - void installXSwiftBusDialog(); + void downloadXSwiftBusDialog(); //! Save the current settings void saveSettings(); //! Selected platform from UI or guessed platform - QString getSelectedOrGuessedPlatform() const; + const BlackMisc::CPlatform &getSelectedOrDefaultPlatform() const; + + //! Selected or default distribution + const BlackMisc::Db::CDistribution getSelectedOrDefaultDistribution() const; }; } // ns } // ns diff --git a/src/blackgui/components/distributioninfocomponent.ui b/src/blackgui/components/updateinfocomponent.ui similarity index 53% rename from src/blackgui/components/distributioninfocomponent.ui rename to src/blackgui/components/updateinfocomponent.ui index 9ecacc864..f06039721 100644 --- a/src/blackgui/components/distributioninfocomponent.ui +++ b/src/blackgui/components/updateinfocomponent.ui @@ -1,13 +1,13 @@ - CDistributionInfoComponent - + CUpdateInfoComponent + 0 0 - 307 - 106 + 262 + 126 @@ -17,9 +17,9 @@ - Distribution info + swift update info - + 0 @@ -32,86 +32,91 @@ 0 - - + + + + + + + + + + + + + + + + XPlane only + - Latest: + download - - - - true + + + + download - + This version: - - + + - Channel: + swift installer: - - + + + + Only required for XP + + + XSwiftBus: + + - - - Platform: - - - - - - - true - - - - - check again + check again - - - - + - Nothing new + <version goes here> - - + + - URL goes here + Channel/OS: - - + + - install + Info: - - + + - XSwiftBus (XPlane only): + <status goes here> diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 9ea3e11e6..0122c7671 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -484,11 +484,11 @@ namespace BlackGui }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); - a = sm->addAction("JSON distributions (info only)"); + a = sm->addAction("JSON update info (for info only)"); c = connect(a, &QAction::triggered, this, [a, this]() { - const CDistributionList d = this->getDistributionInfo(); - this->displayTextInConsole(d.toJsonString()); + const CUpdateInfo info = this->getUpdateInfo(); + this->displayTextInConsole(info.toJsonString()); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index bd8867b6d..28dc9f649 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -40,6 +40,7 @@ using namespace BlackCore::Context; using namespace BlackCore::Data; using namespace BlackCore::Vatsim; using namespace BlackMisc; +using namespace BlackMisc::Db; using namespace BlackMisc::Network; CSwiftLauncher::CSwiftLauncher(QWidget *parent) : @@ -62,7 +63,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : connect(ui->rb_SwiftCoreAudioOnGui, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); connect(ui->rb_SwiftStandalone, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); - connect(ui->comp_DistributionInfo, &CDistributionInfoComponent::distributionInfoAvailable, this, &CSwiftLauncher::distributionInfoAvailable); + connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::updateInfoAvailable, this, &CSwiftLauncher::updateInfoAvailable); connect(ui->comp_DBusSelector, &CDBusServerAddressSelector::editingFinished, this, &CSwiftLauncher::onDBusEditingFinished); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftLauncher::onStyleSheetsChanged); @@ -142,9 +143,9 @@ void CSwiftLauncher::displayLatestNews(QNetworkReply *reply) } } -void CSwiftLauncher::distributionInfoAvailable() +void CSwiftLauncher::updateInfoAvailable() { - this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection()); + this->setHeaderInfo(ui->comp_UpdateInfo->getLatestAvailablePilotClientArtifactForSelection()); this->loadLatestNews(); this->loadAbout(); } @@ -221,12 +222,16 @@ void CSwiftLauncher::initLogDisplay() ui->comp_SwiftLauncherLog->filterUseRadioButtonDescriptiveIcons(false); } -void CSwiftLauncher::setHeaderInfo(const QString &newVersionAvailable) +void CSwiftLauncher::setHeaderInfo(const CArtifact &latestArtifact) { - ui->lbl_HeaderInfo->setVisible(!newVersionAvailable.isEmpty()); - if (!newVersionAvailable.isEmpty()) + const bool isNewer = latestArtifact.isNewerThanCurrentBuild(); + ui->lbl_HeaderInfo->setVisible(isNewer); + if (isNewer) { - ui->lbl_HeaderInfo->setText("New version '" + newVersionAvailable + "' available"); + static const QString t("New version '%1' ['%2'/'%3']"); + ui->lbl_HeaderInfo->setText( + t.arg(latestArtifact.getVersionString(), latestArtifact.getPlatform().getPlatformName(), + latestArtifact.getMostStableDistribution().getChannel())); ui->lbl_HeaderInfo->setStyleSheet("background: red; color: yellow;"); } } diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index b2b77b67e..d812a1212 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -18,6 +18,7 @@ #include "blackcore/data/globalsetup.h" #include "blackcore/data/launchersetup.h" #include "blackcore/coremodeenums.h" +#include "blackmisc/db/artifact.h" #include "blackmisc/identifiable.h" #include #include @@ -110,7 +111,7 @@ private: void initLogDisplay(); //! Set header info - void setHeaderInfo(const QString &newVersionAvailable); + void setHeaderInfo(const BlackMisc::Db::CArtifact &latestArtifact); //! Latest news //! \sa CSwiftLauncher::displayLatestNews @@ -147,7 +148,7 @@ private: void displayLatestNews(QNetworkReply *reply); //! Distribution info is available - void distributionInfoAvailable(); + void updateInfoAvailable(); //! Start button pressed void startButtonPressed(); diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index 229f9e077..95a0a87cb 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -393,7 +393,7 @@ 4 - + 0 @@ -760,9 +760,9 @@ p, li { white-space: pre-wrap; } 1 - BlackGui::Components::CDistributionInfoComponent + BlackGui::Components::CUpdateInfoComponent QFrame -
blackgui/components/distributioninfocomponent.h
+
blackgui/components/updateinfocomponent.h
1