mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-05 01:55:47 +00:00
add helper proto
This commit is contained in:
@ -60,5 +60,4 @@ endif()
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
|
@ -1,108 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "controladaptor.h"
|
||||
|
||||
|
||||
ControlAdaptor::ControlAdaptor(QObject *parent, const QMap<QString, QString> configuration)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
netctlCommand = new Netctl(false, configuration);
|
||||
netctlProfile = new NetctlProfile(false, configuration);
|
||||
}
|
||||
|
||||
|
||||
ControlAdaptor::~ControlAdaptor()
|
||||
{
|
||||
delete netctlCommand;
|
||||
delete netctlProfile;
|
||||
}
|
||||
|
||||
|
||||
// netctlCommand
|
||||
bool ControlAdaptor::autoDisableAll()
|
||||
{
|
||||
return netctlCommand->autoDisableAllProfiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoEnable(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoEnableProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoEnableAll()
|
||||
{
|
||||
return netctlCommand->autoEnableAllProfiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoStart(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoStartProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceEnable()
|
||||
{
|
||||
return netctlCommand->autoEnableService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceRestart()
|
||||
{
|
||||
return netctlCommand->autoRestartService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceStart()
|
||||
{
|
||||
return netctlCommand->autoStartService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Enable(const QString profile)
|
||||
{
|
||||
return netctlCommand->enableProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Restart(const QString profile)
|
||||
{
|
||||
return netctlCommand->restartProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Start(const QString profile)
|
||||
{
|
||||
return netctlCommand->startProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::SwitchTo(const QString profile)
|
||||
{
|
||||
return netctlCommand->switchToProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
// netctlProfile
|
||||
bool ControlAdaptor::Remove(const QString profile)
|
||||
{
|
||||
return netctlProfile->removeProfile(profile);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 CONTROLADAPTOR_H
|
||||
#define CONTROLADAPTOR_H
|
||||
|
||||
#include <QDBusAbstractAdaptor>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class ControlAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.netctlgui")
|
||||
|
||||
public:
|
||||
explicit ControlAdaptor(QObject *parent = 0,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
~ControlAdaptor();
|
||||
|
||||
public slots:
|
||||
// netctlCommand
|
||||
bool autoDisableAll();
|
||||
bool autoEnable(const QString profile);
|
||||
bool autoEnableAll();
|
||||
bool autoStart(const QString profile);
|
||||
bool autoServiceEnable();
|
||||
bool autoServiceRestart();
|
||||
bool autoServiceStart();
|
||||
bool Enable(const QString profile);
|
||||
bool Restart(const QString profile);
|
||||
bool Start(const QString profile);
|
||||
bool SwitchTo(const QString profile);
|
||||
// netctlProfile
|
||||
bool Remove(const QString profile);
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CONTROLADAPTOR_H */
|
@ -19,7 +19,6 @@
|
||||
#include <QApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
@ -55,17 +54,12 @@ int main(int argc, char *argv[])
|
||||
daemon(0, 0);
|
||||
break;
|
||||
}
|
||||
#if QT_VERSION >= 0x050000
|
||||
QApplication::setSetuidAllowed(true);
|
||||
qDebug() << QApplication::isSetuidAllowed();
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// check if exists
|
||||
if (restoreExistSession())
|
||||
return 0;
|
||||
|
||||
// config path
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
// translation
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString());
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
@ -31,7 +32,6 @@
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "bridgewidget.h"
|
||||
#include "controladaptor.h"
|
||||
#include "errorwindow.h"
|
||||
#include "ethernetwidget.h"
|
||||
#include "generalwidget.h"
|
||||
@ -39,7 +39,6 @@
|
||||
#include "language.h"
|
||||
#include "macvlanwidget.h"
|
||||
#include "mobilewidget.h"
|
||||
#include "netctladaptor.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "netctlguiadaptor.h"
|
||||
#include "passwdwidget.h"
|
||||
@ -52,9 +51,6 @@
|
||||
#include "vlanwidget.h"
|
||||
#include "wirelesswidget.h"
|
||||
|
||||
#include <polkit-qt5-1/polkitqt1-authority.h>
|
||||
#include <polkit-qt5-1/polkitqt1-subject.h>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent,
|
||||
const QMap<QString, QVariant> args,
|
||||
@ -157,6 +153,20 @@ QStringList MainWindow::getSettings()
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::isHelperActive()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[isHelperActive]";
|
||||
|
||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Active"));
|
||||
|
||||
if (responce.size() == 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[closeEvent]";
|
||||
@ -279,14 +289,6 @@ void MainWindow::createDBusSession()
|
||||
new NetctlGuiAdaptor(this),
|
||||
QDBusConnection::ExportAllContents))
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register GUI object";
|
||||
if (!bus.registerObject(QString(DBUS_LIB_PATH),
|
||||
new NetctlAdaptor(this, configuration),
|
||||
QDBusConnection::ExportAllContents))
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register library object";
|
||||
if (!bus.registerObject(QString(DBUS_CONTROL_PATH),
|
||||
new ControlAdaptor(this, configuration),
|
||||
QDBusConnection::ExportAllContents))
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register control object";
|
||||
}
|
||||
|
||||
|
||||
@ -342,6 +344,7 @@ void MainWindow::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]";
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(QString(DBUS_OBJECT_PATH));
|
||||
QDBusConnection::sessionBus().unregisterService(QString(DBUS_SERVICE));
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
@ -378,6 +381,20 @@ void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> MainWindow::sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]";
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setIconsToTabs()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[setIconsToTabs]";
|
||||
@ -488,6 +505,37 @@ void MainWindow::showSettingsWindow()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
|
||||
|
||||
QProcess process;
|
||||
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
|
||||
|
||||
process.startDetached(cmd);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
|
||||
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Close"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[startHelper]";
|
||||
|
||||
if (isHelperActive())
|
||||
return forceStopHelper();
|
||||
else
|
||||
return forceStartHelper();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[setTab]";
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
~MainWindow();
|
||||
QString getInformation();
|
||||
QStringList getSettings();
|
||||
bool isHelperActive();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
@ -70,6 +71,10 @@ public slots:
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// helper
|
||||
void forceStartHelper();
|
||||
void forceStopHelper();
|
||||
void startHelper();
|
||||
// main
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
@ -141,6 +146,8 @@ private:
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd);
|
||||
void setIconsToTabs();
|
||||
QString configPath;
|
||||
bool debug;
|
||||
|
@ -1,154 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "netctladaptor.h"
|
||||
|
||||
|
||||
NetctlAdaptor::NetctlAdaptor(QObject *parent, const QMap<QString, QString> configuration)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
netctlCommand = new Netctl(false, configuration);
|
||||
netctlProfile = new NetctlProfile(false, configuration);
|
||||
wpaCommand = new WpaSup(false, configuration);
|
||||
}
|
||||
|
||||
|
||||
NetctlAdaptor::~NetctlAdaptor()
|
||||
{
|
||||
delete netctlCommand;
|
||||
delete netctlProfile;
|
||||
delete wpaCommand;
|
||||
}
|
||||
|
||||
|
||||
// netctlCommand
|
||||
QString NetctlAdaptor::ActiveProfile()
|
||||
{
|
||||
if (netctlCommand->isNetctlAutoRunning())
|
||||
return netctlCommand->autoGetActiveProfile();
|
||||
else
|
||||
return netctlCommand->getActiveProfile();
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::ActiveProfileStatus()
|
||||
{
|
||||
if (netctlCommand->isNetctlAutoRunning())
|
||||
return QString("netctl-auto");
|
||||
else
|
||||
return netctlCommand->getProfileStatus(ActiveProfile());
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::autoIsProfileActive(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::autoIsProfileEnabled(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoIsProfileEnabled(profile);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::Information()
|
||||
{
|
||||
QStringList output;
|
||||
output.append(QString("Profile: %1").arg(ActiveProfile()));
|
||||
output.append(QString("Status: %1").arg(ActiveProfileStatus()));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isProfileActive(const QString profile)
|
||||
{
|
||||
return netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isProfileEnabled(const QString profile)
|
||||
{
|
||||
return netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::ProfileList()
|
||||
{
|
||||
QList<netctlProfileInfo> profilesInfo;
|
||||
if (netctlCommand->isNetctlAutoRunning())
|
||||
profilesInfo = netctlCommand->getProfileListFromNetctlAuto();
|
||||
else
|
||||
profilesInfo = netctlCommand->getProfileList();
|
||||
QStringList info;
|
||||
for (int i=0; i<profilesInfo.count(); i++) {
|
||||
QStringList profileInfo;
|
||||
profileInfo.append(profilesInfo[i].name);
|
||||
profileInfo.append(profilesInfo[i].description);
|
||||
profileInfo.append(QString::number(profilesInfo[i].active));
|
||||
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
||||
info.append(profileInfo.join(QChar('|')));
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
// netctlProfile
|
||||
QStringList NetctlAdaptor::Profile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
settingsList.append(settings.keys()[i] + QString("=") +
|
||||
settings[settings.keys()[i]]);
|
||||
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::ProfileValue(const QString profile, const QString key)
|
||||
{
|
||||
return netctlProfile->getValueFromProfile(profile, key);
|
||||
}
|
||||
|
||||
|
||||
// wpaCommand
|
||||
QString NetctlAdaptor::ProfileByEssid(const QString essid)
|
||||
{
|
||||
return wpaCommand->existentProfile(essid);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::WiFi()
|
||||
{
|
||||
QList<netctlWifiInfo> wifiPoints = wpaCommand->scanWifi();
|
||||
QStringList info;
|
||||
for (int i=0; i<wifiPoints.count(); i++) {
|
||||
QStringList point;
|
||||
point.append(wifiPoints[i].name);
|
||||
point.append(wifiPoints[i].security);
|
||||
point.append(wifiPoints[i].signal);
|
||||
point.append(QString::number(wifiPoints[i].active));
|
||||
point.append(QString::number(wifiPoints[i].exists));
|
||||
info.append(point.join(QChar('|')));
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 NETCTLADAPTOR_H
|
||||
#define NETCTLADAPTOR_H
|
||||
|
||||
#include <QDBusAbstractAdaptor>
|
||||
#include <QStringList>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class NetctlAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.netctlgui")
|
||||
|
||||
public:
|
||||
explicit NetctlAdaptor(QObject *parent = 0,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
~NetctlAdaptor();
|
||||
|
||||
public slots:
|
||||
// netctlCommand
|
||||
QString ActiveProfile();
|
||||
QString ActiveProfileStatus();
|
||||
bool autoIsProfileActive(const QString profile);
|
||||
bool autoIsProfileEnabled(const QString profile);
|
||||
QStringList Information();
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileEnabled(const QString profile);
|
||||
QStringList ProfileList();
|
||||
// netctlProfile
|
||||
QStringList Profile(const QString profile);
|
||||
QString ProfileValue(const QString profile, const QString key);
|
||||
// wpaCommand
|
||||
QString ProfileByEssid(const QString essid);
|
||||
QStringList WiFi();
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
WpaSup *wpaCommand;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLADAPTOR_H */
|
@ -27,7 +27,7 @@ class MainWindow;
|
||||
class NetctlGuiAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.netctlgui")
|
||||
Q_CLASSINFO("D-Bus Interface", "org.netctlgui.netctlgui")
|
||||
|
||||
public:
|
||||
explicit NetctlGuiAdaptor(MainWindow *parent = 0);
|
||||
|
@ -53,21 +53,22 @@ void SettingsWindow::createActions()
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
|
||||
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||
// buttons
|
||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
|
||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
|
||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
|
||||
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectHelperPath()));
|
||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), this, SLOT(selectIfaceDir()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectNetctlPath()));
|
||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectNetctlAutoPath()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectProfileDir()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectRfkillDir()));
|
||||
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectSudoPath()));
|
||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectSystemctlPath()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectWpaCliPath()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectWpaSupPath()));
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +104,16 @@ void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previ
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::closeWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[closeWindow]";
|
||||
|
||||
saveSettings();
|
||||
close();
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::saveSettings()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
|
||||
@ -115,8 +126,6 @@ void SettingsWindow::saveSettings()
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
|
||||
configFile.close();
|
||||
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +153,20 @@ void SettingsWindow::setDefault()
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectHelperPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectHelperPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select helper command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_helperPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectIfaceDir()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectIfaceDir]";
|
||||
@ -273,6 +296,7 @@ void SettingsWindow::showWindow()
|
||||
|
||||
setSettings(getSettings());
|
||||
setTray();
|
||||
updateHelper();
|
||||
|
||||
show();
|
||||
}
|
||||
@ -283,12 +307,21 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
if (ui->checkBox_helperClose->checkState() == 2)
|
||||
settings[QString("CLOSE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
if (ui->checkBox_forceSudo->checkState() == 2)
|
||||
settings[QString("FORCE_SUDO")] = QString("true");
|
||||
else
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
|
||||
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
@ -308,6 +341,10 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
if (ui->checkBox_useHelper->checkState() == 2)
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("USE_HELPER")] = QString("false");
|
||||
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
@ -323,12 +360,21 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
|
||||
|
||||
if (settings[QString("CLOSE_HELPER")] == QString("true"))
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("CLOSETOTRAY")] == QString("true"))
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
|
||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||
ui->comboBox_language->setCurrentIndex(0);
|
||||
for (int i=0; i<ui->comboBox_language->count(); i++)
|
||||
@ -351,6 +397,10 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||
@ -365,9 +415,12 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
|
||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||
settings[QString("LANGUAGE")] = QString("en");
|
||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||
@ -381,6 +434,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
@ -417,3 +471,29 @@ QMap<QString, QString> SettingsWindow::getSettings()
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[startHelper]";
|
||||
|
||||
((MainWindow *)parent())->startHelper();
|
||||
updateHelper();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::updateHelper()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[updateHelper]";
|
||||
|
||||
if (((MainWindow *)parent())->isHelperActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
}
|
||||
else {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Inactive"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Start"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("system-run"));
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
QMap<QString, QString> getSettings();
|
||||
|
||||
public slots:
|
||||
void closeWindow();
|
||||
void setDefault();
|
||||
void showWindow();
|
||||
|
||||
@ -50,7 +51,9 @@ private slots:
|
||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void saveSettings();
|
||||
void setTray();
|
||||
void updateHelper();
|
||||
// buttons
|
||||
void selectHelperPath();
|
||||
void selectIfaceDir();
|
||||
void selectNetctlPath();
|
||||
void selectNetctlAutoPath();
|
||||
@ -60,6 +63,7 @@ private slots:
|
||||
void selectSystemctlPath();
|
||||
void selectWpaCliPath();
|
||||
void selectWpaSupPath();
|
||||
void startHelper();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>321</height>
|
||||
<width>658</width>
|
||||
<height>319</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -67,6 +67,15 @@
|
||||
</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Helper</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>netctl</string>
|
||||
@ -110,7 +119,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_general">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -127,8 +136,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>444</width>
|
||||
<height>260</height>
|
||||
<width>442</width>
|
||||
<height>258</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@ -190,6 +199,125 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_helper">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_helper">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>442</width>
|
||||
<height>258</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_status">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_statusText">
|
||||
<property name="text">
|
||||
<string>Helper status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_status">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_status">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_status">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_useHelper">
|
||||
<property name="text">
|
||||
<string>Use helper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_forceSudo">
|
||||
<property name="text">
|
||||
<string>Force use sudo in helper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_helperClose">
|
||||
<property name="text">
|
||||
<string>Close helper after exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_helperPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_helperPath">
|
||||
<property name="text">
|
||||
<string>Helper command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_helperPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_helperPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_helper">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>104</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_netctl">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
|
Reference in New Issue
Block a user