mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
+ add toolbar config
+ create interface class * update UI
This commit is contained in:
parent
02432be630
commit
26afd90df9
@ -198,12 +198,12 @@ small {
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>QStringList CurrentWiFi()</td>
|
||||
<td>returns current WiFi point in format <code>NAME|SECURITY|TYPE|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>returns current WiFi point in format <code>NAME|SECURITY|TYPE|FREQ|MAC|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseWiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|TYPE|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|TYPE|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code>. First line is always active connection (see <code>CurrentWiFi()</code>)</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
183
sources/gui/src/calls.cpp
Normal file
183
sources/gui/src/calls.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
/***************************************************************************
|
||||
* 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 "calls.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "dbusoperation.h"
|
||||
|
||||
|
||||
bool enableProfileSlot(const QString profile, Netctl *netctlCommand,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
// enable
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("Enable"), args, debug);
|
||||
// check
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileEnabled"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
// enable
|
||||
netctlCommand->enableProfile(profile);
|
||||
// check
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool restartProfileSlot(const QString profile, Netctl *netctlCommand,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
// restart
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("Restart"), args, debug);
|
||||
// check
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
// restart
|
||||
netctlCommand->restartProfile(profile);
|
||||
// check
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool startProfileSlot(const QString profile, Netctl *netctlCommand,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
// get current
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QList<QVariant> responce = sendRequestToLib(QString("ActiveProfile"), debug);
|
||||
QStringList currentProfile;
|
||||
if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|'));
|
||||
// start or switch
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
sendRequestToCtrlWithArgs(QString("Start"), args, debug);
|
||||
else
|
||||
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||
// check
|
||||
responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
// get current
|
||||
QStringList currentProfile = netctlCommand->getActiveProfile();
|
||||
// start or switch
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
netctlCommand->startProfile(profile);
|
||||
else
|
||||
netctlCommand->switchToProfile(profile);
|
||||
// check
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::stopAllProfilesSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper)
|
||||
sendRequestToCtrl(QString("StolAll"), debug);
|
||||
else
|
||||
netctlCommand->stopAllProfiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::switchToProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool netctlAutoStatus = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||
if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool();
|
||||
} else
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
|
||||
bool current;
|
||||
if (netctlAutoStatus) {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("autoStart"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("autoIsProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->autoStartProfile(profile);
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
} else {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
31
sources/gui/src/calls.h
Normal file
31
sources/gui/src/calls.h
Normal file
@ -0,0 +1,31 @@
|
||||
/***************************************************************************
|
||||
* 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 CALLS_H
|
||||
#define CALLS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
bool enableProfileSlot(const QString profile, Netctl *netctlCommand,
|
||||
const bool useHelper, const bool debug = false);
|
||||
|
||||
|
||||
#endif /* CALLS_H */
|
@ -51,6 +51,14 @@ MainWidget::~MainWidget()
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
bool MainWidget::mainTabSelectProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -65,14 +73,6 @@ bool MainWidget::mainTabSelectProfileSlot(const QString profile)
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -82,6 +82,19 @@ void MainWidget::update()
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateMenuMain()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -139,10 +152,10 @@ void MainWidget::updateMainTab()
|
||||
netctlAutoStatus = responce[0].toBool();
|
||||
profiles = parseOutputNetctl(sendRequestToLib(QString("netctlVerboseProfileList"), debug));
|
||||
} else {
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
profiles = netctlCommand->getProfileList();
|
||||
netctlAutoStatus = mainWindow->netctlCommand->isNetctlAutoRunning();
|
||||
profiles = mainWindow->netctlCommand->getProfileList();
|
||||
}
|
||||
ui->widget_netctlAuto->setHidden(!netctlAutoStatus);
|
||||
ui->label_netctlAuto->setHidden(!netctlAutoStatus);
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
ui->tableWidget_main->selectRow(-1);
|
||||
@ -317,7 +330,7 @@ void MainWidget::mainTabRemoveProfile()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlProfile->removeProfile(profile);
|
||||
status = mainWindow->netctlProfile->removeProfile(profile);
|
||||
mainWindow->showMessage(status);
|
||||
|
||||
updateMainTab();
|
||||
@ -380,7 +393,7 @@ void MainWidget::mainTabStopAllProfiles()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->stopAllProfiles();
|
||||
status = mainWindow->netctlCommand->stopAllProfiles();
|
||||
mainWindow->showMessage(status);
|
||||
|
||||
updateMainTab();
|
||||
@ -412,7 +425,6 @@ void MainWidget::createActions()
|
||||
// menu actions
|
||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||
connect(ui->actionNetctl_auto, SIGNAL(triggered(bool)), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||
connect(ui->actionRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
@ -420,7 +432,6 @@ void MainWidget::createActions()
|
||||
connect(ui->actionStop_all, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
|
||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
|
||||
// main tab events
|
||||
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuMain()));
|
||||
@ -432,15 +443,13 @@ void MainWidget::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// backend
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
// windows
|
||||
ui = new Ui::MainWidget;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("NETCTL_TOOLBAR")].toInt()));
|
||||
netctlAutoWin = new NetctlAutoWindow(mainWindow, debug, configuration);
|
||||
|
||||
// append toolbar
|
||||
QMenu *actionMenu = new QMenu(this);
|
||||
@ -455,9 +464,6 @@ void MainWidget::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
|
||||
if (netctlAutoWin != nullptr) delete netctlAutoWin;
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
@ -40,11 +40,13 @@ public:
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~MainWidget();
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
bool mainTabSelectProfileSlot(const QString profile);
|
||||
void showNetctlAutoWindow();
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// update slots
|
||||
@ -64,10 +66,7 @@ private:
|
||||
// ui
|
||||
MainWindow *mainWindow = nullptr;
|
||||
Ui::MainWidget *ui = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
void createActions();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
|
@ -12,12 +12,6 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_netctlAuto" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_netctlAuto">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -34,16 +28,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_netctlAuto">
|
||||
<property name="text">
|
||||
<string>Show</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_main">
|
||||
<property name="contextMenuPolicy">
|
||||
@ -105,7 +89,6 @@
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNetctl_auto"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStart"/>
|
||||
@ -114,14 +97,6 @@
|
||||
<addaction name="actionEdit"/>
|
||||
<addaction name="actionRemove"/>
|
||||
</widget>
|
||||
<action name="actionNetctl_auto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show netctl-auto window</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
@ -38,6 +39,7 @@
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "netctlguiadaptor.h"
|
||||
#include "newprofilewidget.h"
|
||||
#include "passwdwidget.h"
|
||||
@ -71,6 +73,8 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
|
||||
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
updateConfiguration(args);
|
||||
|
||||
// main actions
|
||||
@ -103,6 +107,15 @@ MainWindow::~MainWindow()
|
||||
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
|
||||
forceStopHelper();
|
||||
deleteObjects();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
@ -267,10 +280,19 @@ void MainWindow::closeMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
storeToolBars();
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::openProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
newProfileWidget->profileTabOpenProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showAboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -295,7 +317,7 @@ void MainWindow::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
mainWidget->showNetctlAutoWindow();
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
@ -303,160 +325,11 @@ void MainWindow::showSettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
storeToolBars();
|
||||
settingsWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::enableProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("Enable"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileEnabled"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->enableProfile(profile);
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::openProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
newProfileWidget->profileTabOpenProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::restartProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("Restart"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->restartProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QList<QVariant> responce = sendRequestToLib(QString("ActiveProfile"), debug);
|
||||
QStringList currentProfile;
|
||||
if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|'));
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
sendRequestToCtrlWithArgs(QString("Start"), args, debug);
|
||||
else
|
||||
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||
responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
QStringList currentProfile = netctlCommand->getActiveProfile();
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
netctlCommand->startProfile(profile);
|
||||
else
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::stopAllProfilesSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper)
|
||||
sendRequestToCtrl(QString("StolAll"), debug);
|
||||
else
|
||||
netctlCommand->stopAllProfiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::switchToProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool netctlAutoStatus = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||
if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool();
|
||||
} else
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
|
||||
bool current;
|
||||
if (netctlAutoStatus) {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("autoStart"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("autoIsProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->autoStartProfile(profile);
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
} else {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("SwitchTo"), args, debug);
|
||||
QList<QVariant> responce = sendRequestToLibWithArgs(QString("isProfileActive"), args, debug);
|
||||
if (responce.isEmpty())
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
else
|
||||
current = responce[0].toBool();
|
||||
} else {
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showApi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -556,6 +429,24 @@ void MainWindow::showMessage(const bool status)
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::storeToolBars()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(configPath, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
settings.setValue(QString("MAIN_TOOLBAR"), QString::number(getToolBarArea()));
|
||||
settings.setValue(QString("NETCTL_TOOLBAR"), QString::number(mainWidget->getToolBarArea()));
|
||||
settings.setValue(QString("NETCTLAUTO_TOOLBAR"), QString::number(netctlAutoWin->getToolBarArea()));
|
||||
settings.setValue(QString("PROFILE_TOOLBAR"), QString::number(newProfileWidget->getToolBarArea()));
|
||||
settings.setValue(QString("WIFI_TOOLBAR"), QString::number(wifiMenuWidget->getToolBarArea()));
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -627,6 +518,21 @@ void MainWindow::updateTabs(const int tab)
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
|
||||
qDebug() << findChildren<QToolBar *>().count();
|
||||
}
|
||||
|
||||
|
||||
// private slots
|
||||
void MainWindow::setMainTab()
|
||||
{
|
||||
@ -681,6 +587,7 @@ void MainWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->actionNetctl, SIGNAL(triggered()), this, SLOT(setMainTab()));
|
||||
connect(ui->actionProfiles, SIGNAL(triggered()), this, SLOT(setProfileTab()));
|
||||
connect(ui->actionWiFi_menu, SIGNAL(triggered()), this, SLOT(setWifiTab()));
|
||||
@ -729,17 +636,20 @@ void MainWindow::createObjects()
|
||||
checkHelperStatus();
|
||||
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// frontend
|
||||
mainWidget = new MainWidget(this, configuration, debug);
|
||||
netctlAutoWin = mainWidget->netctlAutoWin;
|
||||
newProfileWidget = new NewProfileWidget(this, configuration, debug);
|
||||
wifiMenuWidget = new WiFiMenuWidget(this, configuration, debug);
|
||||
trayIcon = new TrayIcon(this, debug);
|
||||
// windows
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
ui->retranslateUi(this);
|
||||
ui->layout_main->addWidget(mainWidget);
|
||||
ui->layout_new->addWidget(newProfileWidget);
|
||||
ui->layout_wifi->addWidget(wifiMenuWidget);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt()));
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
}
|
||||
@ -752,6 +662,8 @@ void MainWindow::deleteObjects()
|
||||
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
|
||||
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
|
||||
if (aboutWin != nullptr) delete aboutWin;
|
||||
if (settingsWin != nullptr) delete settingsWin;
|
||||
@ -759,7 +671,6 @@ void MainWindow::deleteObjects()
|
||||
if (mainWidget != nullptr) delete mainWidget;
|
||||
if (newProfileWidget != nullptr) delete newProfileWidget;
|
||||
if (wifiMenuWidget != nullptr) delete wifiMenuWidget;
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
class AboutWindow;
|
||||
class MainWidget;
|
||||
class NetctlAutoWindow;
|
||||
class NewProfileWidget;
|
||||
class SettingsWindow;
|
||||
class TrayIcon;
|
||||
@ -46,11 +47,16 @@ public:
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
~MainWindow();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
QStringList printInformation();
|
||||
QStringList printSettings();
|
||||
QStringList printTrayInformation();
|
||||
bool isHelperActive();
|
||||
bool isHelperServiceActive();
|
||||
// library interfaces
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
@ -58,17 +64,11 @@ protected:
|
||||
public slots:
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void openProfileSlot(const QString profile);
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// trayicon control slots
|
||||
bool enableProfileSlot(const QString profile);
|
||||
void openProfileSlot(const QString profile);
|
||||
bool startProfileSlot(const QString profile);
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(const QString profile);
|
||||
bool restartProfileSlot(const QString profile);
|
||||
// open docs
|
||||
void showApi();
|
||||
void showLibrary();
|
||||
@ -81,8 +81,10 @@ public slots:
|
||||
void setDisabled(const bool disabled = true);
|
||||
void setTab(int tab);
|
||||
void showMessage(const bool status);
|
||||
void storeToolBars();
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateTabs(const int tab);
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
signals:
|
||||
void needToBeConfigured();
|
||||
@ -99,11 +101,11 @@ private:
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
MainWidget *mainWidget = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
NewProfileWidget *newProfileWidget = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
WiFiMenuWidget *wifiMenuWidget = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
bool checkHelperStatus();
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
|
@ -88,6 +88,7 @@
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNetctl_auto"/>
|
||||
<addaction name="actionNetctl"/>
|
||||
<addaction name="actionProfiles"/>
|
||||
<addaction name="actionWiFi_menu"/>
|
||||
@ -213,6 +214,11 @@
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctl_auto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
|
@ -20,10 +20,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "dbusoperation.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
@ -31,11 +31,12 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
|
||||
ui(new Ui::NetctlAutoWindow),
|
||||
debug(debugCmd)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (settings[QString("USE_HELPER")] == QString("true"));
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget->setColumnHidden(2, true);
|
||||
ui->tableWidget->setColumnHidden(3, true);
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(settings[QString("NETCTLAUTO_TOOLBAR")].toInt()));
|
||||
|
||||
createActions();
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
||||
@ -46,12 +47,18 @@ NetctlAutoWindow::~NetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete netctlCommand;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea NetctlAutoWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -98,6 +105,19 @@ void NetctlAutoWindow::showWindow()
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -166,8 +186,8 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
}
|
||||
running = responce[0].toBool();
|
||||
} else {
|
||||
enabled = netctlCommand->isNetctlAutoEnabled();
|
||||
running = netctlCommand->isNetctlAutoRunning();
|
||||
enabled = mainWindow->netctlCommand->isNetctlAutoEnabled();
|
||||
running = mainWindow->netctlCommand->isNetctlAutoRunning();
|
||||
}
|
||||
ui->actionDisableAll->setEnabled(running);
|
||||
ui->actionEnableAll->setEnabled(running);
|
||||
@ -189,7 +209,7 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendRequestToLib(QString("VerboseProfileList"), debug));
|
||||
else
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
profiles = mainWindow->netctlCommand->getProfileListFromNetctlAuto();
|
||||
|
||||
ui->tableWidget->setSortingEnabled(false);
|
||||
ui->tableWidget->selectRow(-1);
|
||||
@ -267,7 +287,7 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoDisableAllProfiles();
|
||||
status = mainWindow->netctlCommand->autoDisableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -296,7 +316,7 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableProfile(profile);
|
||||
status = mainWindow->netctlCommand->autoEnableProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -321,7 +341,7 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableAllProfiles();
|
||||
status = mainWindow->netctlCommand->autoEnableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -350,7 +370,7 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoStartProfile(profile);
|
||||
status = mainWindow->netctlCommand->autoStartProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -374,7 +394,7 @@ void NetctlAutoWindow::netctlAutoEnableService()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableService();
|
||||
status = mainWindow->netctlCommand->autoEnableService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -398,7 +418,7 @@ void NetctlAutoWindow::netctlAutoRestartService()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoRestartService();
|
||||
status = mainWindow->netctlCommand->autoRestartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
@ -422,7 +442,7 @@ void NetctlAutoWindow::netctlAutoStartService()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoStartService();
|
||||
status = mainWindow->netctlCommand->autoStartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
class Netctl;
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class NetctlAutoWindow;
|
||||
@ -37,9 +37,11 @@ public:
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~NetctlAutoWindow();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void showWindow();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// table
|
||||
@ -59,8 +61,8 @@ private slots:
|
||||
private:
|
||||
// ui
|
||||
Ui::NetctlAutoWindow *ui = nullptr;
|
||||
MainWindow *mainWindow = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
bool debug = false;
|
||||
|
@ -62,6 +62,14 @@ NewProfileWidget::~NewProfileWidget()
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea NewProfileWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabOpenProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -80,6 +88,19 @@ void NewProfileWidget::update()
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::updateMenuProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -132,7 +153,7 @@ void NewProfileWidget::profileTabClear()
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendRequestToLib(QString("netctlVerboseProfileList"), debug));
|
||||
else
|
||||
profiles = netctlCommand->getProfileList();
|
||||
profiles = mainWindow->netctlCommand->getProfileList();
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
ui->comboBox_profile->addItem(profiles[i].name);
|
||||
ui->comboBox_profile->setCurrentIndex(-1);
|
||||
@ -322,8 +343,8 @@ void NewProfileWidget::profileTabCreateProfile()
|
||||
status = responce[0].toBool();
|
||||
|
||||
} else {
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
status = netctlProfile->copyProfile(profileTempName);
|
||||
QString profileTempName = mainWindow->netctlProfile->createProfile(profile, settings);
|
||||
status = mainWindow->netctlProfile->copyProfile(profileTempName);
|
||||
}
|
||||
mainWindow->showMessage(status);
|
||||
|
||||
@ -355,7 +376,7 @@ void NewProfileWidget::profileTabLoadProfile()
|
||||
settings[key] = value;
|
||||
}
|
||||
} else
|
||||
settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
settings = mainWindow->netctlProfile->getSettingsFromProfile(profile);
|
||||
|
||||
if (settings.isEmpty()) return ErrorWindow::showWindow(17, QString(PDEBUG), debug);
|
||||
|
||||
@ -414,7 +435,7 @@ void NewProfileWidget::profileTabRemoveProfile()
|
||||
}
|
||||
status = responce[0].toBool();
|
||||
} else
|
||||
status = netctlProfile->removeProfile(profile);
|
||||
status = mainWindow->netctlProfile->removeProfile(profile);
|
||||
mainWindow->showMessage(status);
|
||||
|
||||
updateProfileTab();
|
||||
@ -442,12 +463,10 @@ void NewProfileWidget::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// backend
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
// 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);
|
||||
@ -478,9 +497,6 @@ void NewProfileWidget::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
|
||||
if (bridgeWid != nullptr) delete bridgeWid;
|
||||
if (ethernetWid != nullptr) delete ethernetWid;
|
||||
if (generalWid != nullptr) delete generalWid;
|
||||
|
@ -49,10 +49,12 @@ public:
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~NewProfileWidget();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void profileTabOpenProfileSlot(const QString profile);
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// update slots
|
||||
@ -81,8 +83,6 @@ private:
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
void createActions();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
|
@ -76,6 +76,48 @@ void SettingsWindow::createActions()
|
||||
}
|
||||
|
||||
|
||||
int SettingsWindow::indexByToolBarPosition(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Area" << area;
|
||||
|
||||
switch (area) {
|
||||
case Qt::LeftToolBarArea:
|
||||
return 0;
|
||||
case Qt::RightToolBarArea:
|
||||
return 1;
|
||||
case Qt::TopToolBarArea:
|
||||
return 2;
|
||||
case Qt::BottomToolBarArea:
|
||||
return 3;
|
||||
case Qt::NoToolBarArea:
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea SettingsWindow::indexToToolBarPosition(const int index)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Index" << index;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
return Qt::LeftToolBarArea;
|
||||
case 1:
|
||||
return Qt::RightToolBarArea;
|
||||
case 2:
|
||||
return Qt::TopToolBarArea;
|
||||
case 3:
|
||||
return Qt::BottomToolBarArea;
|
||||
case 4:
|
||||
default:
|
||||
return Qt::NoToolBarArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
@ -169,6 +211,14 @@ void SettingsWindow::saveSettings()
|
||||
settings.setValue(QString("PREFERED_IFACE"), config[QString("PREFERED_IFACE")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
settings.setValue(QString("MAIN_TOOLBAR"), config[QString("MAIN_TOOLBAR")]);
|
||||
settings.setValue(QString("NETCTL_TOOLBAR"), config[QString("NETCTL_TOOLBAR")]);
|
||||
settings.setValue(QString("NETCTLAUTO_TOOLBAR"), config[QString("NETCTLAUTO_TOOLBAR")]);
|
||||
settings.setValue(QString("PROFILE_TOOLBAR"), config[QString("PROFILE_TOOLBAR")]);
|
||||
settings.setValue(QString("WIFI_TOOLBAR"), config[QString("WIFI_TOOLBAR")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
@ -293,12 +343,16 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
config[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
|
||||
config[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
config[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
config[QString("MAIN_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_mainToolbar->currentIndex()));
|
||||
config[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
config[QString("NETCTL_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_netctlToolbar->currentIndex()));
|
||||
config[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
|
||||
config[QString("NETCTLAUTO_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_netctlAutoToolbar->currentIndex()));
|
||||
config[QString("PID_FILE")] = ui->lineEdit_pid->text();
|
||||
config[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
config[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
config[QString("PROFILE_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_profilesToolbar->currentIndex()));
|
||||
config[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
if (ui->checkBox_components->checkState() == 2)
|
||||
config[QString("SKIPCOMPONENTS")] = QString("true");
|
||||
@ -318,6 +372,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
config[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
config[QString("USE_HELPER")] = QString("false");
|
||||
config[QString("WIFI_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_wifiToolbar->currentIndex()));
|
||||
config[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
config[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
@ -352,11 +407,19 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
|
||||
ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]);
|
||||
int index = ui->comboBox_language->findText(config[QString("LANGUAGE")]);
|
||||
ui->comboBox_language->setCurrentIndex(index);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("MAIN_TOOLBAR")].toInt()));
|
||||
ui->comboBox_mainToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("NETCTL_TOOLBAR")].toInt()));
|
||||
ui->comboBox_netctlToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]);
|
||||
ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("NETCTLAUTO_TOOLBAR")].toInt()));
|
||||
ui->comboBox_netctlAutoToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_pid->setText(config[QString("PID_FILE")]);
|
||||
ui->lineEdit_interface->setText(config[QString("PREFERED_IFACE")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("PROFILE_TOOLBAR")].toInt()));
|
||||
ui->comboBox_profilesToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_profilePath->setText(config[QString("PROFILE_DIR")]);
|
||||
ui->lineEdit_rfkill->setText(config[QString("RFKILL_DIR")]);
|
||||
if (config[QString("SKIPCOMPONENTS")] == QString("true"))
|
||||
@ -377,6 +440,8 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("WIFI_TOOLBAR")].toInt()));
|
||||
ui->comboBox_wifiToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_wpaCliPath->setText(config[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(config[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]);
|
||||
@ -447,6 +512,14 @@ QMap<QString, QString> SettingsWindow::getSettings(QString fileName)
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString("")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
config[QString("MAIN_TOOLBAR")] = settings.value(QString("MAIN_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("NETCTL_TOOLBAR")] = settings.value(QString("NETCTL_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("NETCTLAUTO_TOOLBAR")] = settings.value(QString("NETCTLAUTO_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("PROFILE_TOOLBAR")] = settings.value(QString("PROFILE_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("WIFI_TOOLBAR")] = settings.value(QString("WIFI_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
settings.endGroup();
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
|
||||
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
QString file;
|
||||
Ui::SettingsWindow *ui;
|
||||
void createActions();
|
||||
int indexByToolBarPosition(const Qt::ToolBarArea area);
|
||||
Qt::ToolBarArea indexToToolBarPosition(const int index);
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QMap<QString, QString> readSettings();
|
||||
|
@ -37,12 +37,12 @@
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -114,6 +114,14 @@
|
||||
</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Toolbars</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="configure-toolbars"/>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -314,7 +322,7 @@
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_helper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -612,8 +620,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
<width>436</width>
|
||||
<height>173</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -868,8 +876,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
<width>436</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@ -953,8 +961,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
<width>239</width>
|
||||
<height>194</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
@ -1371,6 +1379,317 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_toolbars">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_toolbars">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_toolbars">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mainToolbar">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mainToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Main toolbar</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mainToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_netctlToolbar">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netctlToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl toolbar</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_netctlToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_netctlAutoToolbar">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netctlAutoToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl-auto toolbar</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_netctlAutoToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_profilesToolbar">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_profilesToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profiles toolbar</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_profilesToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wifiToolbar">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wifiToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WiFi toolbar</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_wifiToolbar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_toolbars">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -51,6 +51,14 @@ WiFiMenuWidget::~WiFiMenuWidget()
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea WiFiMenuWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -60,6 +68,19 @@ void WiFiMenuWidget::update()
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WiFiMenuWidget::wifiTabSelectEssidSlot(const QString essid)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -82,11 +103,11 @@ void WiFiMenuWidget::connectToUnknownEssid(const QString passwd)
|
||||
if (useHelper) {
|
||||
QList<QVariant> responce = sendRequestToLib(QString("WirelessInterfaces"), debug);
|
||||
if (responce.isEmpty())
|
||||
interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
interfaces = mainWindow->netctlCommand->getWirelessInterfaceList();
|
||||
else
|
||||
interfaces = responce[0].toStringList();
|
||||
} else
|
||||
interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
interfaces = mainWindow->netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) return;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
@ -118,8 +139,8 @@ void WiFiMenuWidget::connectToUnknownEssid(const QString passwd)
|
||||
args.append(settingsList);
|
||||
sendRequestToCtrlWithArgs(QString("Create"), args, debug);
|
||||
} else {
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
netctlProfile->copyProfile(profileTempName);
|
||||
QString profileTempName = mainWindow->netctlProfile->createProfile(profile, settings);
|
||||
mainWindow->netctlProfile->copyProfile(profileTempName);
|
||||
}
|
||||
QString message;
|
||||
if (mainWindow->startProfileSlot(profile)) {
|
||||
@ -143,7 +164,7 @@ void WiFiMenuWidget::connectToUnknownEssid(const QString passwd)
|
||||
args.append(profile);
|
||||
sendRequestToCtrlWithArgs(QString("Remove"), args, debug);
|
||||
} else
|
||||
netctlProfile->removeProfile(profile);
|
||||
mainWindow->netctlProfile->removeProfile(profile);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -178,6 +199,32 @@ void WiFiMenuWidget::updateMenuWifi()
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateText()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug));
|
||||
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
emit(mainWindow->needToBeConfigured());
|
||||
return;
|
||||
}
|
||||
ui->label_wifi->setText(QApplication::translate("WiFiMenuWidget", "Processing..."));
|
||||
|
||||
netctlWifiInfo current;
|
||||
if (useHelper)
|
||||
current = parseOutputWifi(sendRequestToCtrl(QString("CurrentWiFi"), debug))[0];
|
||||
else
|
||||
current = mainWindow->wpaCommand->scanWifi()[0];
|
||||
if (current.name.isEmpty()) return;
|
||||
|
||||
QString text = QString("");
|
||||
text += QString("%1 - %2 - %3 ").arg(current.name).arg(current.security).arg(current.macs[0]);
|
||||
text += QString("(%1 %2)").arg(current.frequencies[0]).arg(QApplication::translate("WiFiMenuWidget", "MHz"));
|
||||
|
||||
ui->label_wifi->setText(text);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateWifiTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -193,7 +240,7 @@ void WiFiMenuWidget::updateWifiTab()
|
||||
if (useHelper)
|
||||
scanResults = parseOutputWifi(sendRequestToCtrl(QString("VerboseWiFi"), debug));
|
||||
else
|
||||
scanResults = wpaCommand->scanWifi();
|
||||
scanResults = mainWindow->wpaCommand->scanWifi();
|
||||
|
||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||
ui->tableWidget_wifi->selectRow(-1);
|
||||
@ -288,6 +335,7 @@ void WiFiMenuWidget::updateWifiTab()
|
||||
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
updateText();
|
||||
mainWindow->setDisabled(false);
|
||||
mainWindow->showMessage(true);
|
||||
}
|
||||
@ -333,7 +381,7 @@ void WiFiMenuWidget::wifiTabSetEnabled(const bool state)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
ui->tableWidget_wifi->setHidden(!state);
|
||||
ui->label_wifi->setHidden(state);
|
||||
if (!state) ui->label_wifi->setText(QApplication::translate("WiFiMenuWidget", "Please install 'wpa_supplicant' before using it"));
|
||||
}
|
||||
|
||||
|
||||
@ -379,7 +427,7 @@ void WiFiMenuWidget::wifiTabStart()
|
||||
}
|
||||
profileName = responce[0].toString();
|
||||
} else
|
||||
profileName = wpaCommand->existentProfile(profile);
|
||||
profileName = mainWindow->wpaCommand->existentProfile(profile);
|
||||
mainWindow->showMessage(mainWindow->startProfileSlot(profileName));
|
||||
} else {
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||
@ -421,15 +469,12 @@ void WiFiMenuWidget::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// backend
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// 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()));
|
||||
}
|
||||
|
||||
|
||||
@ -437,9 +482,5 @@ void WiFiMenuWidget::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
@ -40,9 +40,11 @@ public:
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~WiFiMenuWidget();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
bool wifiTabSelectEssidSlot(const QString essid);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
@ -51,6 +53,7 @@ public slots:
|
||||
private slots:
|
||||
// update slots
|
||||
void updateMenuWifi();
|
||||
void updateText();
|
||||
void updateWifiTab();
|
||||
// wifi tab slots
|
||||
void wifiTabContextualMenu(const QPoint &pos);
|
||||
@ -63,9 +66,6 @@ private:
|
||||
Ui::WiFiMenuWidget *ui = nullptr;
|
||||
PasswdWidget *passwdWid = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
void createActions();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
|
@ -271,7 +271,9 @@ QString ControlAdaptor::CurrentWiFi()
|
||||
|
||||
QStringList ControlAdaptor::VerboseWiFi()
|
||||
{
|
||||
QList<netctlWifiInfo> wifiPoints = wpaCommand->scanWifi();
|
||||
QList<netctlWifiInfo> wifiPoints;
|
||||
wifiPoints.append(wpaCommand->current());
|
||||
wifiPoints.append(wpaCommand->scanWifi());
|
||||
QStringList info;
|
||||
for (int i=0; i<wifiPoints.count(); i++) {
|
||||
QStringList point;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#ifndef NETCTLGUI_H
|
||||
#define NETCTLGUI_H
|
||||
|
||||
#include "netctlinterface.h"
|
||||
#include "netctlinteract.h"
|
||||
#include "netctlprofile.h"
|
||||
#include "wpasupinteract.h"
|
||||
|
178
sources/netctlgui/include/netctlgui/netctlinterface.h
Normal file
178
sources/netctlgui/include/netctlgui/netctlinterface.h
Normal file
@ -0,0 +1,178 @@
|
||||
/***************************************************************************
|
||||
* 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/ *
|
||||
***************************************************************************/
|
||||
/**
|
||||
* @file netctlinterface.h
|
||||
* Header of netctlgui library
|
||||
* @author Evgeniy Alekseev
|
||||
* @copyright GPLv3
|
||||
* @bug https://github.com/arcan1s/netctl-gui/issues
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NETCTLINTERFACE_H
|
||||
#define NETCTLINTERFACE_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class Netctl;
|
||||
class NetctlProfile;
|
||||
class WpaSup;
|
||||
|
||||
/**
|
||||
* @enum InterfaceAnswer
|
||||
* @brief standard interface answer enumeration
|
||||
* @var InterfaceAnswer::False
|
||||
* false
|
||||
* @var InterfaceAnswer::True
|
||||
* true
|
||||
* @var InterfaceAnswer::Error
|
||||
* an error occurs
|
||||
*/
|
||||
enum InterfaceAnswer {
|
||||
False = 0,
|
||||
True,
|
||||
Error
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The NetctlInterface class provides complex methods to get access to library
|
||||
*/
|
||||
class NetctlInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief NetctlInterface class constructor
|
||||
* @param debugCmd show debug messages
|
||||
* @param settings default settings. See required keys in other modules
|
||||
*/
|
||||
explicit NetctlInterface(const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
/**
|
||||
* @brief NetctlInterface class destructor
|
||||
*/
|
||||
~NetctlInterface();
|
||||
/**
|
||||
* @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
|
||||
* @param profile profile name
|
||||
* @param settings profile settings
|
||||
* @return InterfaceAnswer::False if profile cannot be created
|
||||
* @return InterfaceAnswer::True if profile is created
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer createProfile(const QString profile, const QMap<QString, QString> settings);
|
||||
/**
|
||||
* @brief method which connects to ESSID
|
||||
* @remark netctl independ
|
||||
* @param essid point ESSID
|
||||
* @param settings profile settings (Security, ESSID, Key and Hidden are required)
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString, QString> settings);
|
||||
/**
|
||||
* @brief method which connects to existent profile by ESSID
|
||||
* @remark netctl independ
|
||||
* @param essid point ESSID
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToKnownEssid(const QString essid);
|
||||
/**
|
||||
* @brief method which creates wireless profile and connects to it
|
||||
* @remark netctl independ
|
||||
* @param essid point ESSID
|
||||
* @param settings profile settings (Security, ESSID, Key and Hidden are required)
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToUnknownEssid(const QString essid, QMap<QString, QString> settings);
|
||||
/**
|
||||
* @brief method which enables or disables selected profile and returns its status
|
||||
* @remark netctl 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 enableProfile(const QString profile);
|
||||
/**
|
||||
* @brief method which restarts selected profile and returns its status
|
||||
* @remark netctl only
|
||||
* @param profile profile name
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer restartProfile(const QString profile);
|
||||
/**
|
||||
* @brief method which starts/stops or switchs to selected profile and returns its status
|
||||
* @remark netctl only
|
||||
* @param profile profile name
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer startProfile(const QString profile);
|
||||
/**
|
||||
* @brief method which switchs to selected profile and returns its status
|
||||
* @remark both netctl and netctl-auto
|
||||
* @param profile profile name
|
||||
* @return InterfaceAnswer::False if profile is inactive
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer switchToProfile(const QString profile);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Netctl class
|
||||
*/
|
||||
Netctl *netctlCommand = nullptr;
|
||||
/**
|
||||
* @brief NetctlProfile class
|
||||
*/
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
/**
|
||||
* @brief WpaSup class
|
||||
*/
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug = false;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLINTERFACE_H */
|
@ -79,7 +79,7 @@ typedef struct
|
||||
QStringList macs;
|
||||
QString name;
|
||||
QString security;
|
||||
int signal;
|
||||
int signal = 0;
|
||||
PointType type = PointType::None;
|
||||
bool active = false;
|
||||
bool exists = false;
|
||||
@ -137,7 +137,7 @@ public:
|
||||
* @return false if profile does not exist
|
||||
* @return true if profile exists
|
||||
*/
|
||||
bool isProfileExists(const QString essid);
|
||||
Q_DECL_DEPRECATED bool isProfileExists(const QString essid);
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
|
250
sources/netctlgui/src/netctlinterface.cpp
Normal file
250
sources/netctlgui/src/netctlinterface.cpp
Normal file
@ -0,0 +1,250 @@
|
||||
/***************************************************************************
|
||||
* 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/ *
|
||||
***************************************************************************/
|
||||
/**
|
||||
* @file netctlinterface.cpp
|
||||
* Source code of netctlgui library
|
||||
* @author Evgeniy Alekseev
|
||||
* @copyright GPLv3
|
||||
* @bug https://github.com/arcan1s/netctl-gui/issues
|
||||
*/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
/**
|
||||
* @class NetctlInterface
|
||||
*/
|
||||
/**
|
||||
* @fn NetctlInterface
|
||||
*/
|
||||
NetctlInterface::NetctlInterface(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: debug(debugCmd)
|
||||
{
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
netctlProfile = new NetctlProfile(debug, settings);
|
||||
wpaCommand = new WpaSup(debug, settings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn ~NetctlInterface
|
||||
*/
|
||||
NetctlInterface::~NetctlInterface()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
if (wpaCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
if (wpaCommand->existentProfile(essid).isEmpty())
|
||||
return connectToUnknownEssid(essid, settings);
|
||||
else
|
||||
return connectToKnownEssid(essid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn connectToKnownEssid
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
if (wpaCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
QString profile = wpaCommand->existentProfile(essid);
|
||||
if (profile.isEmpty()) return InterfaceAnswer::Error;
|
||||
|
||||
return startProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn connectToUnknownEssid
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
if (wpaCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
// append settings
|
||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) return InterfaceAnswer::Error;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = interfaces[0];
|
||||
settings[QString("Connection")] = QString("wireless");
|
||||
settings[QString("ESSID")] = QString("'%1'").arg(essid);
|
||||
settings[QString("IP")] = QString("dhcp");
|
||||
|
||||
// save profile
|
||||
QString profile = QString("netctl-gui-%1").arg(essid);
|
||||
profile.remove(QChar('"')).remove(QChar('\''));
|
||||
if (createProfile(profile, settings) != InterfaceAnswer::True) return InterfaceAnswer::Error;
|
||||
|
||||
// start it
|
||||
return startProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn createProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
if (profileTempName.isEmpty()) return InterfaceAnswer::Error;
|
||||
|
||||
return static_cast<InterfaceAnswer>(netctlProfile->copyProfile(profileTempName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn enableProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
netctlCommand->enableProfile(profile);
|
||||
|
||||
return static_cast<InterfaceAnswer>(netctlCommand->isProfileEnabled(profile));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn restartProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::restartProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
netctlCommand->restartProfile(profile);
|
||||
|
||||
return static_cast<InterfaceAnswer>(netctlCommand->isProfileActive(profile));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn startProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::startProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
QStringList current = netctlCommand->getActiveProfile();
|
||||
if ((current.isEmpty()) || (current.contains(profile)))
|
||||
netctlCommand->startProfile(profile);
|
||||
else
|
||||
netctlCommand->switchToProfile(profile);
|
||||
|
||||
return static_cast<InterfaceAnswer>(netctlCommand->isProfileActive(profile));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn switchToProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
|
||||
InterfaceAnswer status = InterfaceAnswer::Error;
|
||||
bool netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
if (netctlAutoStatus) {
|
||||
netctlCommand->autoStartProfile(profile);
|
||||
status = static_cast<InterfaceAnswer>(netctlCommand->autoIsProfileActive(profile));
|
||||
} else {
|
||||
netctlCommand->switchToProfile(profile);
|
||||
status = static_cast<InterfaceAnswer>(netctlCommand->isProfileActive(profile));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
@ -96,9 +96,11 @@ QString WpaSup::existentProfile(const QString essid)
|
||||
|
||||
QString profileFile = QString("");
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID")))
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
profileFile = profileList[i].name;
|
||||
break;
|
||||
}
|
||||
|
||||
return profileFile;
|
||||
}
|
||||
@ -213,8 +215,8 @@ bool WpaSup::isProfileActive(const QString essid)
|
||||
|
||||
QString profileFile;
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID"))) {
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
profileFile = profileList[i].name;
|
||||
break;
|
||||
}
|
||||
@ -241,8 +243,8 @@ bool WpaSup::isProfileExists(const QString essid)
|
||||
|
||||
bool exists = false;
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (essid == netctlProfile->getValueFromProfile(profileList[i].name, QString("ESSID"))) {
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
@ -272,8 +274,10 @@ netctlWifiInfo WpaSup::current()
|
||||
|
||||
netctlWifiInfo current;
|
||||
if (!QFile(_pidFile).exists()) return current;
|
||||
QString rawText = getWpaCliOutput(QString("status"));
|
||||
if (!rawText.contains(QString("wpa_state=COMPLETED\n"))) return current;
|
||||
|
||||
QStringList rawList = getWpaCliOutput(QString("status")).split(QChar('\n'), QString::SkipEmptyParts);
|
||||
QStringList rawList = rawText.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
QStringList line = rawList[i].split(QChar('='));
|
||||
if (line.count() != 2) continue;
|
||||
@ -300,16 +304,10 @@ netctlWifiInfo WpaSup::current()
|
||||
current.security = security;
|
||||
}
|
||||
}
|
||||
current.signal = 0;
|
||||
|
||||
// status
|
||||
current.active = true;
|
||||
QList<netctlProfileInfo> profiles = netctlCommand->getProfileList();
|
||||
for (int j=0; j<profiles.count(); j++) {
|
||||
if (current.name != profiles[j].essid) continue;
|
||||
current.exists = true;
|
||||
break;
|
||||
}
|
||||
current.exists = (!existentProfile(current.name).isEmpty());
|
||||
|
||||
return current;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user