mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 14:15:35 +08:00
Ref T203, CInstallXSwiftBusComponent now using TUpdateInfo (and no longer the XSwiftBus service)
* default name can be set * XSwiftBusFileInfo no longer needed * data read from cache (i.e. TUpdateInfo)
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Db;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Simulation::Settings;
|
using namespace BlackMisc::Simulation::Settings;
|
||||||
@@ -43,8 +44,8 @@ namespace BlackGui
|
|||||||
ui->le_DownloadDir->setText(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
ui->le_DownloadDir->setText(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||||
ui->cb_DownloadFile->setEnabled(false);
|
ui->cb_DownloadFile->setEnabled(false);
|
||||||
|
|
||||||
connect(ui->pb_DialogInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectPluginDirectory);
|
connect(ui->tb_DialogInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectPluginDirectory);
|
||||||
connect(ui->pb_DialogDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectDownloadDirectory);
|
connect(ui->tb_DialogDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectDownloadDirectory);
|
||||||
connect(ui->pb_Download, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::triggerDownloadingOfXSwiftBusFile);
|
connect(ui->pb_Download, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::triggerDownloadingOfXSwiftBusFile);
|
||||||
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);
|
||||||
@@ -130,7 +131,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CRemoteFile rf = this->getRemoteFileSelected();
|
const CRemoteFile rf = this->getRemoteFileSelected();
|
||||||
const CUrl download = rf.getUrl();
|
const CUrl download = rf.getSmartUrl();
|
||||||
if (download.isEmpty())
|
if (download.isEmpty())
|
||||||
{
|
{
|
||||||
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error("No download URL for file name '%1'") << rf.getNameAndSize();
|
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error("No download URL for file name '%1'") << rf.getNameAndSize();
|
||||||
@@ -168,7 +169,9 @@ namespace BlackGui
|
|||||||
CRemoteFile CInstallXSwiftBusComponent::getRemoteFileSelected() const
|
CRemoteFile CInstallXSwiftBusComponent::getRemoteFileSelected() const
|
||||||
{
|
{
|
||||||
const QString fileNameAndSize = ui->cb_DownloadFile->currentText();
|
const QString fileNameAndSize = ui->cb_DownloadFile->currentText();
|
||||||
return m_remoteFiles.findFirstMatchingNameOrDefault(fileNameAndSize);
|
const CUpdateInfo update = m_updates.get();
|
||||||
|
const CRemoteFileList remoteFiles = update.getArtifactsXsb().asRemoteFiles();
|
||||||
|
return remoteFiles.findFirstByMatchingNameOrDefault(fileNameAndSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInstallXSwiftBusComponent::existsDownloadDir() const
|
bool CInstallXSwiftBusComponent::existsDownloadDir() const
|
||||||
@@ -193,6 +196,33 @@ namespace BlackGui
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInstallXSwiftBusComponent::updatesChanged()
|
||||||
|
{
|
||||||
|
const CUpdateInfo updateInfo = m_updates.get();
|
||||||
|
if (updateInfo.getArtifactsXsb().isEmpty()) { return; }
|
||||||
|
const CArtifactList artifacts = updateInfo.getArtifactsXsbLatestVersionFirst();
|
||||||
|
const CRemoteFileList remoteFiles = artifacts.asRemoteFiles();
|
||||||
|
if (!remoteFiles.isEmpty())
|
||||||
|
{
|
||||||
|
const QStringList xSwiftBusFiles(remoteFiles.getNamesPlusSize(true));
|
||||||
|
ui->cb_DownloadFile->addItems(xSwiftBusFiles);
|
||||||
|
|
||||||
|
// current text
|
||||||
|
QString current;
|
||||||
|
if (!m_defaultDownloadName.isEmpty())
|
||||||
|
{
|
||||||
|
const CRemoteFile rf = remoteFiles.findFirstByMatchingNameOrDefault(m_defaultDownloadName);
|
||||||
|
current = rf.getNameAndSize();
|
||||||
|
}
|
||||||
|
ui->cb_DownloadFile->setCurrentText(
|
||||||
|
current.isEmpty() ?
|
||||||
|
remoteFiles.backOrDefault().getNameAndSize() :
|
||||||
|
current
|
||||||
|
); // latest version
|
||||||
|
}
|
||||||
|
ui->cb_DownloadFile->setEnabled(!remoteFiles.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
void CInstallXSwiftBusComponent::openInstallDir()
|
void CInstallXSwiftBusComponent::openInstallDir()
|
||||||
{
|
{
|
||||||
if (!this->existsXSwiftBusPluginDir()) { return; }
|
if (!this->existsXSwiftBusPluginDir()) { return; }
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include "blackgui/overlaymessagesframe.h"
|
#include "blackgui/overlaymessagesframe.h"
|
||||||
#include "blackgui/loadindicator.h"
|
#include "blackgui/loadindicator.h"
|
||||||
#include "blackcore/application/applicationsettings.h"
|
#include "blackcore/application/applicationsettings.h"
|
||||||
|
#include "blackcore/application/updatesettings.h"
|
||||||
|
#include "blackmisc/db/updateinfo.h"
|
||||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||||
#include "blackmisc/network/remotefilelist.h"
|
#include "blackmisc/network/remotefilelist.h"
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@@ -43,12 +45,16 @@ namespace BlackGui
|
|||||||
//! Dtor
|
//! Dtor
|
||||||
virtual ~CInstallXSwiftBusComponent();
|
virtual ~CInstallXSwiftBusComponent();
|
||||||
|
|
||||||
|
//! Set a default name for download
|
||||||
|
void setDefaultDownloadName(const QString &defaultDownload);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CInstallXSwiftBusComponent> ui;
|
QScopedPointer<Ui::CInstallXSwiftBusComponent> ui;
|
||||||
BlackMisc::CSettingReadOnly<BlackCore::Application::TEnabledSimulators> m_enabledSimulators { this };
|
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
||||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this };
|
BlackMisc::CDataReadOnly<BlackMisc::Db::TUpdateInfo> m_updates { this, &CInstallXSwiftBusComponent::updatesChanged };
|
||||||
BlackMisc::Network::CRemoteFileList m_remoteFiles;
|
BlackMisc::CSettingReadOnly<BlackCore::Application::TUpdatePreferences> m_updateSettings { this }; //!< channel/platform selected
|
||||||
const QFileDialog::Options m_fileDialogOptions { QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly | QFileDialog::DontResolveSymlinks };
|
const QFileDialog::Options m_fileDialogOptions { QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly | QFileDialog::DontResolveSymlinks };
|
||||||
|
QString m_defaultDownloadName; //!< default name for download
|
||||||
|
|
||||||
static constexpr int OverlayMsgTimeoutMs = 5000; //!< how long overlay is displayed
|
static constexpr int OverlayMsgTimeoutMs = 5000; //!< how long overlay is displayed
|
||||||
|
|
||||||
@@ -61,13 +67,7 @@ namespace BlackGui
|
|||||||
//! Install from download directory to X-Plane directory
|
//! Install from download directory to X-Plane directory
|
||||||
void installXSwiftBus();
|
void installXSwiftBus();
|
||||||
|
|
||||||
//! Trigger loading of XSwiftBus file info
|
//! Trigger downloading of the XSwiftBus file
|
||||||
void triggerLoadingXSwiftBusFileInfo();
|
|
||||||
|
|
||||||
//! Received info about XSwiftBus download files
|
|
||||||
void loadedAlphaXSwiftBusFileInfo(QNetworkReply *reply);
|
|
||||||
|
|
||||||
//! Trigger downloading of XSwiftBusFile
|
|
||||||
void triggerDownloadingOfXSwiftBusFile();
|
void triggerDownloadingOfXSwiftBusFile();
|
||||||
|
|
||||||
//! Downloaded XSwiftBus file
|
//! Downloaded XSwiftBus file
|
||||||
@@ -85,6 +85,9 @@ namespace BlackGui
|
|||||||
//! X-Plane directory from settings of default directory
|
//! X-Plane directory from settings of default directory
|
||||||
QString getXPlanePluginDirectory() const;
|
QString getXPlanePluginDirectory() const;
|
||||||
|
|
||||||
|
//! Updates have been changed
|
||||||
|
void updatesChanged();
|
||||||
|
|
||||||
//! Show install dir
|
//! Show install dir
|
||||||
void openInstallDir();
|
void openInstallDir();
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,13 @@
|
|||||||
<string>Download and install XSwiftBus</string>
|
<string>Download and install XSwiftBus</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_XSwiftBusPluginDir">
|
||||||
|
<property name="text">
|
||||||
|
<string>Install directory:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="le_XSwiftBusPluginDir">
|
<widget class="QLineEdit" name="le_XSwiftBusPluginDir">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
@@ -84,13 +91,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_XSwiftBusPluginDir">
|
|
||||||
<property name="text">
|
|
||||||
<string>Install directory:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="le_DownloadDir"/>
|
<widget class="QLineEdit" name="le_DownloadDir"/>
|
||||||
</item>
|
</item>
|
||||||
@@ -101,44 +101,58 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2" colspan="2">
|
|
||||||
<widget class="QPushButton" name="pb_Download">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>download and install</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string> download</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
|
||||||
<widget class="QPushButton" name="pb_DialogDownloadDir">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="pb_DialogInstallDir">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="pb_OpenInstallDir">
|
<widget class="QPushButton" name="pb_OpenInstallDir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>open</string>
|
<string>open</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="3">
|
||||||
<widget class="QPushButton" name="pb_OpenDownloadDir">
|
<widget class="QPushButton" name="pb_OpenDownloadDir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>open</string>
|
<string>open</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="2" colspan="2">
|
||||||
|
<widget class="QPushButton" name="pb_Download">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>download and install</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>download</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QToolButton" name="tb_DialogDownloadDir">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>change directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="statusTip">
|
||||||
|
<string>change directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||||
|
<normaloff>:/diagona/icons/diagona/icons/folder--pencil.png</normaloff>:/diagona/icons/diagona/icons/folder--pencil.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="tb_DialogInstallDir">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>change directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="statusTip">
|
||||||
|
<string>change directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||||
|
<normaloff>:/diagona/icons/diagona/icons/folder--pencil.png</normaloff>:/diagona/icons/diagona/icons/folder--pencil.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -190,6 +204,8 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -23,5 +23,10 @@ namespace BlackGui
|
|||||||
|
|
||||||
CInstallXSwiftBusDialog::~CInstallXSwiftBusDialog()
|
CInstallXSwiftBusDialog::~CInstallXSwiftBusDialog()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void CInstallXSwiftBusDialog::setDefaultDownloadName(const QString &defaultName)
|
||||||
|
{
|
||||||
|
ui->comp_InstallXSwiftBus->setDefaultDownloadName(defaultName);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
#ifndef BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
||||||
#define BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
#define BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui { class CInstallXSwiftBusDialog; }
|
namespace Ui { class CInstallXSwiftBusDialog; }
|
||||||
@@ -33,6 +34,9 @@ namespace BlackGui
|
|||||||
//! Dtor
|
//! Dtor
|
||||||
virtual ~CInstallXSwiftBusDialog();
|
virtual ~CInstallXSwiftBusDialog();
|
||||||
|
|
||||||
|
//! \copydoc CInstallXSwiftBusComponent::setDefaultDownloadName
|
||||||
|
void setDefaultDownloadName(const QString &defaultName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CInstallXSwiftBusDialog> ui;
|
QScopedPointer<Ui::CInstallXSwiftBusDialog> ui;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user