refactor: Read AFV URLs from bootstrap.json

This also removes the possibility to change the URL on the fly via the
UI.
Fixes #257
This commit is contained in:
Lars Toenning
2024-02-18 16:33:16 +01:00
parent 8ecc680dfd
commit 5e0f3a05d3
34 changed files with 44 additions and 691 deletions

View File

@@ -227,7 +227,6 @@ add_library(gui SHARED
editors/liveryform.h
editors/situationform.h
editors/aircraftmodelform.h
editors/voicesetupform.h
editors/fsdsetupform.ui
editors/aircraftpartsform.cpp
editors/ownmodelsetform.h
@@ -254,7 +253,6 @@ add_library(gui SHARED
editors/modelmappingform.cpp
editors/distributorform.ui
editors/aircrafticaoform.h
editors/voicesetupform.ui
editors/aircraftpartsform.ui
editors/serverform.cpp
editors/modelmappingmodifyform.ui
@@ -279,7 +277,6 @@ add_library(gui SHARED
editors/interpolationsetupform.cpp
editors/aircrafticaoform.ui
editors/pbhsform.h
editors/voicesetupform.cpp
editors/aircrafticaoform.cpp
editors/cockpitcomform.h
blackguiexport.h

View File

@@ -82,7 +82,7 @@ namespace BlackGui::Components
this->setForceSmall(true);
this->showKillButton(false);
// override details/voice
// override details
ui->comp_NetworkDetails->setAlwaysAllowOverride(true);
// Stored data
@@ -164,12 +164,6 @@ namespace BlackGui::Components
currentServer.setFsdSetup(fsd);
}
if (ui->comp_NetworkDetails->isVoiceSetupOverrideEnabled())
{
const CVoiceSetup voice = ui->comp_NetworkDetails->getVoiceSetup();
currentServer.setVoiceSetup(voice);
}
// update for own aircraft context
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser());
@@ -196,11 +190,6 @@ namespace BlackGui::Components
}
// Login
if (sGui && sGui->getCContextAudioBase())
{
sGui->getCContextAudioBase()->setVoiceSetup(currentServer.getVoiceSetup());
}
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, partnerCs, mode);
if (msg.isSuccess())
{

View File

@@ -95,10 +95,6 @@ namespace BlackGui::Components
ui->form_FsdDetails->setFsdSetupEnabled(false);
ui->form_FsdDetails->setAlwaysAllowOverride(true);
ui->form_Voice->showEnableInfo(true);
ui->form_Voice->setVoiceSetupEnabled(false);
ui->form_Voice->setAlwaysAllowOverride(true);
ui->lblp_AircraftCombinedType->setToolTips("ok", "wrong");
ui->lblp_AirlineIcao->setToolTips("ok", "wrong");
ui->lblp_AircraftIcao->setToolTips("ok", "wrong");
@@ -273,12 +269,6 @@ namespace BlackGui::Components
currentServer.setFsdSetup(fsd);
}
if (ui->form_Voice->isVoiceSetupEnabled())
{
const CVoiceSetup voice = ui->form_Voice->getValue();
currentServer.setVoiceSetup(voice);
}
ui->frp_CurrentServer->setServer(currentServer);
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser());
@@ -286,11 +276,6 @@ namespace BlackGui::Components
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
// Login
if (sGui->getCContextAudioBase())
{
sGui->getCContextAudioBase()->setVoiceSetup(currentServer.getVoiceSetup());
}
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, {}, mode);
if (msg.isSuccess())
{
@@ -460,7 +445,6 @@ namespace BlackGui::Components
// only override if not yet enabled
if (!ui->form_FsdDetails->isFsdSetupEnabled()) { ui->form_FsdDetails->setValue(server.getFsdSetup()); }
if (!ui->form_Voice->isVoiceSetupEnabled()) { ui->form_Voice->setValue(server.getVoiceSetup()); }
ui->tw_Network->setVisible(showNetwork);
ui->tw_Details->setMinimumHeight(showNetwork ? 0 : 125);

View File

@@ -314,35 +314,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Voice">
<attribute name="title">
<string>Voice</string>
</attribute>
<layout class="QVBoxLayout" name="vl_Voice">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CVoiceSetupForm" name="form_Voice">
<property name="minimumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_MatchingLog">
<attribute name="title">
<string>Matching log</string>
@@ -883,12 +854,6 @@
<header>blackgui/editors/fsdsetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CVoiceSetupForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/voicesetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CServerListSelector</class>
<extends>QComboBox</extends>

View File

@@ -46,9 +46,6 @@ namespace BlackGui::Components
ui->form_FsdDetails->showEnableInfo(true);
ui->form_FsdDetails->setFsdSetupEnabled(false);
ui->form_FsdDetails->setReadOnly(false);
ui->form_Voice->showEnableInfo(true);
ui->form_Voice->setVoiceSetupEnabled(false);
ui->form_Voice->setReadOnly(false);
constexpr int MaxLength = 10;
constexpr int MinLength = 0;
@@ -94,16 +91,6 @@ namespace BlackGui::Components
return ui->tw_Details->currentWidget() == ui->tb_OtherServers;
}
CVoiceSetup CNetworkDetailsComponent::getVoiceSetup() const
{
return ui->form_Voice->getValue();
}
bool CNetworkDetailsComponent::isVoiceSetupOverrideEnabled() const
{
return ui->form_Voice->isVoiceSetupEnabled();
}
CFsdSetup CNetworkDetailsComponent::getFsdSetup() const
{
return ui->form_FsdDetails->getValue();
@@ -112,7 +99,6 @@ namespace BlackGui::Components
void CNetworkDetailsComponent::setAlwaysAllowOverride(bool allow)
{
ui->form_FsdDetails->setAlwaysAllowOverride(allow);
ui->form_Voice->setAlwaysAllowOverride(allow);
}
bool CNetworkDetailsComponent::isFsdSetupOverrideEnabled() const
@@ -139,7 +125,6 @@ namespace BlackGui::Components
// only override if not yet enabled
if (!ui->form_FsdDetails->isFsdSetupEnabled()) { ui->form_FsdDetails->setValue(server.getFsdSetup()); }
if (!ui->form_Voice->isVoiceSetupEnabled()) { ui->form_Voice->setValue(server.getVoiceSetup()); }
}
void CNetworkDetailsComponent::onOverrideCredentialsToPilot()

