diff --git a/CHANGELOG b/CHANGELOG index c4faaff..9ce23f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Ver.1.1.1: ++ [gui] added suppoort of macvlan ++ [gui] added ability to remove profile + Ver.1.1.0 (netctl-1.7 update): + [gui] added frequency + [plasmoid] added menu title diff --git a/README.md b/README.md index 2fbc434..1771f97 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,6 @@ Additional information TODO (wish list) ---------------- -* update to upstream (add support of macvlan) -* add option to remove profile * add contextual actions to tables Links diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 9396176..186ec61 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_policy (SET CMP0015 NEW) project (netctl-gui) set (PROJECT_VERSION_MAJOR 1) set (PROJECT_VERSION_MINOR 1) -set (PROJECT_VERSION_PATCH 0) +set (PROJECT_VERSION_PATCH 1) set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) diff --git a/sources/gui/resources/translations/english.ts b/sources/gui/resources/translations/english.ts index 094b053..40be503 100644 --- a/sources/gui/resources/translations/english.ts +++ b/sources/gui/resources/translations/english.ts @@ -484,6 +484,33 @@ Maximum time, in seconds, to wait for IPv6’s Duplicate Address Detection to succeed + + MacvlanWidget + + Form + Form + + + macvlan settings + macvlan settings + + + Mode + Mode + + + MAC address + MAC address + + + Only connect to specified MAC address + Only connect to specified MAC address + + + Optional static MAC address + Optional static MAC address + + MainWindow @@ -690,6 +717,10 @@ Name Description Status Name Description Status + + Remove + Remove + MobileWidget diff --git a/sources/gui/resources/translations/russian.ts b/sources/gui/resources/translations/russian.ts index 3191cb8..548500b 100644 --- a/sources/gui/resources/translations/russian.ts +++ b/sources/gui/resources/translations/russian.ts @@ -484,6 +484,33 @@ Максимальное время в секундах для ожидания выполнения детектирования дубликации IPv6 адресов + + MacvlanWidget + + Form + Form + + + macvlan settings + Опции macvlan + + + Mode + Режим + + + MAC address + MAC адрес + + + Only connect to specified MAC address + Подключаться только к указанному MAC адресу + + + Optional static MAC address + Статический MAC адрес, если нужно + + MainWindow @@ -690,6 +717,10 @@ Name Description Status Имя Описание Статус + + Remove + Удалить + MobileWidget diff --git a/sources/gui/src/generalwidget.ui b/sources/gui/src/generalwidget.ui index 9d4b489..86c9c59 100644 --- a/sources/gui/src/generalwidget.ui +++ b/sources/gui/src/generalwidget.ui @@ -6,8 +6,8 @@ 0 0 - 431 - 537 + 429 + 535 @@ -118,6 +118,11 @@ vlan + + + macvlan + + diff --git a/sources/gui/src/macvlanwidget.cpp b/sources/gui/src/macvlanwidget.cpp new file mode 100644 index 0000000..b01aa49 --- /dev/null +++ b/sources/gui/src/macvlanwidget.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui 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-gui 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-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "macvlanwidget.h" +#include "ui_macvlanwidget.h" + + +MacvlanWidget::MacvlanWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::MacvlanWidget) +{ + ui->setupUi(this); + createFilter(); +} + + +MacvlanWidget::~MacvlanWidget() +{ + delete ui; +} + + +void MacvlanWidget::clear() +{ + ui->comboBox_mode->setCurrentIndex(0); + ui->lineEdit_mac->clear(); +} + + +void MacvlanWidget::setShown(const bool state) +{ + if (state) + show(); + else + hide(); +} + + +void MacvlanWidget::createFilter() +{ + // mac + ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH")); +} + + +QMap MacvlanWidget::getSettings() +{ + QMap macvlanSettings; + + if (isOk() != 0) + return macvlanSettings; + + macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText(); + if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty()) + macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text(); + + return macvlanSettings; +} + + +int MacvlanWidget::isOk() +{ + // all fine + return 0; +} + + +void MacvlanWidget::setSettings(const QMap settings) +{ + QMap macvlanSettings = settings; + + if (macvlanSettings.contains(QString("Mode"))) + for (int i=0; icomboBox_mode->count(); i++) + if (macvlanSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i)) + ui->comboBox_mode->setCurrentIndex(i); + if (macvlanSettings.contains(QString("MACAddress"))) + ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]); +} diff --git a/sources/gui/src/macvlanwidget.h b/sources/gui/src/macvlanwidget.h new file mode 100644 index 0000000..03e5fc3 --- /dev/null +++ b/sources/gui/src/macvlanwidget.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui 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-gui 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-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#ifndef MACVLANWIDGET_H +#define MACVLANWIDGET_H + +#include + + +namespace Ui { +class MacvlanWidget; +} + +class MacvlanWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MacvlanWidget(QWidget *parent = 0); + ~MacvlanWidget(); + QMap getSettings(); + int isOk(); + void setSettings(const QMap settings); + +public slots: + void clear(); + void setShown(const bool state); + +private: + Ui::MacvlanWidget *ui; + void createFilter(); +}; + + +#endif /* MACVLANWIDGET_H */ diff --git a/sources/gui/src/macvlanwidget.ui b/sources/gui/src/macvlanwidget.ui new file mode 100644 index 0000000..e805a0d --- /dev/null +++ b/sources/gui/src/macvlanwidget.ui @@ -0,0 +1,94 @@ + + + MacvlanWidget + + + + 0 + 0 + 396 + 101 + + + + Form + + + + + + QDockWidget::NoDockWidgetFeatures + + + macvlan settings + + + + + + + + + Mode + + + + + + + + bridge + + + + + vepa + + + + + private + + + + + passthru + + + + + + + + + + + + + 150 + 0 + + + + MAC address + + + + + + + Optional static MAC address + + + + + + + + + + + + + + diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index 713acad..d09dc88 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -28,6 +28,7 @@ #include "ethernetwidget.h" #include "generalwidget.h" #include "ipwidget.h" +#include "macvlanwidget.h" #include "mobilewidget.h" #include "netctlinteract.h" #include "netctlprofile.h" @@ -67,6 +68,8 @@ MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const int ta ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid); ethernetWid = new EthernetWidget(this); ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid); + macvlanWid = new MacvlanWidget(this); + ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid); mobileWid = new MobileWidget(this); ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid); pppoeWid = new PppoeWidget(this); @@ -100,6 +103,7 @@ MainWindow::~MainWindow() delete ethernetWid; delete generalWid; delete ipWid; + delete macvlanWid; delete mobileWid; delete pppoeWid; delete tunnelWid; @@ -154,6 +158,7 @@ void MainWindow::createActions() // main page events connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab())); + connect(ui->pushButton_mainRemove, SIGNAL(clicked(bool)), this, SLOT(mainTabRemoveProfile())); connect(ui->pushButton_mainEnable, SIGNAL(clicked(bool)), this, SLOT(mainTabEnableProfile())); connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile())); connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile())); @@ -301,6 +306,21 @@ void MainWindow::updateWifiTab() // main tab slots +void MainWindow::mainTabRemoveProfile() +{ + qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]"; + ui->tabWidget->setDisabled(true); + // call netctlprofile + QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); + if (netctlProfile->removeProfile(profile)) + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); + else + ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); + + updateMainTab(); +} + + void MainWindow::mainTabEnableProfile() { if (!checkExternalApps(QString("netctl"))) { @@ -442,6 +462,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(true); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -454,6 +475,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -467,6 +489,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -479,6 +502,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(true); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -491,6 +515,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(false); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(true); tunnelWid->setShown(false); @@ -503,6 +528,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(false); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(true); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -515,6 +541,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(true); @@ -527,6 +554,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(false); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -539,6 +567,7 @@ void MainWindow::profileTabChangeState(const QString current) ipWid->setShown(true); bridgeWid->setShown(false); ethernetWid->setShown(true); + macvlanWid->setShown(false); mobileWid->setShown(false); pppoeWid->setShown(false); tunnelWid->setShown(false); @@ -546,6 +575,19 @@ void MainWindow::profileTabChangeState(const QString current) vlanWid->setShown(true); wirelessWid->setShown(false); } + else if (current == QString("macvlan")) { + generalWid->setShown(true); + ipWid->setShown(true); + bridgeWid->setShown(false); + ethernetWid->setShown(true); + macvlanWid->setShown(true); + mobileWid->setShown(false); + pppoeWid->setShown(false); + tunnelWid->setShown(false); + tuntapWid->setShown(false); + vlanWid->setShown(false); + wirelessWid->setShown(false); + } } @@ -594,7 +636,8 @@ void MainWindow::profileTabCreateProfile() (generalWid->connectionType->currentText() == QString("bridge")) || (generalWid->connectionType->currentText() == QString("tunnel")) || (generalWid->connectionType->currentText() == QString("tuntap")) || - (generalWid->connectionType->currentText() == QString("vlan"))) { + (generalWid->connectionType->currentText() == QString("vlan")) || + (generalWid->connectionType->currentText() == QString("macvlan"))) { if (ipWid->isOk() == 1) { errorWin = new ErrorWindow(this, 6); errorWin->show(); @@ -697,6 +740,13 @@ void MainWindow::profileTabCreateProfile() return; } } + else if (generalWid->connectionType->currentText() == QString("macvlan")) { + if (ethernetWid->isOk() == 1) { + errorWin = new ErrorWindow(this, 7); + errorWin->show(); + return; + } + } qDebug() << "[MainWindow]" << "[profileTabCreateProfile]"; ui->tabWidget->setDisabled(true); @@ -771,6 +821,17 @@ void MainWindow::profileTabCreateProfile() for (int i=0; iconnectionType->currentText() == QString("macvlan")) { + QMap addSettings = ipWid->getSettings(); + for (int i=0; igetSettings(); + for (int i=0; igetSettings(); + for (int i=0; icreateProfile(profile, settings); @@ -825,6 +886,11 @@ void MainWindow::profileTabLoadProfile() ethernetWid->setSettings(settings); vlanWid->setSettings(settings); } + else if (generalWid->connectionType->currentText() == QString("macvlan")) { + ipWid->setSettings(settings); + ethernetWid->setSettings(settings); + macvlanWid->setSettings(settings); + } } diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 4d8b0cc..84ed9cf 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -28,6 +28,7 @@ class ErrorWindow; class EthernetWidget; class GeneralWidget; class IpWidget; +class MacvlanWidget; class MobileWidget; class Netctl; class NetctlProfile; @@ -67,6 +68,7 @@ private slots: void updateProfileTab(); void updateWifiTab(); // main tab slots + void mainTabRemoveProfile(); void mainTabEnableProfile(); void mainTabRestartProfile(); void mainTabStartProfile(); @@ -89,6 +91,7 @@ private: EthernetWidget *ethernetWid; GeneralWidget *generalWid; IpWidget *ipWid; + MacvlanWidget *macvlanWid; MobileWidget *mobileWid; PppoeWidget *pppoeWid; TunnelWidget *tunnelWid; diff --git a/sources/gui/src/mainwindow.ui b/sources/gui/src/mainwindow.ui index 597dd72..21dde8d 100644 --- a/sources/gui/src/mainwindow.ui +++ b/sources/gui/src/mainwindow.ui @@ -86,6 +86,16 @@ + + + + Remove + + + true + + + @@ -190,8 +200,8 @@ 0 0 - 98 - 28 + 96 + 26 @@ -356,7 +366,7 @@ 0 0 491 - 20 + 22 @@ -390,6 +400,7 @@ tabWidget tableWidget_main pushButton_mainRefresh + pushButton_mainRemove pushButton_mainEnable pushButton_mainRestart pushButton_mainStart diff --git a/sources/gui/src/netctlprofile.cpp b/sources/gui/src/netctlprofile.cpp index 04e5968..d91068d 100644 --- a/sources/gui/src/netctlprofile.cpp +++ b/sources/gui/src/netctlprofile.cpp @@ -55,6 +55,22 @@ bool NetctlProfile::copyProfile(const QString oldPath) } +bool NetctlProfile::removeProfile(const QString profile) +{ + QString profilePath = profileDirectory->absolutePath() + QDir::separator() + profile; + QProcess command; + QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath; + qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText; + command.start(commandText); + command.waitForFinished(-1); + if (command.exitCode() == 0) + return true; + else + return false; +} + + + QString NetctlProfile::createProfile(const QString profile, const QMap settings) { diff --git a/sources/gui/src/netctlprofile.h b/sources/gui/src/netctlprofile.h index b95c7ef..ad4d2ed 100644 --- a/sources/gui/src/netctlprofile.h +++ b/sources/gui/src/netctlprofile.h @@ -34,6 +34,7 @@ public: const QMap settings = QMap()); ~NetctlProfile(); bool copyProfile(const QString oldPath); + bool removeProfile(const QString profile); QString createProfile(const QString profile, const QMap settings); QMap getSettingsFromProfile(const QString profile);