added errorwin and passwdwin

added function to read password
small changes
This commit is contained in:
arcan1s 2014-02-08 17:40:29 +04:00
parent b439906be4
commit da7f1488c8
12 changed files with 628 additions and 23 deletions

View File

@ -0,0 +1,54 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "errorwindow.h"
#include "ui_errorwindow.h"
ErrorWindow::ErrorWindow(QWidget *parent, int messageNumber)
: QMainWindow(parent),
ui(new Ui::ErrorWindow)
{
ui->setupUi(this);
setMessage(messageNumber);
}
ErrorWindow::~ErrorWindow()
{
delete ui;
}
void ErrorWindow::setMessage(int mess)
{
QString message;
switch(mess) {
case 0:
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
case 1:
message = QApplication::translate("ErrorWindow", "Could not find components");
break;
case 2:
message = QApplication::translate("ErrorWindow", "Doesn't support yet");
break;
default:
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
ui->label->setText(message);
}

View File

@ -0,0 +1,41 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ERRORWINDOW_H
#define ERRORWINDOW_H
#include <QMainWindow>
namespace Ui {
class ErrorWindow;
}
class ErrorWindow : public QMainWindow
{
Q_OBJECT
public:
explicit ErrorWindow(QWidget *parent = 0, int messageNumber = 0);
~ErrorWindow();
private:
Ui::ErrorWindow *ui;
void setMessage(int mess);
};
#endif /* ERRORWINDOW_H */

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ErrorWindow</class>
<widget class="QMainWindow" name="ErrorWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>101</height>
</rect>
</property>
<property name="windowTitle">
<string>Error</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_main">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Error text</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_button">
<item>
<spacer name="spacer_button1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_button2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked(bool)</signal>
<receiver>ErrorWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>143</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>252</x>
<y>80</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -21,7 +21,9 @@
#include <QMimeData> #include <QMimeData>
#include <QProcess> #include <QProcess>
#include "errorwindow.h"
#include "netctlinteract.h" #include "netctlinteract.h"
#include "passwdwidget.h"
#include "wpasupinteract.h" #include "wpasupinteract.h"
#include <cstdio> #include <cstdio>
@ -114,6 +116,8 @@ void MainWindow::createActions()
// wifi page events // wifi page events
connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab())); connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab()));
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *))); connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
} }
@ -130,10 +134,13 @@ void MainWindow::updateTabs(const int tab)
void MainWindow::updateMainTab() void MainWindow::updateMainTab()
{ {
if (!checkExternalApps(QString("netctl"))) if (!checkExternalApps(QString("netctl"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return; return;
}
ui->tableWidget_main->setDisabled(true); ui->tabWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileList();; QList<QStringList> profiles = netctlCommand->getProfileList();;
ui->tableWidget_main->setSortingEnabled(false); ui->tableWidget_main->setSortingEnabled(false);
@ -160,7 +167,7 @@ void MainWindow::updateMainTab()
ui->tableWidget_main->setSortingEnabled(true); ui->tableWidget_main->setSortingEnabled(true);
ui->tableWidget_main->resizeRowsToContents(); ui->tableWidget_main->resizeRowsToContents();
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
ui->tableWidget_main->setEnabled(true); ui->tabWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
update(); update();
@ -170,12 +177,15 @@ void MainWindow::updateMainTab()
void MainWindow::updateWifiTab() void MainWindow::updateWifiTab()
{ {
wifiTabSetEnabled(checkExternalApps(QString("wpasup"))); wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
if (!checkExternalApps(QString("wpasup"))) if (!checkExternalApps(QString("wpasup"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return; return;
}
QList<QStringList> scanResults = wpaCommand->scanWifi(); QList<QStringList> scanResults = wpaCommand->scanWifi();
ui->tableWidget_wifi->setDisabled(true); ui->tabWidget->setDisabled(true);
ui->tableWidget_wifi->setSortingEnabled(false); ui->tableWidget_wifi->setSortingEnabled(false);
ui->tableWidget_wifi->selectRow(-1); ui->tableWidget_wifi->selectRow(-1);
ui->tableWidget_wifi->sortByColumn(0, Qt::AscendingOrder); ui->tableWidget_wifi->sortByColumn(0, Qt::AscendingOrder);
@ -203,7 +213,7 @@ void MainWindow::updateWifiTab()
ui->tableWidget_wifi->setSortingEnabled(true); ui->tableWidget_wifi->setSortingEnabled(true);
ui->tableWidget_wifi->resizeRowsToContents(); ui->tableWidget_wifi->resizeRowsToContents();
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
ui->tableWidget_wifi->setEnabled(true); ui->tabWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
update(); update();
@ -213,10 +223,15 @@ void MainWindow::updateWifiTab()
// main tab slots // main tab slots
void MainWindow::mainTabEnableProfile() void MainWindow::mainTabEnableProfile()
{ {
if (!checkExternalApps(QString("netctl"))) if (!checkExternalApps(QString("netctl"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return; return;
ui->tableWidget_main->setDisabled(true); ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->enableProfile(profile); netctlCommand->enableProfile(profile);
if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("enabled")) > -1) { if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("enabled")) > -1) {
@ -231,34 +246,42 @@ void MainWindow::mainTabEnableProfile()
else else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
} }
ui->tableWidget_main->setEnabled(true);
updateMainTab(); updateMainTab();
} }
void MainWindow::mainTabRestartProfile() void MainWindow::mainTabRestartProfile()
{ {
if (!checkExternalApps(QString("netctl"))) if (!checkExternalApps(QString("netctl"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return; return;
ui->tableWidget_main->setDisabled(true); ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->restartProfile(profile); netctlCommand->restartProfile(profile);
if (netctlCommand->isProfileActive(profile)) if (netctlCommand->isProfileActive(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
ui->tableWidget_main->setEnabled(true);
updateMainTab(); updateMainTab();
} }
void MainWindow::mainTabStartProfile() void MainWindow::mainTabStartProfile()
{ {
if (!checkExternalApps(QString("netctl"))) if (!checkExternalApps(QString("netctl"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return; return;
ui->tableWidget_main->setDisabled(true); ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->startProfile(profile); netctlCommand->startProfile(profile);
if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("inactive")) == -1) { if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("inactive")) == -1) {
@ -273,7 +296,6 @@ void MainWindow::mainTabStartProfile()
else else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
} }
ui->tableWidget_main->setEnabled(true);
updateMainTab(); updateMainTab();
} }
@ -281,10 +303,20 @@ void MainWindow::mainTabStartProfile()
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous) void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{ {
Q_UNUSED(previous); Q_UNUSED(previous);
if (current == 0) if (!checkExternalApps(QString("netctl"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return; return;
if (!checkExternalApps(QString("netctl"))) }
if (current == 0) {
ui->pushButton_mainEnable->setDisabled(true);
ui->pushButton_mainRestart->setDisabled(true);
ui->pushButton_mainStart->setDisabled(true);
return; return;
}
ui->pushButton_mainEnable->setEnabled(true);
ui->pushButton_mainStart->setEnabled(true);
QString item = ui->tableWidget_main->item(current->row(), 2)->text(); QString item = ui->tableWidget_main->item(current->row(), 2)->text();
if (!checkState(QString("inactive"), item)) { if (!checkState(QString("inactive"), item)) {
@ -320,15 +352,105 @@ void MainWindow::wifiTabSetEnabled(bool state)
} }
void MainWindow::connectToUnknownEssid(QString passwd)
{
if (!passwd.isEmpty())
delete passwdwid;
QStringList profileInfo;
profileInfo.append(QString("Automatically generated profile by Netctl GUI"));
profileInfo.append(wpaCommand->getInterfaceList()[0]);
profileInfo.append(QString("wireless"));
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
if (checkState(QString("WPA"), security))
profileInfo.append(QString("wpa"));
else if (checkState(QString("wep"), security))
profileInfo.append(QString("wep"));
else
profileInfo.append(QString("none"));
profileInfo.append(ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text());
profileInfo.append(passwd);
profileInfo.append(QString("dhcp"));
updateWifiTab();
}
void MainWindow::wifiTabStart()
{
if (!checkExternalApps(QString("wpasup"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return;
}
if (ui->tableWidget_wifi->currentItem() == 0)
return;
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
ui->pushButton_wifiStart->setDisabled(true);
errorwin = new ErrorWindow(this, 2);
errorwin->show();
return;
}
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
if (checkState(QString("exists"), item)) {
QString profileName = wpaCommand->existentProfile(profile);
netctlCommand->startProfile(profileName);
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text().indexOf(QString("inactive")) == -1) {
if (netctlCommand->isProfileActive(profileName))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
}
else {
if (netctlCommand->isProfileActive(profileName))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
}
else {
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
if (checkState(QString("none"), security))
return connectToUnknownEssid(QString(""));
else {
passwdwid = new PasswdWidget(this);
int widgetWidth = 270;
int widgetHeight = 86;
int x = (width() - widgetWidth) / 2;
int y = (height() - widgetHeight) / 2;
passwdwid->setGeometry(x, y, widgetWidth, widgetHeight);
passwdwid->show();
passwdwid->setFocusToLineEdit();
return;
}
}
updateWifiTab();
}
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous) void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{ {
Q_UNUSED(previous); Q_UNUSED(previous);
if (current == 0) if (!checkExternalApps(QString("wpasup"))) {
errorwin = new ErrorWindow(this, 1);
errorwin->show();
return; return;
if (!checkExternalApps(QString("wpasup"))) }
if (current == 0) {
ui->pushButton_wifiStart->setDisabled(true);
return; return;
}
if (ui->tableWidget_wifi->item(current->row(), 0)->text() == QString("<hidden>")) {
ui->pushButton_wifiStart->setDisabled(true);
return;
}
QString item = ui->tableWidget_wifi->item(current->row(), 3)->text(); ui->pushButton_wifiStart->setEnabled(true);
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
if (checkState(QString("exists"), item)) { if (checkState(QString("exists"), item)) {
if (!checkState(QString("inactive"), item)) if (!checkState(QString("inactive"), item))
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop")); ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop"));

View File

@ -24,7 +24,9 @@
#include <QMainWindow> #include <QMainWindow>
class ErrorWindow;
class Netctl; class Netctl;
class PasswdWidget;
class WpaSup; class WpaSup;
namespace Ui { namespace Ui {
@ -48,9 +50,13 @@ public:
wpaConfDir = 4, wpaConfDir = 4,
wpaConfGroup = 5 wpaConfGroup = 5
}; };
public slots:
void updateTabs(const int tab);
// wifi tab slots
void connectToUnknownEssid(QString passwd);
private slots: private slots:
void updateTabs(const int tab);
void updateMainTab(); void updateMainTab();
void updateWifiTab(); void updateWifiTab();
// main tab slots // main tab slots
@ -60,10 +66,13 @@ private slots:
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous); void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// wifi tab slots // wifi tab slots
void wifiTabSetEnabled(bool state); void wifiTabSetEnabled(bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous); void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
ErrorWindow *errorwin;
PasswdWidget *passwdwid;
bool checkExternalApps(QString apps); bool checkExternalApps(QString apps);
bool checkState(QString state, QString item); bool checkState(QString state, QString item);
void createActions(); void createActions();

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>Netctl GUI</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -101,6 +101,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_mainEnable"> <widget class="QPushButton" name="pushButton_mainEnable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Enable</string> <string>Enable</string>
</property> </property>
@ -111,6 +114,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_mainRestart"> <widget class="QPushButton" name="pushButton_mainRestart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Restart</string> <string>Restart</string>
</property> </property>
@ -121,6 +127,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_mainStart"> <widget class="QPushButton" name="pushButton_mainStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Start</string> <string>Start</string>
</property> </property>
@ -225,6 +234,9 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_wifiStart"> <widget class="QPushButton" name="pushButton_wifiStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Start</string> <string>Start</string>
</property> </property>

View File

@ -44,6 +44,7 @@ public slots:
bool enableProfile(QString profile); bool enableProfile(QString profile);
bool restartProfile(QString profile); bool restartProfile(QString profile);
bool startProfile(QString profile); bool startProfile(QString profile);
// bool createProfile(QStringList profileInfo);
private: private:
MainWindow *parent; MainWindow *parent;

View File

@ -0,0 +1,68 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "passwdwidget.h"
#include "ui_passwdwidget.h"
#include "mainwindow.h"
PasswdWidget::PasswdWidget(MainWindow *wid)
: QWidget(wid),
parent(wid),
ui(new Ui::PasswdWidget)
{
ui->setupUi(this);
createActions();
}
PasswdWidget::~PasswdWidget()
{
delete ui;
}
// ESC press event
void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Escape) {
hide();
parent->updateTabs(2);
this->~PasswdWidget();
}
}
void PasswdWidget::createActions()
{
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply()));
connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(passwdApply()));
}
void PasswdWidget::setFocusToLineEdit()
{
ui->lineEdit->setFocus(Qt::ActiveWindowFocusReason);
}
void PasswdWidget::passwdApply()
{
hide();
return parent->connectToUnknownEssid(ui->lineEdit->text());
}

View File

@ -0,0 +1,54 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PASSWDWIDGET_H
#define PASSWDWIDGET_H
#include <QKeyEvent>
#include <QWidget>
class MainWindow;
namespace Ui {
class PasswdWidget;
}
class PasswdWidget : public QWidget
{
Q_OBJECT
public:
explicit PasswdWidget(MainWindow *wid = 0);
~PasswdWidget();
public slots:
void setFocusToLineEdit();
private slots:
void passwdApply();
private:
MainWindow *parent;
Ui::PasswdWidget *ui;
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
void createActions();
};
#endif /* PASSWDWIDGET_H */

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PasswdWidget</class>
<widget class="QWidget" name="PasswdWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>86</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_passwd">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_button">
<item>
<spacer name="spacer_button1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_button2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -49,7 +49,8 @@ QStringList WpaSup::getInterfaceList()
{ {
QStringList interfaces; QStringList interfaces;
interfaces.append(mainInterface); if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) for (int i=0; i<allInterfaces.count(); i++)
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
@ -110,6 +111,17 @@ bool WpaSup::isProfileExists(QString profile)
} }
QString WpaSup::existentProfile(QString profile)
{
QString profileFile = QString("");
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
profileFile = profileList[i][0];
return profileFile;
}
bool WpaSup::startWpaSupplicant() bool WpaSup::startWpaSupplicant()
{ {
if (!QFile(wpaConf[2]).exists()) { if (!QFile(wpaConf[2]).exists()) {

View File

@ -37,6 +37,7 @@ public:
bool wpaCliCall(QString commandLine); bool wpaCliCall(QString commandLine);
QString getWpaCliOutput(QString commandLine); QString getWpaCliOutput(QString commandLine);
bool isProfileExists(QString profile); bool isProfileExists(QString profile);
QString existentProfile(QString profile);
bool isProfileActive(QString profile); bool isProfileActive(QString profile);
public slots: public slots: