update submodule

update netctl-auto
update interfaces
This commit is contained in:
arcan1s
2015-03-15 18:17:49 +03:00
parent f80d6aae6b
commit 3f49988cef
19 changed files with 220 additions and 378 deletions

View File

@ -35,7 +35,7 @@ QStringList mapToList(const QMap<QString, QString> map)
{
QStringList list;
for (int i=0; i<map.keys().count(); i++)
list.append(QString("%1==X2").arg(map.keys()[i]).arg(map[map.keys()[i]]));
list.append(QString("%1==%2").arg(map.keys()[i]).arg(map[map.keys()[i]]));
return list;
}

View File

@ -188,6 +188,7 @@ netctlInformation generalInformation(NetctlInterface* interface, const bool useH
// main
netctlInformation info;
info.netctlAuto = responce[0].toStringList().takeFirst().toInt();
info.netctlAutoEnabled = responce[0].toStringList().takeFirst().toInt();
QList<netctlProfileInfo> profiles = parseOutputNetctl(responce);
for (int i=0; i<profiles.count(); i++) {
if (profiles[i].netctlAuto)
@ -240,6 +241,3 @@ netctlCurrent trayInformation(NetctlInterface *interface, const bool useHelper,
return netctlCurrent();
}
}

View File

@ -38,7 +38,20 @@ MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, c
mainWindow = dynamic_cast<MainWindow *>(parent);
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects();
// windows
ui = new Ui::MainWidget;
ui->setupUi(this);
ui->tableWidget_main->setColumnHidden(2, true);
ui->tableWidget_main->setColumnHidden(3, true);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("NETCTL_TOOLBAR")].toInt()));
// append toolbar
QMenu *actionMenu = new QMenu(this);
actionMenu->addAction(ui->actionSwitch);
actionMenu->addAction(ui->actionRestart);
actionMenu->addAction(ui->actionEnable);
ui->actionStart->setMenu(actionMenu);
createActions();
}
@ -47,7 +60,7 @@ MainWidget::~MainWidget()
{
if (debug) qDebug() << PDEBUG;
deleteObjects();
if (ui != nullptr) delete ui;
}
@ -414,31 +427,3 @@ void MainWidget::createActions()
this, SLOT(updateMenuMain()));
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
}
void MainWidget::createObjects()
{
if (debug) qDebug() << PDEBUG;
// windows
ui = new Ui::MainWidget;
ui->setupUi(this);
ui->tableWidget_main->setColumnHidden(2, true);
ui->tableWidget_main->setColumnHidden(3, true);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("NETCTL_TOOLBAR")].toInt()));
// append toolbar
QMenu *actionMenu = new QMenu(this);
actionMenu->addAction(ui->actionSwitch);
actionMenu->addAction(ui->actionRestart);
actionMenu->addAction(ui->actionEnable);
ui->actionStart->setMenu(actionMenu);
}
void MainWidget::deleteObjects()
{
if (debug) qDebug() << PDEBUG;
if (ui != nullptr) delete ui;
}

View File

@ -66,8 +66,6 @@ private:
Ui::MainWidget *ui = nullptr;
// backend
void createActions();
void createObjects();
void deleteObjects();
QString configPath;
bool debug = false;
bool useHelper = true;

View File

@ -563,7 +563,6 @@ void MainWindow::createObjects()
netctlCommand = new Netctl(debug, configuration);
netctlInterface = new NetctlInterface(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration);
wpaCommand = new WpaSup(debug, configuration);
// frontend
mainWidget = new MainWidget(this, configuration, debug);
@ -590,7 +589,6 @@ void MainWindow::deleteObjects()
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
if (netctlCommand != nullptr) delete netctlCommand;
if (netctlInterface != nullptr) delete netctlInterface;
if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand;
if (aboutWin != nullptr) delete aboutWin;

View File

@ -56,7 +56,6 @@ public:
// library interfaces
Netctl *netctlCommand = nullptr;
NetctlInterface *netctlInterface = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
protected:

View File

@ -22,6 +22,8 @@
#include <pdebug/pdebug.h>
#include "calls.h"
#include "commonfunctions.h"
#include "dbusoperation.h"
#include "mainwindow.h"
@ -59,19 +61,6 @@ Qt::ToolBarArea NetctlAutoWindow::getToolBarArea()
}
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool) return QApplication::translate("NetctlAutoWindow", "yes");
if (!nullFalse) return QApplication::translate("NetctlAutoWindow", "no");
return QString("");
}
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << PDEBUG;
@ -95,6 +84,17 @@ void NetctlAutoWindow::createActions()
}
void NetctlAutoWindow::showMessage(const bool status)
{
if (debug) qDebug() << PDEBUG;
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
}
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << PDEBUG;
@ -137,10 +137,10 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
// set text
startProfile->setVisible(ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty());
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("list-add"));
} else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
@ -167,36 +167,18 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
netctlInformation info = generalInformation(mainWindow->netctlInterface,
useHelper, debug);
// actions
bool enabled = false;
bool running = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoUpdateTable();
}
enabled = responce[0].toBool();
responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoUpdateTable();
}
running = responce[0].toBool();
} else {
enabled = mainWindow->netctlCommand->isNetctlAutoEnabled();
running = mainWindow->netctlCommand->isNetctlAutoRunning();
}
ui->actionDisableAll->setEnabled(running);
ui->actionEnableAll->setEnabled(running);
ui->actionRestartService->setEnabled(running);
if (enabled)
ui->actionDisableAll->setEnabled(info.netctlAuto);
ui->actionEnableAll->setEnabled(info.netctlAuto);
ui->actionRestartService->setEnabled(info.netctlAuto);
if (info.netctlAutoEnabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
if (running) {
if (info.netctlAuto) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
} else {
@ -205,50 +187,48 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
netctlAutoRefreshButtons(nullptr, nullptr);
return;
}
QList<netctlProfileInfo> profiles;
if (useHelper)
profiles = parseOutputNetctl(sendRequestToLib(QString("VerboseProfileList"), debug));
else
profiles = mainWindow->netctlCommand->getProfileListFromNetctlAuto();
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget->clear();
ui->tableWidget->setRowCount(profiles.count());
ui->tableWidget->setRowCount(info.netctlAutoProfiles.count());
// create header
QStringList headerList;
headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Enabled"));
ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items
for (int i=0; i<profiles.count(); i++) {
for (int i=0; i<info.netctlAutoProfiles.count(); i++) {
// font
QFont font;
font.setBold(profiles[i].active);
font.setItalic(profiles[i].enabled);
font.setBold(info.netctlAutoProfiles[i].active);
font.setItalic(info.netctlAutoProfiles[i].enabled);
// tooltip
QString toolTip = QString("");
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile"))
.arg(info.netctlAutoProfiles[i].name);
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active"))
.arg(checkStatus(info.netctlAutoProfiles[i].active));
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled"))
.arg(checkStatus(!info.netctlAutoProfiles[i].enabled));
// name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(info.netctlAutoProfiles[i].name));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
ui->tableWidget->item(i, 0)->setFont(font);
// description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(info.netctlAutoProfiles[i].description));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[i].active, true)));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// enabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[i].enabled, true)));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
@ -264,8 +244,8 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
#endif
ui->tableWidget->setCurrentCell(-1, -1);
ui->tableWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
ui->tableWidget->setDisabled(false);
showMessage(true);
netctlAutoRefreshButtons(nullptr, nullptr);
update();
@ -277,21 +257,15 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToCtrl(QString("autoDisableAll"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoDisableAllProfiles();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoDisableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoDisableAllProfiles();
else try {
responce = sendRequestToCtrl(QString("autoDisableAll"), debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -300,27 +274,21 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == nullptr) return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false;
if (useHelper) {
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoEnableProfile(profile);
else try {
QList<QVariant> args;
args.append(profile);
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoEnableProfile();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoEnableProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -331,21 +299,15 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToCtrl(QString("autoEnableAll"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoEnableAllProfiles();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoEnableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoEnableAllProfiles();
else try {
responce = sendRequestToCtrl(QString("autoEnableAll"), debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -354,27 +316,21 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == nullptr) return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false;
if (useHelper) {
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoStartProfile(profile);
else try {
QList<QVariant> args;
args.append(profile);
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoStartProfile();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoStartProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -384,21 +340,15 @@ void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceEnable"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoEnableService();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoEnableService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoEnableService();
else try {
responce = sendRequestToCtrl(QString("autoServiceEnable"), debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -408,21 +358,15 @@ void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceRestart"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoRestartService();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoRestartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoRestartService();
else try {
responce = sendRequestToCtrl(QString("autoServiceRestart"), debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -432,21 +376,15 @@ void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper) {
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceStart"), debug);
if (responce.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
useHelper = false;
return netctlAutoStartService();
}
status = responce[0].toBool();
} else
status = mainWindow->netctlCommand->autoStartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
bool responce = false;
if (!useHelper)
responce = mainWindow->netctlCommand->autoStartService();
else try {
responce = sendRequestToCtrl(QString("autoServiceStart"), debug)[0].toBool();
} catch (...) {
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
}
showMessage(responce);
netctlAutoUpdateTable();
}
@ -461,10 +399,10 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
ui->actionEnable->setEnabled(selected);
ui->actionSwitch->setEnabled(selected && ui->tableWidget->item(current->row(), 2)->text().isEmpty());
if (selected && !ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
} else {
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
}
}

View File

@ -40,6 +40,7 @@ public:
Qt::ToolBarArea getToolBarArea();
public slots:
void showMessage(const bool status);
void showWindow();
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
@ -63,7 +64,6 @@ private:
Ui::NetctlAutoWindow *ui = nullptr;
MainWindow *mainWindow = nullptr;
// backend
QString checkStatus(const bool statusBool, const bool nullFalse = false);
void createActions();
bool debug = false;
bool useHelper = true;

View File

@ -50,7 +50,34 @@ NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString>
mainWindow = dynamic_cast<MainWindow *>(parent);
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects();
// windows
ui = new Ui::NewProfileWidget;
ui->setupUi(this);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("PROFILE_TOOLBAR")].toInt()));
// profile widgets
generalWid = new GeneralWidget(this, configuration);
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);
macvlanWid = new MacvlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
createActions();
}
@ -59,7 +86,19 @@ NewProfileWidget::~NewProfileWidget()
{
if (debug) qDebug() << PDEBUG;
deleteObjects();
if (bridgeWid != nullptr) delete bridgeWid;
if (ethernetWid != nullptr) delete ethernetWid;
if (generalWid != nullptr) delete generalWid;
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;
if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid;
if (ui != nullptr) delete ui;
}
@ -118,9 +157,29 @@ void NewProfileWidget::updateProfileTab()
if (debug) qDebug() << PDEBUG;
mainWindow->setDisabled(true);
profileTabClear();
ui->comboBox_profile->clear();
QList<netctlProfileInfo> profiles = generalInformation(mainWindow->netctlInterface,
useHelper, debug).netctlProfiles;
for (int i=0; i<profiles.count(); i++)
ui->comboBox_profile->addItem(profiles[i].name);
ui->comboBox_profile->setCurrentIndex(-1);
generalWid->clear();
ipWid->clear();
bridgeWid->clear();
ethernetWid->clear();
macvlanWid->clear();
mobileWid->clear();
pppoeWid->clear();
tunnelWid->clear();
tuntapWid->clear();
vlanWid->clear();
wirelessWid->clear();
profileTabChangeState(generalWid->connectionType->currentText());
mainWindow->setDisabled(false);
mainWindow->showMessage(true);
}
@ -145,33 +204,6 @@ void NewProfileWidget::profileTabChangeState(const QString current)
}
void NewProfileWidget::profileTabClear()
{
if (debug) qDebug() << PDEBUG;
ui->comboBox_profile->clear();
QList<netctlProfileInfo> profiles = generalInformation(mainWindow->netctlInterface,
useHelper, debug).netctlProfiles;
for (int i=0; i<profiles.count(); i++)
ui->comboBox_profile->addItem(profiles[i].name);
ui->comboBox_profile->setCurrentIndex(-1);
generalWid->clear();
ipWid->clear();
bridgeWid->clear();
ethernetWid->clear();
macvlanWid->clear();
mobileWid->clear();
pppoeWid->clear();
tunnelWid->clear();
tuntapWid->clear();
vlanWid->clear();
wirelessWid->clear();
profileTabChangeState(generalWid->connectionType->currentText());
}
void NewProfileWidget::profileTabCreateProfile()
{
if (debug) qDebug() << PDEBUG;
@ -398,7 +430,7 @@ void NewProfileWidget::createActions()
if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(updateProfileTab()));
connect(ui->actionLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
connect(ui->actionSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
@ -408,57 +440,3 @@ void NewProfileWidget::createActions()
connect(ui->comboBox_profile->lineEdit(), SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
}
void NewProfileWidget::createObjects()
{
if (debug) qDebug() << PDEBUG;
// windows
ui = new Ui::NewProfileWidget;
ui->setupUi(this);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("PROFILE_TOOLBAR")].toInt()));
// profile widgets
generalWid = new GeneralWidget(this, configuration);
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);
macvlanWid = new MacvlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
}
void NewProfileWidget::deleteObjects()
{
if (debug) qDebug() << PDEBUG;
if (bridgeWid != nullptr) delete bridgeWid;
if (ethernetWid != nullptr) delete ethernetWid;
if (generalWid != nullptr) delete generalWid;
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;
if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid;
if (ui != nullptr) delete ui;
}

View File

@ -62,7 +62,6 @@ private slots:
void updateProfileTab();
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabClear();
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabRemoveProfile();
@ -84,8 +83,6 @@ private:
WirelessWidget *wirelessWid = nullptr;
// backend
void createActions();
void createObjects();
void deleteObjects();
bool debug = false;
bool useHelper = true;
// configuration

View File

@ -76,17 +76,17 @@ void TrayIcon::updateMenu()
contextMenu[QString("title")]->setText(profiles.join(QString(" | ")));
}
startProfileMenu->setVisible(!info.netctlAuto);
startProfileMenu->menuAction()->setVisible(!info.netctlAuto);
contextMenu[QString("stop")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
contextMenu[QString("stopall")]->setVisible(!info.netctlAuto && (info.current.count() > 1));
switchToProfileMenu->setVisible(info.netctlAuto);
switchToProfileMenu->menuAction()->setVisible(info.netctlAuto);
contextMenu[QString("restart")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
contextMenu[QString("enable")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
if (info.netctlAuto) {
switchToProfileMenu->clear();
for (int i=0; i<info.current.count(); i++)
switchToProfileMenu->addAction(info.current[i]);
for (int i=0; i<info.profiles.count(); i++)
switchToProfileMenu->addAction(info.profiles[i]);
} else {
if (info.current.count() == 1) {
contextMenu[QString("stop")]->setText(QApplication::translate("TrayIcon", "Stop %1").arg(info.current[0]));
@ -97,16 +97,11 @@ void TrayIcon::updateMenu()
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Enable %1").arg(info.current[0]));
}
startProfileMenu->clear();
for (int i=0; i<info.current.count(); i++)
startProfileMenu->addAction(info.current[i]);
for (int i=0; i<info.profiles.count(); i++)
startProfileMenu->addAction(info.profiles[i]);
}
if (mainWindow->isHidden())
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Show"));
else
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Hide"));
setContextMenu(menuActions);
// setContextMenu(menuActions);
}
@ -164,6 +159,7 @@ void TrayIcon::init()
setToolTip(QString("netctl-gui"));
createActions();
setContextMenu(menuActions);
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(itemActivated(QSystemTrayIcon::ActivationReason)));
@ -180,8 +176,6 @@ void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
mainWindow->showMainWindow();
break;
case QSystemTrayIcon::Context:
// clear menu before update
setContextMenu(0);
updateMenu();
break;
default:
@ -214,7 +208,7 @@ void TrayIcon::startProfileTraySlot(QAction *action)
{
if (debug) qDebug() << PDEBUG;
QString profile = action->text().remove(QChar('&'));
QString profile = action == nullptr ? mainWindow->printInformation()[0] : action->text().remove(QChar('&'));
startProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug);
}
@ -231,6 +225,7 @@ void TrayIcon::stopAllProfilesTraySlot()
void TrayIcon::switchToProfileTraySlot(QAction *action)
{
if (debug) qDebug() << PDEBUG;
if (action == nullptr) return;
QString profile = action->text().remove(QChar('&'));

View File

@ -42,7 +42,7 @@ private slots:
void itemActivated(const QSystemTrayIcon::ActivationReason reason);
void enableProfileTraySlot();
void restartProfileTraySlot();
void startProfileTraySlot(QAction *action);
void startProfileTraySlot(QAction *action = nullptr);
void stopAllProfilesTraySlot();
void switchToProfileTraySlot(QAction *action);

View File

@ -39,7 +39,13 @@ WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> set
mainWindow = dynamic_cast<MainWindow *>(parent);
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects();
// windows
ui = new Ui::WiFiMenuWidget;
ui->setupUi(this);
ui->tableWidget_wifi->setColumnHidden(5, true);
ui->tableWidget_wifi->setColumnHidden(6, true);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("WIFI_TOOLBAR")].toInt()));
createActions();
}
@ -48,7 +54,7 @@ WiFiMenuWidget::~WiFiMenuWidget()
{
if (debug) qDebug() << PDEBUG;
deleteObjects();
if (ui != nullptr) delete ui;
}
@ -175,7 +181,7 @@ void WiFiMenuWidget::updateMenuWifi()
void WiFiMenuWidget::updateText(const netctlWifiInfo current)
{
if (debug) qDebug() << PDEBUG;
if (wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
emit(mainWindow->needToBeConfigured());
@ -194,7 +200,7 @@ void WiFiMenuWidget::updateText(const netctlWifiInfo current)
void WiFiMenuWidget::updateWifiTab()
{
if (debug) qDebug() << PDEBUG;
if (wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
emit(mainWindow->needToBeConfigured());
@ -212,7 +218,8 @@ void WiFiMenuWidget::updateWifiTab()
ui->tableWidget_wifi->selectRow(-1);
ui->tableWidget_wifi->sortByColumn(3, Qt::AscendingOrder);
ui->tableWidget_wifi->clear();
ui->tableWidget_wifi->setRowCount(scanResults.count());
// -1 because the first is always current point
ui->tableWidget_wifi->setRowCount(scanResults.count() - 1);
// create header
QStringList headerList;
@ -422,24 +429,3 @@ void WiFiMenuWidget::createActions()
this, SLOT(updateMenuWifi()));
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
}
void WiFiMenuWidget::createObjects()
{
if (debug) qDebug() << PDEBUG;
// windows
ui = new Ui::WiFiMenuWidget;
ui->setupUi(this);
ui->tableWidget_wifi->setColumnHidden(5, true);
ui->tableWidget_wifi->setColumnHidden(6, true);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("WIFI_TOOLBAR")].toInt()));
}
void WiFiMenuWidget::deleteObjects()
{
if (debug) qDebug() << PDEBUG;
if (ui != nullptr) delete ui;
}

