diff --git a/src/blackgui/components/settingsnetworkserverscomponent.ui b/src/blackgui/components/settingsnetworkserverscomponent.ui
index 37e566a09..e998c8200 100644
--- a/src/blackgui/components/settingsnetworkserverscomponent.ui
+++ b/src/blackgui/components/settingsnetworkserverscomponent.ui
@@ -62,7 +62,7 @@
0
- 150
+ 160
diff --git a/src/blackgui/editors/serverform.cpp b/src/blackgui/editors/serverform.cpp
index 629428d73..86433438b 100644
--- a/src/blackgui/editors/serverform.cpp
+++ b/src/blackgui/editors/serverform.cpp
@@ -27,15 +27,10 @@ namespace BlackGui
{
ui->setupUi(this);
ui->le_Port->setValidator(new QIntValidator(1, 65535, this));
+ this->initServerTypes();
- // init all server type values
- ui->cb_ServerType->clear();
- int c = 0;
- for (int type : CServer::allServerTypes())
- {
- const CServer::ServerType st = static_cast(type);
- ui->cb_ServerType->insertItem(c++, CServer::serverTypeToString(st), QVariant::fromValue(type));
- }
+ connect(ui->cbp_Ecosystem, &CEcosystemComboBox::currentTextChanged, this, &CServerForm::onChangedEcoSystem);
+ connect(ui->cb_ServerType, &QComboBox::currentTextChanged, this, &CServerForm::onChangedServerType);
}
CServerForm::~CServerForm()
@@ -48,6 +43,7 @@ namespace BlackGui
ui->le_RealName->setText(user.getRealName());
ui->le_Name->setText(server.getName());
ui->cb_ServerType->setCurrentText(server.getServerTypeAsString());
+ ui->cbp_Ecosystem->setCurrentEcosystem(server.getEcosystem());
ui->le_Password->setText(user.getPassword());
ui->le_Description->setText(server.getDescription());
ui->le_Address->setText(server.getAddress());
@@ -57,26 +53,31 @@ namespace BlackGui
BlackMisc::Network::CServer CServerForm::getServer() const
{
- CUser user(
+ const CUser user(
ui->le_NetworkId->text().trimmed(),
ui->le_RealName->text().trimmed().simplified(),
"",
ui->le_Password->text().trimmed()
);
- CServer server(
+ const CFsdSetup setup(ui->form_ServerFsd->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,
- ui->cb_ServerType->currentData().value(),
+ user, setup,
+ ui->cbp_Ecosystem->getSelectedEcosystem(),
+ this->getServerType(),
true
);
- CFsdSetup setup(ui->form_ServerFsd->getValue());
- server.setFsdSetup(setup);
return server;
}
+ CServer::ServerType CServerForm::getServerType() const
+ {
+ return ui->cb_ServerType->currentData().value();
+ }
+
void CServerForm::setReadOnly(bool readOnly)
{
ui->le_NetworkId->setReadOnly(readOnly);
@@ -88,23 +89,49 @@ namespace BlackGui
ui->le_Password->setReadOnly(readOnly);
ui->form_ServerFsd->setReadOnly(readOnly);
ui->cb_ServerType->setEnabled(!readOnly);
+ ui->cbp_Ecosystem->setEnabled(!readOnly);
}
void CServerForm::showPasswordField(bool show)
{
if (ui->le_Password->isVisible() == show) { return; }
if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); }
- if (show)
- {
- ui->lbl_IdPassword->setText(m_passwordNameLabel);
- }
- else
- {
- ui->lbl_IdPassword->setText("Id");
- }
+ ui->lbl_IdPassword->setText(show ? m_passwordNameLabel : "Id");
ui->le_Password->setVisible(show);
}
+ void CServerForm::initServerTypes()
+ {
+ // init all server type values
+ int c = 0;
+ ui->cb_ServerType->clear();
+ for (const int type : CServer::allServerTypes())
+ {
+ const CServer::ServerType st = static_cast(type);
+ ui->cb_ServerType->insertItem(c++, CServer::serverTypeToString(st), QVariant::fromValue(type));
+ }
+ }
+
+ void CServerForm::onChangedServerType(const QString &text)
+ {
+ Q_UNUSED(text);
+ const CServer::ServerType t = this->getServerType();
+ const CServer dummy(t);
+ const CEcosystem es = dummy.getEcosystem();
+ if (es.isUnspecified()) { return; }
+ if (es.isSystem(CEcosystem::NoSystem)) { return; }
+ ui->cbp_Ecosystem->setCurrentEcosystem(es);
+ }
+
+ void CServerForm::onChangedEcoSystem(const QString &text)
+ {
+ Q_UNUSED(text);
+ const CEcosystem es = ui->cbp_Ecosystem->getSelectedEcosystem();
+ const CServer dummy(es);
+ if (dummy.hasUnspecifiedServerType()) { return; }
+ ui->cb_ServerType->setCurrentText(dummy.getServerTypeAsString());
+ }
+
BlackMisc::CStatusMessageList CServerForm::validate(bool nested) const
{
Q_UNUSED(nested);
diff --git a/src/blackgui/editors/serverform.h b/src/blackgui/editors/serverform.h
index 55366cf64..64587e53b 100644
--- a/src/blackgui/editors/serverform.h
+++ b/src/blackgui/editors/serverform.h
@@ -47,6 +47,9 @@ namespace BlackGui
//! Get server
BlackMisc::Network::CServer getServer() const;
+ //! Get currently selected server type
+ BlackMisc::Network::CServer::ServerType getServerType() const;
+
//! \name Form class implementations
//! @{
virtual void setReadOnly(bool readonly) override;
@@ -57,6 +60,10 @@ namespace BlackGui
void showPasswordField(bool show);
private:
+ void initServerTypes();
+ void onChangedServerType(const QString &text);
+ void onChangedEcoSystem(const QString &text);
+
QScopedPointer ui;
QString m_passwordNameLabel;
};
diff --git a/src/blackgui/editors/serverform.ui b/src/blackgui/editors/serverform.ui
index 7893aca0e..1570c7dcb 100644
--- a/src/blackgui/editors/serverform.ui
+++ b/src/blackgui/editors/serverform.ui
@@ -2,23 +2,9 @@
CNetworkServerForm
-
-
- 0
- 0
- 275
- 172
-
-
Frame
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
0
@@ -59,64 +45,23 @@
-
-
+
- 4
+ 3
- 4
+ 3
- 4
+ 3
- 4
+ 3
-
- 4
-
-
-
-
-
- Id/Password:
-
-
-
- -
-
-
-
-
-
- id
-
-
-
-
- Name/Type:
-
-
-
- -
-
-
- Real name:
-
-
-
- -
-
-
- Description:
-
-
-
- -
-
-
- Addr./ port:
+ Name:
@@ -127,17 +72,45 @@
- -
+
-
+
+
+ Eco./type:
+
+
+
+ -
- -
+
-
+
+
+ Description:
+
+
+
+ -
server description
- -
+
-
+
+
+ Addr./ port:
+
+
+
+ -
+
+
+ e.g. "server.foo.com"
+
+
+
+ -
6809
@@ -147,14 +120,14 @@
- -
-
-
- e.g. "server.foo.com"
+
-
+
+
+ Real name:
- -
+
-
@@ -164,7 +137,24 @@
- -
+
-
+
+
+ Id/Password:
+
+
+
+ -
+
+
+
+
+
+ id
+
+
+
+ -
32
@@ -177,6 +167,9 @@
+ -
+
+
@@ -222,9 +215,15 @@
blackgui/editors/fsdsetupform.h
1
+
+ BlackGui::CEcosystemComboBox
+ QComboBox
+ blackgui/ecosystemcombobox.h
+
le_Name
+ cbp_Ecosystem
cb_ServerType
le_Description
le_Address