started work on wifi-menu

This commit is contained in:
arcan1s 2014-02-05 00:28:02 +04:00
parent 121ba0e54f
commit fc43861ba6
7 changed files with 210 additions and 7 deletions

View File

@ -19,6 +19,7 @@
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "netctlinteract.h" #include "netctlinteract.h"
#include "wpasupinteract.h"
#include <cstdio> #include <cstdio>
@ -37,8 +38,11 @@ MainWindow::MainWindow(QWidget *parent)
netctlPath = QString("/usr/bin/netctl"); netctlPath = QString("/usr/bin/netctl");
profileDir = QString("/etc/netctl"); profileDir = QString("/etc/netctl");
sudoPath = QString("/usr/bin/kdesu -c"); sudoPath = QString("/usr/bin/kdesu -c");
wpaCliPath = QString("/usr/bin/wpa_cli");
ifaceDir = QString("/sys/class/net/");
netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath); netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath);
wpaCliCommand = new WpaSup(this, wpaCliPath, ifaceDir);
createActions(); createActions();
updateMainTab(); updateMainTab();
@ -71,6 +75,8 @@ void MainWindow::updateTabs(const int tab)
{ {
if (tab == 0) if (tab == 0)
updateMainTab(); updateMainTab();
else if (tab == 2)
updateWifiTab();
} }
@ -98,6 +104,12 @@ void MainWindow::updateMainTab()
} }
void MainWindow::updateWifiTab()
{
}
// main tab slots // main tab slots
void MainWindow::mainTabEnableProfile() void MainWindow::mainTabEnableProfile()
{ {

View File

@ -25,6 +25,7 @@
class Netctl; class Netctl;
class WpaSup;
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
@ -41,6 +42,7 @@ public:
private slots: private slots:
void updateTabs(const int tab); void updateTabs(const int tab);
void updateMainTab(); void updateMainTab();
void updateWifiTab();
// main tab slots // main tab slots
void mainTabEnableProfile(); void mainTabEnableProfile();
void mainTabRestartProfile(); void mainTabRestartProfile();
@ -49,12 +51,16 @@ private slots:
private: private:
Netctl *netctlCommand; Netctl *netctlCommand;
WpaSup *wpaCliCommand;
Ui::MainWindow *ui; Ui::MainWindow *ui;
void createActions(); void createActions();
// configuration // configuration
QString netctlPath; QString netctlPath;
QString profileDir; QString profileDir;
QString sudoPath; QString sudoPath;
QString wpaCliPath;
QString ifaceDir;
}; };
#endif /* MAINWINDOW_H */ #endif /* MAINWINDOW_H */

View File

@ -17,6 +17,9 @@
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_main"> <widget class="QWidget" name="tab_main">
<attribute name="title"> <attribute name="title">
<string>Connect to profile</string> <string>Connect to profile</string>
@ -124,6 +127,91 @@
<attribute name="title"> <attribute name="title">
<string>Connect to Wi-Fi</string> <string>Connect to Wi-Fi</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_wifi">
<property name="text">
<string>Please install 'wpa_supplicant' before using</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_wifi">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Signal</string>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wifiButtons">
<item>
<widget class="QPushButton" name="pushButton_wifiRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_wifiButtons">
<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_wifiStart">
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>

View File

@ -41,6 +41,12 @@ Netctl::~Netctl()
// general information // general information
QStringList Netctl::getProfileList()
{
return profileDirectory->entryList(QDir::Files);
}
QStringList Netctl::getProfileDescriptions(QStringList profileList) QStringList Netctl::getProfileDescriptions(QStringList profileList)
{ {
QStringList descriptions; QStringList descriptions;
@ -71,12 +77,6 @@ QStringList Netctl::getProfileDescriptions(QStringList profileList)
} }
QStringList Netctl::getProfileList()
{
return profileDirectory->entryList(QDir::Files);
}
QStringList Netctl::getProfileStatuses(QStringList profileList) QStringList Netctl::getProfileStatuses(QStringList profileList)
{ {
QStringList statuses; QStringList statuses;

View File

@ -32,8 +32,8 @@ public:
Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath); Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath);
~Netctl(); ~Netctl();
// general information // general information
QStringList getProfileDescriptions(QStringList profileList);
QStringList getProfileList(); QStringList getProfileList();
QStringList getProfileDescriptions(QStringList profileList);
QStringList getProfileStatuses(QStringList profileList); QStringList getProfileStatuses(QStringList profileList);
bool isProfileActive(QString profile); bool isProfileActive(QString profile);
bool isProfileEnabled(QString profile); bool isProfileEnabled(QString profile);
@ -49,4 +49,5 @@ private:
QString sudoCommand; QString sudoCommand;
}; };
#endif /* NETCTLINTERACT_H */ #endif /* NETCTLINTERACT_H */

View File

@ -0,0 +1,52 @@
/***************************************************************************
* 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 "wpasupinteract.h"
#include "mainwindow.h"
#include <cstdio>
WpaSup::WpaSup(MainWindow *wid, QString wpaCliPath, QString ifaceDir)
: parent(wid),
wpaCliCommand(wpaCliPath),
ifaceDirectory(new QDir(ifaceDir))
{
}
WpaSup::~WpaSup()
{
delete ifaceDirectory;
}
// general information
QStringList WpaSup::getInterfaceList()
{
QStringList interfaces;
QStringList allInterfaces;
allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++)
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
return interfaces;
}

View File

@ -0,0 +1,44 @@
/***************************************************************************
* 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 WPASUPINTERACT_H
#define WPASUPINTERACT_H
#include <QDir>
#include <QWidget>
class MainWindow;
class WpaSup : public QWidget
{
Q_OBJECT
public:
WpaSup(MainWindow *wid, QString wpaCliPath, QString ifaceDir);
~WpaSup();
// general information
QStringList getInterfaceList();
private:
MainWindow *parent;
QString wpaCliCommand;
QDir *ifaceDirectory;
};
#endif /* WPASUPINTERACT_H */