6 #include <QIntValidator>
11 #include "ui_serverform.h"
16 using namespace swift::misc::audio;
17 using namespace swift::misc::network;
19 namespace swift::gui::editors
21 CServerForm::CServerForm(QWidget *parent) :
CForm(parent), ui(new Ui::CNetworkServerForm)
24 ui->le_Port->setValidator(
new QIntValidator(1, 65535,
this));
25 this->initServerTypes();
27 connect(ui->cbp_Ecosystem, &CEcosystemComboBox::currentTextChanged,
this, &CServerForm::onChangedEcoSystem);
28 connect(ui->cb_ServerType, &QComboBox::currentTextChanged,
this, &CServerForm::onChangedServerType);
29 connect(ui->tb_Unhide, &QToolButton::clicked,
this, &CServerForm::tempUnhidePassword);
37 ui->le_NetworkId->setText(user.
getId());
39 ui->le_Name->setText(server.
getName());
41 ui->cbp_Ecosystem->setCurrentEcosystem(server.
getEcosystem());
45 ui->le_Port->setText(QString::number(server.
getPort()));
51 const CUser user(ui->le_NetworkId->text().trimmed(), ui->le_RealName->text().trimmed().simplified(), QString(),
52 ui->le_Password->text().trimmed());
53 const CFsdSetup fsdSetup(ui->form_ServerFsd->getValue());
54 const CServer server(ui->le_Name->text().trimmed().simplified(),
55 ui->le_Description->text().trimmed().simplified(), ui->le_Address->text().trimmed(),
56 ui->le_Port->text().trimmed().toInt(), user, fsdSetup,
57 ui->cbp_Ecosystem->getSelectedEcosystem(), this->getServerType(),
true);
70 ui->form_ServerFsd->setReadOnly(readOnly);
72 ui->le_NetworkId->setReadOnly(readOnly);
73 ui->le_RealName->setReadOnly(readOnly);
74 ui->le_Name->setReadOnly(readOnly);
75 ui->le_Description->setReadOnly(readOnly);
76 ui->le_Address->setReadOnly(readOnly);
77 ui->le_Port->setReadOnly(readOnly);
78 ui->le_Password->setReadOnly(readOnly);
79 ui->cb_ServerType->setEnabled(!readOnly);
80 ui->cbp_Ecosystem->setEnabled(!readOnly);
81 ui->tb_Unhide->setVisible(!readOnly);
87 if (ui->wi_Password->isVisible() == show) {
return; }
88 if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); }
89 ui->lbl_IdPassword->setText(show ? m_passwordNameLabel :
"Id");
90 ui->wi_Password->setVisible(show);
93 void CServerForm::initServerTypes()
97 ui->cb_ServerType->clear();
98 for (
const int type : CServer::allServerTypes())
101 ui->cb_ServerType->insertItem(c++, CServer::serverTypeToString(st), QVariant::fromValue(type));
105 void CServerForm::onChangedServerType(
const QString &text)
112 if (es.
isSystem(CEcosystem::NoSystem)) {
return; }
113 ui->cbp_Ecosystem->setCurrentEcosystem(es);
116 void CServerForm::onChangedEcoSystem(
const QString &text)
119 const CEcosystem es = ui->cbp_Ecosystem->getSelectedEcosystem();
121 if (dummy.hasUnspecifiedServerType()) {
return; }
122 ui->cb_ServerType->setCurrentText(dummy.getServerTypeAsString());
static void tempUnhidePassword(QLineEdit *lineEdit, int unhideMs=5000)
Temp. unhide password.
Status messages, e.g. from Core -> GUI.
Ecosystem of server belonging together.
bool isUnspecified() const
Unknown system?
bool isSystem(System s) const
Is system?
Value object for a FSD setup.
Value object encapsulating information of a server.
const QString & getDescription() const
Get description.
const QString & getServerTypeAsString() const
Get server type as string.
int getPort() const
Get port.
CStatusMessageList validate() const
Validate, provide details about issues.
const QString & getName() const
Get name.
const CFsdSetup & getFsdSetup() const
Get FSD setup.
const QString & getAddress() const
Get address.
const CEcosystem & getEcosystem() const
Get the ecosystem.
const CUser & getUser() const
Get user.
Value object encapsulating information of a user.
const QString & getPassword() const
Get password.
const QString & getRealName() const
Get full name.
const QString & getId() const
Get id.
Free functions in swift::misc.