mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #681, adjusted form classes
* made server form a CForm, not a component * adjusted other forms
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackgui/components/logincomponent.h"
|
||||
#include "blackgui/components/serverform.h"
|
||||
#include "blackgui/editors/serverform.h"
|
||||
#include "blackgui/components/serverlistselector.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/loginmodebuttons.h"
|
||||
|
||||
@@ -501,7 +501,7 @@
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CServerForm" name="frp_CurrentServer">
|
||||
<widget class="BlackGui::Editors::CServerForm" name="frp_CurrentServer">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
@@ -572,9 +572,9 @@
|
||||
<header>blackgui/components/serverlistselector.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CServerForm</class>
|
||||
<class>BlackGui::Editors::CServerForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/serverform.h</header>
|
||||
<header>blackgui/editors/serverform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/* 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 "blackgui/components/serverform.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "ui_serverform.h"
|
||||
|
||||
#include <QIntValidator>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (this->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");
|
||||
}
|
||||
this->ui->le_Password->setVisible(show);
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList CServerForm::validate() const
|
||||
{
|
||||
CServer server = getServer();
|
||||
return server.validate();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -1,66 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_NETWORKSERVERFORM_H
|
||||
#define BLACKGUI_COMPONENTS_NETWORKSERVERFORM_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/network/server.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CNetworkServerForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Server form
|
||||
class BLACKGUI_EXPORT CServerForm : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CServerForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CServerForm();
|
||||
|
||||
//! Set server
|
||||
void setServer(const BlackMisc::Network::CServer &server);
|
||||
|
||||
//! Get server
|
||||
BlackMisc::Network::CServer getServer() const;
|
||||
|
||||
//! Set read only
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
//! Show the password field
|
||||
void showPasswordField(bool show);
|
||||
|
||||
//! Validate and provide messages (empty means OK)
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CNetworkServerForm> ui;
|
||||
QString m_passwordNameLabel;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
@@ -1,209 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CNetworkServerForm</class>
|
||||
<widget class="QFrame" name="CNetworkServerForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>347</width>
|
||||
<height>126</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_NetworkServerForm">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_ServerForm">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Address">
|
||||
<property name="text">
|
||||
<string>Addr./ port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Name">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_RealName">
|
||||
<property name="text">
|
||||
<string>Real name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="le_Name">
|
||||
<property name="placeholderText">
|
||||
<string>server name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>server description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="le_RealName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>your name if required</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_IdPassword">
|
||||
<property name="text">
|
||||
<string>Id/Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Address">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. "server.foo.com"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QWidget" name="wi_NanePassword" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_NamePassword">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<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>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_NetworkId">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_Password">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="le_Port">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>6809</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>le_Name</tabstop>
|
||||
<tabstop>le_Description</tabstop>
|
||||
<tabstop>le_Address</tabstop>
|
||||
<tabstop>le_Port</tabstop>
|
||||
<tabstop>le_RealName</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user