Ref T41, adjusted info component to be used with dialog

This commit is contained in:
Klaus Basan
2017-04-25 14:37:26 +02:00
committed by Mathew Sutcliffe
parent d1bf788f07
commit 7f0a971b4a
4 changed files with 27 additions and 5 deletions

View File

@@ -36,19 +36,29 @@ namespace BlackGui
// use version signal as trigger for completion
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
QTimer::singleShot(10 * 1000, this, [ = ]
const int time = this->m_distributionInfo.get().isEmpty() ? 10 * 1000 : 500;
QTimer::singleShot(time, this, [ = ]
{
// use this as timeout failover with cached data
if (m_distributionsLoaded) { return; }
this->ps_loadedDistributionInfo(true);
});
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_loadSetup);
}
CDistributionInfoComponent::~CDistributionInfoComponent()
{ }
bool CDistributionInfoComponent::isNewVersionAvailable() const
{
const QStringList channelPlatform = m_distributionSettings.get();
Q_ASSERT_X(channelPlatform.size() == 2, Q_FUNC_INFO, "wrong setting");
const QVersionNumber vCurrentChannelPlatform = m_distributionInfo.get().getQVersionForChannelAndPlatform(channelPlatform);
if (vCurrentChannelPlatform.isNull() || vCurrentChannelPlatform.segmentCount() < 4) return false;
const QVersionNumber vCurrent = CBuildConfig::getVersion();
return (vCurrentChannelPlatform > vCurrent);
}
void CDistributionInfoComponent::ps_loadSetup()
{
if (!ui->le_LatestVersion->text().isEmpty())
@@ -98,6 +108,7 @@ namespace BlackGui
const CDistributionList distributions(m_distributionInfo.get());
const QStringList channels = distributions.getChannels();
const QStringList settings = m_distributionSettings.get(); // channel / platform
Q_ASSERT_X(settings.size() == 2, Q_FUNC_INFO, "Settings");
// default value
QString channel = ui->cb_Channels->currentText();
@@ -169,6 +180,8 @@ namespace BlackGui
ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, currentPlatform));
ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform));
}
emit selectionChanged();
}
}
} // ns

View File

@@ -37,12 +37,21 @@ namespace BlackGui
virtual ~CDistributionInfoComponent();
//! Is there a new version available return version, else empty string
QString getNewVersionAvailable() const { return m_newVersionAvailable; }
QString getNewAvailableVersionForSelection() const { return m_newVersionAvailable; }
//! Is there a new version available?
bool isNewVersionAvailable() const;
//! Current distribution
BlackMisc::Db::CDistribution getCurrentDistribution() { return m_currentDistribution; }
signals:
//! Distribution info loaded
void distributionInfoAvailable(bool success);
//! New platfrom or channel
void selectionChanged();
private slots:
//! Load latest version
void ps_loadSetup();

View File

@@ -42,7 +42,7 @@ namespace BlackGui
explicit CDistributorPreferencesComponent(QWidget *parent = nullptr);
//! Destructor
~CDistributorPreferencesComponent();
virtual ~CDistributorPreferencesComponent();
private slots:
//! Changed preferences

View File

@@ -136,7 +136,7 @@ void CSwiftLauncher::ps_distributionInfoAvailable(bool success)
{
if (success)
{
this->setHeaderInfo(ui->comp_DistributionInfo->getNewVersionAvailable());
this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection());
}
else
{