View File

@@ -13,7 +13,6 @@
#include "blackmisc/network/data/lastserver.h"
#include "blackmisc/network/entityflags.h"
#include "blackmisc/network/fsdsetup.h"
#include "blackmisc/audio/voicesetup.h"
#include "blackmisc/settingscache.h"
#include "blackmisc/datacache.h"
#include "blackmisc/network/connectionstatus.h"
@@ -49,7 +48,6 @@ namespace BlackGui::Components
enum Details
{
DetailsServer,
DetailsVoice,
DetailsBack
};
@@ -68,12 +66,6 @@ namespace BlackGui::Components
//! Specific setup enabled?
bool isFsdSetupOverrideEnabled() const;
//! Voice setup
BlackMisc::Audio::CVoiceSetup getVoiceSetup() const;
//! Specific setup enabled?
bool isVoiceSetupOverrideEnabled() const;
//! Login mode
BlackMisc::Network::CLoginMode getLoginMode() const;

View File

@@ -333,35 +333,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Voice">
<attribute name="title">
<string>Voice</string>
</attribute>
<layout class="QVBoxLayout" name="vl_Voice">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="BlackGui::Editors::CVoiceSetupForm" name="form_Voice">
<property name="minimumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_BackToServer">
<attribute name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
@@ -395,12 +366,6 @@
<header>blackgui/editors/fsdsetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CVoiceSetupForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/voicesetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CServerListSelector</class>
<extends>QComboBox</extends>

View File

