-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwificonnectdialog.cpp
52 lines (46 loc) · 1.66 KB
/
wificonnectdialog.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
#include "wificonnectdialog.h"
#include "ui_wificonnectdialog.h"
#include "networkmanager.h"
#include <QMessageBox>
#include <QDebug>
WifiConnectDialog::WifiConnectDialog(NetworkService *service, QWidget *parent) :
QDialog(parent),
ui(new Ui::WifiConnectDialog)
{
ui->setupUi(this);
setModal(true);
mCurrentNetworkService = service;
ui->labelName->setText(service->name());
ui->progressBar->setValue(service->strength());
ui->linePassword->setEnabled(service->securityType() > 1);
connect(ui->checkBox, SIGNAL(toggled(bool)), SLOT(checkChanged()));
connect(ui->pushConnect, SIGNAL(clicked(bool)), SLOT(connectClicked()));
connect(service, SIGNAL(connectRequestFailed(QString)), SLOT(connectRequestFailed(QString)));
connect(service, SIGNAL(connectedChanged(bool)), SLOT(connectedChanged()));
}
WifiConnectDialog::~WifiConnectDialog()
{
delete ui;
}
void WifiConnectDialog::checkChanged()
{
ui->linePassword->setEchoMode(ui->checkBox->isChecked() ? QLineEdit::Normal : QLineEdit::Password);
}
void WifiConnectDialog::connectClicked()
{
//qDebug() << mCurrentNetworkService-> << " : " << mCurrentNetworkService->available();
//NetworkManager::instance()->registerAgent(mCurrentNetworkService->path());
mCurrentNetworkService->setPassphrase(ui->linePassword->text());
mCurrentNetworkService->requestConnect();
ui->pushConnect->setEnabled(false);
}
void WifiConnectDialog::connectRequestFailed(const QString &error)
{
QMessageBox::critical(this, tr("Error"), error);
ui->pushConnect->setEnabled(true);
}
void WifiConnectDialog::connectedChanged()
{
if(mCurrentNetworkService->connected())
close();
}