View File

@ -67,8 +67,6 @@ private:
PasswdWidget *passwdWid = nullptr;
// backend
void createActions();
void createObjects();
void deleteObjects();
bool debug = false;
bool hiddenNetwork = false;
bool useHelper = true;

View File

@ -41,12 +41,6 @@ InterfaceAdaptor::~InterfaceAdaptor()
// control slots
int InterfaceAdaptor::autoEnable(const QString profile)
{
return netctlInterface->autoEnableProfile(profile);
}
int InterfaceAdaptor::Create(const QString profile, const QStringList settingsList)
{
return netctlInterface->createProfile(profile, listToMap(settingsList));
@ -113,6 +107,7 @@ QStringList InterfaceAdaptor::Information()
netctlInformation information = netctlInterface->information();
QStringList info;
info.append(QString::number(information.netctlAuto));
info.append(QString::number(information.netctlAutoEnabled));
QList<netctlProfileInfo> profiles = information.netctlProfiles;
profiles.append(information.netctlAutoProfiles);

View File

@ -36,7 +36,6 @@ public:
public slots:
// control slots
int autoEnable(const QString profile);
int Create(const QString profile, const QStringList settingsList);
int Enable(const QString profile);
int Essid(const QString essid, QStringList settingsList);

View File

@ -74,18 +74,21 @@ typedef struct
/**
* @struct netctlInformation
* @brief general information structure
* @var netctlCurrent::netctlProfiles
* @var netctlInformation::netctlProfiles
* list of profiles
* @var netctlCurrent::netctlAutoProfiles
* @var netctlInformation::netctlAutoProfiles
* list of netctl-auto profiles
* @var netctlCurrent::netctlAuto
* @var netctlInformation::netctlAuto
* is netctl-auto active
* @var netctlInformation::netctlAutoEnabled
* is netctl-auto enabled
*/
typedef struct
{
QList<netctlProfileInfo> netctlProfiles;
QList<netctlProfileInfo> netctlAutoProfiles;
bool netctlAuto = false;
bool netctlAutoEnabled = false;
} netctlInformation;
/**
@ -108,15 +111,6 @@ public:
*/
~NetctlInterface();
// control methods
/**
* @brief method which enables or disables selected profile and returns its status
* @remark netctl-auto only
* @param profile profile name
* @return InterfaceAnswer::False if profile is disabled
* @return InterfaceAnswer::True if profile is enabled
* @return InterfaceAnswer::Error if an error occurs
*/
InterfaceAnswer autoEnableProfile(const QString profile);
/**
* @brief method which creates and copies profile
* @remark netctl independ

View File

@ -57,23 +57,6 @@ NetctlInterface::~NetctlInterface()
}
/**
* @fn autoEnableProfile
*/
InterfaceAnswer NetctlInterface::autoEnableProfile(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (netctlCommand == nullptr) {
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
return InterfaceAnswer::Error;
}
netctlCommand->autoEnableProfile(profile);
return static_cast<InterfaceAnswer>(netctlCommand->autoIsProfileEnabled(profile));
}
/**
* @fn connectToEssid
*/
@ -300,6 +283,7 @@ netctlInformation NetctlInterface::information()
netctlInformation info;
info.netctlAuto = netctlCommand->isNetctlAutoRunning();
info.netctlAutoEnabled = netctlCommand->isNetctlAutoEnabled();
info.netctlProfiles = netctlCommand->getProfileList();
if (info.netctlAuto) info.netctlAutoProfiles = netctlCommand->getProfileListFromNetctlAuto();