Ref T730, Ref T731 update voice server setup to AfV URLs (formerly UDP ports)

This commit is contained in:
Klaus Basan
2019-10-08 03:03:57 +02:00
committed by Mat Sutcliffe
parent e485824bfc
commit 2123529fd8
6 changed files with 80 additions and 67 deletions

View File

@@ -205,7 +205,7 @@
<string>reload</string>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</iconset>
</property>
</widget>
@@ -331,7 +331,7 @@
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignLeft|Qt::AlignTop">
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CVoiceSetupForm" name="form_Voice">
<property name="minimumSize">
<size>
@@ -494,7 +494,7 @@
<string>refresh</string>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</iconset>
</property>
</widget>
@@ -511,7 +511,7 @@
<string>quick mapping wizard</string>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/own/icons/own/swift3D/sw3DGreen-24.png</normaloff>:/own/icons/own/swift3D/sw3DGreen-24.png</iconset>
</property>
</widget>
@@ -896,6 +896,17 @@
<header>blackgui/editors/voicesetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CServerListSelector</class>
<extends>QComboBox</extends>
<header>blackgui/components/serverlistselector.h</header>
</customwidget>
<customwidget>
<class>BlackGui::CLoginModeButtons</class>
<extends>QFrame</extends>
<header>blackgui/loginmodebuttons.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CTickLabel</class>
<extends>QLabel</extends>
@@ -925,17 +936,6 @@
<header>blackgui/components/dbairlineicaoselectorcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CServerListSelector</class>
<extends>QComboBox</extends>
<header>blackgui/components/serverlistselector.h</header>
</customwidget>
<customwidget>
<class>BlackGui::CLoginModeButtons</class>
<extends>QFrame</extends>
<header>blackgui/loginmodebuttons.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CPilotForm</class>
<extends>QFrame</extends>
@@ -971,8 +971,6 @@
<tabstop>pb_OverrideCredentialsOtherServers</tabstop>
<tabstop>sa_FsdDetails</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@@ -267,7 +267,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<iconset>
<normaloff>:/diagona/icons/diagona/icons/question-button.png</normaloff>:/diagona/icons/diagona/icons/question-button.png</iconset>
</property>
</widget>
@@ -322,7 +322,7 @@
<attribute name="title">
<string>Voice</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vl_VoiceSetup">
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CVoiceSetupForm" name="form_Voice">
<property name="frameShape">
@@ -346,17 +346,17 @@
<header>blackgui/editors/fsdsetupform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CEcosystemComboBox</class>
<extends>QComboBox</extends>
<header>blackgui/ecosystemcombobox.h</header>
</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>
<header>blackgui/ecosystemcombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tw_ServerForm</tabstop>
@@ -371,8 +371,6 @@
<tabstop>le_Password</tabstop>
<tabstop>tb_Unhide</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@@ -24,8 +24,6 @@ namespace BlackGui
{
ui->setupUi(this);
ui->cb_Override->setChecked(true);
QIntValidator *v = new QIntValidator(0, 65535, ui->le_VatsimUdpPort);
ui->le_VatsimUdpPort->setValidator(v);
this->resetToDefaultValues();
connect(ui->cb_Override, &QCheckBox::toggled, this, &CVoiceSetupForm::enabledToggled, Qt::QueuedConnection);
connect(ui->pb_SetDefaults, &QPushButton::clicked, this, &CVoiceSetupForm::resetToDefaultValues);
@@ -36,7 +34,7 @@ namespace BlackGui
CVoiceSetup CVoiceSetupForm::getValue() const
{
const CVoiceSetup s = CVoiceSetup(ui->le_VatsimUdpPort->text().toInt());
const CVoiceSetup s(ui->le_AfvVoiceServerUrl->text(), ui->le_AfvMapUrl->text());
return s;
}
@@ -48,7 +46,8 @@ namespace BlackGui
void CVoiceSetupForm::setValue(const CVoiceSetup &setup)
{
ui->le_VatsimUdpPort->setText(QString::number(setup.getVatsimUdpVoicePort()));
ui->le_AfvVoiceServerUrl->setText(setup.getAfvVoiceServerUrl());
ui->le_AfvMapUrl->setText(setup.getAfvMapUrl());
}
bool CVoiceSetupForm::isVoiceSetupEnabled() const
@@ -80,7 +79,8 @@ namespace BlackGui
void CVoiceSetupForm::setReadOnly(bool readonly)
{
ui->pb_SetDefaults->setEnabled(!readonly);
ui->le_VatsimUdpPort->setReadOnly(readonly);
ui->le_AfvVoiceServerUrl->setReadOnly(readonly);
ui->le_AfvMapUrl->setReadOnly(readonly);
CGuiUtility::checkBoxesReadOnly(this, readonly);
if (m_alwaysAllowOverride)
{
@@ -101,7 +101,7 @@ namespace BlackGui
CStatusMessageList CVoiceSetupForm::validate(bool nested) const
{
Q_UNUSED(nested);
Q_UNUSED(nested)
const CVoiceSetup val(this->getValue());
CStatusMessageList msgs(val.validate());
if (this->isReadOnly())
@@ -114,7 +114,7 @@ namespace BlackGui
void CVoiceSetupForm::enabledToggled(bool enabled)
{
Q_UNUSED(enabled);
Q_UNUSED(enabled)
this->setReadOnly(!enabled);
}

View File

@@ -2,16 +2,8 @@
<ui version="4.0">
<class>CVoiceSetupForm</class>
<widget class="QFrame" name="CVoiceSetupForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>45</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
<string>AfV voice setup</string>
</property>
<layout class="QGridLayout" name="gl_VoiceSetup" columnstretch="1,1,1">
<property name="leftMargin">
@@ -29,6 +21,13 @@
<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">
@@ -37,14 +36,14 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_VatsimUdpPort">
<widget class="QLabel" name="lbl_AfvVoiceServerUrl">
<property name="text">
<string>Voice UDP Port</string>
<string>AfV voice server URL</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_VatsimUdpPort"/>
<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">
@@ -53,19 +52,23 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_SetDefaults">
<item row="3" column="0">
<widget class="QLabel" name="lbl_AfvMapUrl">
<property name="text">
<string>set defaults</string>
<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_VatsimUdpPort</tabstop>
<tabstop>le_AfvVoiceServerUrl</tabstop>
<tabstop>le_AfvMapUrl</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -21,15 +21,16 @@ namespace BlackMisc
{
QString CVoiceSetup::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
return QStringLiteral("Port: %1").arg(getVatsimUdpVoicePort());
Q_UNUSED(i18n)
return QStringLiteral("Port: %1").arg(getAfvVoiceServerUrl());
}
CStatusMessageList CVoiceSetup::validate() const
{
static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
CStatusMessageList msgs;
if (this->getVatsimUdpVoicePort() < 1 || this->getVatsimUdpVoicePort() > 65535) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Invalid voice port")); }
if (this->getAfvVoiceServerUrl().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Invalid voice server url")); }
if (this->getAfvMapUrl().isEmpty()) { msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Invalid voice server url")); }
msgs.addCategories(cats);
return msgs;
}
@@ -40,7 +41,8 @@ namespace BlackMisc
return s;
}
CVoiceSetup::CVoiceSetup(int vatsimUdpPort) : m_vatismVoiceUdpPort(vatsimUdpPort)
CVoiceSetup::CVoiceSetup(const QString &afvVoiceServerUrl, const QString &afvMapUrl) :
m_afvVoiceServerUrl(afvVoiceServerUrl), m_afvMapUrl(afvMapUrl)
{ }
CVariant CVoiceSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
@@ -49,7 +51,8 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexVatsimVoiceUdpPort: return CVariant::fromValue(m_vatismVoiceUdpPort);
case IndexAfvVoiceServerUrl: return CVariant::fromValue(m_afvVoiceServerUrl);
case IndexAfvMapUrl: return CVariant::fromValue(m_afvMapUrl);
default: return CValueObject::propertyByIndex(index);
}
}
@@ -60,7 +63,8 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexVatsimVoiceUdpPort: m_vatismVoiceUdpPort = variant.toInt(); break;
case IndexAfvVoiceServerUrl: m_afvVoiceServerUrl = variant.toQString(); break;
case IndexAfvMapUrl: m_afvMapUrl = variant.toQString(); break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
@@ -73,7 +77,8 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexVatsimVoiceUdpPort: return Compare::compare(m_vatismVoiceUdpPort, compareValue.m_vatismVoiceUdpPort);
case IndexAfvVoiceServerUrl: return m_afvVoiceServerUrl.compare(compareValue.m_afvVoiceServerUrl, Qt::CaseInsensitive);
case IndexAfvMapUrl: return m_afvMapUrl.compare(compareValue.m_afvMapUrl, Qt::CaseInsensitive);
default: break;
}
BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));

