diff --git a/src/blackgui/components/configurationwizard.cpp b/src/blackgui/components/configurationwizard.cpp index 3fe0833fa..38630fe58 100644 --- a/src/blackgui/components/configurationwizard.cpp +++ b/src/blackgui/components/configurationwizard.cpp @@ -10,10 +10,12 @@ #include "configurationwizard.h" #include "ui_configurationwizard.h" #include "blackgui/guiapplication.h" +#include "blackmisc/math/mathutils.h" #include "blackmisc/directoryutils.h" #include using namespace BlackMisc; +using namespace BlackMisc::Math; namespace BlackGui { @@ -26,7 +28,7 @@ namespace BlackGui ui->setupUi(this); ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); - ui->wp_XSwiftBus->setConfigComponent(ui->comp_XSwiftBus); + ui->wp_SimulatorSpecific->setConfigComponent(ui->comp_XSwiftBus, ui->comp_FsxTerrainProbe); ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad); ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys); ui->wp_Legal->setConfigComponent(ui->comp_LegalInformation); @@ -118,7 +120,7 @@ namespace BlackGui { QWidget *parent = this->parentWidget(); if (!parent) { return; } - if (parent->windowOpacity() == opacity) { return; } + if (CMathUtils::epsilonEqual(parent->windowOpacity(), opacity)) { return; } parent->setWindowOpacity(opacity); } } // ns diff --git a/src/blackgui/components/configurationwizard.ui b/src/blackgui/components/configurationwizard.ui index aa25c7f8e..3cc5b70c8 100644 --- a/src/blackgui/components/configurationwizard.ui +++ b/src/blackgui/components/configurationwizard.ui @@ -22,9 +22,6 @@ true - - QWizard::ClassicStyle - QWizard::HaveCustomButton1 @@ -194,12 +191,12 @@ - + - XSwiftBus + Simulator specific installations - Install XSwiftBus (X-Plane only) + Install XSwiftBus (X-Plane only) or swift terrain probe (FSX/P3D only) @@ -219,21 +216,18 @@ 0 - 100 + 150 - - QFrame::StyledPanel - - - QFrame::Raised - - - - - I do not have X-Plane / I will do this later / Is already installed + + + + + 0 + 75 + @@ -329,12 +323,6 @@
blackgui/components/installxswiftbuscomponent.h
1 - - BlackGui::Components::CInstallXSwiftBusWizardPage - QWizardPage -
blackgui/components/installxswiftbuscomponent.h
- 1 -
BlackGui::Components::CFirstModelSetWizardPage QWizardPage @@ -377,25 +365,21 @@
blackgui/components/copysettingsandcachescomponent.h
1
+ + BlackGui::Components::CInstallSimulatorSpecificWizardPage + QWizardPage +
blackgui/components/installsimulatorspecificwizardpage.h
+ 1 +
+ + BlackGui::Components::CInstallFsxTerrainProbeComponent + QWidget +
blackgui/components/installfsxterrainprobecomponent.h
+ 1 +
- - pb_SkipXSwiftBus - clicked() - CConfigurationWizard - next() - - - 713 - 63 - - - 791 - 64 - - - pb_SkipFirstModelSet clicked() diff --git a/src/blackgui/components/installfsxterrainprobecomponent.cpp b/src/blackgui/components/installfsxterrainprobecomponent.cpp new file mode 100644 index 000000000..b13cf7675 --- /dev/null +++ b/src/blackgui/components/installfsxterrainprobecomponent.cpp @@ -0,0 +1,88 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "installfsxterrainprobecomponent.h" +#include "ui_installfsxterrainprobecomponent.h" +#include "blackgui/overlaymessagesframe.h" +#include "blackgui/guiutility.h" +#include "blackmisc/simulation/fscommon/fscommonutil.h" +#include "blackmisc/simulation/simulatorinfo.h" +#include "blackmisc/directoryutils.h" +#include "blackmisc/fileutils.h" + +#include +#include +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackMisc::Simulation::FsCommon; + +namespace BlackGui +{ + namespace Components + { + CInstallFsxTerrainProbeComponent::CInstallFsxTerrainProbeComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CInstallFsxTerrainProbeComponent) + { + ui->setupUi(this); + ui->le_Source->setText(CDirectoryUtils::shareTerrainProbeDirectory()); + + ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons); + ui->comp_SimulatorSelector->setFsxP3DOnly(); + ui->comp_SimulatorSelector->setValue(CSimulatorInfo::fsx()); + + connect(ui->pb_Copy, &QPushButton::released, this, &CInstallFsxTerrainProbeComponent::copyProbe); + connect(ui->pb_DirectoryBrowser, &QPushButton::released, this, &CInstallFsxTerrainProbeComponent::selectSimObjectsDir); + connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CInstallFsxTerrainProbeComponent::onSimulatorChanged); + + QPointer myself; + QTimer::singleShot(250, this, [ = ] + { + if (!myself) { return; } + this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); + }); + } + + CInstallFsxTerrainProbeComponent::~CInstallFsxTerrainProbeComponent() + { } + + void CInstallFsxTerrainProbeComponent::copyProbe() + { + if (ui->le_Target->text().isEmpty()) { return; } + CStatusMessageList msgs; + const int copied = CFsCommonUtil::copyFsxTerrainProbeFiles(ui->le_Target->text(), msgs); + COverlayMessagesWizardPage *mf = CGuiUtility::nextOverlayMessageWizardPage(this); + if (mf) { mf->showOverlayMessages(msgs, false, 5000); } + Q_UNUSED(copied); + } + + void CInstallFsxTerrainProbeComponent::onSimulatorChanged(const CSimulatorInfo &simulator) + { + const QStringList modelDirs = m_simulatorSettings.getModelDirectoriesOrDefault(simulator); + if (!modelDirs.isEmpty() && !modelDirs.front().isEmpty()) + { + ui->le_Target->setText(modelDirs.front()); + } + else + { + ui->le_Target->clear(); + } + } + + void CInstallFsxTerrainProbeComponent::selectSimObjectsDir() + { + const QString startDirectory = CFileUtils::fixWindowsUncPath(ui->le_Target->text()); + const QString dir = QFileDialog::getExistingDirectory(this, "SimObjects directory", startDirectory, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + } + } // ns +} // ns diff --git a/src/blackgui/components/installfsxterrainprobecomponent.h b/src/blackgui/components/installfsxterrainprobecomponent.h new file mode 100644 index 000000000..75c6ad58f --- /dev/null +++ b/src/blackgui/components/installfsxterrainprobecomponent.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_INSTALLFSXTERRAINPROBECOMPONENT_H +#define BLACKGUI_COMPONENTS_INSTALLFSXTERRAINPROBECOMPONENT_H + +#include "blackmisc/simulation/settings/simulatorsettings.h" +#include +#include + +namespace Ui { class CInstallFsxTerrainProbeComponent; } +namespace BlackGui +{ + namespace Components + { + //! Install the FSX/P3D terrain probe + class CInstallFsxTerrainProbeComponent : public QFrame + { + Q_OBJECT + + public: + explicit CInstallFsxTerrainProbeComponent(QWidget *parent = nullptr); + + //! Destructors + virtual ~CInstallFsxTerrainProbeComponent(); + + private: + QScopedPointer ui; + + //! Select the directory + void selectSimObjectsDir(); + + //! Copy probe + void copyProbe(); + + //! Simulator has been changed + void onSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); + + BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for SimObjects directories + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/installfsxterrainprobecomponent.ui b/src/blackgui/components/installfsxterrainprobecomponent.ui new file mode 100644 index 000000000..abab49d47 --- /dev/null +++ b/src/blackgui/components/installfsxterrainprobecomponent.ui @@ -0,0 +1,154 @@ + + + CInstallFsxTerrainProbeComponent + + + + 0 + 0 + 427 + 194 + + + + Copy swift probe + + + + + + + + + background: "lightgrey" + + + <img width="100" src=":/simulators/icons/simulators/FSX.png"/> + + + + + + + background: "lightgrey" + + + <img width="130" src=":/simulators/icons/simulators/Prepar3D.png"/> + + + + + + + <html><head/><body><p><span style=" font-size:9pt;">The </span><span style=" font-size:9pt; font-style:italic;">swift</span><span style=" font-size:9pt;"> probe allows to query data around the displayed aircraft. It is needed whenever you use the 32bit version of the P3D/FSX driver. The probe needs to be copied into the SimObjects/Misc folder.</span></p></body></html> + + + Qt::RichText + + + true + + + + + + + + + + Copy swift probe + + + + + + Target: + + + + + + + specify the SimObjects directory + + + + + + + Simulator: + + + + + + + ... + + + + + + + copy + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 125 + 0 + + + + + + + + true + + + source directory of probe + + + + + + + + + + + + + + BlackGui::Components::CSimulatorSelector + QFrame +
blackgui/components/simulatorselector.h
+ 1 +
+
+ + le_Target + pb_DirectoryBrowser + + + +
diff --git a/src/blackgui/components/installsimulatorspecificwizardpage.h b/src/blackgui/components/installsimulatorspecificwizardpage.h new file mode 100644 index 000000000..e500bc924 --- /dev/null +++ b/src/blackgui/components/installsimulatorspecificwizardpage.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_INSTALLSIMULATORSPECIFICCOMPONENT_H +#define BLACKGUI_COMPONENTS_INSTALLSIMULATORSPECIFICCOMPONENT_H + +#include "blackgui/overlaymessagesframe.h" +#include + +namespace BlackGui +{ + namespace Components + { + class CInstallXSwiftBusComponent; + class CInstallFsxTerrainProbeComponent; + + /** + * Simulator specific installation + */ + class CInstallSimulatorSpecificWizardPage : public COverlayMessagesWizardPage + { + public: + //! Constructors + using COverlayMessagesWizardPage::COverlayMessagesWizardPage; + + //! Set config + void setConfigComponent(CInstallXSwiftBusComponent *config, CInstallFsxTerrainProbeComponent *fsxTerrainProbe) + { + m_xSwiftBusConfig = config; + m_fsxTerrainProbe = fsxTerrainProbe; + } + + //! \copydoc QWizardPage::validatePage + virtual bool validatePage() override { return true; } + + private: + CInstallXSwiftBusComponent *m_xSwiftBusConfig = nullptr; + CInstallFsxTerrainProbeComponent *m_fsxTerrainProbe = nullptr; + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/installxswiftbuscomponent.ui b/src/blackgui/components/installxswiftbuscomponent.ui index c12730bfd..597bfe57d 100644 --- a/src/blackgui/components/installxswiftbuscomponent.ui +++ b/src/blackgui/components/installxswiftbuscomponent.ui @@ -66,7 +66,19 @@ Download and install XSwiftBus - + + + 4 + + + 4 + + + 4 + + + 4 + @@ -156,7 +168,7 @@ - <html><head/><body><p><span style=" font-weight:600;">Warning: </span>There might be conflicts with other XPlane plugins using the same libraries as <span style=" font-style:italic;">swift</span>, such as <span style=" font-style:italic;">XSquawkBox</span>. You have to disable those pluigns before you can use <span style=" font-style:italic;">swift</span><span style=" font-style:italic;">XSwiftBus</span>.</p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Warning: </span>Possible conflicts with plugins using the same libraries <span style=" font-style:italic;">(e.g. XSquawkBox</span>). You have to disable those pluigns before you can use <span style=" font-style:italic;">swiftXSwiftBus</span>.</p></body></html> true @@ -172,6 +184,18 @@ XSwiftBus settings + + 4 + + + 4 + + + 4 + + + 4 +