mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
intermediate commit
This commit is contained in:
parent
026f08d0cf
commit
23df40960c
@ -48,7 +48,7 @@ void EthernetWidget::clear()
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
ui->pushButton_ethernetAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ void EthernetWidget::selectWpaConfig()
|
||||
|
||||
void EthernetWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ethernetAdvanced->text().indexOf(QString("Show")) > -1) {
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setShown(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
}
|
||||
|
@ -44,6 +44,9 @@
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -57,7 +57,7 @@ void GeneralWidget::clear()
|
||||
ui->lineEdit_execDownPre->clear();
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
ui->pushButton_generalAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
void GeneralWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_generalAdvanced->text().indexOf(QString("Show")) > -1) {
|
||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||
ui->widget_generalAdvanced->setShown(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
}
|
||||
|
@ -217,6 +217,9 @@
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -76,7 +76,7 @@ void IpWidget::clear()
|
||||
ui->lineEdit_dnsOptions->clear();
|
||||
ui->listWidget_dnsOptions->clear();
|
||||
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
ui->pushButton_ipAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ void IpWidget::changeDhcpClient(int index)
|
||||
|
||||
void IpWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ipAdvanced->text().indexOf(QString("Show")) > -1) {
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setShown(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>430</width>
|
||||
<height>1287</height>
|
||||
<height>1353</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -270,6 +270,9 @@
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -59,14 +59,16 @@ MainWindow::MainWindow(QWidget *parent, bool defaultSettings, int tabNum)
|
||||
sudoPath = QString("/usr/bin/kdesu");
|
||||
wpaConfig.append(QString("/usr/bin/wpa_cli"));
|
||||
wpaConfig.append(QString("/usr/bin/wpa_supplicant"));
|
||||
ifaceDir = QString("/sys/class/net/");
|
||||
preferedInterface = QString("");
|
||||
//// additional settings
|
||||
ifaceDir = QString("/sys/class/net/");
|
||||
rfkillDir = QString("/sys/class/rfkill/");
|
||||
wpaConfig.append(QString("/run/wpa_supplicant_netctl-gui.pid"));
|
||||
wpaConfig.append(QString("nl80211,wext"));
|
||||
wpaConfig.append(QString("/run/wpa_supplicant_netctl-gui"));
|
||||
wpaConfig.append(QString("users"));
|
||||
|
||||
|
||||
// gui
|
||||
generalWid = new GeneralWidget(this, ifaceDir, profileDir);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
@ -86,7 +88,7 @@ MainWindow::MainWindow(QWidget *parent, bool defaultSettings, int tabNum)
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this);
|
||||
wirelessWid = new WirelessWidget(this, rfkillDir);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
// backend
|
||||
netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath);
|
||||
|
@ -104,12 +104,13 @@ private:
|
||||
bool checkState(QString state, QString item);
|
||||
void createActions();
|
||||
// configuration
|
||||
QString ifaceDir;
|
||||
QString netctlPath;
|
||||
QString preferedInterface;
|
||||
QString profileDir;
|
||||
QString rfkillDir;
|
||||
QString sudoPath;
|
||||
QStringList wpaConfig;
|
||||
QString ifaceDir;
|
||||
QString preferedInterface;
|
||||
};
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ void MobileWidget::clear()
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
ui->lineEdit_options->clear();
|
||||
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
ui->pushButton_mobileAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void MobileWidget::selectOptionsFile()
|
||||
|
||||
void MobileWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_mobileAdvanced->text().indexOf(QString("Show")) > -1) {
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setShown(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>445</width>
|
||||
<height>367</height>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -189,6 +189,9 @@
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -60,7 +60,7 @@ void PppoeWidget::clear()
|
||||
ui->lineEdit_mac->clear();
|
||||
ui->checkBox_ipv6->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
ui->pushButton_pppoeAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ void PppoeWidget::selectOptionsFile()
|
||||
|
||||
void PppoeWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_pppoeAdvanced->text().indexOf(QString("Show")) > -1) {
|
||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||
ui->widget_pppoeAdvanced->setShown(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>573</height>
|
||||
<height>602</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -161,6 +161,9 @@
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -18,16 +18,191 @@
|
||||
#include "wirelesswidget.h"
|
||||
#include "ui_wirelesswidget.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QKeyEvent>
|
||||
|
||||
WirelessWidget::WirelessWidget(QWidget *parent)
|
||||
|
||||
WirelessWidget::WirelessWidget(QWidget *parent, QString rfkillDir)
|
||||
: QWidget(parent),
|
||||
rfkillDirectory(new QDir(rfkillDir)),
|
||||
ui(new Ui::WirelessWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
WirelessWidget::~WirelessWidget()
|
||||
{
|
||||
delete rfkillDirectory;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::clear()
|
||||
{
|
||||
ui->comboBox_security->setCurrentIndex(0);
|
||||
changeSecurity(ui->comboBox_security->currentIndex());
|
||||
ui->lineEdit_essid->clear();
|
||||
ui->lineEdit_wpaConfigSection->clear();
|
||||
ui->listWidget_wpaConfigSection->clear();
|
||||
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
|
||||
ui->lineEdit_key->clear();
|
||||
ui->checkBox_hidden->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_adhoc->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_freq->setValue(2412);
|
||||
ui->listWidget_freq->clear();
|
||||
ui->spinBox_priority->setValue(0);
|
||||
ui->lineEdit_country->clear();
|
||||
ui->lineEdit_wpaGroup->clear();
|
||||
ui->comboBox_drivers->setCurrentIndex(0);
|
||||
ui->listWidget_drivers->clear();
|
||||
ui->comboBox_rfkill->addItem(QString("auto"));
|
||||
if (rfkillDirectory->exists()) {
|
||||
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<rfkillDevices.count(); i++) {
|
||||
QFile device(rfkillDirectory->absolutePath() + QDir::separator() + rfkillDevices[i] +
|
||||
QDir::separator() + QString("name"));
|
||||
QString deviceName;
|
||||
if (device.open(QIODevice::ReadOnly))
|
||||
deviceName = QString(device.readLine()).remove(QString("\n"));
|
||||
ui->comboBox_rfkill->addItem(deviceName);
|
||||
}
|
||||
}
|
||||
ui->comboBox_rfkill->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_wirelessAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_wirelessAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_drivers, SIGNAL(clicked(bool)), this, SLOT(addDriver()));
|
||||
connect(ui->pushButton_freq, SIGNAL(clicked(bool)), this, SLOT(addFreq()));
|
||||
connect(ui->pushButton_wpaConfigSection, SIGNAL(clicked(bool)), this, SLOT(addOption()));
|
||||
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
|
||||
connect(ui->comboBox_security, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSecurity(int)));
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_wpaConfigSection->hasFocus() &&
|
||||
(ui->listWidget_wpaConfigSection->currentItem() != 0))
|
||||
delete ui->listWidget_wpaConfigSection->currentItem();
|
||||
else if (ui->listWidget_freq->hasFocus() &&
|
||||
(ui->listWidget_freq->currentItem() != 0))
|
||||
delete ui->listWidget_freq->currentItem();
|
||||
else if (ui->listWidget_drivers->hasFocus() &&
|
||||
(ui->listWidget_drivers->currentItem() != 0))
|
||||
delete ui->listWidget_drivers->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addDriver()
|
||||
{
|
||||
QString driver = ui->comboBox_drivers->currentText();
|
||||
bool exists = false;
|
||||
for (int i=0; i<ui->listWidget_drivers->count(); i++)
|
||||
if (ui->listWidget_drivers->item(i)->text() == driver)
|
||||
exists = true;
|
||||
if (!exists)
|
||||
ui->listWidget_drivers->addItem(driver);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addFreq()
|
||||
{
|
||||
QString freq = QString(ui->spinBox_freq->value());
|
||||
bool exists = false;
|
||||
for (int i=0; i<ui->listWidget_freq->count(); i++)
|
||||
if (ui->listWidget_freq->item(i)->text() == freq)
|
||||
exists = true;
|
||||
if (!exists)
|
||||
ui->listWidget_freq->addItem(freq);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addOption()
|
||||
{
|
||||
if (!ui->lineEdit_wpaConfigSection->text().isEmpty())
|
||||
ui->listWidget_wpaConfigSection->addItem(ui->lineEdit_wpaConfigSection->text());
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::changeSecurity(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if ((index == 1) || (index == 2)) {
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setShown(true);
|
||||
}
|
||||
else if (index == 3) {
|
||||
ui->widget_wpaConfigSection->setShown(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if (index == 4) {
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setShown(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::selectWpaConfig()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
||||
ui->widget_wirelessAdvanced->setShown(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_wirelessAdvanced->setHidden(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QHash<QString, QString> WirelessWidget::getSettings()
|
||||
{
|
||||
QHash<QString, QString> wirelessSettings;
|
||||
|
||||
if (isOk() == 0) {
|
||||
// wirelessSettings[QString("VLANID")] = QString(ui->spinBox_vlan->value());
|
||||
clear();
|
||||
}
|
||||
|
||||
return wirelessSettings;
|
||||
}
|
||||
|
||||
|
||||
int WirelessWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef WIRELESSWIDGET_H
|
||||
#define WIRELESSWIDGET_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
@ -30,11 +31,28 @@ class WirelessWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WirelessWidget(QWidget *parent = 0);
|
||||
explicit WirelessWidget(QWidget *parent = 0,
|
||||
QString rfkillDir = QString(""));
|
||||
~WirelessWidget();
|
||||
QHash<QString, QString> getSettings();
|
||||
int isOk();
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void addDriver();
|
||||
void addFreq();
|
||||
void addOption();
|
||||
void changeSecurity(int index);
|
||||
void showAdvanced();
|
||||
void selectWpaConfig();
|
||||
|
||||
private:
|
||||
QDir *rfkillDirectory;
|
||||
Ui::WirelessWidget *ui;
|
||||
void createActions();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>760</height>
|
||||
<height>765</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -141,10 +141,10 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpaConfigFile" native="true">
|
||||
<widget class="QWidget" name="widget_wpaConfig" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_wpaConfigFile">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaConfigFile">
|
||||
<widget class="QLabel" name="label_wpaConfig">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@ -157,12 +157,19 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfigFile">
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfig">
|
||||
<property name="toolTip">
|
||||
<string>Path to a wpa_supplicant configuration file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfig">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -232,6 +239,9 @@
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -504,7 +514,8 @@
|
||||
<tabstop>lineEdit_wpaConfigSection</tabstop>
|
||||
<tabstop>pushButton_wpaConfigSection</tabstop>
|
||||
<tabstop>listWidget_wpaConfigSection</tabstop>
|
||||
<tabstop>lineEdit_wpaConfigFile</tabstop>
|
||||
<tabstop>lineEdit_wpaConfig</tabstop>
|
||||
<tabstop>pushButton_wpaConfig</tabstop>
|
||||
<tabstop>lineEdit_key</tabstop>
|
||||
<tabstop>checkBox_hidden</tabstop>
|
||||
<tabstop>checkBox_adhoc</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user