Ref T246, 1st version of model set wizard

* dialog for CDbOwnModelsComponent / CDbOwnModelSetComponent
* qss
* added page in wizard
This commit is contained in:
Klaus Basan
2018-02-10 01:20:20 +01:00
parent ccd7c477e2
commit 4f63c04225
15 changed files with 930 additions and 76 deletions

View File

@@ -37,6 +37,7 @@ namespace BlackGui
ConfigSimulator,
XSwiftBus,
DataLoad,
FirstModelSet,
ConfigHotkeys
};

View File

@@ -150,7 +150,7 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item row="0" column="0">
<item row="1" column="0">
<widget class="BlackGui::Components::CInstallXSwiftBusComponent" name="comp_XSwiftBus">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@@ -160,6 +160,13 @@
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_SkipXSwiftBus">
<property name="text">
<string> I do not have X-Plane / I will do this later / Is already installed </string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CInitialDataLoadWizardPage" name="wp_DataLoad">
@@ -194,6 +201,45 @@
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CFirstModelSetWizardPage" name="wp_FirstModelSet">
<property name="title">
<string>First model set</string>
</property>
<property name="subTitle">
<string>Configure a simple model set</string>
</property>
<layout class="QVBoxLayout" name="vl_FirstModelSet">
<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 alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_SkipFirstModelSet">
<property name="text">
<string> I will do that later (skip) </string>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Components::CFirstModelSetComponent" name="comp_FirstModelSet">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CConfigHotkeyWizardPage" name="wp_Hotkeys">
<property name="title">
<string>Hotkeys</string>
@@ -281,7 +327,52 @@
<header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CFirstModelSetComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/firstmodelsetcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CFirstModelSetWizardPage</class>
<extends>QWizardPage</extends>
<header>blackgui/components/firstmodelsetcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>pb_SkipFirstModelSet</sender>
<signal>clicked()</signal>
<receiver>CConfigurationWizard</receiver>
<slot>next()</slot>
<hints>
<hint type="sourcelabel">
<x>749</x>
<y>70</y>
</hint>
<hint type="destinationlabel">
<x>804</x>
<y>75</y>
</hint>
</hints>
</connection>
<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>
</connections>
</ui>

View File

@@ -142,6 +142,7 @@ namespace BlackGui
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
this->loadInstalledModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
ui->comp_SimulatorSelector->setValue(simulator);
ui->le_Simulator->setText(simulator.toQString());
}

View File

