mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T165, directly display distributions info
* use digest signal to avoid unnecessary signals * better user experience by directly displaying info
This commit is contained in:
@@ -36,16 +36,14 @@ namespace BlackGui
|
||||
ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
|
||||
|
||||
// use version signal as trigger for completion
|
||||
if (!m_distributionsInfo.get().isEmpty())
|
||||
const CDistributionList distributions = m_distributionsInfo.get();
|
||||
if (!distributions.isEmpty())
|
||||
{
|
||||
// we have at least cached data:
|
||||
// in case CGuiApplication::distributionInfoAvailable never comes/was already sent
|
||||
QTimer::singleShot(15 * 1000, this, [ = ]
|
||||
{
|
||||
// use this as timeout failover with cached data
|
||||
if (m_distributionsLoaded) { return; }
|
||||
this->ps_loadedDistributionInfo(true);
|
||||
});
|
||||
// 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");
|
||||
@@ -76,7 +74,6 @@ namespace BlackGui
|
||||
if (msgs.isSuccess())
|
||||
{
|
||||
ui->le_LatestVersion->setText("");
|
||||
m_distributionsLoaded = false; // reset
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,20 +82,16 @@ namespace BlackGui
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
m_distributionsLoaded = false;
|
||||
ui->pb_CheckForUpdates->setToolTip("");
|
||||
CLogMessage(this).warning("Loading setup or distribution information failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// only emit once
|
||||
if (m_distributionsLoaded) { return; }
|
||||
m_distributionsLoaded = true;
|
||||
this->ps_channelChanged();
|
||||
ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl());
|
||||
|
||||
// emit only after all has been set
|
||||
emit this->distributionInfoAvailable(success);
|
||||
// emit via digest signal
|
||||
m_dsDistributionAvailable.inputSignal();
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_changedDistributionCache()
|
||||
@@ -128,6 +121,11 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::triggerInfoAvailableSignal()
|
||||
{
|
||||
emit this->distributionInfoAvailable(true);
|
||||
}
|
||||
|
||||
void CDistributionInfoComponent::ps_channelChanged()
|
||||
{
|
||||
const CDistributionList distributions(m_distributionsInfo.get());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CDistributionInfoComponent; }
|
||||
@@ -77,15 +78,18 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CDistributionInfoComponent> ui;
|
||||
QScopedPointer<CInstallXSwiftBusDialog> m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus
|
||||
bool m_distributionsLoaded = false; //!< distribution info loaded
|
||||
QString m_newVersionAvailable; //!< new version number if any
|
||||
BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Db::TDistributionsInfo> m_distributionsInfo { this, &CDistributionInfoComponent::ps_changedDistributionCache }; //!< version cache
|
||||
BlackMisc::CSetting<BlackCore::Application::TDistribution> m_distributionSetting { this }; //!< channel/platform selected
|
||||
BlackMisc::CDigestSignal m_dsDistributionAvailable { this, &CDistributionInfoComponent::triggerInfoAvailableSignal, 10000, 2 };
|
||||
|
||||
//! Save the current settings
|
||||
void saveSettings();
|
||||
|
||||
//! Trigger the CDistributionInfoComponent::distributionInfoAvailable signal
|
||||
void triggerInfoAvailableSignal();
|
||||
|
||||
//! Selected platform from UI or guessed platform
|
||||
QString getSelectedOrGuessedPlatform() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user