mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
added errorwin and passwdwin
added function to read password small changes
This commit is contained in:
parent
b439906be4
commit
da7f1488c8
54
sources/gui/src/errorwindow.cpp
Normal file
54
sources/gui/src/errorwindow.cpp
Normal 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);
|
||||
}
|
41
sources/gui/src/errorwindow.h
Normal file
41
sources/gui/src/errorwindow.h
Normal 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 */
|
123
sources/gui/src/errorwindow.ui
Normal file
123
sources/gui/src/errorwindow.ui
Normal 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>
|
@ -21,7 +21,9 @@
|
||||
#include <QMimeData>
|
||||
#include <QProcess>
|
||||
|
||||
#include "errorwindow.h"
|
||||
#include "netctlinteract.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "wpasupinteract.h"
|
||||
#include <cstdio>
|
||||
|
||||
@ -114,6 +116,8 @@ void MainWindow::createActions()
|
||||
|
||||
// wifi page events
|
||||
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 *)));
|
||||
}
|
||||
|
||||
@ -130,10 +134,13 @@ void MainWindow::updateTabs(const int tab)
|
||||
|
||||
void MainWindow::updateMainTab()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl")))
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorwin = new ErrorWindow(this, 1);
|
||||
errorwin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
ui->tableWidget_main->setDisabled(true);
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QList<QStringList> profiles = netctlCommand->getProfileList();;
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
@ -160,7 +167,7 @@ void MainWindow::updateMainTab()
|
||||
ui->tableWidget_main->setSortingEnabled(true);
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
ui->tableWidget_main->setEnabled(true);
|
||||
ui->tabWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
|
||||
|
||||
update();
|
||||
@ -170,12 +177,15 @@ void MainWindow::updateMainTab()
|
||||
void MainWindow::updateWifiTab()
|
||||
{
|
||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
||||
if (!checkExternalApps(QString("wpasup")))
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorwin = new ErrorWindow(this, 1);
|
||||
errorwin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QStringList> scanResults = wpaCommand->scanWifi();
|
||||
|
||||
ui->tableWidget_wifi->setDisabled(true);
|
||||
ui->tabWidget->setDisabled(true);
|
||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||
ui->tableWidget_wifi->selectRow(-1);
|
||||
ui->tableWidget_wifi->sortByColumn(0, Qt::AscendingOrder);
|
||||
@ -203,7 +213,7 @@ void MainWindow::updateWifiTab()
|
||||
ui->tableWidget_wifi->setSortingEnabled(true);
|
||||
ui->tableWidget_wifi->resizeRowsToContents();
|
||||
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
ui->tableWidget_wifi->setEnabled(true);
|
||||
ui->tabWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
|
||||
|
||||
update();
|
||||
@ -213,10 +223,15 @@ void MainWindow::updateWifiTab()
|
||||
// main tab slots
|
||||
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;
|
||||
|
||||
ui->tableWidget_main->setDisabled(true);
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->enableProfile(profile);
|
||||
if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("enabled")) > -1) {
|
||||
@ -231,34 +246,42 @@ void MainWindow::mainTabEnableProfile()
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
ui->tableWidget_main->setEnabled(true);
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
ui->tableWidget_main->setDisabled(true);
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->restartProfile(profile);
|
||||
if (netctlCommand->isProfileActive(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
ui->tableWidget_main->setEnabled(true);
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
ui->tableWidget_main->setDisabled(true);
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->startProfile(profile);
|
||||
if (ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().indexOf(QString("inactive")) == -1) {
|
||||
@ -273,7 +296,6 @@ void MainWindow::mainTabStartProfile()
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
ui->tableWidget_main->setEnabled(true);
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
@ -281,10 +303,20 @@ void MainWindow::mainTabStartProfile()
|
||||
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (current == 0)
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorwin = new ErrorWindow(this, 1);
|
||||
errorwin->show();
|
||||
return;
|
||||
if (!checkExternalApps(QString("netctl")))
|
||||
}
|
||||
if (current == 0) {
|
||||
ui->pushButton_mainEnable->setDisabled(true);
|
||||
ui->pushButton_mainRestart->setDisabled(true);
|
||||
ui->pushButton_mainStart->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->pushButton_mainEnable->setEnabled(true);
|
||||
ui->pushButton_mainStart->setEnabled(true);
|
||||
|
||||
QString item = ui->tableWidget_main->item(current->row(), 2)->text();
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (current == 0)
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorwin = new ErrorWindow(this, 1);
|
||||
errorwin->show();
|
||||
return;
|
||||
if (!checkExternalApps(QString("wpasup")))
|
||||
}
|
||||
if (current == 0) {
|
||||
ui->pushButton_wifiStart->setDisabled(true);
|
||||
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("inactive"), item))
|
||||
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop"));
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
class ErrorWindow;
|
||||
class Netctl;
|
||||
class PasswdWidget;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
@ -49,8 +51,12 @@ public:
|
||||
wpaConfGroup = 5
|
||||
};
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void updateTabs(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(QString passwd);
|
||||
|
||||
private slots:
|
||||
void updateMainTab();
|
||||
void updateWifiTab();
|
||||
// main tab slots
|
||||
@ -60,10 +66,13 @@ private slots:
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// wifi tab slots
|
||||
void wifiTabSetEnabled(bool state);
|
||||
void wifiTabStart();
|
||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ErrorWindow *errorwin;
|
||||
PasswdWidget *passwdwid;
|
||||
bool checkExternalApps(QString apps);
|
||||
bool checkState(QString state, QString item);
|
||||
void createActions();
|
||||
|
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>Netctl GUI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@ -101,6 +101,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainEnable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
@ -111,6 +114,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
@ -121,6 +127,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
@ -225,6 +234,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
|
@ -44,6 +44,7 @@ public slots:
|
||||
bool enableProfile(QString profile);
|
||||
bool restartProfile(QString profile);
|
||||
bool startProfile(QString profile);
|
||||
// bool createProfile(QStringList profileInfo);
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
|
68
sources/gui/src/passwdwidget.cpp
Normal file
68
sources/gui/src/passwdwidget.cpp
Normal 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());
|
||||
}
|
54
sources/gui/src/passwdwidget.h
Normal file
54
sources/gui/src/passwdwidget.h
Normal 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 */
|
108
sources/gui/src/passwdwidget.ui
Normal file
108
sources/gui/src/passwdwidget.ui
Normal 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>
|
@ -49,7 +49,8 @@ QStringList WpaSup::getInterfaceList()
|
||||
{
|
||||
QStringList interfaces;
|
||||
|
||||
interfaces.append(mainInterface);
|
||||
if (!mainInterface.isEmpty())
|
||||
interfaces.append(mainInterface);
|
||||
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<allInterfaces.count(); 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()
|
||||
{
|
||||
if (!QFile(wpaConf[2]).exists()) {
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
bool wpaCliCall(QString commandLine);
|
||||
QString getWpaCliOutput(QString commandLine);
|
||||
bool isProfileExists(QString profile);
|
||||
QString existentProfile(QString profile);
|
||||
bool isProfileActive(QString profile);
|
||||
|
||||
public slots:
|
||||
|
Loading…
Reference in New Issue
Block a user