@@ -0,0 +1,46 @@
/* 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 "dbownmodelsdialog.h"
#include "dbownmodelscomponent.h"
#include "ui_dbownmodelsdialog.h"
using namespace BlackMisc::Simulation;
namespace BlackGui
{
namespace Components
{
CDbOwnModelsDialog::CDbOwnModelsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CDbOwnModelsDialog)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
CDbOwnModelsDialog::~CDbOwnModelsDialog()
{ }
void CDbOwnModelsDialog::setSimulator(const CSimulatorInfo &simulator)
{
ui->comp_OwnModels->setSimulator(simulator);
}
bool CDbOwnModelsDialog::requestModelsInBackground(const CSimulatorInfo &simulator, bool onlyIfNotEmpty)
{
return ui->comp_OwnModels->requestModelsInBackground(simulator, onlyIfNotEmpty);
}
const CDbOwnModelsComponent *CDbOwnModelsDialog::modelsComponent() const
{
return ui->comp_OwnModels;
}
} // ns
} // ns

View File

@@ -0,0 +1,54 @@
/* 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_DBAIRLINEICAOSELECTORBASE_DBOWNMODELSDIALOG_H
#define BLACKGUI_DBAIRLINEICAOSELECTORBASE_DBOWNMODELSDIALOG_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/simulation/simulatorinfo.h"
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class CDbOwnModelsDialog; }
namespace BlackGui
{
namespace Components
{
class CDbOwnModelsComponent;
//! Own models dialog
class BLACKGUI_EXPORT CDbOwnModelsDialog : public QDialog
{
Q_OBJECT
public:
//! Constructor
explicit CDbOwnModelsDialog(QWidget *parent = nullptr);
//! Destructor
virtual ~CDbOwnModelsDialog();
//! \copydoc CDbOwnModelsComponent::setSimulator
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! \copydoc CDbOwnModelsComponent::requestModelsInBackground
bool requestModelsInBackground(const BlackMisc::Simulation::CSimulatorInfo &simulator, bool onlyIfNotEmpty);
//! Direct access to component
//! \remark allows to use the powerful component class
const CDbOwnModelsComponent *modelsComponent() const;
private:
QScopedPointer<Ui::CDbOwnModelsDialog> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbOwnModelsDialog</class>
<widget class="QDialog" name="CDbOwnModelsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Own models dialog</string>
</property>
<layout class="QVBoxLayout" name="vl_OwnModelsDialog">
<item>
<widget class="BlackGui::Components::CDbOwnModelsComponent" name="comp_OwnModels">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_OwnModelsDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbOwnModelsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbownmodelscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_OwnModelsDialog</sender>
<signal>accepted()</signal>
<receiver>CDbOwnModelsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_OwnModelsDialog</sender>
<signal>rejected()</signal>
<receiver>CDbOwnModelsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -72,15 +72,15 @@ namespace BlackGui
//! \fixme maybe it would be better to set those in stylesheet file
ui->pb_SaveAsSetForSimulator->setStyleSheet("padding-left: 3px; padding-right: 3px;");
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_ShowMatrix, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::ps_viewModelChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::ps_onJsonDataLoaded);
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
connect(ui->pb_ShowMatrix, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::setSimulator, Qt::QueuedConnection);
connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::changeSimulator, Qt::QueuedConnection);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::onRowCountChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::viewModelChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::onJsonDataLoaded);
const CSimulatorInfo simulator = m_modelSetLoader.getSimulator();
if (simulator.isSingleSimulator())
@@ -107,7 +107,7 @@ namespace BlackGui
void CDbOwnModelSetComponent::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
this->setModelSetSimulator(simulator);
this->setSimulator(simulator);
if (models.isEmpty())
{
ui->tvp_OwnModelSet->clear();
@@ -142,12 +142,17 @@ namespace BlackGui
ui->tvp_OwnModelSet->updateContainerMaybeAsync(updatedModels);
}
const CAircraftModelList &CDbOwnModelSetComponent::getModelSet() const
const CAircraftModelList &CDbOwnModelSetComponent::getModelSetFromView() const
{
return ui->tvp_OwnModelSet->container();
}
const CSimulatorInfo CDbOwnModelSetComponent::getModelSetSimulator() const
int CDbOwnModelSetComponent::getModelSetCountFromView() const
{
return ui->tvp_OwnModelSet->container().size();
}
CSimulatorInfo CDbOwnModelSetComponent::getModelSetSimulator() const
{
return m_modelSetLoader.getSimulator();
}
@@ -164,7 +169,7 @@ namespace BlackGui
if (!this->getModelSetSimulator().isSingleSimulator())
{
// no sim yet, we set it
this->setModelSetSimulator(simulator);
this->setSimulator(simulator);
}
if (simulator != this->getModelSetSimulator())
{
@@ -174,7 +179,7 @@ namespace BlackGui
}
const bool allowExcludedModels = m_modelSettings.get().getAllowExcludedModels();
CAircraftModelList updateModels(this->getModelSet());
CAircraftModelList updateModels(this->getModelSetFromView());
int d = updateModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
if (d > 0)
{
@@ -194,16 +199,16 @@ namespace BlackGui
CDbMappingComponentAware::setMappingComponent(component);
if (component)
{
connect(this->getMappingComponent(), &CDbMappingComponent::tabIndexChanged, this, &CDbOwnModelSetComponent::ps_tabIndexChanged);
connect(this->getMappingComponent(), &CDbMappingComponent::tabIndexChanged, this, &CDbOwnModelSetComponent::tabIndexChanged);
}
}
void CDbOwnModelSetComponent::ps_tabIndexChanged(int index)
void CDbOwnModelSetComponent::tabIndexChanged(int index)
{
Q_UNUSED(index);
}
void CDbOwnModelSetComponent::ps_buttonClicked()
void CDbOwnModelSetComponent::buttonClicked()
{
const QObject *sender = QObject::sender();
if (sender == ui->pb_CreateNewSet)
@@ -229,23 +234,7 @@ namespace BlackGui
}
}
void CDbOwnModelSetComponent::ps_changeSimulator(const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
this->setModelSetSimulator(simulator);
this->updateViewToCurrentModels();
}
void CDbOwnModelSetComponent::ps_onSimulatorChanged(const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
this->ps_changeSimulator(simulator);
}
void CDbOwnModelSetComponent::ps_onRowCountChanged(int count, bool withFilter)
void CDbOwnModelSetComponent::onRowCountChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
@@ -263,11 +252,11 @@ namespace BlackGui
}
}
void CDbOwnModelSetComponent::ps_onJsonDataLoaded(const CSimulatorInfo &simulator)
void CDbOwnModelSetComponent::onJsonDataLoaded(const CSimulatorInfo &simulator)
{
if (simulator.isSingleSimulator())
{
this->setModelSetSimulator(simulator);
this->setSimulator(simulator);
}
}
@@ -281,15 +270,15 @@ namespace BlackGui
}
}
void CDbOwnModelSetComponent::ps_viewModelChanged()
void CDbOwnModelSetComponent::viewModelChanged()
{
ui->pb_SaveAsSetForSimulator->setEnabled(true);
}
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &sim)
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &simulator)
{
Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const QString name("modelset" + sim.toQString(true));
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const QString name("modelset" + simulator.toQString(true));
ui->tvp_OwnModelSet->setSaveFileName(name);
}
@@ -328,21 +317,29 @@ namespace BlackGui
}
}
void CDbOwnModelSetComponent::changeSimulator(const CSimulatorInfo &simulator)
{
m_modelSetLoader.setSimulator(simulator);
ui->tvp_OwnModelSet->setSimulatorForLoading(simulator);
ui->le_Simulator->setText(simulator.toQString(true));
ui->comp_SimulatorSelector->setValue(simulator);
this->updateViewToCurrentModels();
}
void CDbOwnModelSetComponent::showAirlineAircraftMatrix() const
{
const CAircraftModelList set(this->getModelSet());
const CAircraftModelList set(this->getModelSetFromView());
const QString file = CAircraftModelUtilities::createIcaoAirlineAircraftHtmlMatrixFile(set, sGui->getTemporaryDirectory());
if (file.isEmpty()) { return; }
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
}
void CDbOwnModelSetComponent::setModelSetSimulator(const CSimulatorInfo &simulator)
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &simulator)
{
if (m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
m_modelSetLoader.changeSimulator(simulator);
ui->tvp_OwnModelSet->setSimulatorForLoading(simulator);
ui->le_Simulator->setText(simulator.toQString(true));
ui->comp_SimulatorSelector->setValue(simulator);
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const CSimulatorInfo currentSimulator = m_modelSetLoader.getSimulator();
if (currentSimulator == simulator) { return; } // avoid unnecessary signals
this->changeSimulator(simulator);
}
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)
@@ -380,7 +377,7 @@ namespace BlackGui
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
{
Q_UNUSED(checked);
ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FSX));
ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::FSX));
});
m_setActions.append(a);
@@ -398,7 +395,7 @@ namespace BlackGui
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
{
Q_UNUSED(checked);
ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::P3D));
ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::P3D));
});
m_setActions.append(a);
@@ -416,7 +413,7 @@ namespace BlackGui
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
{
Q_UNUSED(checked);
ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FS9));
ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::FS9));
});
m_setActions.append(a);
@@ -434,7 +431,7 @@ namespace BlackGui
connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
{
Q_UNUSED(checked);
ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE));
ownModelSetComp->setSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE));
});
m_setActions.append(a);

View File

@@ -77,13 +77,24 @@ namespace BlackGui
BlackMisc::CStatusMessage addToModelSet(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Current model set for simulator CDbOwnModelSetComponent::getModelSetSimulator
const BlackMisc::Simulation::CAircraftModelList &getModelSet() const;
//! \remark this the set from the container, which can be different from cache while updating
const BlackMisc::Simulation::CAircraftModelList &getModelSetFromView() const;
//! Current sount of model set for simulator CDbOwnModelSetComponent::getModelSetSimulator
//! \remark this the set from the container, which can be different from cache while updating
int getModelSetCountFromView() const;
//! \copydoc BlackMisc::Simulation::CAircraftModelSetLoader::getCachedModels
BlackMisc::Simulation::CAircraftModelList getModelSetFromLoader() const { return m_modelSetLoader.getCachedModels(this->getModelSetSimulator()); }
//! Model set is for simulator
const BlackMisc::Simulation::CSimulatorInfo getModelSetSimulator() const;
BlackMisc::Simulation::CSimulatorInfo getModelSetSimulator() const;
//! Simulator
void setModelSetSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Used model set loader
const BlackMisc::Simulation::CAircraftModelSetLoader &modelSetLoader() const { return m_modelSetLoader; }
//! \copydoc CDbMappingComponentAware::setMappingComponent
virtual void setMappingComponent(CDbMappingComponent *component) override;
@@ -104,34 +115,27 @@ namespace BlackGui
//! Replace or add models provided for a given simulator
void replaceOrAddModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
private slots:
private:
//! Tab has been changed
void ps_tabIndexChanged(int index);
void tabIndexChanged(int index);
//! Button was clicked
void ps_buttonClicked();
//! Change current simulator
void ps_changeSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Simulator has been changed (in loader)
void ps_onSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
void buttonClicked();
//! View has changed row count
void ps_onRowCountChanged(int count, bool withFilter);
void onRowCountChanged(int count, bool withFilter);
//! JSON data have been loaded from disk
void ps_onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator);
void onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Model (of view) has been changed
void ps_viewModelChanged();
void viewModelChanged();
private:
//! Preferences changed
void distributorPreferencesChanged();
//! Default file name
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Update view to current models
void updateViewToCurrentModels();
@@ -139,6 +143,9 @@ namespace BlackGui
//! Create new set
void createNewSet();
//! Unchecked version of setSimulator
void changeSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Show the airline/aircraft matrix
void showAirlineAircraftMatrix() const;

View File

@@ -0,0 +1,40 @@
/* 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 "dbownmodelsetdialog.h"
#include "ui_dbownmodelsetdialog.h"
using namespace BlackMisc::Simulation;
namespace BlackGui
{
namespace Components
{
CDbOwnModelSetDialog::CDbOwnModelSetDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CDbOwnModelSetDialog)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
CDbOwnModelSetDialog::~CDbOwnModelSetDialog()
{ }
void CDbOwnModelSetDialog::setSimulator(const CSimulatorInfo &simulator)
{
ui->comp_OwnModelSet->setSimulator(simulator);
}
const CDbOwnModelSetComponent *CDbOwnModelSetDialog::modelSetComponent() const
{
return ui->comp_OwnModelSet;
}
} // ns
} // ns

View File

@@ -0,0 +1,49 @@
/* 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_DBOWNMODELSETDIALOG_H
#define BLACKGUI_COMPONENTS_DBOWNMODELSETDIALOG_H
#include "blackmisc/simulation/simulatorinfo.h"
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class CDbOwnModelSetDialog; }
namespace BlackGui
{
namespace Components
{
class CDbOwnModelSetComponent;
//! Dialog version of
class CDbOwnModelSetDialog : public QDialog
{
Q_OBJECT
public:
//! Constructor
explicit CDbOwnModelSetDialog(QWidget *parent = nullptr);
//! Destructor
virtual ~CDbOwnModelSetDialog();
//! \copydoc CDbOwnModelSetComponent::setSimulator
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Direct access to CDbOwnModelSetComponent
const CDbOwnModelSetComponent *modelSetComponent() const;
private:
QScopedPointer<Ui::CDbOwnModelSetDialog> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbOwnModelSetDialog</class>
<widget class="QDialog" name="CDbOwnModelSetDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Own model set dialog</string>
</property>
<layout class="QVBoxLayout" name="vl_OwnModelSetDialog">
<item>
<widget class="BlackGui::Components::CDbOwnModelSetComponent" name="comp_OwnModelSet">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_OwnModelSetDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbOwnModelSetComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbownmodelsetcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_OwnModelSetDialog</sender>
<signal>accepted()</signal>
<receiver>CDbOwnModelSetDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_OwnModelSetDialog</sender>
<signal>rejected()</signal>
<receiver>CDbOwnModelSetDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,121 @@
/* 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 "firstmodelsetcomponent.h"
#include "ui_firstmodelsetcomponent.h"
#include "dbownmodelsdialog.h"
#include "dbownmodelscomponent.h"
#include "dbownmodelsetdialog.h"
#include "dbownmodelsetcomponent.h"
#include <QStringList>
using namespace BlackMisc::Simulation;
namespace BlackGui
{
namespace Components
{
CFirstModelSetComponent::CFirstModelSetComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CFirstModelSetComponent)
{
ui->setupUi(this);
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
ui->comp_SimulatorSelector->setRememberSelection(true);
// we use the powerful component to access own models
m_modelsDialog.reset(new CDbOwnModelsDialog(this));
m_modelSetDialog.reset(new CDbOwnModelSetDialog(this));
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue());
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CFirstModelSetComponent::onSimulatorChanged);
connect(ui->pb_ModelSet, &QPushButton::clicked, this, &CFirstModelSetComponent::openOwnModelSetDialog);
connect(ui->pb_Models, &QPushButton::clicked, this, &CFirstModelSetComponent::openOwnModelsDialog);
connect(ui->pb_ModelsTriggerReload, &QPushButton::clicked, this, &CFirstModelSetComponent::openOwnModelsDialog);
}
CFirstModelSetComponent::~CFirstModelSetComponent()
{ }
void CFirstModelSetComponent::onSimulatorChanged(const CSimulatorInfo &simulator)
{
Q_ASSERT_X(m_modelsDialog, Q_FUNC_INFO, "No models dialog");
m_modelsDialog->setSimulator(simulator);
Q_ASSERT_X(m_modelSetDialog, Q_FUNC_INFO, "No model set dialog");
m_modelSetDialog->setSimulator(simulator);
// kind of hack, but simplest solution
// we us the loader of the components directly,
// avoid to fully init a loader logic here
const QStringList dirs = this->simulatorSettings().getModelDirectoriesOrDefault(simulator);
ui->le_ModelDirectories->setText(dirs.join(", "));
static const QString modelInfo("Models already indexed: %1");
static const QString modelsNo("No models so far");
const int models = this->modelLoader()->getAircraftModelsCount();
ui->le_ModelsInfo->setText(models > 0 ? modelInfo.arg(models) : modelsNo);
static const QString modelSetInfo("Models in set: %1");
static const QString modelsSetNo("Model set is empty");
const int modelSet = this->modelSetLoader().getAircraftModelsCount();
ui->le_ModelSetInfo->setText(models > 0 ? modelSetInfo.arg(modelSet) : modelsSetNo);
}
const CDbOwnModelsComponent *CFirstModelSetComponent::modelsComponent() const
{
Q_ASSERT_X(m_modelsDialog, Q_FUNC_INFO, "No models dialog");
Q_ASSERT_X(m_modelsDialog->modelsComponent(), Q_FUNC_INFO, "No models component");
return m_modelsDialog->modelsComponent();
}
const CDbOwnModelSetComponent *CFirstModelSetComponent::modelSetComponent() const
{
Q_ASSERT_X(m_modelSetDialog, Q_FUNC_INFO, "No model set dialog");
Q_ASSERT_X(m_modelSetDialog->modelSetComponent(), Q_FUNC_INFO, "No model set component");
return m_modelSetDialog->modelSetComponent();
}
BlackMisc::Simulation::IAircraftModelLoader *CFirstModelSetComponent::modelLoader() const
{
Q_ASSERT_X(m_modelsDialog->modelsComponent()->modelLoader(), Q_FUNC_INFO, "No model loader");
return m_modelsDialog->modelsComponent()->modelLoader();
}
const CAircraftModelSetLoader &CFirstModelSetComponent::modelSetLoader() const
{
return this->modelSetComponent()->modelSetLoader();
}
const Settings::CMultiSimulatorSettings &CFirstModelSetComponent::simulatorSettings() const
{
return this->modelLoader()->multiSimulatorSettings();
}
void CFirstModelSetComponent::openOwnModelsDialog()
{
m_modelsDialog->setSimulator(ui->comp_SimulatorSelector->getValue());
m_modelsDialog->show();
bool const reload = QObject::sender() == ui->pb_ModelsTriggerReload;
if (reload) { m_modelsDialog->requestModelsInBackground(ui->comp_SimulatorSelector->getValue(), true); }
}
void CFirstModelSetComponent::openOwnModelSetDialog()
{
m_modelSetDialog->setSimulator(ui->comp_SimulatorSelector->getValue());
m_modelSetDialog->show();
}
bool CFirstModelSetWizardPage::validatePage()
{
return true;
}
} // ns
} // ns

View File

@@ -0,0 +1,94 @@
/* 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_FIRSTMODELSETCOMPONENT_H
#define BLACKGUI_COMPONENTS_FIRSTMODELSETCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackcore/application/applicationsettings.h"
#include "blackmisc/simulation/aircraftmodelsetloader.h"
#include "blackmisc/simulation/settings/simulatorsettings.h"
#include "blackmisc/simulation/aircraftmodelloader.h"
#include "blackmisc/simulation/simulatorinfo.h"
#include <QFrame>
#include <QWizardPage>
namespace Ui { class CFirstModelSetComponent; }
namespace BlackGui
{
namespace Components
{
class CDbOwnModelsDialog;
class CDbOwnModelsComponent;
class CDbOwnModelSetDialog;
class CDbOwnModelSetComponent;
//! Create a first model set
class CFirstModelSetComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CFirstModelSetComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CFirstModelSetComponent();
private:
QScopedPointer<Ui::CFirstModelSetComponent> ui;
QScopedPointer<CDbOwnModelsDialog> m_modelsDialog;
QScopedPointer<CDbOwnModelSetDialog> m_modelSetDialog;
//! Simulator has been changed
void onSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Direct access to component
const CDbOwnModelsComponent *modelsComponent() const;
//! Direct access to component
const CDbOwnModelSetComponent *modelSetComponent() const;
//! Direct access to component's loader
BlackMisc::Simulation::IAircraftModelLoader *modelLoader() const;
//! Model set loader
const BlackMisc::Simulation::CAircraftModelSetLoader &modelSetLoader() const;
//! Simulator settings
const BlackMisc::Simulation::Settings::CMultiSimulatorSettings &simulatorSettings() const;
//! Open own models dialog
void openOwnModelsDialog();
//! Own model set dialog
void openOwnModelSetDialog();
};
//! Wizard page for CFirstModelSetComponent
class CFirstModelSetWizardPage : public QWizardPage
{
public:
//! Constructors
using QWizardPage::QWizardPage;
//! Set config
void setFirstModelSet(CFirstModelSetComponent *firstModelSet) { m_firstModelSet = firstModelSet; }
//! \copydoc QWizardPage::validatePage
virtual bool validatePage() override;
private:
CFirstModelSetComponent *m_firstModelSet = nullptr;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CFirstModelSetComponent</class>
<widget class="QFrame" name="CFirstModelSetComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Configure a 1st model set</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignTop">
<widget class="QFrame" name="fr_Info">
<layout class="QGridLayout" name="gl_Info" columnstretch="1,5">
<item row="0" column="1">
<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 model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.&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>
<item row="0" column="0">
<widget class="QLabel" name="lbl_SwiftIcon">
<property name="text">
<string>&lt;html&gt;&lt;img src=&quot;:/own/icons/own/swift3D/sw3DOrange-32.png&quot;&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_Models">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbl_ModelDirectories">
<property name="text">
<string>Model directories:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_ModelDirectories">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Models">
<property name="text">
<string>Models:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gl_Models">
<item row="1" column="0">
<widget class="QPushButton" name="pb_ModelSet">
<property name="text">
<string>show set</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_Models">
<property name="text">
<string> show models </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_ModelsTriggerReload">
<property name="text">
<string> trigger reload </string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_ModelsInfo">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="le_ModelSetInfo">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QWidget" name="wi_OwnModels" native="true">
<layout class="QHBoxLayout" name="hl_OwnModels">
<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>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="wi_ModelSet" native="true">
<layout class="QHBoxLayout" name="hl_ModelSet">
<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>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_Distributor">
<property name="text">
<string>Distributors:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="BlackGui::Components::CDbDistributorComponent" name="comp_Distributors">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</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>
<customwidget>
<class>BlackGui::Components::CDbDistributorComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbdistributorcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>