Ref T357, wizard page to copy terrain probe

- changed xSwiftBus page and added terrain probe copy Ui as well
- component for terrain probe
This commit is contained in:
Klaus Basan
2018-09-17 03:02:43 +02:00
parent 6b01021a0a
commit 00651ae9f8
7 changed files with 397 additions and 43 deletions

View File

@@ -10,10 +10,12 @@
#include "configurationwizard.h" #include "configurationwizard.h"
#include "ui_configurationwizard.h" #include "ui_configurationwizard.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackmisc/math/mathutils.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include <QPointer> #include <QPointer>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Math;
namespace BlackGui namespace BlackGui
{ {
@@ -26,7 +28,7 @@ namespace BlackGui
ui->setupUi(this); ui->setupUi(this);
ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels); ui->wp_CopyModels->setConfigComponent(ui->comp_CopyModels);
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator); 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_DataLoad->setConfigComponent(ui->comp_DataLoad);
ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys); ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys);
ui->wp_Legal->setConfigComponent(ui->comp_LegalInformation); ui->wp_Legal->setConfigComponent(ui->comp_LegalInformation);
@@ -118,7 +120,7 @@ namespace BlackGui
{ {
QWidget *parent = this->parentWidget(); QWidget *parent = this->parentWidget();
if (!parent) { return; } if (!parent) { return; }
if (parent->windowOpacity() == opacity) { return; } if (CMathUtils::epsilonEqual(parent->windowOpacity(), opacity)) { return; }
parent->setWindowOpacity(opacity); parent->setWindowOpacity(opacity);
} }
} // ns } // ns

View File

@@ -22,9 +22,6 @@
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="wizardStyle">
<enum>QWizard::ClassicStyle</enum>
</property>
<property name="options"> <property name="options">
<set>QWizard::HaveCustomButton1</set> <set>QWizard::HaveCustomButton1</set>
</property> </property>
@@ -194,12 +191,12 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="BlackGui::Components::CInstallXSwiftBusWizardPage" name="wp_XSwiftBus"> <widget class="BlackGui::Components::CInstallSimulatorSpecificWizardPage" name="wp_SimulatorSpecific">
<property name="title"> <property name="title">
<string>XSwiftBus</string> <string>Simulator specific installations</string>
</property> </property>
<property name="subTitle"> <property name="subTitle">
<string>Install XSwiftBus (X-Plane only)</string> <string>Install XSwiftBus (X-Plane only) or swift terrain probe (FSX/P3D only)</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="leftMargin">
@@ -219,21 +216,18 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>100</height> <height>150</height>
</size> </size>
</property> </property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="0" alignment="Qt::AlignRight"> <item row="0" column="0">
<widget class="QPushButton" name="pb_SkipXSwiftBus"> <widget class="BlackGui::Components::CInstallFsxTerrainProbeComponent" name="comp_FsxTerrainProbe" native="true">
<property name="text"> <property name="minimumSize">
<string> I do not have X-Plane / I will do this later / Is already installed </string> <size>
<width>0</width>
<height>75</height>
</size>
</property> </property>
</widget> </widget>
</item> </item>
@@ -329,12 +323,6 @@
<header>blackgui/components/installxswiftbuscomponent.h</header> <header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>BlackGui::Components::CInstallXSwiftBusWizardPage</class>
<extends>QWizardPage</extends>
<header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>BlackGui::Components::CFirstModelSetWizardPage</class> <class>BlackGui::Components::CFirstModelSetWizardPage</class>
<extends>QWizardPage</extends> <extends>QWizardPage</extends>
@@ -377,25 +365,21 @@
<header>blackgui/components/copysettingsandcachescomponent.h</header> <header>blackgui/components/copysettingsandcachescomponent.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>BlackGui::Components::CInstallSimulatorSpecificWizardPage</class>
<extends>QWizardPage</extends>
<header>blackgui/components/installsimulatorspecificwizardpage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInstallFsxTerrainProbeComponent</class>
<extends>QWidget</extends>
<header>blackgui/components/installfsxterrainprobecomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection>
<sender>pb_SkipXSwiftBus</sender>
<signal>clicked()</signal>
<receiver>CConfigurationWizard</receiver>
<slot>next()</slot>
<hints>
<hint type="sourcelabel">
<x>713</x>
<y>63</y>
</hint>
<hint type="destinationlabel">
<x>791</x>
<y>64</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>pb_SkipFirstModelSet</sender> <sender>pb_SkipFirstModelSet</sender>
<signal>clicked()</signal> <signal>clicked()</signal>

