mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
now plasmoid works normally
This commit is contained in:
parent
695f697a9e
commit
40b05e2ea5
@ -46,7 +46,7 @@
|
|||||||
<widget class="QLabel" name="label_autoUpdate">
|
<widget class="QLabel" name="label_autoUpdate">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>150</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -170,6 +170,29 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_sudo">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_sudo">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>23</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use sudo for netctl</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_sudo"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_showBigInterface">
|
<widget class="QCheckBox" name="checkBox_showBigInterface">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -624,6 +647,8 @@
|
|||||||
<tabstop>pushButton_gui</tabstop>
|
<tabstop>pushButton_gui</tabstop>
|
||||||
<tabstop>lineEdit_netctl</tabstop>
|
<tabstop>lineEdit_netctl</tabstop>
|
||||||
<tabstop>pushButton_netctl</tabstop>
|
<tabstop>pushButton_netctl</tabstop>
|
||||||
|
<tabstop>checkBox_sudo</tabstop>
|
||||||
|
<tabstop>lineEdit_sudo</tabstop>
|
||||||
<tabstop>checkBox_showBigInterface</tabstop>
|
<tabstop>checkBox_showBigInterface</tabstop>
|
||||||
<tabstop>checkBox_showNetDev</tabstop>
|
<tabstop>checkBox_showNetDev</tabstop>
|
||||||
<tabstop>checkBox_showExtIp</tabstop>
|
<tabstop>checkBox_showExtIp</tabstop>
|
||||||
|
@ -27,11 +27,9 @@
|
|||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
|
|
||||||
#include <QGraphicsLinearLayout>
|
#include <QGraphicsLinearLayout>
|
||||||
|
#include <QMenu>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
// temporary
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
Netctl::Netctl(QObject *parent, const QVariantList &args) :
|
Netctl::Netctl(QObject *parent, const QVariantList &args) :
|
||||||
Plasma::Applet(parent, args)
|
Plasma::Applet(parent, args)
|
||||||
@ -87,27 +85,58 @@ void Netctl::init()
|
|||||||
|
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
void Netctl::startProfileSlot()
|
void Netctl::startProfileSlot(QAction *action)
|
||||||
{
|
{
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine;
|
||||||
|
commandLine = QString("");
|
||||||
|
if (status)
|
||||||
|
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
|
||||||
|
if (useSudo)
|
||||||
|
commandLine = sudoPath + QString(" \"") + commandLine + netctlPath + QString(" start ") + action->text().mid(1) + QString("\"");
|
||||||
|
else
|
||||||
|
commandLine = commandLine + netctlPath + QString(" start ") + action->text().mid(1);
|
||||||
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::stopProfileSlot()
|
void Netctl::stopProfileSlot()
|
||||||
{
|
{
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine;
|
||||||
|
if (useSudo)
|
||||||
|
commandLine = sudoPath + QString(" \"") + netctlPath + QString(" stop ") + profileName + QString("\"");
|
||||||
|
else
|
||||||
|
commandLine = netctlPath + QString(" stop ") + profileName;
|
||||||
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::restartProfileSlot()
|
void Netctl::restartProfileSlot()
|
||||||
{
|
{
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine;
|
||||||
|
if (useSudo)
|
||||||
|
commandLine = sudoPath + QString(" \"") + netctlPath + QString(" restart ") + profileName + QString("\"");
|
||||||
|
else
|
||||||
|
commandLine = netctlPath + QString(" restart ") + profileName;
|
||||||
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::enableProfileAutoloadSlot()
|
void Netctl::enableProfileAutoloadSlot()
|
||||||
{
|
{
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine, enableStatus;
|
||||||
|
if (profileStatus == QString("(enable"))
|
||||||
|
enableStatus = QString("disable");
|
||||||
|
else
|
||||||
|
enableStatus = QString("enable");
|
||||||
|
if (useSudo)
|
||||||
|
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
|
||||||
|
else
|
||||||
|
commandLine = netctlPath + enableStatus + profileName;
|
||||||
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,6 +145,9 @@ void Netctl::createActions()
|
|||||||
menuActions.clear();
|
menuActions.clear();
|
||||||
|
|
||||||
startProfile = new QAction(QString("Start profile"), this);
|
startProfile = new QAction(QString("Start profile"), this);
|
||||||
|
startProfileMenu = new QMenu(NULL);
|
||||||
|
startProfile->setMenu(startProfileMenu);
|
||||||
|
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileSlot(QAction *)));
|
||||||
menuActions.append(startProfile);
|
menuActions.append(startProfile);
|
||||||
|
|
||||||
stopProfile = new QAction(QString("Stop profile"), this);
|
stopProfile = new QAction(QString("Stop profile"), this);
|
||||||
@ -153,6 +185,13 @@ QList<QAction*> Netctl::contextualActions()
|
|||||||
enableProfileAutoload->setVisible(false);
|
enableProfileAutoload->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startProfileMenu->clear();
|
||||||
|
for (int i=0; i<profileList.count(); i++) {
|
||||||
|
QAction *profile = new QAction(profileList[i], this);
|
||||||
|
startProfileMenu->addAction(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return menuActions;
|
return menuActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +206,6 @@ void Netctl::showGui()
|
|||||||
|
|
||||||
void Netctl::sendNotification(const QString eventId, const int num)
|
void Netctl::sendNotification(const QString eventId, const int num)
|
||||||
{
|
{
|
||||||
// send notification
|
|
||||||
KNotification *notification = new KNotification(eventId);
|
KNotification *notification = new KNotification(eventId);
|
||||||
notification->setComponentData(KComponentData("plasma_applet_netctl"));
|
notification->setComponentData(KComponentData("plasma_applet_netctl"));
|
||||||
notification->setTitle(QString(i18n("Netctl plasmoid")));
|
notification->setTitle(QString(i18n("Netctl plasmoid")));
|
||||||
@ -222,10 +260,10 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
if (data.keys().count() == 0)
|
if (data.keys().count() == 0)
|
||||||
return;
|
return;
|
||||||
QString value = data[QString("value")].toString();;
|
QString value = data[QString("value")].toString();;
|
||||||
|
if (value.isEmpty())
|
||||||
|
value = QString("N\\A");
|
||||||
|
|
||||||
if (sourceName == QString("currentProfile")) {
|
if (sourceName == QString("currentProfile")) {
|
||||||
if (value.isEmpty())
|
|
||||||
value = QString("N\\A");
|
|
||||||
profileName = value;
|
profileName = value;
|
||||||
|
|
||||||
// update text
|
// update text
|
||||||
@ -240,22 +278,16 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("extIp")) {
|
else if (sourceName == QString("extIp")) {
|
||||||
if (value.isEmpty())
|
|
||||||
value = QString("N\\A");
|
|
||||||
extIp = value;
|
extIp = value;
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("intIp")) {
|
else if (sourceName == QString("intIp")) {
|
||||||
if (value.isEmpty())
|
|
||||||
value = QString("N\\A");
|
|
||||||
intIp = value;
|
intIp = value;
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("interfaces")) {
|
else if (sourceName == QString("interfaces")) {
|
||||||
if (value.isEmpty())
|
|
||||||
value = QString("N\\A");
|
|
||||||
interfaces = value;
|
interfaces = value;
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("profiles")) {
|
else if (sourceName == QString("profiles")) {
|
||||||
return;
|
profileList = value.split(QString(","));
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("statusBool")) {
|
else if (sourceName == QString("statusBool")) {
|
||||||
if (value == QString("true")) {
|
if (value == QString("true")) {
|
||||||
@ -318,6 +350,11 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
uiConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
uiConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
||||||
uiConfig.lineEdit_gui->setText(guiPath);
|
uiConfig.lineEdit_gui->setText(guiPath);
|
||||||
uiConfig.lineEdit_netctl->setText(netctlPath);
|
uiConfig.lineEdit_netctl->setText(netctlPath);
|
||||||
|
if (useSudo)
|
||||||
|
uiConfig.checkBox_sudo->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
uiConfig.checkBox_sudo->setCheckState(Qt::Unchecked);
|
||||||
|
uiConfig.lineEdit_sudo->setText(sudoPath);
|
||||||
if (showBigInterface)
|
if (showBigInterface)
|
||||||
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Checked);
|
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Checked);
|
||||||
else
|
else
|
||||||
@ -351,6 +388,7 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
parent->addPage(configwin, i18n("Netctl plasmoid"), Applet::icon());
|
parent->addPage(configwin, i18n("Netctl plasmoid"), Applet::icon());
|
||||||
|
|
||||||
connect(uiConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface()));
|
connect(uiConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface()));
|
||||||
|
connect(uiConfig.checkBox_sudo, SIGNAL(stateChanged(int)), this, SLOT(setSudo()));
|
||||||
|
|
||||||
connect(uiConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe()));
|
connect(uiConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe()));
|
||||||
connect(uiConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe()));
|
connect(uiConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe()));
|
||||||
@ -370,6 +408,11 @@ void Netctl::configAccepted()
|
|||||||
cg.writeEntry("autoUpdateInterval", uiConfig.spinBox_autoUpdate->value());
|
cg.writeEntry("autoUpdateInterval", uiConfig.spinBox_autoUpdate->value());
|
||||||
cg.writeEntry("guiPath", uiConfig.lineEdit_gui->text());
|
cg.writeEntry("guiPath", uiConfig.lineEdit_gui->text());
|
||||||
cg.writeEntry("netctlPath", uiConfig.lineEdit_netctl->text());
|
cg.writeEntry("netctlPath", uiConfig.lineEdit_netctl->text());
|
||||||
|
if (uiConfig.checkBox_sudo->checkState() == 0)
|
||||||
|
cg.writeEntry("useSudo", false);
|
||||||
|
else
|
||||||
|
cg.writeEntry("useSudo", true);
|
||||||
|
cg.writeEntry("sudoPath", uiConfig.lineEdit_sudo->text());
|
||||||
if (uiConfig.checkBox_showBigInterface->checkState() == 0)
|
if (uiConfig.checkBox_showBigInterface->checkState() == 0)
|
||||||
cg.writeEntry("showBigInterface", false);
|
cg.writeEntry("showBigInterface", false);
|
||||||
else
|
else
|
||||||
@ -404,6 +447,8 @@ void Netctl::configChanged()
|
|||||||
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
||||||
guiPath = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
guiPath = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
||||||
netctlPath = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
netctlPath = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
||||||
|
useSudo = cg.readEntry("useSudo", true);
|
||||||
|
sudoPath = cg.readEntry("sudoPath", "/usr/bin/kdesu -c");
|
||||||
showBigInterface = cg.readEntry("showBigInterface", true);
|
showBigInterface = cg.readEntry("showBigInterface", true);
|
||||||
showNetDev = cg.readEntry("showNetDev", true);
|
showNetDev = cg.readEntry("showNetDev", true);
|
||||||
showExtIp = cg.readEntry("showExtIp", true);
|
showExtIp = cg.readEntry("showExtIp", true);
|
||||||
@ -443,4 +488,13 @@ void Netctl::setBigInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::setSudo()
|
||||||
|
{
|
||||||
|
if (uiConfig.checkBox_sudo->checkState() == 0)
|
||||||
|
uiConfig.lineEdit_sudo->setDisabled(true);
|
||||||
|
else if (uiConfig.checkBox_showBigInterface->checkState() == 2)
|
||||||
|
uiConfig.lineEdit_sudo->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "netctl.moc"
|
#include "netctl.moc"
|
||||||
|
@ -46,6 +46,7 @@ public slots:
|
|||||||
void configAccepted();
|
void configAccepted();
|
||||||
void configChanged();
|
void configChanged();
|
||||||
void setBigInterface();
|
void setBigInterface();
|
||||||
|
void setSudo();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// configuration interface
|
// configuration interface
|
||||||
@ -54,7 +55,7 @@ private slots:
|
|||||||
void selectActiveIcon();
|
void selectActiveIcon();
|
||||||
void selectInactiveIcon();
|
void selectInactiveIcon();
|
||||||
// context menu
|
// context menu
|
||||||
void startProfileSlot();
|
void startProfileSlot(QAction *action);
|
||||||
void stopProfileSlot();
|
void stopProfileSlot();
|
||||||
void restartProfileSlot();
|
void restartProfileSlot();
|
||||||
void enableProfileAutoloadSlot();
|
void enableProfileAutoloadSlot();
|
||||||
@ -78,11 +79,13 @@ private:
|
|||||||
QString intIp;
|
QString intIp;
|
||||||
QString extIp;
|
QString extIp;
|
||||||
QString interfaces;
|
QString interfaces;
|
||||||
|
QStringList profileList;
|
||||||
QStringList formatLine;
|
QStringList formatLine;
|
||||||
// context menu
|
// context menu
|
||||||
void createActions();
|
void createActions();
|
||||||
QList<QAction*> menuActions;
|
QList<QAction*> menuActions;
|
||||||
QAction *startProfile;
|
QAction *startProfile;
|
||||||
|
QMenu *startProfileMenu;
|
||||||
QAction *stopProfile;
|
QAction *stopProfile;
|
||||||
QAction *restartProfile;
|
QAction *restartProfile;
|
||||||
QAction *enableProfileAutoload;
|
QAction *enableProfileAutoload;
|
||||||
@ -95,6 +98,8 @@ private:
|
|||||||
int autoUpdateInterval;
|
int autoUpdateInterval;
|
||||||
QString guiPath;
|
QString guiPath;
|
||||||
QString netctlPath;
|
QString netctlPath;
|
||||||
|
bool useSudo;
|
||||||
|
QString sudoPath;
|
||||||
bool showBigInterface;
|
bool showBigInterface;
|
||||||
bool showNetDev;
|
bool showNetDev;
|
||||||
bool showExtIp;
|
bool showExtIp;
|
||||||
|
Loading…
Reference in New Issue
Block a user