-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadddevicedialog.cpp
More file actions
83 lines (66 loc) · 1.78 KB
/
Copy pathadddevicedialog.cpp
File metadata and controls
83 lines (66 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "adddevicedialog.h"
#include "ui_adddevicedialog.h"
#include "deviceconfiguration.h"
#include <QAbstractButton>
AddDeviceDialog::AddDeviceDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddDeviceDialog)
{
ui->setupUi(this);
connect(ui->NameEdit,
SIGNAL(textChanged(const QString&)),
this,
SLOT(NameChanged(const QString&)));
ui->buttonBox->buttons().at(0)->setEnabled(false);
}
AddDeviceDialog::~AddDeviceDialog()
{
delete ui;
}
QString AddDeviceDialog::Name()
{
return ui->NameEdit->text();
}
QString AddDeviceDialog::Host()
{
return ui->HostEdit->text();
}
unsigned int AddDeviceDialog::Port()
{
return ui->PortEdit->value();
}
void AddDeviceDialog::SetMainWindow(MainWindow *Window)
{
m_MainWindow = Window;
}
void AddDeviceDialog::SetEditModeForDevice(const DeviceConfiguration& Configuration)
{
m_EditMode = true;
ui->TitleLabel->setText("Edit TCP Device");
std::string Name;
std::string Host;
int Port;
Configuration.Get("Name", Name);
Configuration.Get("Host", Host);
Configuration.Get("Port", Port);
ui->NameTakenLabel->setVisible(false);
ui->NameEdit->setText(QString::fromStdString(Name));
ui->NameEdit->setEnabled(false);
ui->HostEdit->setText(QString::fromStdString(Host));
ui->PortEdit->setValue(Port);
ui->buttonBox->buttons().at(0)->setEnabled(true);
}
void AddDeviceDialog::NameChanged(const QString& NewName)
{
if (!m_MainWindow) { return; }
if (m_MainWindow->ContainsDeviceName(NewName))
{
ui->NameTakenLabel->setText("Invalid");
ui->buttonBox->buttons().at(0)->setEnabled(false);
}
else
{
ui->NameTakenLabel->setText("Valid");
ui->buttonBox->buttons().at(0)->setEnabled(true);
}
}