From 1dd6a0852d05886dd2ff7af80c44e88b1134d3fc Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 6 Mar 2019 17:47:55 +0100 Subject: [PATCH] Fixed update info * save before displaying "update info" as it relies on saved channel * signal to indicate new version, using that for launcher header --- .../components/updateinfocomponent.cpp | 14 ++++++++++--- src/blackgui/components/updateinfocomponent.h | 4 ++++ src/swiftlauncher/swiftlauncher.cpp | 20 ++++++++++--------- src/swiftlauncher/swiftlauncher.ui | 6 +++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/blackgui/components/updateinfocomponent.cpp b/src/blackgui/components/updateinfocomponent.cpp index d67b67042..9d25e4227 100644 --- a/src/blackgui/components/updateinfocomponent.cpp +++ b/src/blackgui/components/updateinfocomponent.cpp @@ -137,7 +137,7 @@ namespace BlackGui const QString platform = ui->cb_Platforms->currentText(); if (!CPlatform::isCurrentPlatform(platform)) { - const QMessageBox::StandardButton ret = QMessageBox::warning(this, tr("Download installer"), + const QMessageBox::StandardButton ret = QMessageBox::warning(this, "Download installer", QStringLiteral( "The platform '%1' does not match your current platform '%2'.\n" "Do you want to continue?").arg(platform, CPlatform::currentPlatform().getPlatformName()), @@ -197,7 +197,8 @@ namespace BlackGui // for XSwiftBus we only show public (unrestricted) ones, as the follow up dialog will only show unrestricted const CUpdateInfo updateInfo(m_updateInfo.get()); const CArtifactList artifactsPilotClient = updateInfo.getArtifactsPilotClient().findByDistributionAndPlatform(selectedDistribution, selectedPlatform, true); - const CArtifactList artifactsXsb = updateInfo.getArtifactsXSwiftBus().findWithUnrestrictedDistributions().findByDistributionAndPlatform(selectedDistribution, selectedPlatform, true); + const CArtifactList artifactsXsb = updateInfo.getArtifactsXSwiftBus().findWithUnrestrictedDistributions().findByDistributionAndPlatform(selectedDistribution, selectedPlatform, true); + const CArtifact latestPilotClient = artifactsPilotClient.getLatestArtifactOrDefault(); const QStringList sortedPilotClientVersions = artifactsPilotClient.getSortedVersions(); ui->cb_ArtifactsPilotClient->clear(); @@ -209,6 +210,9 @@ namespace BlackGui ui->cb_ArtifactsXsb->insertItems(0, sortedXsbVersions); ui->pb_DownloadXSwiftBus->setEnabled(!artifactsXsb.isEmpty()); + // save the settings as this is needed afterwards + this->saveSettings(); + //! \fixme hardcoded stylesheet color const bool newer = this->isNewPilotClientVersionAvailable(); ui->lbl_StatusInfo->setText(newer ? "New version available" : "Nothing new"); @@ -216,8 +220,12 @@ namespace BlackGui "background-color: green; color: white;" : "background-color: red; color: white;"); - this->saveSettings(); emit this->selectionChanged(); + + if (newer && latestPilotClient.isLoadedFromDb()) + { + emit this->newerPilotClientAvailable(latestPilotClient); + } } const CPlatform &CUpdateInfoComponent::getSelectedOrDefaultPlatform() const diff --git a/src/blackgui/components/updateinfocomponent.h b/src/blackgui/components/updateinfocomponent.h index 8350e3f84..7ee1ca108 100644 --- a/src/blackgui/components/updateinfocomponent.h +++ b/src/blackgui/components/updateinfocomponent.h @@ -14,6 +14,7 @@ #include "blackcore/application/updatesettings.h" #include "blackgui/blackguiexport.h" #include "blackmisc/db/updateinfo.h" +#include "blackmisc/db/artifact.h" #include "blackmisc/settingscache.h" #include "blackmisc/digestsignal.h" #include @@ -53,6 +54,9 @@ namespace BlackGui //! Update info loaded void updateInfoAvailable(); + //! A newer pilot client is available + void newerPilotClientAvailable(const BlackMisc::Db::CArtifact &latestPilotClient); + //! New platfrom or channel void selectionChanged(); diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index c8c736ccf..8e04f364c 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -56,21 +56,23 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : this->init(); connect(ui->tb_SwiftCore, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); connect(ui->tb_SwiftMappingTool, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); - connect(ui->tb_SwiftGui, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); - connect(ui->tb_Database, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); + connect(ui->tb_SwiftGui, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); + connect(ui->tb_Database, &QPushButton::pressed, this, &CSwiftLauncher::startButtonPressed); connect(ui->tb_BackToMain, &QToolButton::pressed, this, &CSwiftLauncher::showMainPage); connect(ui->tb_ConfigurationWizard, &QToolButton::pressed, this, &CSwiftLauncher::startWizard); connect(ui->tb_Launcher, &QToolBox::currentChanged, this, &CSwiftLauncher::tabChanged); connect(ui->rb_SwiftCoreAudioOnCore, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); - connect(ui->rb_SwiftCoreAudioOnGui, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); - connect(ui->rb_SwiftStandalone, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); + connect(ui->rb_SwiftCoreAudioOnGui, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); + connect(ui->rb_SwiftStandalone, &QRadioButton::released, this, &CSwiftLauncher::onCoreModeReleased); - connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::updateInfoAvailable, this, &CSwiftLauncher::updateInfoAvailable); - connect(ui->comp_DBusSelector, &CDBusServerAddressSelector::editingFinished, this, &CSwiftLauncher::onDBusEditingFinished); + connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::updateInfoAvailable, this, &CSwiftLauncher::updateInfoAvailable, Qt::QueuedConnection); + connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::newerPilotClientAvailable, this, &CSwiftLauncher::setHeaderInfo, Qt::QueuedConnection); + connect(ui->comp_DBusSelector, &CDBusServerAddressSelector::editingFinished, this, &CSwiftLauncher::onDBusEditingFinished, Qt::QueuedConnection); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CSwiftLauncher::onStyleSheetsChanged, Qt::QueuedConnection); - new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(showLogPage())); + const QShortcut *logPageShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(showLogPage())); + Q_UNUSED(logPageShortCut); // default from settings this->setDefaults(); @@ -86,7 +88,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : const QPointer myself(this); QTimer::singleShot(2500, this, [ = ] { - if (!myself) { return; } + if (!sGui || sGui->isShuttingDown() || !myself) { return; } myself->startWizard(); }); } @@ -198,7 +200,7 @@ void CSwiftLauncher::loadLatestNews() CFailoverUrlList newsUrls(sGui->getGlobalSetup().getSwiftLatestNewsUrls()); const CUrl newsUrl(newsUrls.obtainNextWorkingUrl(true, 10 * 1000)); - // const CUrl newsUrl("https://dev.swift-project.org/phame/blog/view/1/"); + // const CUrl newsUrl("https://dev.swift-project.org/phame/blog/view/1/?__print__=1"); if (newsUrl.isEmpty()) { diff --git a/src/swiftlauncher/swiftlauncher.ui b/src/swiftlauncher/swiftlauncher.ui index ce00f10f5..f45d265f5 100644 --- a/src/swiftlauncher/swiftlauncher.ui +++ b/src/swiftlauncher/swiftlauncher.ui @@ -88,7 +88,7 @@ - 0 + 3 6 @@ -403,7 +403,7 @@ 0 - 100 + 110 @@ -443,7 +443,7 @@ 0 0 376 - 136 + 126