View File

@@ -32,20 +32,27 @@ namespace BlackMisc
//! Properties by index
enum ColumnIndex
{
IndexVatsimVoiceUdpPort = CPropertyIndex::GlobalIndexCVoiceSetup,
IndexAfvVoiceServerUrl = CPropertyIndex::GlobalIndexCVoiceSetup,
IndexAfvMapUrl
};
//! Default constructor.
CVoiceSetup() {}
//! Setup with values
CVoiceSetup(int vatsimUdpPort);
CVoiceSetup(const QString &afvVoiceServerUrl, const QString &afvMapUrl);
//! The voice UDP port
void setVatsimUdpVoicePort(int port) { m_vatismVoiceUdpPort = port;}
//! AFV voice server URL
void setAfvVoiceServerUrl(const QString &serverUrl) { m_afvVoiceServerUrl = serverUrl;}
//! VATSIM UDP voice port
int getVatsimUdpVoicePort() const { return m_vatismVoiceUdpPort; }
//! AFV voice server URL
const QString &getAfvVoiceServerUrl() const { return m_afvVoiceServerUrl; }
//! AFV map URL
void setAfvMapUrl(const QString &mapUrl) { m_afvMapUrl = mapUrl;}
//! AFV map URL
const QString &getAfvMapUrl() const { return m_afvMapUrl; }
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
@@ -66,11 +73,13 @@ namespace BlackMisc
static const CVoiceSetup &vatsimStandard();
private:
int m_vatismVoiceUdpPort = 3292;
QString m_afvVoiceServerUrl = "https://voice1.vatsim.uk";
QString m_afvMapUrl = "https://afv-map.vatsim.net/";
BLACK_METACLASS(
CVoiceSetup,
BLACK_METAMEMBER(vatismVoiceUdpPort)
BLACK_METAMEMBER(afvVoiceServerUrl),
BLACK_METAMEMBER(afvMapUrl)
);
};
} // namespace