mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T165, using CGuiApplication::distributionInfoAvailable is redundant, the cache changed signal is enough
* distribution info avaialble signal no longer needs flag * some functions can be removed
This commit is contained in:
@@ -37,19 +37,10 @@ namespace BlackGui
|
||||
|
||||
// use version signal as trigger for completion
|
||||
const CDistributionList distributions = m_distributionsInfo.get();
|
||||
if (!distributions.isEmpty())
|
||||
{
|
||||
// we have at least cached data:
|
||||
// in case CGuiApplication::distributionInfoAvailable never comes/was already sent
|
||||
// 1) we do not know if we missed the signal, the server is down etc
|
||||
// 2) for better user experience we display straight away, it will overridden if the signal will br received
|
||||
this->ps_loadedDistributionInfo(true);
|
||||
}
|
||||
if (!distributions.isEmpty()) { this->changedDistributionInfo(); }
|
||||
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
|
||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_requestLoadOfSetup);
|
||||
connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_installXSwiftBusDialog);
|
||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::requestLoadOfSetup);
|
||||
connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::installXSwiftBusDialog);
|
||||
}
|
||||
|
||||
CDistributionInfoComponent::~CDistributionInfoComponent()
|
||||
@@ -65,7 +56,7 @@ namespace BlackGui
|
||||
return (vCurrentChannelPlatform > vCurrent);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_requestLoadOfSetup()
|
||||
void CDistributionInfoComponent::requestLoadOfSetup()
|
||||
{
|
||||
if (sGui && !ui->le_LatestVersion->text().isEmpty())
|
||||
{
|
||||
@@ -78,28 +69,16 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_loadedDistributionInfo(bool success)
|
||||
void CDistributionInfoComponent::changedDistributionInfo()
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
ui->pb_CheckForUpdates->setToolTip("");
|
||||
CLogMessage(this).warning("Loading setup or distribution information failed");
|
||||
return;
|
||||
}
|
||||
|
||||
this->ps_channelChanged();
|
||||
this->channelChanged();
|
||||
ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl());
|
||||
|
||||
// emit via digest signal
|
||||
m_dsDistributionAvailable.inputSignal();
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_changedDistributionCache()
|
||||
{
|
||||
this->ps_loadedDistributionInfo(true);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_installXSwiftBusDialog()
|
||||
void CDistributionInfoComponent::installXSwiftBusDialog()
|
||||
{
|
||||
if (!m_installXSwiftBusDialog)
|
||||
{
|
||||
@@ -121,12 +100,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::triggerInfoAvailableSignal()
|
||||
{
|
||||
emit this->distributionInfoAvailable(true);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_channelChanged()
|
||||
void CDistributionInfoComponent::channelChanged()
|
||||
{
|
||||
const CDistributionList distributions(m_distributionsInfo.get());
|
||||
const QStringList channels = distributions.getChannels().toList();
|
||||
@@ -161,12 +135,12 @@ namespace BlackGui
|
||||
if (!platform.isEmpty()) { ui->cb_Platforms->setCurrentText(platform); }
|
||||
|
||||
// platform dependent stuff
|
||||
this->ps_platformChanged();
|
||||
connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_channelChanged);
|
||||
connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_platformChanged);
|
||||
this->platformChanged();
|
||||
connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::channelChanged);
|
||||
connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::platformChanged);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_platformChanged()
|
||||
void CDistributionInfoComponent::platformChanged()
|
||||
{
|
||||
this->saveSettings();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace BlackGui
|
||||
|
||||
signals:
|
||||
//! Distribution info loaded
|
||||
void distributionInfoAvailable(bool success);
|
||||
void distributionInfoAvailable();
|
||||
|
||||
//! New platfrom or channel
|
||||
void selectionChanged();
|
||||
@@ -61,15 +61,15 @@ namespace BlackGui
|
||||
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::changedDistributionCache }; //!< version cache
|
||||
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::triggerInfoAvailableSignal, 10000, 2 };
|
||||
BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::distributionInfoAvailable, 10000, 2 };
|
||||
|
||||
//! Load latest version
|
||||
void requestLoadOfSetup();
|
||||
|
||||
//! Loaded latest version
|
||||
void loadedDistributionInfo(bool success);
|
||||
void changedDistributionInfo();
|
||||
|
||||
//! Channel has been changed
|
||||
void channelChanged();
|
||||
@@ -77,18 +77,12 @@ namespace BlackGui
|
||||
//! Platform changed
|
||||
void platformChanged();
|
||||
|
||||
//! Cache values have been changed
|
||||
void changedDistributionCache();
|
||||
|
||||
//! Install XSwiftBus dialog
|
||||
void installXSwiftBusDialog();
|
||||
|
||||
//! Save the current settings
|
||||
void saveSettings();
|
||||
|
||||
//! Trigger the CDistributionInfoComponent::distributionInfoAvailable signal
|
||||
void triggerInfoAvailableSignal();
|
||||
|
||||
//! Selected platform from UI or guessed platform
|
||||
QString getSelectedOrGuessedPlatform() const;
|
||||
};
|
||||
|
||||
@@ -145,16 +145,9 @@ void CSwiftLauncher::ps_displayLatestNews(QNetworkReply *reply)
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftLauncher::ps_distributionInfoAvailable(bool success)
|
||||
void CSwiftLauncher::ps_distributionInfoAvailable()
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setHeaderInfo("");
|
||||
}
|
||||
this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection());
|
||||
this->loadLatestNews();
|
||||
this->loadAbout();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ private slots:
|
||||
void ps_displayLatestNews(QNetworkReply *reply);
|
||||
|
||||
//! Distribution info is available
|
||||
void ps_distributionInfoAvailable(bool success);
|
||||
void ps_distributionInfoAvailable();
|
||||
|
||||
//! Start button pressed
|
||||
void ps_startButtonPressed();
|
||||
|
||||
Reference in New Issue
Block a user