mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #288, a server form used in login screen and settings
This commit is contained in:
committed by
Roland Winklmeier
parent
c6d14c31fd
commit
2a831f8252
82
src/blackgui/serverform.cpp
Normal file
82
src/blackgui/serverform.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "serverform.h"
|
||||
#include "ui_serverform.h"
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CServerForm::CServerForm(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CNetworkServerForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->le_Port->setValidator(new QIntValidator(1, 65535, this));
|
||||
}
|
||||
|
||||
CServerForm::~CServerForm()
|
||||
{ }
|
||||
|
||||
void CServerForm::setServer(const CServer &server)
|
||||
{
|
||||
CUser user = server.getUser();
|
||||
this->ui->le_NetworkId->setText(user.getId());
|
||||
this->ui->le_RealName->setText(user.getRealName());
|
||||
this->ui->le_Name->setText(server.getName());
|
||||
this->ui->le_Password->setText(user.getPassword());
|
||||
this->ui->le_Description->setText(server.getDescription());
|
||||
this->ui->le_Address->setText(server.getAddress());
|
||||
this->ui->le_Port->setText(QString::number(server.getPort()));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CServer CServerForm::getServer() const
|
||||
{
|
||||
CUser user(
|
||||
this->ui->le_NetworkId->text().trimmed(),
|
||||
this->ui->le_RealName->text().trimmed().simplified(),
|
||||
"",
|
||||
this->ui->le_Password->text().trimmed()
|
||||
);
|
||||
CServer server(
|
||||
this->ui->le_Name->text().trimmed().simplified(),
|
||||
this->ui->le_Description->text().trimmed().simplified(),
|
||||
this->ui->le_Address->text().trimmed(),
|
||||
this->ui->le_Port->text().trimmed().toInt(),
|
||||
user
|
||||
);
|
||||
return server;
|
||||
}
|
||||
|
||||
void CServerForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->ui->le_NetworkId->setReadOnly(readOnly);
|
||||
this->ui->le_RealName->setReadOnly(readOnly);
|
||||
this->ui->le_Name->setReadOnly(readOnly);
|
||||
this->ui->le_Description->setReadOnly(readOnly);
|
||||
this->ui->le_Address->setReadOnly(readOnly);
|
||||
this->ui->le_Port->setReadOnly(readOnly);
|
||||
this->ui->le_Password->setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
void CServerForm::showPasswordField(bool show)
|
||||
{
|
||||
this->ui->lbl_Password->setVisible(show);
|
||||
this->ui->le_Password->setVisible(show);
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList CServerForm::validate() const
|
||||
{
|
||||
CServer server = getServer();
|
||||
return server.validate();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user