From ec27411b1d268b5cfd7c6af4b12855e8b5c4a199 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Mon, 10 Feb 2014 10:58:29 +0400 Subject: [PATCH] added ethernet widget --- sources/gui/src/ethernetwidget.cpp | 33 ++++ sources/gui/src/ethernetwidget.h | 41 +++++ sources/gui/src/ethernetwidget.ui | 243 +++++++++++++++++++++++++++++ sources/gui/src/generalwidget.cpp | 1 + sources/gui/src/generalwidget.ui | 106 +++++-------- sources/gui/src/ipwidget.cpp | 1 + sources/gui/src/ipwidget.ui | 200 +++++++++++++++++------- sources/gui/src/mainwindow.cpp | 60 ++++--- sources/gui/src/mainwindow.h | 12 +- sources/gui/src/mainwindow.ui | 10 +- 10 files changed, 549 insertions(+), 158 deletions(-) create mode 100644 sources/gui/src/ethernetwidget.cpp create mode 100644 sources/gui/src/ethernetwidget.h create mode 100644 sources/gui/src/ethernetwidget.ui diff --git a/sources/gui/src/ethernetwidget.cpp b/sources/gui/src/ethernetwidget.cpp new file mode 100644 index 0000000..e1d9bab --- /dev/null +++ b/sources/gui/src/ethernetwidget.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "ethernetwidget.h" +#include "ui_ethernetwidget.h" + + +EthernetWidget::EthernetWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::EthernetWidget) +{ + ui->setupUi(this); +} + + +EthernetWidget::~EthernetWidget() +{ + delete ui; +} diff --git a/sources/gui/src/ethernetwidget.h b/sources/gui/src/ethernetwidget.h new file mode 100644 index 0000000..c3cd322 --- /dev/null +++ b/sources/gui/src/ethernetwidget.h @@ -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 ETHERNETWIDGET_H +#define ETHERNETWIDGET_H + +#include + + +namespace Ui { +class EthernetWidget; +} + +class EthernetWidget : public QWidget +{ + Q_OBJECT + +public: + explicit EthernetWidget(QWidget *parent = 0); + ~EthernetWidget(); + +private: + Ui::EthernetWidget *ui; +}; + + +#endif /* ETHERNETWIDGET_H */ diff --git a/sources/gui/src/ethernetwidget.ui b/sources/gui/src/ethernetwidget.ui new file mode 100644 index 0000000..54a7024 --- /dev/null +++ b/sources/gui/src/ethernetwidget.ui @@ -0,0 +1,243 @@ + + + EthernetWidget + + + + 0 + 0 + 431 + 275 + + + + Form + + + + + + QDockWidget::NoDockWidgetFeatures + + + Ethernet options + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Show advanced + + + + + + + + + + + + <html><head/><body><p>Whether or not the absence of a carrier is acceptable</p></body></html> + + + Skip no carrier + + + + + + + Set to ‘yes’ to use 802.1x authentication + + + 802.1x authentication + + + true + + + + + + + + + + + + + 150 + 0 + + + + WPA config file + + + + + + + Path to a wpa_supplicant configuration file + + + + + + + + + + + + 150 + 0 + + + + WPA driver + + + + + + + The wpa_supplicant driver to use for 802.1x authentication + + + + wired + + + + + nl80211 + + + + + wext + + + + + + + + + + + + + + + + 150 + 0 + + + + Timeout carrier + + + + + + + Maximum time, in seconds, to wait for a carrier + + + 999 + + + 5 + + + + + + + + + + + + 150 + 0 + + + + Timeout carrier + + + + + + + Maximum time, in seconds, to wait for 802.1x authentication to succeed + + + 999 + + + 15 + + + + + + + + + + + + + + + + pushButton_advanced + checkBox + checkBox_2 + lineEdit + comboBox + spinBox + spinBox_2 + + + + + checkBox_2 + clicked(bool) + widget_2 + setShown(bool) + + + 70 + 112 + + + 125 + 130 + + + + + diff --git a/sources/gui/src/generalwidget.cpp b/sources/gui/src/generalwidget.cpp index 722b6fa..b75376a 100644 --- a/sources/gui/src/generalwidget.cpp +++ b/sources/gui/src/generalwidget.cpp @@ -26,6 +26,7 @@ GeneralWidget::GeneralWidget(QWidget *parent) ui->setupUi(this); } + GeneralWidget::~GeneralWidget() { delete ui; diff --git a/sources/gui/src/generalwidget.ui b/sources/gui/src/generalwidget.ui index 3ab0846..25d5a0f 100644 --- a/sources/gui/src/generalwidget.ui +++ b/sources/gui/src/generalwidget.ui @@ -6,8 +6,8 @@ 0 0 - 587 - 473 + 431 + 498 @@ -150,9 +150,9 @@ - + - + @@ -161,41 +161,24 @@ - - - - - - 150 - 0 - - - - true - - - - - - - Add - - - - - - - - - Qt::Vertical - - + + - 20 - 40 + 150 + 0 - + + true + + + + + + + Add + + @@ -242,9 +225,9 @@ - + - + @@ -253,41 +236,24 @@ - - - - - - 150 - 0 - - - - true - - - - - - - Add - - - - - - - - - Qt::Vertical - - + + - 20 - 40 + 150 + 0 - + + true + + + + + + + Add + + diff --git a/sources/gui/src/ipwidget.cpp b/sources/gui/src/ipwidget.cpp index 58272f1..1023fc0 100644 --- a/sources/gui/src/ipwidget.cpp +++ b/sources/gui/src/ipwidget.cpp @@ -26,6 +26,7 @@ IpWidget::IpWidget(QWidget *parent) ui->setupUi(this); } + IpWidget::~IpWidget() { delete ui; diff --git a/sources/gui/src/ipwidget.ui b/sources/gui/src/ipwidget.ui index 278fa4b..e308f4d 100644 --- a/sources/gui/src/ipwidget.ui +++ b/sources/gui/src/ipwidget.ui @@ -1,13 +1,13 @@ - IpWdiget - + IpWidget + 0 0 - 478 - 1254 + 431 + 1287 @@ -99,7 +99,7 @@ - An array of physical network interfaces that this profile needs before it can be started + An array of IP addresses suffixed with ‘/<netmask>’ @@ -121,7 +121,11 @@ - + + + An IP routing gateway address + + @@ -143,7 +147,11 @@ - + + + An array of custom routes + + @@ -283,7 +291,7 @@ - An array of physical network interfaces that this profile needs before it can be started + An array of IPv6 addresses @@ -305,7 +313,11 @@ - + + + An IPv6 routing gateway address + + @@ -327,7 +339,11 @@ - + + + An array of custom routes + + @@ -457,7 +473,7 @@ - An array of physical network interfaces that this profile needs before it can be started + An array of argument lines to pass to ip @@ -473,7 +489,11 @@ - + + + A system hostname + + @@ -481,6 +501,12 @@ + + + 150 + 0 + + Timeout DAD @@ -488,6 +514,9 @@ + + Set to ‘yes’ to release the DHCP lease when the profile is stopped + 1 @@ -521,6 +550,9 @@ + + The name of the preferred DHCP client + dhcpcd @@ -533,13 +565,6 @@ - - - - DHCP release on stop - - - @@ -558,7 +583,11 @@ - + + + Additional options to be passed to the DHCP client + + @@ -578,7 +607,11 @@ - + + + Additional options to be passed to the DHCP client + + @@ -598,7 +631,11 @@ - + + + Additional options to be passed to the DHCP client + + @@ -619,6 +656,9 @@ + + Maximum time, in seconds, to wait for DHCP to be successful + 1 @@ -632,6 +672,16 @@ + + + + Set to ‘yes’ to release the DHCP lease when the profile is stopped + + + DHCP release on stop + + + @@ -676,7 +726,7 @@ - An array of physical network interfaces that this profile needs before it can be started + An array of DNS nameservers @@ -698,7 +748,11 @@ - + + + A ‘domain’ line for /etc/resolv.conf + + @@ -718,7 +772,11 @@ - + + + A ‘search’ line for /etc/resolv.conf + + @@ -760,7 +818,7 @@ - An array of physical network interfaces that this profile needs before it can be started + An array of ‘options’ lines for /etc/resolv.conf @@ -777,23 +835,49 @@ - label - comboBox_ip - spinBox - label_2 - spinBox_2 - spinBox_3 - label_3 - label_4 - spinBox_4 - pushButton_bindto - label_5 - spinBox_5 - label_15 - label_timeoutDhcp - spinBox_timeoutDhcp - dockWidget_ip + + checkBox_ip + comboBox_ip + lineEdit_ipAddress + pushButton_ipAddress + listWidget_ipAddress + lineEdit_gateway + lineEdit_ipRoutes + lineEdit_ipRoutes2 + pushButton_ipRoutes + listWidget_ipRoutes + checkBox_ip6 + comboBox_ip6 + lineEdit_ipAddress6 + pushButton_ipAddress6 + listWidget_ipAddress6 + lineEdit_gateway6 + lineEdit_ipRoutes6 + lineEdit_ipRoutes62 + pushButton_ipRoutes6 + listWidget_ipRoutes6 + pushButton_ipAdvanced + lineEdit_custom + pushButton_custom + listWidget_custom + lineEdit_hostname + spinBox_timeoutDad + comboBox_dhcp + lineEdit_dhcpcdOpt + lineEdit_dhclientOpt + lineEdit_dhclientOpt6 + spinBox_timeoutDhcp + checkBox_dhcp + lineEdit_dns + pushButton_dns + listWidget_dns + lineEdit_dnsDomain + lineEdit_dnsSearch_2 + lineEdit_dnsSearch + pushButton_dnsSearch + listWidget_dnsSearch + @@ -803,12 +887,12 @@ setEnabled(bool) - 23 - 19 + 33 + 49 - 225 - 24 + 458 + 53 @@ -819,12 +903,12 @@ setShown(bool) - 23 - 24 + 33 + 54 - 19 - 46 + 28 + 101 @@ -835,12 +919,12 @@ setEnabled(bool) - 117 - 291 + 127 + 348 - 264 - 302 + 458 + 349 @@ -851,12 +935,12 @@ setShown(bool) - 96 - 291 + 106 + 348 - 47 - 315 + 56 + 608 diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index b71c093..9fbbff1 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -22,6 +22,9 @@ #include #include "errorwindow.h" +#include "ethernetwidget.h" +#include "generalwidget.h" +#include "ipwidget.h" #include "netctlinteract.h" #include "netctlprofile.h" #include "passwdwidget.h" @@ -54,6 +57,14 @@ MainWindow::MainWindow(QWidget *parent) wpaConfig.append(QString("/run/wpa_supplicant_netctl-gui")); wpaConfig.append(QString("users")); + // gui + generalWid = new GeneralWidget(this); + ui->scrollAreaWidgetContents->layout()->addWidget(generalWid); + ipWid = new IpWidget(this); + ui->scrollAreaWidgetContents->layout()->addWidget(ipWid); + ethernetWid = new EthernetWidget(this); + ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid); + // backend netctlCommand = new Netctl(this, netctlPath, profileDir, sudoPath); netctlProfile = new NetctlProfile(this, profileDir, sudoPath); wpaCommand = new WpaSup(this, wpaConfig, sudoPath, ifaceDir, preferedInterface); @@ -65,6 +76,9 @@ MainWindow::MainWindow(QWidget *parent) MainWindow::~MainWindow() { + delete ethernetWid; + delete generalWid; + delete ipWid; delete netctlCommand; delete netctlProfile; delete wpaCommand; @@ -140,8 +154,8 @@ void MainWindow::updateTabs(const int tab) void MainWindow::updateMainTab() { if (!checkExternalApps(QString("netctl"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } @@ -189,8 +203,8 @@ void MainWindow::updateWifiTab() { wifiTabSetEnabled(checkExternalApps(QString("wpasup"))); if (!checkExternalApps(QString("wpasup"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } @@ -235,8 +249,8 @@ void MainWindow::updateWifiTab() void MainWindow::mainTabEnableProfile() { if (!checkExternalApps(QString("netctl"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } if (ui->tableWidget_main->currentItem() == 0) @@ -264,8 +278,8 @@ void MainWindow::mainTabEnableProfile() void MainWindow::mainTabRestartProfile() { if (!checkExternalApps(QString("netctl"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } if (ui->tableWidget_main->currentItem() == 0) @@ -285,8 +299,8 @@ void MainWindow::mainTabRestartProfile() void MainWindow::mainTabStartProfile() { if (!checkExternalApps(QString("netctl"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } if (ui->tableWidget_main->currentItem() == 0) @@ -315,8 +329,8 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt { Q_UNUSED(previous); if (!checkExternalApps(QString("netctl"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } if (current == 0) { @@ -365,7 +379,7 @@ void MainWindow::wifiTabSetEnabled(bool state) void MainWindow::connectToUnknownEssid(QString passwd) { if (!passwd.isEmpty()) - delete passwdwid; + delete passwdWid; QStringList profileInfo; profileInfo.append(QString("Automatically generated profile by Netctl GUI")); profileInfo.append(wpaCommand->getInterfaceList()[0]); @@ -390,16 +404,16 @@ void MainWindow::connectToUnknownEssid(QString passwd) void MainWindow::wifiTabStart() { if (!checkExternalApps(QString("wpasup"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + 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("")) { ui->pushButton_wifiStart->setDisabled(true); - errorwin = new ErrorWindow(this, 2); - errorwin->show(); + errorWin = new ErrorWindow(this, 2); + errorWin->show(); return; } @@ -427,14 +441,14 @@ void MainWindow::wifiTabStart() if (checkState(QString("none"), security)) return connectToUnknownEssid(QString("")); else { - passwdwid = new PasswdWidget(this); + 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(); + passwdWid->setGeometry(x, y, widgetWidth, widgetHeight); + passwdWid->show(); + passwdWid->setFocusToLineEdit(); return; } } @@ -446,8 +460,8 @@ void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt { Q_UNUSED(previous); if (!checkExternalApps(QString("wpasup"))) { - errorwin = new ErrorWindow(this, 1); - errorwin->show(); + errorWin = new ErrorWindow(this, 1); + errorWin->show(); return; } if (current == 0) { diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 1887ce2..200e044 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -25,6 +25,9 @@ class ErrorWindow; +class EthernetWidget; +class GeneralWidget; +class IpWidget; class Netctl; class NetctlProfile; class PasswdWidget; @@ -73,9 +76,14 @@ private slots: void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous); private: + // ui Ui::MainWindow *ui; - ErrorWindow *errorwin; - PasswdWidget *passwdwid; + EthernetWidget *ethernetWid; + GeneralWidget *generalWid; + IpWidget *ipWid; + // backend + ErrorWindow *errorWin; + PasswdWidget *passwdWid; bool checkExternalApps(QString apps); bool checkState(QString state, QString item); void createActions(); diff --git a/sources/gui/src/mainwindow.ui b/sources/gui/src/mainwindow.ui index df3ba88..57432e0 100644 --- a/sources/gui/src/mainwindow.ui +++ b/sources/gui/src/mainwindow.ui @@ -18,7 +18,7 @@ - 0 + 1 @@ -163,8 +163,8 @@ 0 0 - 439 - 421 + 429 + 410 @@ -173,7 +173,7 @@ 0 - + @@ -291,7 +291,7 @@ 0 0 471 - 23 + 20