-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
85 lines (65 loc) · 1.82 KB
/
Copy pathmainwindow.cpp
File metadata and controls
85 lines (65 loc) · 1.82 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
84
85
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
t = new QtTelnet;
connect(t, SIGNAL(message(const QString &)),
this, SLOT(telnetMessage(const QString &)));
connect(t, SIGNAL(loginRequired()),
this, SLOT(telnetLoginRequired()));
connect(t, SIGNAL(loginFailed()),
this, SLOT(telnetLoginFailed()));
connect(t, SIGNAL(loggedOut()),
this, SLOT(telnetLoggedOut()));
connect(t, SIGNAL(loggedIn()),
this, SLOT(telnetLoggedIn()));
connect(t, SIGNAL(connectionError(QAbstractSocket::SocketError)),
this, SLOT(telnetConnectionError(QAbstractSocket::SocketError)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::telnetMessage(const QString &msg)
{
ui->textEdit->append(stripCR(msg));
//QScrollBar *s = ui->textEdit->verticalScrollBar();
//s->setValue(s->maximum());
}
void MainWindow::telnetLoginRequired()
{
}
void MainWindow::telnetLoginFailed()
{
}
void MainWindow::telnetLoggedOut()
{
}
void MainWindow::telnetLoggedIn()
{
}
void MainWindow::telnetConnectionError(QAbstractSocket::SocketError error)
{
ui->lineEdit_status->setText(QString("Connection error: %1").arg(error));
}
void MainWindow::on_pushButton_connect_clicked()
{
t->connectToHost("localhost",5401);
}
QString MainWindow::stripCR(const QString &msg)
{
QString nmsg(msg);
nmsg.remove('\r');
nmsg.remove(QRegExp("\033\\[[0-9;]*[A-Za-z]")); // Also remove terminal control codes
return nmsg;
}
void MainWindow::on_pushButton_Send_clicked()
{
QString aux;
aux = ui->lineEdit_data->text();
t->sendData(aux);
ui->lineEdit_data->clear();
}