From 49fcfafc9e183e3b620516c5ce1b423643dcf53d Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 18 Feb 2014 00:38:57 +0400 Subject: [PATCH] now general widget has been completed --- sources/gui/src/bridgewidget.cpp | 33 +++++++++++++++++++++++ sources/gui/src/bridgewidget.h | 41 ++++++++++++++++++++++++++++ sources/gui/src/bridgewidget.ui | 45 +++++++++++++++++++++++++++++++ sources/gui/src/generalwidget.cpp | 37 ++++++++++++++++++++++++- sources/gui/src/generalwidget.ui | 6 ++--- sources/gui/src/mainwindow.cpp | 13 ++++++--- sources/gui/src/mainwindow.h | 2 ++ sources/gui/src/tuntapwidget.ui | 2 +- 8 files changed, 170 insertions(+), 9 deletions(-) create mode 100644 sources/gui/src/bridgewidget.cpp create mode 100644 sources/gui/src/bridgewidget.h create mode 100644 sources/gui/src/bridgewidget.ui diff --git a/sources/gui/src/bridgewidget.cpp b/sources/gui/src/bridgewidget.cpp new file mode 100644 index 0000000..9216655 --- /dev/null +++ b/sources/gui/src/bridgewidget.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 "bridgewidget.h" +#include "ui_bridgewidget.h" + + +BridgeWidget::BridgeWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::BridgeWidget) +{ + ui->setupUi(this); +} + + +BridgeWidget::~BridgeWidget() +{ + delete ui; +} diff --git a/sources/gui/src/bridgewidget.h b/sources/gui/src/bridgewidget.h new file mode 100644 index 0000000..a85f606 --- /dev/null +++ b/sources/gui/src/bridgewidget.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 BRIDGEWIDGET_H +#define BRIDGEWIDGET_H + +#include + + +namespace Ui { +class BridgeWidget; +} + +class BridgeWidget : public QWidget +{ + Q_OBJECT + +public: + explicit BridgeWidget(QWidget *parent = 0); + ~BridgeWidget(); + +private: + Ui::BridgeWidget *ui; +}; + + +#endif /* BRIDGEWIDGET_H */ diff --git a/sources/gui/src/bridgewidget.ui b/sources/gui/src/bridgewidget.ui new file mode 100644 index 0000000..d0265cb --- /dev/null +++ b/sources/gui/src/bridgewidget.ui @@ -0,0 +1,45 @@ + + + BridgeWidget + + + + 0 + 0 + 424 + 76 + + + + Form + + + + + + QDockWidget::NoDockWidgetFeatures + + + Bridge settings + + + + + + + Skip (R)STP and immediately activate all bridge members + + + Skip forwarding delay + + + + + + + + + + + + diff --git a/sources/gui/src/generalwidget.cpp b/sources/gui/src/generalwidget.cpp index 8cd663b..5b7dcbc 100644 --- a/sources/gui/src/generalwidget.cpp +++ b/sources/gui/src/generalwidget.cpp @@ -44,7 +44,7 @@ GeneralWidget::~GeneralWidget() void GeneralWidget::clear() { - ui->lineEdit_description->clear(); + ui->lineEdit_description->setText(QString("Generated from Netctl GUI")); ui->comboBox_connection->setCurrentIndex(0); ui->comboBox_interface->clear(); ui->comboBox_interface->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot)); @@ -108,11 +108,46 @@ void GeneralWidget::showAdvanced() QHash GeneralWidget::getSettings() { + QHash generalSettings; + if (isOk() == 0) { + generalSettings[QString("Description")] = ui->lineEdit_description->text(); + generalSettings[QString("Connection")] = ui->comboBox_connection->currentText(); + generalSettings[QString("Interface")] = ui->comboBox_interface->currentText(); + if (ui->listWidget_bindto->count() != 0) { + QStringList interfaces; + for (int i=0; ilistWidget_bindto->count(); i++) + interfaces.append(ui->listWidget_bindto->item(i)->text()); + generalSettings[QString("BindsToInterfaces")] = interfaces.join(QString(" ")); + } + if (ui->listWidget_after->count() != 0) { + QStringList profiles; + for (int i=0; ilistWidget_after->count(); i++) + profiles.append(ui->listWidget_after->item(i)->text()); + generalSettings[QString("After")] = profiles.join(QString(" ")); + } + if (!ui->lineEdit_execUpPost->text().isEmpty()) + generalSettings[QString("ExecUpPost")] = ui->lineEdit_execUpPost->text(); + if (!ui->lineEdit_execDownPre->text().isEmpty()) + generalSettings[QString("ExecDownPre")] = ui->lineEdit_execDownPre->text(); + if (ui->checkBox_forceConnect->checkState() == Qt::Checked) + generalSettings[QString("ForceConnect")] = QString("yes"); + } + + return generalSettings; } int GeneralWidget::isOk() { + // bind interfaces is not set + if ((ui->comboBox_connection->currentText() == QString("bond")) || + (ui->comboBox_connection->currentText() == QString("bridge"))) + if (ui->listWidget_bindto->count() == 0) + return 1; + // empty description + if (ui->lineEdit_description->text().isEmpty()) + return 2; + // all fine return 0; } diff --git a/sources/gui/src/generalwidget.ui b/sources/gui/src/generalwidget.ui index 151f043..e2473ba 100644 --- a/sources/gui/src/generalwidget.ui +++ b/sources/gui/src/generalwidget.ui @@ -7,7 +7,7 @@ 0 0 431 - 498 + 537 @@ -150,7 +150,7 @@ - + @@ -225,7 +225,7 @@ - + diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index f6f1ade..2fa3b91 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -21,6 +21,7 @@ #include #include +#include "bridgewidget.h" #include "errorwindow.h" #include "ethernetwidget.h" #include "generalwidget.h" @@ -68,6 +69,8 @@ MainWindow::MainWindow(QWidget *parent) ui->scrollAreaWidgetContents->layout()->addWidget(generalWid); ipWid = new IpWidget(this); ui->scrollAreaWidgetContents->layout()->addWidget(ipWid); + bridgeWid = new BridgeWidget(this); + ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid); ethernetWid = new EthernetWidget(this); ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid); mobileWid = new MobilePpp(this); @@ -94,19 +97,21 @@ MainWindow::MainWindow(QWidget *parent) MainWindow::~MainWindow() { + delete netctlCommand; + delete netctlProfile; + delete wpaCommand; + + delete bridgeWid; delete ethernetWid; delete generalWid; delete ipWid; delete mobileWid; - delete netctlCommand; - delete netctlProfile; delete pppoeWid; delete tunnelWid; delete tuntapWid; - delete ui; delete vlanWid; - delete wpaCommand; delete wirelessWid; + delete ui; } diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index f1bb0d9..a7b69af 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -24,6 +24,7 @@ #include +class BridgeWidget; class ErrorWindow; class EthernetWidget; class GeneralWidget; @@ -84,6 +85,7 @@ private slots: private: // ui Ui::MainWindow *ui; + BridgeWidget *bridgeWid; EthernetWidget *ethernetWid; GeneralWidget *generalWid; IpWidget *ipWid; diff --git a/sources/gui/src/tuntapwidget.ui b/sources/gui/src/tuntapwidget.ui index 03f5f02..45e4976 100644 --- a/sources/gui/src/tuntapwidget.ui +++ b/sources/gui/src/tuntapwidget.ui @@ -20,7 +20,7 @@ QDockWidget::NoDockWidgetFeatures - Tunnel settings + Tuntap settings