-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidget.cpp
executable file
·107 lines (84 loc) · 1.89 KB
/
widget.cpp
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "widget.h"
#include "ui_widget.h"
extern "C"{
#include "ftpclient.h"
}
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setLogin(false);
ui->comboBox->setEnabled(false);
ui->commandBtn->setEnabled(false);
}
Widget::~Widget()
{
delete ui;
}
bool Widget::isLogin()
{
return login;
}
void Widget::setLogin(bool value){
login = value;
}
void Widget::setCommand(QString c)
{
command = c;
}
QString Widget::getCommand()
{
return command;
}
void Widget::on_connectBtn_clicked()
{
QFont font("wenquanyi",12,QFont::Bold);
ld.show();
ld.setFont(font);
if(ld.exec() == QDialog::Accepted && this->isLogin() == false){
this->setLogin(true);
ui->connectBtn->setText("Logout");
ui->comboBox->setEnabled(true);
ui->commandBtn->setEnabled(true);
ui->connectBtn->setEnabled(false);
this->setWindowState(Qt::WindowActive);
}
#if 0
else if(this->isLogin() == true){
QString quit="quit";
//command = quit.toLatin1().data();
//handle_user_input(command);
handle_user_input(quit.toLatin1().data());
//this->setLogin(false);
}
#endif
}
void Widget::on_comboBox_activated(QString cmd)
{
this->setCommand(cmd);
}
void Widget::on_commandBtn_clicked()
{
char *cmd = NULL;
cmd = this->getCommand().toLatin1().data();
test(cmd);
handle_user_input(cmd);
QString content;
char *str;
str = handle_server_ack();
content = QString(QLatin1String(str)) ;
ui->textBrowser->setText(content);
}
void Widget::on_quitBtn_clicked()
{
QString quit="quit";
if(this->isLogin() == true){
command = quit.toLatin1().data();
//handle_user_input(command);
handle_user_input(quit.toLatin1().data());
this->close();
}else{
this->close();
}
}