mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 07:05:38 +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
|
// use version signal as trigger for completion
|
||||||
const CDistributionList distributions = m_distributionsInfo.get();
|
const CDistributionList distributions = m_distributionsInfo.get();
|
||||||
if (!distributions.isEmpty())
|
if (!distributions.isEmpty()) { this->changedDistributionInfo(); }
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::requestLoadOfSetup);
|
||||||
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
|
connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::installXSwiftBusDialog);
|
||||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_requestLoadOfSetup);
|
|
||||||
connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_installXSwiftBusDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDistributionInfoComponent::~CDistributionInfoComponent()
|
CDistributionInfoComponent::~CDistributionInfoComponent()
|
||||||
@@ -65,7 +56,7 @@ namespace BlackGui
|
|||||||
return (vCurrentChannelPlatform > vCurrent);
|
return (vCurrentChannelPlatform > vCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_requestLoadOfSetup()
|
void CDistributionInfoComponent::requestLoadOfSetup()
|
||||||
{
|
{
|
||||||
if (sGui && !ui->le_LatestVersion->text().isEmpty())
|
if (sGui && !ui->le_LatestVersion->text().isEmpty())
|
||||||
{
|
{
|
||||||
@@ -78,28 +69,16 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_loadedDistributionInfo(bool success)
|
void CDistributionInfoComponent::changedDistributionInfo()
|
||||||
{
|
{
|
||||||
if (!success)
|
this->channelChanged();
|
||||||
{
|
|
||||||
ui->pb_CheckForUpdates->setToolTip("");
|
|
||||||
CLogMessage(this).warning("Loading setup or distribution information failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->ps_channelChanged();
|
|
||||||
ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl());
|
ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl());
|
||||||
|
|
||||||
// emit via digest signal
|
// emit via digest signal
|
||||||
m_dsDistributionAvailable.inputSignal();
|
m_dsDistributionAvailable.inputSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_changedDistributionCache()
|
void CDistributionInfoComponent::installXSwiftBusDialog()
|
||||||
{
|
|
||||||
this->ps_loadedDistributionInfo(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_installXSwiftBusDialog()
|
|
||||||
{
|
{
|
||||||
if (!m_installXSwiftBusDialog)
|
if (!m_installXSwiftBusDialog)
|
||||||
{
|
{
|
||||||
@@ -121,12 +100,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDistributionInfoComponent::triggerInfoAvailableSignal()
|
void CDistributionInfoComponent::channelChanged()
|
||||||
{
|
|
||||||
emit this->distributionInfoAvailable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_channelChanged()
|
|
||||||
{
|
{
|
||||||
const CDistributionList distributions(m_distributionsInfo.get());
|
const CDistributionList distributions(m_distributionsInfo.get());
|
||||||
const QStringList channels = distributions.getChannels().toList();
|
const QStringList channels = distributions.getChannels().toList();
|
||||||
@@ -161,12 +135,12 @@ namespace BlackGui
|
|||||||
if (!platform.isEmpty()) { ui->cb_Platforms->setCurrentText(platform); }
|
if (!platform.isEmpty()) { ui->cb_Platforms->setCurrentText(platform); }
|
||||||
|
|
||||||
// platform dependent stuff
|
// platform dependent stuff
|
||||||
this->ps_platformChanged();
|
this->platformChanged();
|
||||||
connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_channelChanged);
|
connect(ui->cb_Channels, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::channelChanged);
|
||||||
connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::ps_platformChanged);
|
connect(ui->cb_Platforms, &QComboBox::currentTextChanged, this, &CDistributionInfoComponent::platformChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDistributionInfoComponent::ps_platformChanged()
|
void CDistributionInfoComponent::platformChanged()
|
||||||
{
|
{
|
||||||
this->saveSettings();
|
this->saveSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Distribution info loaded
|
//! Distribution info loaded
|
||||||
void distributionInfoAvailable(bool success);
|
void distributionInfoAvailable();
|
||||||
|
|
||||||
//! New platfrom or channel
|
//! New platfrom or channel
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
@@ -61,15 +61,15 @@ namespace BlackGui
|
|||||||
QScopedPointer<CInstallXSwiftBusDialog> m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus
|
QScopedPointer<CInstallXSwiftBusDialog> m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus
|
||||||
QString m_newVersionAvailable; //!< new version number if any
|
QString m_newVersionAvailable; //!< new version number if any
|
||||||
BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution
|
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::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
|
//! Load latest version
|
||||||
void requestLoadOfSetup();
|
void requestLoadOfSetup();
|
||||||
|
|
||||||
//! Loaded latest version
|
//! Loaded latest version
|
||||||
void loadedDistributionInfo(bool success);
|
void changedDistributionInfo();
|
||||||
|
|
||||||
//! Channel has been changed
|
//! Channel has been changed
|
||||||
void channelChanged();
|
void channelChanged();
|
||||||
@@ -77,18 +77,12 @@ namespace BlackGui
|
|||||||
//! Platform changed
|
//! Platform changed
|
||||||
void platformChanged();
|
void platformChanged();
|
||||||
|
|
||||||
//! Cache values have been changed
|
|
||||||
void changedDistributionCache();
|
|
||||||
|
|
||||||
//! Install XSwiftBus dialog
|
//! Install XSwiftBus dialog
|
||||||
void installXSwiftBusDialog();
|
void installXSwiftBusDialog();
|
||||||
|
|
||||||
//! Save the current settings
|
//! Save the current settings
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
//! Trigger the CDistributionInfoComponent::distributionInfoAvailable signal
|
|
||||||
void triggerInfoAvailableSignal();
|
|
||||||
|
|
||||||
//! Selected platform from UI or guessed platform
|
//! Selected platform from UI or guessed platform
|
||||||
QString getSelectedOrGuessedPlatform() const;
|
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());
|
this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->setHeaderInfo("");
|
|
||||||
}
|
|
||||||
this->loadLatestNews();
|
this->loadLatestNews();
|
||||||
this->loadAbout();
|
this->loadAbout();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ private slots:
|
|||||||
void ps_displayLatestNews(QNetworkReply *reply);
|
void ps_displayLatestNews(QNetworkReply *reply);
|
||||||
|
|
||||||
//! Distribution info is available
|
//! Distribution info is available
|
||||||
void ps_distributionInfoAvailable(bool success);
|
void ps_distributionInfoAvailable();
|
||||||
|
|
||||||
//! Start button pressed
|
//! Start button pressed
|
||||||
void ps_startButtonPressed();
|
void ps_startButtonPressed();
|
||||||
|
|||||||
Reference in New Issue
Block a user