mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
started work on wifi-menu
This commit is contained in:
parent
121ba0e54f
commit
fc43861ba6
@ -19,6 +19,7 @@
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "netctlinteract.h"
|
||||
#include "wpasupinteract.h"
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
@ -37,8 +38,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
netctlPath = QString("/usr/bin/netctl");
|
||||
profileDir = QString("/etc/netctl");
|
||||
sudoPath = QString("/usr/bin/kdesu -c");
|
||||
wpaCliPath = QString("/usr/bin/wpa_cli");
|
||||
ifaceDir = QString("/sys/class/net/");
|
||||
|
||||
netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath);
|
||||
wpaCliCommand = new WpaSup(this, wpaCliPath, ifaceDir);
|
||||
|
||||
createActions();
|
||||
updateMainTab();
|
||||
@ -71,6 +75,8 @@ void MainWindow::updateTabs(const int tab)
|
||||
{
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +104,12 @@ void MainWindow::updateMainTab()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateWifiTab()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// main tab slots
|
||||
void MainWindow::mainTabEnableProfile()
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
|
||||
class Netctl;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -41,6 +42,7 @@ public:
|
||||
private slots:
|
||||
void updateTabs(const int tab);
|
||||
void updateMainTab();
|
||||
void updateWifiTab();
|
||||
// main tab slots
|
||||
void mainTabEnableProfile();
|
||||
void mainTabRestartProfile();
|
||||
@ -49,12 +51,16 @@ private slots:
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand;
|
||||
WpaSup *wpaCliCommand;
|
||||
Ui::MainWindow *ui;
|
||||
void createActions();
|
||||
// configuration
|
||||
QString netctlPath;
|
||||
QString profileDir;
|
||||
QString sudoPath;
|
||||
QString wpaCliPath;
|
||||
QString ifaceDir;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
||||
|
@ -17,6 +17,9 @@
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_main">
|
||||
<attribute name="title">
|
||||
<string>Connect to profile</string>
|
||||
@ -124,6 +127,91 @@
|
||||
<attribute name="title">
|
||||
<string>Connect to Wi-Fi</string>
|
||||
</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>
|
||||
</item>
|
||||
|
@ -41,6 +41,12 @@ Netctl::~Netctl()
|
||||
|
||||
|
||||
// general information
|
||||
QStringList Netctl::getProfileList()
|
||||
{
|
||||
return profileDirectory->entryList(QDir::Files);
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileDescriptions(QStringList profileList)
|
||||
{
|
||||
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 statuses;
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath);
|
||||
~Netctl();
|
||||
// general information
|
||||
QStringList getProfileDescriptions(QStringList profileList);
|
||||
QStringList getProfileList();
|
||||
QStringList getProfileDescriptions(QStringList profileList);
|
||||
QStringList getProfileStatuses(QStringList profileList);
|
||||
bool isProfileActive(QString profile);
|
||||
bool isProfileEnabled(QString profile);
|
||||
@ -49,4 +49,5 @@ private:
|
||||
QString sudoCommand;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLINTERACT_H */
|
||||
|
52
sources/gui/src/wpasupinteract.cpp
Normal file
52
sources/gui/src/wpasupinteract.cpp
Normal 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;
|
||||
}
|
44
sources/gui/src/wpasupinteract.h
Normal file
44
sources/gui/src/wpasupinteract.h
Normal 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 */
|
Loading…
Reference in New Issue
Block a user