Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterNetUI.cpp
1#include "ParameterNetUI.h"
2#include "ui_ParameterNetUI.h"
3#include <QLoggingCategory>
4#include <QMessageBox>
5
6static Q_LOGGING_CATEGORY(log, "Client.Parameter.Net.UI")
7
8CParameterNetUI::CParameterNetUI(QWidget *parent)
9 : CParameterUI(parent),
10 ui(new Ui::CParameterNetUI),
11 m_pNet(nullptr)
12{
13 ui->setupUi(this);
14 connect(ui->leHost, &QLineEdit::editingFinished, this, [&](){
15 emit sigHostChanged(ui->leHost->text());
16 });
17}
18
19CParameterNetUI::~CParameterNetUI()
20{
21 delete ui;
22}
23
26{
27 if(!pParameter) return -1;
28
29 m_pNet = qobject_cast<CParameterNet*>(pParameter);
30
31 ui->leHost->setText(m_pNet->GetHost());
32 ui->spPort->setValue(m_pNet->GetPort());
33
34 // Call user UI SetParameter
35 ui->wUser->SetParameter(&m_pNet->m_User);
36
37 return 0;
38}
40
43{
44 if(validity && ui->leHost->text().isEmpty()) {
45 QMessageBox::critical(this, tr("Error"),
46 m_pNet->GetPrompt());
47 qCritical(log) << "The host is empty" << m_pNet->GetPrompt();
48 ui->leHost->setFocus();
49 return false;
50 }
51 return true;
52}
54
57{
58 int nRet = 0;
59
60 m_pNet->SetHost(ui->leHost->text());
61 m_pNet->SetPort(ui->spPort->value());
62
63 // Accept user UI parameters
64 ui->wUser->Accept();
65 return nRet;
66}
68
70{
71 auto s = ui->leHost->text().split(":");
72 if(s.size() == 2) // IPV4
73 {
74 ui->spPort->setValue(s[1].toUInt());
75 ui->leHost->setText(s[0]);
76 }
77}
The net parameter UI.
int Accept()
Accept parameters.
void on_leHost_editingFinished()
[Accept]
bool CheckValidity(bool validity=false)
[Set Parameter]
int SetParameter(CParameter *pParameter)
[Parameter commone functions]
CParameterUser m_User
[Instance user]
The parameter UI interface.
Definition ParameterUI.h:15
Parameter interface.
Definition Parameter.h:169