mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T203, moved distribution info component to update info component
* adjusted components like launcher etc. * deleted CDistributionInfoComponent * CUpdateInfoComponent uses TUpdateInfo/CUpdateInfo * UI adjustments
This commit is contained in:
@@ -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("<a href=\"%1\"><img src=\":/own/icons/own/drophere16.png\"></a> %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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>150</height>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>130</height>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -36,7 +36,7 @@
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo">
|
||||
<widget class="BlackGui::Components::CUpdateInfoComponent" name="comp_UpdateInfo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -52,7 +52,7 @@
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
@@ -84,9 +84,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDistributionInfoComponent</class>
|
||||
<class>BlackGui::Components::CUpdateInfoComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/distributioninfocomponent.h</header>
|
||||
<header>blackgui/components/updateinfocomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
||||
204
src/blackgui/components/updateinfocomponent.cpp
Normal file
204
src/blackgui/components/updateinfocomponent.cpp
Normal file
@@ -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<QDesktopServices>
|
||||
|
||||
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
|
||||
@@ -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 <QFrame>
|
||||
|
||||
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::CDistributionInfoComponent> ui;
|
||||
QScopedPointer<Ui::CUpdateInfoComponent> ui;
|
||||
QScopedPointer<CInstallXSwiftBusDialog> m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus
|
||||
QString m_newVersionAvailable; //!< new version number if any
|
||||
BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Db::TDistributionsInfo> m_distributionsInfo { this, &CDistributionInfoComponent::changedDistributionInfo }; //!< version cache
|
||||
BlackMisc::CSetting<BlackCore::Application::TDistribution> m_distributionSetting { this }; //!< channel/platform selected
|
||||
BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::distributionInfoAvailable, 10000, 2 };
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Db::TUpdateInfo> m_updateInfo { this, &CUpdateInfoComponent::changedUpdateInfo }; //!< version cache
|
||||
BlackMisc::CSetting<BlackCore::Application::TUpdatePreferences> 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
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDistributionInfoComponent</class>
|
||||
<widget class="QFrame" name="CDistributionInfoComponent">
|
||||
<class>CUpdateInfoComponent</class>
|
||||
<widget class="QFrame" name="CUpdateInfoComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>307</width>
|
||||
<height>106</height>
|
||||
<width>262</width>
|
||||
<height>126</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -17,9 +17,9 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Distribution info</string>
|
||||
<string>swift update info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_DistributionInfo">
|
||||
<layout class="QGridLayout" name="gl_DistributionInfo" columnstretch="1,2,1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -32,86 +32,91 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_LatestVersion">
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="cb_Platforms"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="cb_Channels"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="cb_ArtifactsPilotClient"/>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="cb_ArtifactsXsb"/>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QPushButton" name="pb_DownloadXSwiftBus">
|
||||
<property name="toolTip">
|
||||
<string>XPlane only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Latest:</string>
|
||||
<string>download</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_LatestVersion">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="pb_DownloadInstaller">
|
||||
<property name="text">
|
||||
<string>download</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_CurrentVersion">
|
||||
<property name="text">
|
||||
<string>This version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Channel">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_ArtifactsSwift">
|
||||
<property name="text">
|
||||
<string>Channel:</string>
|
||||
<string>swift installer:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="cb_Platforms"/>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_ArtifactsXSwiftBus">
|
||||
<property name="toolTip">
|
||||
<string>Only required for XP</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>XSwiftBus:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_Platforms">
|
||||
<property name="text">
|
||||
<string>Platform:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_CurrentVersion">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="pb_CheckForUpdates">
|
||||
<property name="text">
|
||||
<string>check again</string>
|
||||
<string> check again </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cb_Channels"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_NewVersionInfo">
|
||||
<widget class="QLabel" name="lbl_CurrentVersionDisplay">
|
||||
<property name="text">
|
||||
<string>Nothing new</string>
|
||||
<string><version goes here></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lbl_NewVersionUrl">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Channel">
|
||||
<property name="text">
|
||||
<string>URL goes here</string>
|
||||
<string>Channel/OS:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QPushButton" name="pb_InstallXSwiftBus">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>install</string>
|
||||
<string>Info:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="lbl_XSwiftBus">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_StatusInfo">
|
||||
<property name="text">
|
||||
<string>XSwiftBus (XPlane only):</string>
|
||||
<string><status goes here></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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;");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <QDialog>
|
||||
#include <QTimer>
|
||||
@@ -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();
|
||||
|
||||
@@ -393,7 +393,7 @@
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDistributionInfoComponent" name="comp_DistributionInfo">
|
||||
<widget class="BlackGui::Components::CUpdateInfoComponent" name="comp_UpdateInfo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -760,9 +760,9 @@ p, li { white-space: pre-wrap; }
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDistributionInfoComponent</class>
|
||||
<class>BlackGui::Components::CUpdateInfoComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/distributioninfocomponent.h</header>
|
||||
<header>blackgui/components/updateinfocomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user