View File

@@ -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 <QPushButton>
#include <QFileDialog>
#include <QPointer>
#include <QTimer>
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<CInstallFsxTerrainProbeComponent> 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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CInstallFsxTerrainProbeComponent> 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

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CInstallFsxTerrainProbeComponent</class>
<widget class="QFrame" name="CInstallFsxTerrainProbeComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>194</height>
</rect>
</property>
<property name="windowTitle">
<string>Copy swift probe</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="fr_InfoHeader">
<layout class="QHBoxLayout" name="hl_InfoHeader" stretch="1,1,3">
<item>
<widget class="QLabel" name="lbl_FSX">
<property name="styleSheet">
<string notr="true">background: &quot;lightgrey&quot;</string>
</property>
<property name="text">
<string>&lt;img width=&quot;100&quot; src=&quot;:/simulators/icons/simulators/FSX.png&quot;/&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_P3D">
<property name="styleSheet">
<string notr="true">background: &quot;lightgrey&quot;</string>
</property>
<property name="text">
<string>&lt;img width=&quot;130&quot; src=&quot;:/simulators/icons/simulators/Prepar3D.png&quot;/&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Explaination">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;The &lt;/span&gt;&lt;span style=&quot; font-size:9pt; font-style:italic;&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt; 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.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_CopySwiftProbe">
<property name="title">
<string>Copy swift probe</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="lbl_Target">
<property name="text">
<string>Target:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_Target">
<property name="placeholderText">
<string>specify the SimObjects directory</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Simulator">
<property name="text">
<string>Simulator:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pb_DirectoryBrowser">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_Copy">
<property name="text">
<string>copy</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="wi_Simulator" native="true">
<layout class="QHBoxLayout" name="hl_Simulator">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_Source">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>source directory of probe</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CSimulatorSelector</class>
<extends>QFrame</extends>
<header>blackgui/components/simulatorselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>le_Target</tabstop>
<tabstop>pb_DirectoryBrowser</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -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 <QWizard>
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

View File

@@ -66,7 +66,19 @@
<property name="title"> <property name="title">
<string>Download and install XSwiftBus</string> <string>Download and install XSwiftBus</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gl_DownloadAndInstall">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="lbl_XSwiftBusPluginDir"> <widget class="QLabel" name="lbl_XSwiftBusPluginDir">
<property name="text"> <property name="text">
@@ -156,7 +168,7 @@
<item row="0" column="0" colspan="4"> <item row="0" column="0" colspan="4">
<widget class="QLabel" name="lbl_Warning"> <widget class="QLabel" name="lbl_Warning">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Warning: &lt;/span&gt;There might be conflicts with other XPlane plugins using the same libraries as &lt;span style=&quot; font-style:italic;&quot;&gt;swift&lt;/span&gt;, such as &lt;span style=&quot; font-style:italic;&quot;&gt;XSquawkBox&lt;/span&gt;. You have to disable those pluigns before you can use &lt;span style=&quot; font-style:italic;&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;XSwiftBus&lt;/span&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Warning: &lt;/span&gt;Possible conflicts with plugins using the same libraries &lt;span style=&quot; font-style:italic;&quot;&gt;(e.g. XSquawkBox&lt;/span&gt;). You have to disable those pluigns before you can use &lt;span style=&quot; font-style:italic;&quot;&gt;swiftXSwiftBus&lt;/span&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@@ -172,6 +184,18 @@
<string>XSwiftBus settings</string> <string>XSwiftBus settings</string>
</property> </property>
<layout class="QVBoxLayout" name="vl_XSwiftBusSettings"> <layout class="QVBoxLayout" name="vl_XSwiftBusSettings">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item> <item>
<widget class="BlackGui::Components::CSettingsXSwiftBusComponent" name="comp_SettingsXSwiftBus"> <widget class="BlackGui::Components::CSettingsXSwiftBusComponent" name="comp_SettingsXSwiftBus">
<property name="minimumSize"> <property name="minimumSize">