mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
Ref T203, renamed loadedAlphaXSwiftBusFileInfo in CInstallXSwiftBusComponent
This commit is contained in:
@@ -49,13 +49,19 @@ namespace BlackGui
|
|||||||
connect(ui->pb_OpenDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openDownloadDir);
|
connect(ui->pb_OpenDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openDownloadDir);
|
||||||
connect(ui->pb_OpenInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openInstallDir);
|
connect(ui->pb_OpenInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openInstallDir);
|
||||||
|
|
||||||
// lod metadata
|
// init upate info
|
||||||
this->triggerLoadingXSwiftBusFileInfo();
|
this->updatesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
CInstallXSwiftBusComponent::~CInstallXSwiftBusComponent()
|
CInstallXSwiftBusComponent::~CInstallXSwiftBusComponent()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void CInstallXSwiftBusComponent::setDefaultDownloadName(const QString &defaultDownload)
|
||||||
|
{
|
||||||
|
m_defaultDownloadName = defaultDownload;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CInstallXSwiftBusComponent::selectPluginDirectory()
|
void CInstallXSwiftBusComponent::selectPluginDirectory()
|
||||||
{
|
{
|
||||||
QString xPlanePluginDir = ui->le_XSwiftBusPluginDir->text().trimmed();
|
QString xPlanePluginDir = ui->le_XSwiftBusPluginDir->text().trimmed();
|
||||||
@@ -113,57 +119,9 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInstallXSwiftBusComponent::triggerLoadingXSwiftBusFileInfo()
|
|
||||||
{
|
|
||||||
if (!sGui || !sGui->hasWebDataServices() || sGui->isShuttingDown()) { return; }
|
|
||||||
const CUrl url = sGui->getGlobalSetup().getAlphaXSwiftBusFilesServiceUrl();
|
|
||||||
if (url.isEmpty()) { return; }
|
|
||||||
sGui->getFromNetwork(url, { this, &CInstallXSwiftBusComponent::loadedXSwiftBusFileInfo });
|
|
||||||
CLogMessage(this).info("Trigger loading XSwiftBus file info from '%1'") << url.getHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInstallXSwiftBusComponent::loadedXSwiftBusFileInfo(QNetworkReply *reply)
|
|
||||||
{
|
|
||||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(reply); // clean up reply afterwards
|
|
||||||
if (sGui && sGui->isShuttingDown()) { return; }
|
|
||||||
m_remoteFiles.clear();
|
|
||||||
|
|
||||||
if (nwReply->error() == QNetworkReply::NoError)
|
|
||||||
{
|
|
||||||
const QString json = reply->readAll();
|
|
||||||
if (!json.isEmpty())
|
|
||||||
{
|
|
||||||
const CRemoteFileList remoteFiles = CRemoteFileList::fromDatabaseJson(json);
|
|
||||||
m_remoteFiles = remoteFiles;
|
|
||||||
CLogMessage(this).info("Loaded %1 XSwiftBus file info entries from '%2'") << remoteFiles.size() << nwReply->url().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sGui && !sGui->isShuttingDown())
|
|
||||||
{
|
|
||||||
QTimer::singleShot(30 * 1000, this, &CInstallXSwiftBusComponent::triggerLoadingXSwiftBusFileInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->cb_DownloadFile->clear();
|
|
||||||
if (!m_remoteFiles.isEmpty())
|
|
||||||
{
|
|
||||||
QStringList xSWiftBusFiles(m_remoteFiles.getNamesPlusSize(true));
|
|
||||||
std::reverse(xSWiftBusFiles.begin(), xSWiftBusFiles.end()); // latest on top
|
|
||||||
ui->cb_DownloadFile->addItems(xSWiftBusFiles);
|
|
||||||
ui->cb_DownloadFile->setCurrentText(m_remoteFiles.backOrDefault().getNameAndSize()); // latest version
|
|
||||||
}
|
|
||||||
ui->cb_DownloadFile->setEnabled(!m_remoteFiles.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInstallXSwiftBusComponent::triggerDownloadingOfXSwiftBusFile()
|
void CInstallXSwiftBusComponent::triggerDownloadingOfXSwiftBusFile()
|
||||||
{
|
{
|
||||||
if (!sGui || !sGui->hasWebDataServices() || sGui->isShuttingDown()) { return; }
|
if (!sGui || !sGui->hasWebDataServices() || sGui->isShuttingDown()) { return; }
|
||||||
if (m_remoteFiles.isEmpty())
|
|
||||||
{
|
|
||||||
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error("No remote file information");
|
|
||||||
this->showOverlayMessage(msg, CInstallXSwiftBusComponent::OverlayMsgTimeoutMs);
|
|
||||||
this->triggerLoadingXSwiftBusFileInfo(); // try to reload
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this->existsDownloadDir())
|
if (!this->existsDownloadDir())
|
||||||
{
|
{
|
||||||
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error("Invalid download directory");
|
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error("Invalid download directory");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace BlackGui
|
|||||||
void triggerLoadingXSwiftBusFileInfo();
|
void triggerLoadingXSwiftBusFileInfo();
|
||||||
|
|
||||||
//! Received info about XSwiftBus download files
|
//! Received info about XSwiftBus download files
|
||||||
void loadedXSwiftBusFileInfo(QNetworkReply *reply);
|
void loadedAlphaXSwiftBusFileInfo(QNetworkReply *reply);
|
||||||
|
|
||||||
//! Trigger downloading of XSwiftBusFile
|
//! Trigger downloading of XSwiftBusFile
|
||||||
void triggerDownloadingOfXSwiftBusFile();
|
void triggerDownloadingOfXSwiftBusFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user