@@ -44,7 +44,6 @@ namespace BlackGui::Editors
ui->le_Address->setText(server.getAddress());
ui->le_Port->setText(QString::number(server.getPort()));
ui->form_ServerFsd->setValue(server.getFsdSetup());
ui->form_Voice->setValue(server.getVoiceSetup());
}
CServer CServerForm::getServer() const
@@ -55,14 +54,13 @@ namespace BlackGui::Editors
QString(),
ui->le_Password->text().trimmed());
const CFsdSetup fsdSetup(ui->form_ServerFsd->getValue());
const CVoiceSetup voiceSetup(ui->form_Voice->getValue());
const CServer server(
ui->le_Name->text().trimmed().simplified(),
ui->le_Description->text().trimmed().simplified(),
ui->le_Address->text().trimmed(),
ui->le_Port->text().trimmed().toInt(),
user,
fsdSetup, voiceSetup,
fsdSetup,
ui->cbp_Ecosystem->getSelectedEcosystem(),
this->getServerType(),
true);
@@ -82,7 +80,6 @@ namespace BlackGui::Editors
void CServerForm::setReadOnly(bool readOnly)
{
ui->form_ServerFsd->setReadOnly(readOnly);
ui->form_Voice->setReadOnly(readOnly);
ui->le_NetworkId->setReadOnly(readOnly);
ui->le_RealName->setReadOnly(readOnly);

View File

@@ -318,23 +318,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_ServerVoicce">
<attribute name="title">
<string>Voice</string>
</attribute>
<layout class="QVBoxLayout" name="vl_VoiceSetup">
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CVoiceSetupForm" name="form_Voice">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -346,12 +329,6 @@
<header>blackgui/editors/fsdsetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CVoiceSetupForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/voicesetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CEcosystemComboBox</class>
<extends>QComboBox</extends>

View File

@@ -1,125 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
#include "voicesetupform.h"
#include "ui_voicesetupform.h"
#include <QIntValidator>
using namespace BlackMisc;
using namespace BlackMisc::Audio;
using namespace BlackMisc::Network;
namespace BlackGui::Editors
{
CVoiceSetupForm::CVoiceSetupForm(QWidget *parent) : CForm(parent),
ui(new Ui::CVoiceSetupForm)
{
ui->setupUi(this);
ui->cb_Override->setChecked(true);
this->resetToDefaultValues();
connect(ui->cb_Override, &QCheckBox::toggled, this, &CVoiceSetupForm::enabledToggled, Qt::QueuedConnection);
connect(ui->pb_SetDefaults, &QPushButton::clicked, this, &CVoiceSetupForm::resetToDefaultValues);
}
CVoiceSetupForm::~CVoiceSetupForm()
{}
CVoiceSetup CVoiceSetupForm::getValue() const
{
const CVoiceSetup s(ui->le_AfvVoiceServerUrl->text(), ui->le_AfvMapUrl->text());
return s;
}
const CVoiceSetup &CVoiceSetupForm::getDisabledValue() const
{
static const CVoiceSetup s;
return s;
}
void CVoiceSetupForm::setValue(const CVoiceSetup &setup)
{
ui->le_AfvVoiceServerUrl->setText(setup.getAfvVoiceServerUrl());
ui->le_AfvMapUrl->setText(setup.getAfvMapUrl());
}
bool CVoiceSetupForm::isVoiceSetupEnabled() const
{
return ui->cb_Override->isChecked();
}
void CVoiceSetupForm::setVoiceSetupEnabled(bool enabled)
{
ui->cb_Override->setChecked(enabled);
}
void CVoiceSetupForm::setAlwaysAllowOverride(bool allow)
{
m_alwaysAllowOverride = allow;
if (allow)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
}
void CVoiceSetupForm::showEnableInfo(bool visible)
{
m_visibleEnableInfo = visible;
this->visibleEnableInfo(visible);
}
void CVoiceSetupForm::setReadOnly(bool readonly)
{
ui->pb_SetDefaults->setEnabled(!readonly);
ui->le_AfvVoiceServerUrl->setReadOnly(readonly);
ui->le_AfvMapUrl->setReadOnly(readonly);
CGuiUtility::checkBoxesReadOnly(this, readonly);
if (m_alwaysAllowOverride)
{
ui->cb_Override->setEnabled(true);
CGuiUtility::checkBoxReadOnly(ui->cb_Override, false);
}
/**
if (readonly && ui->cb_Override->isChecked())
{
// this is no value which will be stored
ui->cb_Override->setChecked(false);
}
**/
this->forceStyleSheetUpdate();
}
CStatusMessageList CVoiceSetupForm::validate(bool nested) const
{
Q_UNUSED(nested)
const CVoiceSetup val(this->getValue());
CStatusMessageList msgs(val.validate());
if (this->isReadOnly())
{
// in readonly I cannot change the data anyway, so skip warnings
msgs.removeWarningsAndBelow();
}
return msgs;
}
void CVoiceSetupForm::enabledToggled(bool enabled)
{
Q_UNUSED(enabled)
this->setReadOnly(!enabled);
}
void CVoiceSetupForm::visibleEnableInfo(bool visible)
{
ui->cb_Override->setVisible(visible);
ui->lbl_VoiceSetup->setVisible(visible);
ui->pb_SetDefaults->setVisible(visible);
}
void CVoiceSetupForm::resetToDefaultValues()
{
CVoiceSetup s;
this->setValue(s);
}
} // ns

View File

@@ -1,76 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef BLACKGUI_COMPONENTS_VOICESETUPFORM_H
#define BLACKGUI_COMPONENTS_VOICESETUPFORM_H
#include "blackmisc/audio/voicesetup.h"
#include "blackmisc/statusmessagelist.h"
#include "blackgui/editors/form.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui
{
class CVoiceSetupForm;
}
namespace BlackGui::Editors
{
//! Voice form
class CVoiceSetupForm : public CForm
{
Q_OBJECT
public:
//! Ctor
explicit CVoiceSetupForm(QWidget *parent = nullptr);
//! Dtor
virtual ~CVoiceSetupForm() override;
//! Voice setup from GUI
BlackMisc::Audio::CVoiceSetup getValue() const;
//! Voice setup when disabled
const BlackMisc::Audio::CVoiceSetup &getDisabledValue() const;
//! Set to GUI
void setValue(const BlackMisc::Audio::CVoiceSetup &setup);
//! Enabled?
bool isVoiceSetupEnabled() const;
//! Set enabled / disabled
void setVoiceSetupEnabled(bool enabled);
//! Allow override even in read only mode
void setAlwaysAllowOverride(bool allow);
//! Show the enable info
void showEnableInfo(bool visible);
//! Set default values
void resetToDefaultValues();
//! \name Form class implementations
//! @{
virtual void setReadOnly(bool readonly) override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
private:
//! Enable / disable
void enabledToggled(bool enabled);
//! Show / hide visible "enable" info
void visibleEnableInfo(bool visible);
QScopedPointer<Ui::CVoiceSetupForm> ui;
bool m_alwaysAllowOverride = false;
bool m_visibleEnableInfo = true;
};
} // ns
#endif // guard

View File

@@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CVoiceSetupForm</class>
<widget class="QFrame" name="CVoiceSetupForm">
<property name="windowTitle">
<string>AfV voice setup</string>
</property>
<layout class="QGridLayout" name="gl_VoiceSetup" columnstretch="1,1,1">
<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>
<property name="horizontalSpacing">
<number>4</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="pb_SetDefaults">
<property name="text">
<string>set defaults</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cb_Override">
<property name="text">
<string>override</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_AfvVoiceServerUrl">
<property name="text">
<string>AfV voice server URL</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="le_AfvVoiceServerUrl"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_VoiceSetup">
<property name="text">
<string>Voice setup</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_AfvMapUrl">
<property name="text">
<string>AfV map URL</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="le_AfvMapUrl"/>
</item>
</layout>
</widget>
<tabstops>
<tabstop>cb_Override</tabstop>
<tabstop>pb_SetDefaults</tabstop>
<tabstop>le_AfvVoiceServerUrl</tabstop>
<tabstop>le_AfvMapUrl</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>