mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #886, config page for simulator(s)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
b53d4b6b58
commit
5b92b2068e
98
src/blackgui/components/configsimulatorcomponent.cpp
Normal file
98
src/blackgui/components/configsimulatorcomponent.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "configsimulatorcomponent.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include "ui_configsimulatorcomponent.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackConfig;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CConfigSimulatorComponent::CConfigSimulatorComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CConfigSimulatorComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->preselectSimulators();
|
||||
}
|
||||
|
||||
CConfigSimulatorComponent::~CConfigSimulatorComponent()
|
||||
{ }
|
||||
|
||||
void CConfigSimulatorComponent::save()
|
||||
{
|
||||
ui->comp_SettingsSimulator->save();
|
||||
const QStringList sims = this->selectedSimsToPluginIds();
|
||||
const CStatusMessage msg = m_enabledSimulators.setAndSave(sims);
|
||||
CLogMessage::preformatted(msg);
|
||||
}
|
||||
|
||||
void CConfigSimulatorComponent::preselectSimulators()
|
||||
{
|
||||
CSimulatorInfo sims;
|
||||
if (m_enabledSimulators.isSaved())
|
||||
{
|
||||
sims = CSimulatorInfo(m_enabledSimulators.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
// by model set
|
||||
sims = m_modelSets.simulatorsWithInitializedCache();
|
||||
}
|
||||
|
||||
const bool p3d = (sims.p3d() || !CFsCommonUtil::p3dDir().isEmpty()) && CBuildConfig::isCompiledWithP3DSupport();
|
||||
const bool fsx = (sims.fsx() || !CFsCommonUtil::fsxDir().isEmpty()) && CBuildConfig::isCompiledWithFsxSupport();
|
||||
const bool fs9 = (sims.fs9() || !CFsCommonUtil::fs9Dir().isEmpty()) && CBuildConfig::isCompiledWithFs9Support();
|
||||
const bool xp = sims.xplane() && CBuildConfig::isCompiledWithXPlaneSupport();
|
||||
|
||||
ui->cb_P3D->setChecked(p3d);
|
||||
ui->cb_FSX->setChecked(fsx);
|
||||
ui->cb_FS9->setChecked(fs9);
|
||||
ui->cb_XP->setChecked(xp); // \fixme some default for XP?
|
||||
|
||||
ui->cb_P3D->setEnabled(CBuildConfig::isCompiledWithP3DSupport());
|
||||
ui->cb_FSX->setEnabled(CBuildConfig::isCompiledWithFsxSupport());
|
||||
ui->cb_FS9->setEnabled(CBuildConfig::isCompiledWithFs9Support());
|
||||
ui->cb_XP->setEnabled(CBuildConfig::isCompiledWithXPlaneSupport());
|
||||
|
||||
if (p3d) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::P3D)); }
|
||||
else if (fsx) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::FSX)); }
|
||||
else if (fs9) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::FS9)); }
|
||||
else if (xp) { ui->comp_SettingsSimulator->setSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE)); }
|
||||
}
|
||||
|
||||
QStringList CConfigSimulatorComponent::selectedSimsToPluginIds()
|
||||
{
|
||||
QStringList ids;
|
||||
|
||||
// have to match ids from swift-plugin-simulators.xml
|
||||
if (ui->cb_FS9->isChecked()) { ids << "fs2004"; }
|
||||
if (ui->cb_FSX->isChecked()) { ids << "fsx"; }
|
||||
if (ui->cb_P3D->isChecked()) { ids << "p3d"; }
|
||||
if (ui->cb_XP->isChecked()) { ids << "xplane"; }
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
bool CConfigSimulatorWizardPage::validatePage()
|
||||
{
|
||||
Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config");
|
||||
m_config->save();
|
||||
return true;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
75
src/blackgui/components/configsimulatorcomponent.h
Normal file
75
src/blackgui/components/configsimulatorcomponent.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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_CONFIGSIMULATORCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_CONFIGSIMULATORCOMPONENT_H
|
||||
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include <QWizardPage>
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CConfigSimulatorComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Simulator configuration
|
||||
*/
|
||||
class CConfigSimulatorComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CConfigSimulatorComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CConfigSimulatorComponent();
|
||||
|
||||
//! Save data
|
||||
void save();
|
||||
|
||||
private:
|
||||
//! Preselect simulators
|
||||
void preselectSimulators();
|
||||
|
||||
//! Get the plugin ids
|
||||
QStringList selectedSimsToPluginIds();
|
||||
|
||||
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_enabledSimulators { this };
|
||||
BlackMisc::Simulation::Data::CModelSetCaches m_modelSets { true, this };
|
||||
QScopedPointer<Ui::CConfigSimulatorComponent> ui;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wizard page for CConfigSimulatorComponent
|
||||
*/
|
||||
class CConfigSimulatorWizardPage : public QWizardPage
|
||||
{
|
||||
public:
|
||||
//! Constructors
|
||||
using QWizardPage::QWizardPage;
|
||||
|
||||
//! Set config
|
||||
void setConfigComponent(CConfigSimulatorComponent *config) { m_config = config; }
|
||||
|
||||
//! \copydoc QWizardPage::validatePage
|
||||
virtual bool validatePage() override;
|
||||
|
||||
private:
|
||||
CConfigSimulatorComponent *m_config = nullptr;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
190
src/blackgui/components/configsimulatorcomponent.ui
Normal file
190
src/blackgui/components/configsimulatorcomponent.ui
Normal file
@@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CConfigSimulatorComponent</class>
|
||||
<widget class="QFrame" name="CConfigSimulatorComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_ConfigSimulator">
|
||||
<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>
|
||||
<widget class="QGroupBox" name="gb_Simulator">
|
||||
<property name="title">
|
||||
<string>Select your simulator(s)</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Simulator">
|
||||
<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="0" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="lbl_FSX">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: "lightgrey"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><img width="100" src=":/simulators/icons/simulators/FSX.png"/></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="lbl_FS9">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: "lightgrey"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><img width="100" src=":/simulators/icons/simulators/FS9.png"/></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="lbl_XP">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: "lightgrey"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><img width="100" src=":/simulators/icons/simulators/XPlane.png"/></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_FSX">
|
||||
<property name="text">
|
||||
<string>FSX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_XP">
|
||||
<property name="text">
|
||||
<string>XPlane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_FS9">
|
||||
<property name="text">
|
||||
<string>FS9</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_P3D">
|
||||
<property name="text">
|
||||
<string>P3D</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_P3D">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: "lightgrey"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><img width="130" src=":/simulators/icons/simulators/Prepar3D.png"/></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_SimulatorSetup">
|
||||
<property name="title">
|
||||
<string>Setup of each individual simulator</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_GroupSimulator">
|
||||
<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>
|
||||
<widget class="QLabel" name="lbl_SimulatorHint">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Simulator directories: <span style=" font-weight:600;">Normally</span> there is <span style=" font-weight:600;">no need</span> to override the defaults. But if the simulator directories / excludes are incorrect you can set individual values here.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CSettingsSimulatorBasicsComponent" name="comp_SettingsSimulator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs_SimulatorComponent">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsSimulatorBasicsComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/settingssimulatorbasicscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -32,7 +32,7 @@ namespace BlackGui
|
||||
connect(ui->pb_ExcludeFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_excludeFileDialog);
|
||||
connect(ui->pb_ModelFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_modelFileDialog);
|
||||
connect(ui->pb_SimulatorFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_simulatorFileDialog);
|
||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_save);
|
||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::save);
|
||||
connect(ui->pb_Reset, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_reset);
|
||||
connect(ui->pb_CopyDefaults, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::ps_copyDefaults);
|
||||
connect(ui->le_SimulatorDirectory, &QLineEdit::returnPressed, this, &CSettingsSimulatorBasicsComponent::ps_simulatorDirectoryEntered);
|
||||
@@ -55,11 +55,6 @@ namespace BlackGui
|
||||
ui->comp_SimulatorSelector->setValue(simulator);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorBasicsComponent::save()
|
||||
{
|
||||
this->ps_save();
|
||||
}
|
||||
|
||||
void CSettingsSimulatorBasicsComponent::setSmallLayout(bool small)
|
||||
{
|
||||
ui->lbl_ExcludeDirectories->setWordWrap(small);
|
||||
@@ -104,7 +99,7 @@ namespace BlackGui
|
||||
this->displayDefaultValuesAsPlaceholder(simulator);
|
||||
}
|
||||
|
||||
void CSettingsSimulatorBasicsComponent::ps_save()
|
||||
void CSettingsSimulatorBasicsComponent::save()
|
||||
{
|
||||
const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue());
|
||||
CSimulatorSettings s = this->getSettings(simulator);
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace BlackGui
|
||||
void ps_excludeFileDialog();
|
||||
void ps_simulatorFileDialog();
|
||||
void ps_simulatorDirectoryEntered();
|
||||
void ps_save();
|
||||
void ps_copyDefaults();
|
||||
void ps_reset();
|
||||
void ps_simulatorChanged();
|
||||
|
||||
@@ -44,16 +44,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" alignment="Qt::AlignTop">
|
||||
<widget class="QLabel" name="lbl_ExcludeDirectories">
|
||||
<property name="toolTip">
|
||||
<string>Excluded from model loading</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exclude directory patterns:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" alignment="Qt::AlignTop">
|
||||
<widget class="QLabel" name="lbl_ModelDirectory">
|
||||
<property name="text">
|
||||
@@ -129,6 +119,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" rowspan="4" alignment="Qt::AlignTop">
|
||||
<widget class="QLabel" name="lbl_ExcludeDirectories">
|
||||
<property name="toolTip">
|
||||
<string>Excluded from model loading</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exclude directory patterns:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
Reference in New Issue
Block a user