-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.cpp
69 lines (51 loc) · 1.36 KB
/
login.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
#include "login.h"
#include "ui_login.h"
#include "mainwindow.h"
#include "qftp.h"
#include <QDataStream>
#include <QFile>
Login::Login(QWidget *parent) :
QDialog(parent),
ui(new Ui::Login)
{
ui->setupUi(this);
ui->pwdText->setEchoMode(QLineEdit::Password);
readInfo();
connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(connectFtp()));
connect(this, SIGNAL(sendConnectInfo(QString,QString,QString)), parentWidget(), SLOT(connectFtp(QString,QString,QString)));
}
void Login::connectFtp()
{
emit sendConnectInfo(ui->ipText->text(), ui->idText->text(), ui->pwdText->text());
}
void Login::readInfo()
{
QFile file("temp.dat"); //FIXME
if(!file.open(QFile::ReadOnly| QFile::Text)) {
qDebug()<<"cannot read file";
}
QDataStream in(&file);
in.setVersion(QDataStream::Qt_5_3);
QString ip, id, pwd;
in >> ip >> id >> pwd;
ui->ipText->insert(ip);
ui->idText->insert(id);
ui->pwdText->insert(pwd);
file.close();
}
void Login::writeInfo()
{
QFile file("temp.dat"); //FIXME
if(!file.open(QFile::WriteOnly | QFile::Text)) {
qDebug()<<"cannot write file";
}
QDataStream out(&file);
out.setVersion(QDataStream::Qt_5_3);
out << ui->ipText->text() << ui->idText->text() << ui->pwdText->text();
file.close();
//TODO Check Error
}
Login::~Login()
{
delete ui;
}