mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T41, adjusted info component to be used with dialog
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d1bf788f07
commit
7f0a971b4a
@@ -36,19 +36,29 @@ namespace BlackGui
|
|||||||
|
|
||||||
// use version signal as trigger for completion
|
// use version signal as trigger for completion
|
||||||
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
|
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
|
// use this as timeout failover with cached data
|
||||||
if (m_distributionsLoaded) { return; }
|
if (m_distributionsLoaded) { return; }
|
||||||
this->ps_loadedDistributionInfo(true);
|
this->ps_loadedDistributionInfo(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_loadSetup);
|
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_loadSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDistributionInfoComponent::~CDistributionInfoComponent()
|
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()
|
void CDistributionInfoComponent::ps_loadSetup()
|
||||||
{
|
{
|
||||||
if (!ui->le_LatestVersion->text().isEmpty())
|
if (!ui->le_LatestVersion->text().isEmpty())
|
||||||
@@ -98,6 +108,7 @@ namespace BlackGui
|
|||||||
const CDistributionList distributions(m_distributionInfo.get());
|
const CDistributionList distributions(m_distributionInfo.get());
|
||||||
const QStringList channels = distributions.getChannels();
|
const QStringList channels = distributions.getChannels();
|
||||||
const QStringList settings = m_distributionSettings.get(); // channel / platform
|
const QStringList settings = m_distributionSettings.get(); // channel / platform
|
||||||
|
Q_ASSERT_X(settings.size() == 2, Q_FUNC_INFO, "Settings");
|
||||||
|
|
||||||
// default value
|
// default value
|
||||||
QString channel = ui->cb_Channels->currentText();
|
QString channel = ui->cb_Channels->currentText();
|
||||||
@@ -169,6 +180,8 @@ namespace BlackGui
|
|||||||
ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, currentPlatform));
|
ui->lbl_NewVersionUrl->setText(hl.arg(urlStr, currentPlatform));
|
||||||
ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform));
|
ui->lbl_NewVersionUrl->setToolTip("Download '" + latestVersionStr + "' " + m_currentDistribution.getFilename(currentPlatform));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -37,12 +37,21 @@ namespace BlackGui
|
|||||||
virtual ~CDistributionInfoComponent();
|
virtual ~CDistributionInfoComponent();
|
||||||
|
|
||||||
//! Is there a new version available return version, else empty string
|
//! 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:
|
signals:
|
||||||
//! Distribution info loaded
|
//! Distribution info loaded
|
||||||
void distributionInfoAvailable(bool success);
|
void distributionInfoAvailable(bool success);
|
||||||
|
|
||||||
|
//! New platfrom or channel
|
||||||
|
void selectionChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Load latest version
|
//! Load latest version
|
||||||
void ps_loadSetup();
|
void ps_loadSetup();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace BlackGui
|
|||||||
explicit CDistributorPreferencesComponent(QWidget *parent = nullptr);
|
explicit CDistributorPreferencesComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~CDistributorPreferencesComponent();
|
virtual ~CDistributorPreferencesComponent();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Changed preferences
|
//! Changed preferences
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ void CSwiftLauncher::ps_distributionInfoAvailable(bool success)
|
|||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
this->setHeaderInfo(ui->comp_DistributionInfo->getNewVersionAvailable());
|
this->setHeaderInfo(ui->comp_DistributionInfo->getNewAvailableVersionForSelection());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user