From 9b01fcd4e185126ce6286c3c83d8ba0612b3f6ea Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 12 Jul 2014 22:15:39 +0400 Subject: [PATCH] refactoring of the configuration interface --- CHANGELOG | 2 + README.md | 1 - sources/dataengine/netctl.cpp | 7 +- sources/gui/src/main.cpp | 18 +- sources/gui/src/mainwindow.cpp | 15 +- sources/gui/src/mainwindow.h | 4 +- sources/gui/src/settingswindow.cpp | 14 + sources/gui/src/settingswindow.h | 2 + sources/gui/src/settingswindow.ui | 1183 +++++++++++++++------------- sources/plasmoid/dataengine.ui | 216 +++++ sources/plasmoid/netctl.cpp | 192 ++++- sources/plasmoid/netctl.h | 12 + 12 files changed, 1087 insertions(+), 579 deletions(-) create mode 100644 sources/plasmoid/dataengine.ui diff --git a/CHANGELOG b/CHANGELOG index 54a2ab2..364c2fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,9 +10,11 @@ Ver.1.2.0: + [gui] added support of netctl-auto + [lib] detached backend from frontend + [plasmoid] added support of netctl-auto ++ [plasmoid] added dataengine configuration * [all] small changes in the project architecture * [gui] more debug information * [gui] changed lineEdit_profile to comboBox +* [gui] refactoring of configuration interface * [plasmoid] edited configuration interface Ver.1.1.0 (netctl-1.7 update): diff --git a/README.md b/README.md index 7303c9b..e62fbc8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,6 @@ Additional information TODO (wish list) ---------------- -* split configuration interface * man pages * code review diff --git a/sources/dataengine/netctl.cpp b/sources/dataengine/netctl.cpp index b84f5b8..3b960a3 100644 --- a/sources/dataengine/netctl.cpp +++ b/sources/dataengine/netctl.cpp @@ -17,9 +17,9 @@ #include "netctl.h" +#include +#include #include -#include -#include #include #include #include @@ -65,8 +65,7 @@ void Netctl::readConfiguration() QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf"); QFile confFile(fileName); - bool ok = confFile.open(QIODevice::ReadOnly); - if (!ok) { + if (!confFile.open(QIODevice::ReadOnly)) { configuration = updateConfiguration(rawConfig); return; } diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index 0d909c5..a2570ec 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -49,17 +49,19 @@ int main(int argc, char *argv[]) helpMessage += QApplication::translate("MainWindow", " Evgeniy Alekseev aka arcanis\n"); helpMessage += QApplication::translate("MainWindow", " E-mail : esalexeev@gmail.com\n\n"); helpMessage += QApplication::translate("MainWindow", "Usage:\n"); - helpMessage += QApplication::translate("MainWindow", "netctl-gui [ -d | --debug ] [ --default ] [ --netctl-auto ] [ -t NUM | --tab NUM ]\n"); - helpMessage += QApplication::translate("MainWindow", " [ -h | --help]\n\n"); + helpMessage += QApplication::translate("MainWindow", "netctl-gui [ -d | --debug ] [ --default ] [ --netctl-auto ] [ --settings ]\n"); + helpMessage += QApplication::translate("MainWindow", " [ -t NUM | --tab NUM ] [ -h | --help]\n\n"); helpMessage += QApplication::translate("MainWindow", "Parametrs:\n"); helpMessage += QApplication::translate("MainWindow", " -d --debug - print debug information\n"); helpMessage += QApplication::translate("MainWindow", " --default - start with default settings\n"); helpMessage += QApplication::translate("MainWindow", " --netctl-auto - show netctl-auto window\n"); + helpMessage += QApplication::translate("MainWindow", " --settings - show settings window\n"); helpMessage += QApplication::translate("MainWindow", " -t NUM --tab NUM - open a tab with number NUM\n"); helpMessage += QApplication::translate("MainWindow", " -h --help - show this help and exit\n"); bool defaultSettings = false; bool debug = false; - bool netctlAuto = false; + bool showNetctlAuto = false; + bool showSettings = false; int tabNumber = 1; for (int i=1; itabWidget->currentIndex()); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready")); - if (netctlAuto) + if (showNetctlAuto) netctlAutoWin->showWindow(); + if (showSettings) + settingsWin->showWindow(); } @@ -1287,6 +1294,8 @@ void MainWindow::connectToUnknownEssid(const QString passwd) if (!passwd.isEmpty()) settings[QString("Key")] = QString("'") + passwd + QString("'"); settings[QString("IP")] = QString("dhcp"); + if (hiddenNetwork) + settings[QString("Hidden")] = QString("yes"); QString profile = QString("netctl-gui-") + settings[QString("ESSID")]; profile.remove(QString("'")); @@ -1325,6 +1334,7 @@ void MainWindow::wifiTabStart() if (ui->tableWidget_wifi->currentItem() == 0) return; if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("")) { + hiddenNetwork = true; passwdWid = new PasswdWidget(this); passwdWid->setPassword(false); int widgetWidth = 270; @@ -1338,6 +1348,7 @@ void MainWindow::wifiTabStart() } ui->tabWidget->setDisabled(true); + hiddenNetwork = false; QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text(); QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); if (checkState(QString("exists"), item)) { diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 556597f..2105dcf 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -54,7 +54,8 @@ public: explicit MainWindow(QWidget *parent = 0, const bool defaultSettings = false, const bool debugCmd = false, - const bool netctlAuto = false, + const bool showNetctlAuto = false, + const bool showSettings = false, const int tabNum = 1); ~MainWindow(); @@ -123,6 +124,7 @@ private: void keyPressEvent(QKeyEvent *pressedKey); void setIconsToButtons(); bool debug; + bool hiddenNetwork; // configuration QMap configuration; }; diff --git a/sources/gui/src/settingswindow.cpp b/sources/gui/src/settingswindow.cpp index 4c9c976..39b885d 100644 --- a/sources/gui/src/settingswindow.cpp +++ b/sources/gui/src/settingswindow.cpp @@ -52,6 +52,7 @@ void SettingsWindow::createActions() { if (debug) qDebug() << "[SettingsWindow]" << "[createActions]"; + connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *))); connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show())); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close())); connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault())); @@ -90,6 +91,19 @@ void SettingsWindow::addLanguages() } +void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous) +{ + Q_UNUSED(previous) + if (debug) qDebug() << "[SettingsWindow]" << "[changePage]"; + + for (int i=0; itreeWidget->topLevelItemCount(); i++) + if (current == ui->treeWidget->topLevelItem(i)) { + ui->stackedWidget->setCurrentIndex(i); + break; + } +} + + void SettingsWindow::saveSettings() { if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]"; diff --git a/sources/gui/src/settingswindow.h b/sources/gui/src/settingswindow.h index 6b75cc9..1dc3683 100644 --- a/sources/gui/src/settingswindow.h +++ b/sources/gui/src/settingswindow.h @@ -20,6 +20,7 @@ #include #include +#include class MainWindow; @@ -46,6 +47,7 @@ public slots: private slots: void addLanguages(); + void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous); void saveSettings(); // buttons void selectIfaceDir(); diff --git a/sources/gui/src/settingswindow.ui b/sources/gui/src/settingswindow.ui index 46630bc..23b0e9f 100644 --- a/sources/gui/src/settingswindow.ui +++ b/sources/gui/src/settingswindow.ui @@ -6,603 +6,676 @@ 0 0 - 457 - 311 + 592 + 333 Settings - + - - - 0 - - - - General - - + + + + + QAbstractItemView::NoEditTriggers + + + false + + + + 32 + 32 + + + + 0 + + + false + + + false + + + true + + + true + + + + + + - + + General + + + + + + + + + + netctl + + + + :/icon.png:/icon.png + + + + + sudo + + + + + + + + + + wpa_supplicant + + + + :/wifi.png:/wifi.png + + + + + Other + + + + + + + + + + + + + 0 + + + - + + + + + Language + + + + + + + Select a language + + + + + + + - Language + You will need to restart the application + + + Qt::AlignCenter - - - Select a language + + + Qt::Vertical - - - - - - - - You will need to restart the application - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - netctl - - - - - - - + - 150 - 0 + 424 + 223 - - systemctl path - - - - - - - Path to systemctl - - - - - - - Browse - - + - - - + + + - - + + + + + + 150 + 0 + + + + systemctl path + + + + + + + Path to systemctl + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + netctl path + + + + + + + Path to netctl + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + netctl-auto path + + + + + + + Path to netctl-auto + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + netctl-auto service + + + + + + + Name of netctl-auto systemd service + + + + + + + + + + + + 150 + 0 + + + + Profile path + + + + + + + Path to profile directory + + + + + + + Browse + + + + + + + + + Qt::Vertical + + - 150 - 0 + 424 + 122 - - netctl path - - - - - - - Path to netctl - - - - - - - Browse - - + - - - + + + - - + + + + + + 150 + 0 + + + + sudo path + + + + + + + Path to sudo + + + + + + + Browse + + + + + + + + + Qt::Vertical + + - 150 - 0 + 424 + 244 - - netctl-auto path - - - - - - - Path to netctl-auto - - - - - - - Browse - - + - - - + + + - - + + + + + + 150 + 0 + + + + wpa_supplicant path + + + + + + + Path to wpa_supplicant + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + wpa_cli path + + + + + + + Path to wpa_cli + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + wpa_actiond path + + + + + + + Path to wpa_actiond + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + PID file + + + + + + + wpa_supplicant PID file + + + + + + + + + + + + 150 + 0 + + + + wpa_supplicant drivers + + + + + + + wpa_supplicant drivers comma separated + + + + + + + + + + + + 150 + 0 + + + + ctrl_interface directory + + + + + + + Path to control directory + + + + + + + + + + + + 150 + 0 + + + + ctrl_interface group + + + + + + + Group of control directory + + + + + + + + + Qt::Vertical + + - 150 - 0 + 20 + 66 - - netctl-auto service - - - - - - - Name of netctl-auto systemd service - - + - - - + + + - - + + + + + + 150 + 0 + + + + Path to interface list + + + + + + + Path to directory which contains network devices + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + Path to rfkill device list + + + + + + + Path to directory which contains rfkill devices + + + + + + + Browse + + + + + + + + + + + + 150 + 0 + + + + Prefered wireless interface + + + + + + + Prefered wireless interface + + + + + + + + + Qt::Vertical + + - 150 - 0 + 424 + 184 - - Profile path - - - - - - - Path to profile directory - - - - - - - Browse - - + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - sudo - - - - - - - - - 150 - 0 - - - - sudo path - - - - - - - Path to sudo - - - - - - - Browse - - - - - - - - - Qt::Vertical - - - - 20 - 192 - - - - - - - - - wpa_supplicant - - - - - - - - - 150 - 0 - - - - wpa_supplicant path - - - - - - - Path to wpa_supplicant - - - - - - - Browse - - - - - - - - - - - - 150 - 0 - - - - wpa_cli path - - - - - - - Path to wpa_cli - - - - - - - Browse - - - - - - - - - - - - 150 - 0 - - - - wpa_actiond path - - - - - - - Path to wpa_actiond - - - - - - - Browse - - - - - - - - - - - - 150 - 0 - - - - PID file - - - - - - - wpa_supplicant PID file - - - - - - - - - - - - 150 - 0 - - - - wpa_supplicant drivers - - - - - - - wpa_supplicant drivers comma separated - - - - - - - - - - - - 150 - 0 - - - - ctrl_interface directory - - - - - - - Path to control directory - - - - - - - - - - - - 150 - 0 - - - - ctrl_interface group - - - - - - - Group of control directory - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Other - - - - - - - - - 150 - 0 - - - - Path to interface list - - - - - - - Path to directory which contains network devices - - - - - - - Browse - - - - - - - - - - - - 150 - 0 - - - - Path to rfkill device list - - - - - - - Path to directory which contains rfkill devices - - - - - - - Browse - - - - - - - - - - - - 150 - 0 - - - - Prefered wireless interface - - - - - - - Prefered wireless interface - - - - - - - - - Qt::Vertical - - - - 20 - 130 - - - - - - - + + + + @@ -614,6 +687,8 @@ - + + + diff --git a/sources/plasmoid/dataengine.ui b/sources/plasmoid/dataengine.ui new file mode 100644 index 0000000..4112472 --- /dev/null +++ b/sources/plasmoid/dataengine.ui @@ -0,0 +1,216 @@ + + + DataEngineWindow + + + + 0 + 0 + 480 + 337 + + + + + 480 + 320 + + + + Configuration Window + + + + + + + + + 150 + 23 + + + + Path to netctl + + + + + + + + + + + 100 + 23 + + + + Browse + + + + + + + + + + + + 150 + 23 + + + + Path to netctl-auto + + + + + + + + + + + 100 + 23 + + + + Browse + + + + + + + + + + + + 150 + 23 + + + + Path to ip + + + + + + + + + + + 100 + 23 + + + + Browse + + + + + + + + + + + + 150 + 23 + + + + Path to interface list + + + + + + + + + + + 100 + 23 + + + + Browse + + + + + + + + + + + + 150 + 23 + + + + Check external IP + + + true + + + + + + + + + + + 100 + 23 + + + + Browse + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + lineEdit_ip + lineEdit_netctl + pushButton_netctl + checkBox_extIp + lineEdit_extIp + pushButton_extIp + + + + diff --git a/sources/plasmoid/netctl.cpp b/sources/plasmoid/netctl.cpp index f5a5c7c..dd7ac54 100644 --- a/sources/plasmoid/netctl.cpp +++ b/sources/plasmoid/netctl.cpp @@ -21,7 +21,9 @@ #include #include +#include #include +#include #include #include @@ -89,6 +91,75 @@ void Netctl::init() } +QMap Netctl::readDataEngineConfiguration() +{ + QMap rawConfig; + rawConfig[QString("CMD")] = QString("/usr/bin/netctl"); + rawConfig[QString("EXTIP")] = QString("false"); + rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip"); + rawConfig[QString("IPCMD")] = QString("/usr/bin/ip"); + rawConfig[QString("NETDIR")] = QString("/sys/class/net/"); + rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto"); + + QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf"); + QFile confFile(fileName); + if (!confFile.open(QIODevice::ReadOnly)) + return updateConfiguration(rawConfig); + QString fileStr; + QStringList value; + while (true) { + fileStr = QString(confFile.readLine()).trimmed(); + if (fileStr[0] == QChar('#')) continue; + if (fileStr[0] == QChar(';')) continue; + if (fileStr.contains(QChar('='))) { + value.clear(); + for (int i=1; i settings) +{ + QMap config = updateConfiguration(settings); + QString fileName = KGlobal::dirs()->locateLocal("config", "netctl.conf"); + QFile confFile(fileName); + if (!confFile.open(QIODevice::WriteOnly)) + return; + for (int i=0; i Netctl::updateConfiguration(const QMap rawConfig) +{ + QMap config; + QString key, value; + // remove spaces and copy source map + for (int i=0; isetText(url.path()); } @@ -433,7 +504,7 @@ void Netctl::selectActiveIcon() void Netctl::selectGuiExe() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiWidConfig.lineEdit_gui->setText(url.path()); } @@ -441,7 +512,7 @@ void Netctl::selectGuiExe() void Netctl::selectInactiveIcon() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiAppConfig.lineEdit_inactiveIcon->setText(url.path()); } @@ -449,7 +520,7 @@ void Netctl::selectInactiveIcon() void Netctl::selectNetctlExe() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiWidConfig.lineEdit_netctl->setText(url.path()); } @@ -457,7 +528,7 @@ void Netctl::selectNetctlExe() void Netctl::selectNetctlAutoExe() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiWidConfig.lineEdit_netctlAuto->setText(url.path()); } @@ -465,7 +536,7 @@ void Netctl::selectNetctlAutoExe() void Netctl::selectSudoExe() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiWidConfig.lineEdit_sudo->setText(url.path()); } @@ -473,18 +544,61 @@ void Netctl::selectSudoExe() void Netctl::selectWifiExe() { - KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); if (!url.isEmpty()) uiWidConfig.lineEdit_wifi->setText(url.path()); } +void Netctl::selectDataEngineExternalIpExe() +{ + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); + if (!url.isEmpty()) + uiDEConfig.lineEdit_extIp->setText(url.path()); +} + + +void Netctl::selectDataEngineInterfacesDirectory() +{ + KUrl url = KFileDialog::getExistingDirectoryUrl(KUrl("/")); + if (!url.isEmpty()) + uiDEConfig.lineEdit_interface->setText(url.path()); +} + + +void Netctl::selectDataEngineIpExe() +{ + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); + if (!url.isEmpty()) + uiDEConfig.lineEdit_ip->setText(url.path()); +} + + +void Netctl::selectDataEngineNetctlExe() +{ + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); + if (!url.isEmpty()) + uiDEConfig.lineEdit_netctl->setText(url.path()); +} + + +void Netctl::selectDataEngineNetctlAutoExe() +{ + KUrl url = KFileDialog::getOpenUrl(KUrl("/usr/bin"), "*"); + if (!url.isEmpty()) + uiDEConfig.lineEdit_netctlAuto->setText(url.path()); +} + + void Netctl::createConfigurationInterface(KConfigDialog *parent) { QWidget *configWidget = new QWidget; uiWidConfig.setupUi(configWidget); QWidget *appWidget = new QWidget; uiAppConfig.setupUi(appWidget); + QWidget *deWidget = new QWidget; + uiDEConfig.setupUi(deWidget); + QString text = QString(NAME) + " - " + QString(VERSION) + "\n" + "(c) " + QString(DATE) + " " + QString(AUTHOR); uiWidConfig.label_info->setText(text); @@ -498,11 +612,13 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) else uiWidConfig.checkBox_sudo->setCheckState(Qt::Unchecked); uiWidConfig.lineEdit_sudo->setText(paths[QString("sudo")]); + setSudo(); if (useWifi) uiWidConfig.checkBox_wifi->setCheckState(Qt::Checked); else uiWidConfig.checkBox_wifi->setCheckState(Qt::Unchecked); uiWidConfig.lineEdit_wifi->setText(paths[QString("wifi")]); + setWifi(); if (bigInterface[QString("main")]) uiWidConfig.checkBox_showBigInterface->setCheckState(Qt::Checked); else @@ -539,13 +655,27 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) uiAppConfig.lineEdit_activeIcon->setText(paths[QString("active")]); uiAppConfig.lineEdit_inactiveIcon->setText(paths[QString("inactive")]); + QMap deSettings = readDataEngineConfiguration(); + uiDEConfig.lineEdit_netctl->setText(deSettings[QString("CMD")]); + uiDEConfig.lineEdit_netctlAuto->setText(deSettings[QString("NETCTLAUTOCMD")]); + uiDEConfig.lineEdit_ip->setText(deSettings[QString("IPCMD")]); + uiDEConfig.lineEdit_interface->setText(deSettings[QString("NETDIR")]); + if (deSettings[QString("EXTIP")] == QString("true")) + uiDEConfig.checkBox_extIp->setCheckState(Qt::Checked); + else + uiDEConfig.checkBox_extIp->setCheckState(Qt::Unchecked); + uiDEConfig.lineEdit_extIp->setText(deSettings[QString("EXTIPCMD")]); + setDataEngineExternalIp(); + parent->addPage(configWidget, i18n("Netctl plasmoid"), Applet::icon()); parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme")); + parent->addPage(deWidget, i18n("DataEngine"), Applet::icon()); connect(uiWidConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface())); connect(uiWidConfig.checkBox_sudo, SIGNAL(stateChanged(int)), this, SLOT(setSudo())); connect(uiWidConfig.checkBox_wifi, SIGNAL(stateChanged(int)), this, SLOT(setWifi())); + connect(uiDEConfig.checkBox_extIp, SIGNAL(stateChanged(int)), this, SLOT(setDataEngineExternalIp())); connect(uiWidConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe())); connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe())); @@ -554,6 +684,11 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) connect(uiWidConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selecWifiExe())); connect(uiAppConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon())); connect(uiAppConfig.pushButton_inactiveIcon, SIGNAL(clicked()), this, SLOT(selectInactiveIcon())); + connect(uiDEConfig.pushButton_extIp, SIGNAL(clicked()), this, SLOT(selectDataEngineExternalIpExe())); + connect(uiDEConfig.pushButton_interface, SIGNAL(clicked()), this, SLOT(selectDataEngineInterfacesDirectory())); + connect(uiDEConfig.pushButton_ip, SIGNAL(clicked()), this, SLOT(selectDataEngineIpExe())); + connect(uiDEConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectDataEngineNetctlExe())); + connect(uiDEConfig.pushButton_netctlAuto, SIGNAL(clicked()), this, SLOT(selectDataEngineNetctlAutoExe())); connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); @@ -603,6 +738,18 @@ void Netctl::configAccepted() cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyle->currentText()); cg.writeEntry("activeIconPath", uiAppConfig.lineEdit_activeIcon->text()); cg.writeEntry("inactiveIconPath", uiAppConfig.lineEdit_inactiveIcon->text()); + + QMap deSettings; + deSettings[QString("CMD")] = uiDEConfig.lineEdit_netctl->text(); + deSettings[QString("NETCTLAUTOCMD")] = uiDEConfig.lineEdit_netctlAuto->text(); + deSettings[QString("IPCMD")] = uiDEConfig.lineEdit_ip->text(); + deSettings[QString("NETDIR")] = uiDEConfig.lineEdit_interface->text(); + if (uiDEConfig.checkBox_extIp->checkState() == 0) + deSettings[QString("EXTIP")] = QString("false"); + else + deSettings[QString("EXTIP")] = QString("true"); + deSettings[QString("EXTIPCMD")] = uiDEConfig.lineEdit_extIp->text(); + writeDataEngineConfiguration(deSettings); } @@ -661,19 +808,40 @@ void Netctl::setBigInterface() void Netctl::setSudo() { - if (uiWidConfig.checkBox_sudo->checkState() == 0) + if (uiWidConfig.checkBox_sudo->checkState() == 0) { uiWidConfig.lineEdit_sudo->setDisabled(true); - else if (uiWidConfig.checkBox_sudo->checkState() == 2) + uiWidConfig.pushButton_sudo->setDisabled(true); + } + else if (uiWidConfig.checkBox_sudo->checkState() == 2) { uiWidConfig.lineEdit_sudo->setEnabled(true); + uiWidConfig.pushButton_sudo->setEnabled(true); + } } void Netctl::setWifi() { - if (uiWidConfig.checkBox_wifi->checkState() == 0) + if (uiWidConfig.checkBox_wifi->checkState() == 0) { uiWidConfig.lineEdit_wifi->setDisabled(true); - else if (uiWidConfig.checkBox_wifi->checkState() == 2) - uiWidConfig.checkBox_wifi->setEnabled(true); + uiWidConfig.pushButton_wifi->setDisabled(true); + } + else if (uiWidConfig.checkBox_wifi->checkState() == 2) { + uiWidConfig.lineEdit_wifi->setEnabled(true); + uiWidConfig.pushButton_wifi->setEnabled(true); + } +} + + +void Netctl::setDataEngineExternalIp() +{ + if (uiDEConfig.checkBox_extIp->checkState() == 0) { + uiDEConfig.lineEdit_extIp->setDisabled(true); + uiDEConfig.pushButton_extIp->setDisabled(true); + } + else if (uiDEConfig.checkBox_extIp->checkState() == 2) { + uiDEConfig.lineEdit_extIp->setEnabled(true); + uiDEConfig.pushButton_extIp->setEnabled(true); + } } diff --git a/sources/plasmoid/netctl.h b/sources/plasmoid/netctl.h index 724665e..19c4345 100644 --- a/sources/plasmoid/netctl.h +++ b/sources/plasmoid/netctl.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -39,6 +40,9 @@ public: Netctl(QObject *parent, const QVariantList &args); ~Netctl(); void init(); + QMap readDataEngineConfiguration(); + void writeDataEngineConfiguration(const QMap settings); + QMap updateConfiguration(const QMap rawConfig); public slots: // events @@ -53,6 +57,7 @@ public slots: void setBigInterface(); void setSudo(); void setWifi(); + void setDataEngineExternalIp(); private slots: // ui @@ -65,6 +70,12 @@ private slots: void selectNetctlAutoExe(); void selectSudoExe(); void selectWifiExe(); + // dataengine + void selectDataEngineExternalIpExe(); + void selectDataEngineInterfacesDirectory(); + void selectDataEngineIpExe(); + void selectDataEngineNetctlExe(); + void selectDataEngineNetctlAutoExe(); // context menu void enableProfileSlot(); void startProfileSlot(QAction *profile); @@ -98,6 +109,7 @@ private: void disconnectFromEngine(); // configuration interface Ui::AppearanceWindow uiAppConfig; + Ui::DataEngineWindow uiDEConfig; Ui::ConfigWindow uiWidConfig; // configuration int autoUpdateInterval;