mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +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>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Db;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
@@ -43,8 +44,8 @@ namespace BlackGui
|
||||
ui->le_DownloadDir->setText(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
ui->cb_DownloadFile->setEnabled(false);
|
||||
|
||||
connect(ui->pb_DialogInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectPluginDirectory);
|
||||
connect(ui->pb_DialogDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectDownloadDirectory);
|
||||
connect(ui->tb_DialogInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectPluginDirectory);
|
||||
connect(ui->tb_DialogDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::selectDownloadDirectory);
|
||||
connect(ui->pb_Download, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::triggerDownloadingOfXSwiftBusFile);
|
||||
connect(ui->pb_OpenDownloadDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openDownloadDir);
|
||||
connect(ui->pb_OpenInstallDir, &QPushButton::pressed, this, &CInstallXSwiftBusComponent::openInstallDir);
|
||||
@@ -130,7 +131,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
const CRemoteFile rf = this->getRemoteFileSelected();
|
||||
const CUrl download = rf.getUrl();
|
||||
const CUrl download = rf.getSmartUrl();
|
||||
if (download.isEmpty())
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
@@ -193,6 +196,33 @@ namespace BlackGui
|
||||
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()
|
||||
{
|
||||
if (!this->existsXSwiftBusPluginDir()) { return; }
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/loadindicator.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include "blackcore/application/updatesettings.h"
|
||||
#include "blackmisc/db/updateinfo.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
#include "blackmisc/network/remotefilelist.h"
|
||||
#include <QNetworkReply>
|
||||
@@ -43,12 +45,16 @@ namespace BlackGui
|
||||
//! Dtor
|
||||
virtual ~CInstallXSwiftBusComponent();
|
||||
|
||||
//! Set a default name for download
|
||||
void setDefaultDownloadName(const QString &defaultDownload);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInstallXSwiftBusComponent> ui;
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Application::TEnabledSimulators> m_enabledSimulators { this };
|
||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this };
|
||||
BlackMisc::Network::CRemoteFileList m_remoteFiles;
|
||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Db::TUpdateInfo> m_updates { this, &CInstallXSwiftBusComponent::updatesChanged };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Application::TUpdatePreferences> m_updateSettings { this }; //!< channel/platform selected
|
||||
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
|
||||
|
||||
@@ -61,13 +67,7 @@ namespace BlackGui
|
||||
//! Install from download directory to X-Plane directory
|
||||
void installXSwiftBus();
|
||||
|
||||
//! Trigger loading of XSwiftBus file info
|
||||
void triggerLoadingXSwiftBusFileInfo();
|
||||
|
||||
//! Received info about XSwiftBus download files
|
||||
void loadedAlphaXSwiftBusFileInfo(QNetworkReply *reply);
|
||||
|
||||
//! Trigger downloading of XSwiftBusFile
|
||||
//! Trigger downloading of the XSwiftBus file
|
||||
void triggerDownloadingOfXSwiftBusFile();
|
||||
|
||||
//! Downloaded XSwiftBus file
|
||||
@@ -85,6 +85,9 @@ namespace BlackGui
|
||||
//! X-Plane directory from settings of default directory
|
||||
QString getXPlanePluginDirectory() const;
|
||||
|
||||
//! Updates have been changed
|
||||
void updatesChanged();
|
||||
|
||||
//! Show install dir
|
||||
void openInstallDir();
|
||||
|
||||
|
||||
@@ -67,6 +67,13 @@
|
||||
<string>Download and install XSwiftBus</string>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QLineEdit" name="le_XSwiftBusPluginDir">
|
||||
<property name="placeholderText">
|
||||
@@ -84,13 +91,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLineEdit" name="le_DownloadDir"/>
|
||||
</item>
|
||||
@@ -101,44 +101,58 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<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">
|
||||
<property name="text">
|
||||
<string>open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pb_OpenDownloadDir">
|
||||
<property name="text">
|
||||
<string>open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -190,6 +204,8 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -23,5 +23,10 @@ namespace BlackGui
|
||||
|
||||
CInstallXSwiftBusDialog::~CInstallXSwiftBusDialog()
|
||||
{ }
|
||||
|
||||
void CInstallXSwiftBusDialog::setDefaultDownloadName(const QString &defaultName)
|
||||
{
|
||||
ui->comp_InstallXSwiftBus->setDefaultDownloadName(defaultName);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
||||
#define BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui { class CInstallXSwiftBusDialog; }
|
||||
@@ -33,6 +34,9 @@ namespace BlackGui
|
||||
//! Dtor
|
||||
virtual ~CInstallXSwiftBusDialog();
|
||||
|
||||
//! \copydoc CInstallXSwiftBusComponent::setDefaultDownloadName
|
||||
void setDefaultDownloadName(const QString &defaultName);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInstallXSwiftBusDialog> ui;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user