mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-25 07:57:20 +00:00
add plasmoid helper integration
This commit is contained in:
parent
501b43002e
commit
fe672aa8cc
@ -64,7 +64,7 @@ Additional information
|
|||||||
TODO (wish list)
|
TODO (wish list)
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
* plasmoid helper integration
|
* refactoring (I think that classes with more than 1k lines is not good :/)
|
||||||
* remove suid from helper (polkit integration or run through sudo)
|
* remove suid from helper (polkit integration or run through sudo)
|
||||||
* security notes / project architecture
|
* security notes / project architecture
|
||||||
* autotests
|
* autotests
|
||||||
|
@ -435,6 +435,20 @@ void MainWindow::reportABug()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::checkHelperStatus()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[checkHelperStatus]";
|
||||||
|
|
||||||
|
if (useHelper) useHelper = isHelperActive();
|
||||||
|
if (useHelper)
|
||||||
|
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||||
|
DBUS_HELPER_INTERFACE, QString("Update"),
|
||||||
|
QList<QVariant>(), true, debug);
|
||||||
|
if (isHelperServiceActive())
|
||||||
|
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// main tab slots
|
// main tab slots
|
||||||
void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
@ -495,6 +496,9 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
useHelper = false;
|
useHelper = false;
|
||||||
configuration[QString("USE_HELPER")] = QString("false");
|
configuration[QString("USE_HELPER")] = QString("false");
|
||||||
}
|
}
|
||||||
|
// some helper fixs
|
||||||
|
// because interface will be created with a delay
|
||||||
|
QTimer::singleShot(1000, this, SLOT(checkHelperStatus()));
|
||||||
|
|
||||||
// update translation
|
// update translation
|
||||||
qApp->removeTranslator(translator);
|
qApp->removeTranslator(translator);
|
||||||
@ -506,14 +510,6 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
delete settingsWin;
|
delete settingsWin;
|
||||||
|
|
||||||
createObjects();
|
createObjects();
|
||||||
// some helper fixs
|
|
||||||
if (useHelper) useHelper = isHelperActive();
|
|
||||||
if (useHelper)
|
|
||||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
|
||||||
DBUS_HELPER_INTERFACE, QString("Update"),
|
|
||||||
QList<QVariant>(), true, debug);
|
|
||||||
if (isHelperServiceActive())
|
|
||||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
|
||||||
// update ui
|
// update ui
|
||||||
setTab(args[QString("tab")].toInt() - 1);
|
setTab(args[QString("tab")].toInt() - 1);
|
||||||
createActions();
|
createActions();
|
||||||
|
@ -96,6 +96,7 @@ public slots:
|
|||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void checkHelperStatus();
|
||||||
void reportABug();
|
void reportABug();
|
||||||
// menu update slots
|
// menu update slots
|
||||||
void setMenuActionsShown(const bool state = true);
|
void setMenuActionsShown(const bool state = true);
|
||||||
|
@ -23,10 +23,13 @@
|
|||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
|
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "netctl.h"
|
#include "netctl.h"
|
||||||
#include "ui_about.h"
|
#include "ui_about.h"
|
||||||
@ -290,8 +293,6 @@ void Netctl::enableProfileSlot()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[enableProfileSlot]";
|
if (debug) qDebug() << "[PLASMOID]" << "[enableProfileSlot]";
|
||||||
|
|
||||||
QProcess command;
|
|
||||||
QString commandLine = QString("");
|
|
||||||
QString enableStatus = QString("");
|
QString enableStatus = QString("");
|
||||||
if (info[QString("status")].contains(QString("enabled"))) {
|
if (info[QString("status")].contains(QString("enabled"))) {
|
||||||
enableStatus = QString(" disable ");
|
enableStatus = QString(" disable ");
|
||||||
@ -301,12 +302,41 @@ void Netctl::enableProfileSlot()
|
|||||||
enableStatus = QString(" enable ");
|
enableStatus = QString(" enable ");
|
||||||
sendNotification(QString("Info"), i18n("Set profile %1 enabled", info[QString("name")]));
|
sendNotification(QString("Info"), i18n("Set profile %1 enabled", info[QString("name")]));
|
||||||
}
|
}
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(info[QString("name")]);
|
||||||
|
sendDBusRequest(QString("Enable"), args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = QString("");
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
commandLine = paths[QString("sudo")] + QString(" ");
|
commandLine = paths[QString("sudo")] + QString(" ");
|
||||||
commandLine += paths[QString("netctl")] + enableStatus + info[QString("name")];
|
commandLine += paths[QString("netctl")] + enableStatus + info[QString("name")];
|
||||||
|
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::restartProfileSlot()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[restartProfileSlot]";
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Restart profile %1", info[QString("name")]));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(info[QString("name")]);
|
||||||
|
sendDBusRequest(QString("Restart"), args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = QString("");
|
||||||
|
if (useSudo)
|
||||||
|
commandLine = paths[QString("sudo")] + QString(" ");
|
||||||
|
commandLine += paths[QString("netctl")] + QString(" restart ") + info[QString("name")];
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::startProfileSlot(QAction *profile)
|
void Netctl::startProfileSlot(QAction *profile)
|
||||||
@ -314,33 +344,48 @@ void Netctl::startProfileSlot(QAction *profile)
|
|||||||
if (debug) qDebug() << "[PLASMOID]" << "[startProfileSlot]";
|
if (debug) qDebug() << "[PLASMOID]" << "[startProfileSlot]";
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[startProfileSlot]" << ":" << "Profile" << profile->text().remove(QChar('&'));
|
if (debug) qDebug() << "[PLASMOID]" << "[startProfileSlot]" << ":" << "Profile" << profile->text().remove(QChar('&'));
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QChar('&'))));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(profile->text().remove(QChar('&')));
|
||||||
|
if (status)
|
||||||
|
sendDBusRequest(QString("SwitchTo"), args);
|
||||||
|
else
|
||||||
|
sendDBusRequest(QString("Start"), args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = QString("");
|
QString commandLine = QString("");
|
||||||
sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QChar('&'))));
|
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
commandLine = paths[QString("sudo")] + QString(" ");
|
commandLine = paths[QString("sudo")] + QString(" ");
|
||||||
if (status)
|
if (status)
|
||||||
commandLine += paths[QString("netctl")] + QString(" switch-to ") + profile->text().remove(QChar('&'));
|
commandLine += paths[QString("netctl")] + QString(" switch-to ") + profile->text().remove(QChar('&'));
|
||||||
else
|
else
|
||||||
commandLine += paths[QString("netctl")] + QString(" start ") + profile->text().remove(QChar('&'));
|
commandLine += paths[QString("netctl")] + QString(" start ") + profile->text().remove(QChar('&'));
|
||||||
|
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::stopProfileSlot()
|
void Netctl::stopProfileSlot()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[stopProfileSlot]";
|
if (debug) qDebug() << "[PLASMOID]" << "[stopProfileSlot]";
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Stop profile %1", info[QString("name")]));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(info[QString("name")]);
|
||||||
|
sendDBusRequest(QString("Start"), args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = QString("");
|
QString commandLine = QString("");
|
||||||
sendNotification(QString("Info"), i18n("Stop profile %1", info[QString("name")]));
|
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
commandLine = paths[QString("sudo")] + QString(" ");
|
commandLine = paths[QString("sudo")] + QString(" ");
|
||||||
commandLine += paths[QString("netctl")] + QString(" stop ") + info[QString("name")];
|
commandLine += paths[QString("netctl")] + QString(" stop ") + info[QString("name")];
|
||||||
|
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::switchToProfileSlot(QAction *profile)
|
void Netctl::switchToProfileSlot(QAction *profile)
|
||||||
@ -348,29 +393,37 @@ void Netctl::switchToProfileSlot(QAction *profile)
|
|||||||
if (debug) qDebug() << "[PLASMOID]" << "[switchToProfileSlot]";
|
if (debug) qDebug() << "[PLASMOID]" << "[switchToProfileSlot]";
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[switchToProfileSlot]" << ":" << "Profile" << profile->text().remove(QChar('&'));
|
if (debug) qDebug() << "[PLASMOID]" << "[switchToProfileSlot]" << ":" << "Profile" << profile->text().remove(QChar('&'));
|
||||||
|
|
||||||
QProcess command;
|
|
||||||
QString commandLine;
|
|
||||||
commandLine = QString("");
|
|
||||||
sendNotification(QString("Info"), i18n("Switch to profile %1", profile->text().remove(QChar('&'))));
|
|
||||||
commandLine = paths[QString("netctlAuto")] + QString(" switch-to ") +
|
|
||||||
profile->text().remove(QChar('&'));
|
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Switch to profile %1", profile->text().remove(QChar('&'))));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(profile->text().remove(QChar('&')));
|
||||||
|
sendDBusRequest(QString("autoStart"), args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = paths[QString("netctlAuto")] + QString(" switch-to ") +
|
||||||
|
profile->text().remove(QChar('&'));
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::startHelper()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[startHelper]";
|
||||||
|
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = paths[QString("helper")];
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::restartProfileSlot()
|
void Netctl::checkHelperStatus()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[restartProfileSlot]";
|
if (debug) qDebug() << "[PLASMOID]" << "[checkHelperStatus]";
|
||||||
|
|
||||||
QProcess command;
|
if (useHelper) useHelper = !sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty();
|
||||||
QString commandLine = QString("");
|
|
||||||
sendNotification(QString("Info"), i18n("Restart profile %1", info[QString("name")]));
|
|
||||||
if (useSudo)
|
|
||||||
commandLine = paths[QString("sudo")] + QString(" ");
|
|
||||||
commandLine += paths[QString("netctl")] + QString(" restart ") + info[QString("name")];
|
|
||||||
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -608,6 +661,26 @@ void Netctl::disconnectFromEngine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> Netctl::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[sendDBusRequest]";
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[sendDBusRequest]" << ":" << "cmd" << cmd;
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[sendDBusRequest]" << ":" << "args" << args;
|
||||||
|
|
||||||
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
|
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||||
|
DBUS_HELPER_INTERFACE, cmd);
|
||||||
|
if (!args.isEmpty())
|
||||||
|
request.setArguments(args);
|
||||||
|
QDBusMessage response = bus.call(request);
|
||||||
|
QList<QVariant> arguments = response.arguments();
|
||||||
|
if (arguments.size() == 0)
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[sendDBusRequest]" << ":" << "Error message" << response.errorMessage();
|
||||||
|
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// configuration interface
|
// configuration interface
|
||||||
void Netctl::selectAbstractSomething()
|
void Netctl::selectAbstractSomething()
|
||||||
{
|
{
|
||||||
@ -625,6 +698,8 @@ void Netctl::selectAbstractSomething()
|
|||||||
}
|
}
|
||||||
else if (sender() == uiWidConfig.pushButton_gui)
|
else if (sender() == uiWidConfig.pushButton_gui)
|
||||||
lineEdit = uiWidConfig.lineEdit_gui;
|
lineEdit = uiWidConfig.lineEdit_gui;
|
||||||
|
else if (sender() == uiWidConfig.pushButton_helper)
|
||||||
|
lineEdit = uiWidConfig.lineEdit_helper;
|
||||||
else if (sender() == uiWidConfig.pushButton_netctl)
|
else if (sender() == uiWidConfig.pushButton_netctl)
|
||||||
lineEdit = uiWidConfig.lineEdit_netctl;
|
lineEdit = uiWidConfig.lineEdit_netctl;
|
||||||
else if (sender() == uiWidConfig.pushButton_netctlAuto)
|
else if (sender() == uiWidConfig.pushButton_netctlAuto)
|
||||||
@ -662,6 +737,12 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
|
|
||||||
uiWidConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
uiWidConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
||||||
uiWidConfig.lineEdit_gui->setText(paths[QString("gui")]);
|
uiWidConfig.lineEdit_gui->setText(paths[QString("gui")]);
|
||||||
|
if (useHelper)
|
||||||
|
uiWidConfig.checkBox_helper->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
uiWidConfig.checkBox_helper->setCheckState(Qt::Unchecked);
|
||||||
|
uiWidConfig.lineEdit_helper->setText(paths[QString("helper")]);
|
||||||
|
setHelper();
|
||||||
uiWidConfig.lineEdit_netctl->setText(paths[QString("netctl")]);
|
uiWidConfig.lineEdit_netctl->setText(paths[QString("netctl")]);
|
||||||
uiWidConfig.lineEdit_netctlAuto->setText(paths[QString("netctlAuto")]);
|
uiWidConfig.lineEdit_netctlAuto->setText(paths[QString("netctlAuto")]);
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
@ -742,6 +823,7 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
parent->addPage(deWidget, i18n("DataEngine"), Applet::icon());
|
parent->addPage(deWidget, i18n("DataEngine"), Applet::icon());
|
||||||
parent->addPage(aboutWidget, i18n("About"), QString("help-about"));
|
parent->addPage(aboutWidget, i18n("About"), QString("help-about"));
|
||||||
|
|
||||||
|
connect(uiWidConfig.checkBox_helper, SIGNAL(stateChanged(int)), this, SLOT(setHelper()));
|
||||||
connect(uiWidConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this,
|
connect(uiWidConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this,
|
||||||
SLOT(setBigInterface()));
|
SLOT(setBigInterface()));
|
||||||
connect(uiWidConfig.checkBox_sudo, SIGNAL(stateChanged(int)), this, SLOT(setSudo()));
|
connect(uiWidConfig.checkBox_sudo, SIGNAL(stateChanged(int)), this, SLOT(setSudo()));
|
||||||
@ -750,6 +832,7 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
connect(uiDEConfig.checkBox_extIp6, SIGNAL(stateChanged(int)), this, SLOT(setDataEngineExternalIp6()));
|
connect(uiDEConfig.checkBox_extIp6, SIGNAL(stateChanged(int)), this, SLOT(setDataEngineExternalIp6()));
|
||||||
|
|
||||||
connect(uiWidConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
connect(uiWidConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
||||||
|
connect(uiWidConfig.pushButton_helper, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
||||||
connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
||||||
connect(uiWidConfig.pushButton_netctlAuto, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
connect(uiWidConfig.pushButton_netctlAuto, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
||||||
connect(uiWidConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
connect(uiWidConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectAbstractSomething()));
|
||||||
@ -775,6 +858,11 @@ void Netctl::configAccepted()
|
|||||||
|
|
||||||
cg.writeEntry("autoUpdateInterval", uiWidConfig.spinBox_autoUpdate->value());
|
cg.writeEntry("autoUpdateInterval", uiWidConfig.spinBox_autoUpdate->value());
|
||||||
cg.writeEntry("guiPath", uiWidConfig.lineEdit_gui->text());
|
cg.writeEntry("guiPath", uiWidConfig.lineEdit_gui->text());
|
||||||
|
if (uiWidConfig.checkBox_helper->checkState() == 0)
|
||||||
|
cg.writeEntry("useHelper", false);
|
||||||
|
else
|
||||||
|
cg.writeEntry("useHelper", true);
|
||||||
|
cg.writeEntry("helperPath", uiWidConfig.lineEdit_helper->text());
|
||||||
cg.writeEntry("netctlPath", uiWidConfig.lineEdit_netctl->text());
|
cg.writeEntry("netctlPath", uiWidConfig.lineEdit_netctl->text());
|
||||||
cg.writeEntry("netctlAutoPath", uiWidConfig.lineEdit_netctlAuto->text());
|
cg.writeEntry("netctlAutoPath", uiWidConfig.lineEdit_netctlAuto->text());
|
||||||
if (uiWidConfig.checkBox_sudo->checkState() == 0)
|
if (uiWidConfig.checkBox_sudo->checkState() == 0)
|
||||||
@ -829,6 +917,7 @@ void Netctl::configChanged()
|
|||||||
|
|
||||||
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
||||||
paths[QString("gui")] = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
paths[QString("gui")] = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
||||||
|
paths[QString("helper")] = cg.readEntry("helperPath", "/usr/bin/netctlgui-helper");
|
||||||
paths[QString("netctl")] = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
paths[QString("netctl")] = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
||||||
paths[QString("netctlAuto")] = cg.readEntry("netctlAutoPath", "/usr/bin/netctl-auto");
|
paths[QString("netctlAuto")] = cg.readEntry("netctlAutoPath", "/usr/bin/netctl-auto");
|
||||||
paths[QString("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu");
|
paths[QString("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu");
|
||||||
@ -836,6 +925,7 @@ void Netctl::configChanged()
|
|||||||
useSudo = cg.readEntry("useSudo", true);
|
useSudo = cg.readEntry("useSudo", true);
|
||||||
useWifi = cg.readEntry("useWifi", false);
|
useWifi = cg.readEntry("useWifi", false);
|
||||||
bigInterface = cg.readEntry("showBigInterface", true);
|
bigInterface = cg.readEntry("showBigInterface", true);
|
||||||
|
useHelper = cg.readEntry("useHelper", true);
|
||||||
textPattern = cg.readEntry("textPattern", "$current $status<br>IPv4: $intip4<br>IPv6: $intip6");
|
textPattern = cg.readEntry("textPattern", "$current $status<br>IPv4: $intip4<br>IPv6: $intip6");
|
||||||
|
|
||||||
QString textAlign = cg.readEntry("textAlign", "center");
|
QString textAlign = cg.readEntry("textAlign", "center");
|
||||||
@ -860,6 +950,8 @@ void Netctl::configChanged()
|
|||||||
.arg(fontColor);
|
.arg(fontColor);
|
||||||
formatLine[1] = QString("</p></body></html>");
|
formatLine[1] = QString("</p></body></html>");
|
||||||
|
|
||||||
|
if (useHelper) startHelper();
|
||||||
|
QTimer::singleShot(1000, this, SLOT(checkHelperStatus()));
|
||||||
connectToEngine();
|
connectToEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,6 +997,19 @@ void Netctl::setDataEngineExternalIp6()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::setHelper()
|
||||||
|
{
|
||||||
|
if (uiWidConfig.checkBox_helper->checkState() == 0) {
|
||||||
|
uiWidConfig.lineEdit_helper->setDisabled(true);
|
||||||
|
uiWidConfig.pushButton_helper->setDisabled(true);
|
||||||
|
}
|
||||||
|
else if (uiWidConfig.checkBox_helper->checkState() == 2) {
|
||||||
|
uiWidConfig.lineEdit_helper->setEnabled(true);
|
||||||
|
uiWidConfig.pushButton_helper->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::setSudo()
|
void Netctl::setSudo()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[setSudo]";
|
if (debug) qDebug() << "[PLASMOID]" << "[setSudo]";
|
||||||
|
@ -73,6 +73,7 @@ public slots:
|
|||||||
void setBigInterface();
|
void setBigInterface();
|
||||||
void setDataEngineExternalIp();
|
void setDataEngineExternalIp();
|
||||||
void setDataEngineExternalIp6();
|
void setDataEngineExternalIp6();
|
||||||
|
void setHelper();
|
||||||
void setSudo();
|
void setSudo();
|
||||||
void setWifi();
|
void setWifi();
|
||||||
|
|
||||||
@ -84,10 +85,13 @@ private slots:
|
|||||||
void selectAbstractSomething();
|
void selectAbstractSomething();
|
||||||
// context menu
|
// context menu
|
||||||
void enableProfileSlot();
|
void enableProfileSlot();
|
||||||
|
void restartProfileSlot();
|
||||||
void startProfileSlot(QAction *profile);
|
void startProfileSlot(QAction *profile);
|
||||||
void stopProfileSlot();
|
void stopProfileSlot();
|
||||||
void switchToProfileSlot(QAction *profile);
|
void switchToProfileSlot(QAction *profile);
|
||||||
void restartProfileSlot();
|
// helper
|
||||||
|
void checkHelperStatus();
|
||||||
|
void startHelper();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void createConfigurationInterface(KConfigDialog *parent);
|
void createConfigurationInterface(KConfigDialog *parent);
|
||||||
@ -113,6 +117,7 @@ private:
|
|||||||
Plasma::DataEngine *netctlEngine;
|
Plasma::DataEngine *netctlEngine;
|
||||||
void connectToEngine();
|
void connectToEngine();
|
||||||
void disconnectFromEngine();
|
void disconnectFromEngine();
|
||||||
|
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
||||||
// configuration interface
|
// configuration interface
|
||||||
Ui::AppearanceWindow uiAppConfig;
|
Ui::AppearanceWindow uiAppConfig;
|
||||||
Ui::DataEngineWindow uiDEConfig;
|
Ui::DataEngineWindow uiDEConfig;
|
||||||
@ -125,7 +130,7 @@ private:
|
|||||||
QString textPattern;
|
QString textPattern;
|
||||||
QStringList formatLine;
|
QStringList formatLine;
|
||||||
QMap<QString, QString> paths;
|
QMap<QString, QString> paths;
|
||||||
bool useSudo, useWifi;
|
bool useHelper, useSudo, useWifi;
|
||||||
};
|
};
|
||||||
|
|
||||||
K_EXPORT_PLASMA_APPLET(netctl, Netctl)
|
K_EXPORT_PLASMA_APPLET(netctl, Netctl)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>480</width>
|
<width>480</width>
|
||||||
<height>335</height>
|
<height>342</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -111,6 +111,42 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_helper">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_helper">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>23</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use helper</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_helper"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_helper">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>23</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_netctl">
|
<layout class="QHBoxLayout" name="layout_netctl">
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user