add support of netctl-auto to plasmoid and dataengine

This commit is contained in:
arcan1s 2014-07-12 18:19:19 +04:00
parent ae001b4d7f
commit 021a870220
10 changed files with 291 additions and 173 deletions

View File

@ -1,5 +1,6 @@
Ver.1.2.0: Ver.1.2.0:
+ [all] added icons + [all] added icons
+ [dataengine] added support of netctl-auto
+ [gui] added suppoort of macvlan + [gui] added suppoort of macvlan
+ [gui] added ability to remove profile + [gui] added ability to remove profile
+ [gui] added support of hidden wifi network + [gui] added support of hidden wifi network
@ -8,6 +9,7 @@ Ver.1.2.0:
+ [gui] added clear() function to profileTab + [gui] added clear() function to profileTab
+ [gui] added support of netctl-auto + [gui] added support of netctl-auto
+ [lib] detached backend from frontend + [lib] detached backend from frontend
+ [plasmoid] added support of netctl-auto
* [all] small changes in the project architecture * [all] small changes in the project architecture
* [gui] more debug information * [gui] more debug information
* [gui] changed lineEdit_profile to comboBox * [gui] changed lineEdit_profile to comboBox

View File

@ -59,7 +59,9 @@ Installation
Available cmake flags: Available cmake flags:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine * `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_GUI:BOOL=0` - do not build GUI * `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid * `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI * `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
@ -69,7 +71,7 @@ Additional information
TODO (wish list) TODO (wish list)
---------------- ----------------
* netctl-auto support to dataengine * split configuration interface
* man pages * man pages
* code review * code review

View File

@ -3,6 +3,8 @@
## Commands ## Commands
# command # command
CMD=/usr/bin/netctl CMD=/usr/bin/netctl
# netctl-auto command
NETCTLAUTOCMD=/usr/bin/netctl-auto
# ip command # ip command
IPCMD=/usr/bin/ip IPCMD=/usr/bin/ip

View File

@ -61,6 +61,7 @@ void Netctl::readConfiguration()
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip"); rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip"); rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
rawConfig[QString("NETDIR")] = QString("/sys/class/net/"); rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf"); QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
QFile confFile(fileName); QFile confFile(fileName);
@ -101,7 +102,8 @@ QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString>
key.remove(QChar(' ')); key.remove(QChar(' '));
if ((key != QString("CMD")) && if ((key != QString("CMD")) &&
(key != QString("EXTIPCMD")) && (key != QString("EXTIPCMD")) &&
(key != QString("IPCMD"))) (key != QString("IPCMD")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' ')); value.remove(QChar(' '));
config[key] = value; config[key] = value;
} }
@ -196,15 +198,20 @@ bool Netctl::getProfileStatus(const QString cmd)
} }
QString Netctl::getProfileStringStatus(const QString cmd) QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{ {
QProcess command; QProcess command;
QString status = QString("static"); QString status = QString("static");
QString profile = getCurrentProfile(cmd); // check netctl-auto
command.start(cmd + QString(" is-enabled ") + profile); if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
command.waitForFinished(-1); status = QString("netctl-auto");
if (command.exitCode() == 0) else {
status = QString("enabled"); // check netctl
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
command.waitForFinished(-1);
if (command.exitCode() == 0)
status = QString("enabled");
}
return status; return status;
} }
@ -214,7 +221,9 @@ bool Netctl::updateSourceEvent(const QString &source)
QString key = QString("value"); QString key = QString("value");
QString value = QString(""); QString value = QString("");
if (source == QString("currentProfile")) { if (source == QString("currentProfile")) {
value = getCurrentProfile(configuration[QString("CMD")]); value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
if (value.isEmpty())
value = getCurrentProfile(configuration[QString("CMD")]);
} }
else if (source == QString("extIp")) { else if (source == QString("extIp")) {
if (configuration[QString("EXTIP")] == QString("true")) if (configuration[QString("EXTIP")] == QString("true"))
@ -227,16 +236,21 @@ bool Netctl::updateSourceEvent(const QString &source)
value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]); value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]);
} }
else if (source == QString("profiles")) { else if (source == QString("profiles")) {
value = getProfileList(configuration[QString("CMD")]).join(QChar(',')); value = getProfileList(configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
if (value.isEmpty())
value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
} }
else if (source == QString("statusBool")) { else if (source == QString("statusBool")) {
if (getProfileStatus(configuration[QString("CMD")])) if (getProfileStatus(configuration[QString("NETCTLAUTOCMD")]))
value = QString("true");
else if (getProfileStatus(configuration[QString("CMD")]))
value = QString("true"); value = QString("true");
else else
value = QString("false"); value = QString("false");
} }
else if (source == QString("statusString")) { else if (source == QString("statusString")) {
value = getProfileStringStatus(configuration[QString("CMD")]); value = getProfileStringStatus(configuration[QString("CMD")],
configuration[QString("NETCTLAUTOCMD")]);
} }
setData(source, key, value); setData(source, key, value);
return true; return true;

View File

@ -33,7 +33,7 @@ public:
QString getIntIp(const QString cmd, const QString dir); QString getIntIp(const QString cmd, const QString dir);
QStringList getProfileList(const QString cmd); QStringList getProfileList(const QString cmd);
bool getProfileStatus(const QString cmd); bool getProfileStatus(const QString cmd);
QString getProfileStringStatus(const QString cmd); QString getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
protected: protected:
bool sourceRequestEvent(const QString &name); bool sourceRequestEvent(const QString &name);
@ -41,6 +41,7 @@ protected:
QStringList sources() const; QStringList sources() const;
private: private:
bool isNetctlAutoRunning();
// configuration // configuration
QMap<QString, QString> configuration; QMap<QString, QString> configuration;
void readConfiguration(); void readConfiguration();

View File

@ -54,7 +54,7 @@ void NetctlAutoWindow::createActions()
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles())); connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile())); connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\ connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoAppendTable())); connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile())); connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
// service // service
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService())); connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
@ -68,7 +68,7 @@ void NetctlAutoWindow::createActions()
// buttons // buttons
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile())); connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoAppendTable())); connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile())); connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
} }
@ -77,14 +77,14 @@ void NetctlAutoWindow::showWindow()
{ {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]"; if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
netctlAutoAppendTable(); netctlAutoUpdateTable();
show(); show();
} }
void NetctlAutoWindow::netctlAutoAppendTable() void NetctlAutoWindow::netctlAutoUpdateTable()
{ {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoAppendTable]"; if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
ui->tableWidget->setDisabled(true); ui->tableWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto(); QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
@ -233,7 +233,7 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -251,7 +251,7 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -265,7 +265,7 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -283,7 +283,7 @@ void NetctlAutoWindow::netctlAutoStartProfile()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -296,7 +296,7 @@ void NetctlAutoWindow::netctlAutoEnableService()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -309,7 +309,7 @@ void NetctlAutoWindow::netctlAutoRestartService()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }
@ -322,7 +322,7 @@ void NetctlAutoWindow::netctlAutoStartService()
else else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoAppendTable(); netctlAutoUpdateTable();
} }

View File

@ -44,8 +44,8 @@ public slots:
private slots: private slots:
// table // table
void netctlAutoAppendTable();
void netctlAutoContextualMenu(const QPoint &pos); void netctlAutoContextualMenu(const QPoint &pos);
void netctlAutoUpdateTable();
// netctl-auto // netctl-auto
void netctlAutoDisableAllProfiles(); void netctlAutoDisableAllProfiles();
void netctlAutoEnableProfile(); void netctlAutoEnableProfile();

View File

@ -45,6 +45,7 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
Netctl::~Netctl() Netctl::~Netctl()
{ {
// delete startProfileMenu; // delete startProfileMenu;
// delete switchToProfileMenu;
// delete startProfile; // delete startProfile;
// delete stopProfile; // delete stopProfile;
// delete restartProfile; // delete restartProfile;
@ -127,21 +128,29 @@ void Netctl::enableProfileSlot()
void Netctl::startProfileSlot(QAction *profile) void Netctl::startProfileSlot(QAction *profile)
{ {
bool ready = true;
QProcess command; QProcess command;
QString commandLine; QString commandLine;
commandLine = QString(""); commandLine = QString("");
sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QString("&")))); sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QString("&"))));
if (status) if (status) {
commandLine = paths[QString("netctl")] + QString(" stop ") + commandLine = paths[QString("netctl")] + QString(" stop ") + info[QString("name")];
info[QString("name")] + QString(" && "); if (useSudo)
if (useSudo) commandLine = paths[QString("sudo")] + QString(" ") + commandLine;
commandLine = paths[QString("sudo")] + QString(" ") + commandLine + command.start(commandLine);
paths[QString("netctl")] + QString(" start ") + command.waitForFinished(-1);
profile->text().remove(QString("&")); if (command.exitCode() != 0)
else ready = false;
commandLine = commandLine + paths[QString("netctl")] + QString(" start ") + }
profile->text().remove(QString("&")); if (ready) {
command.startDetached(commandLine); if (useSudo)
commandLine = paths[QString("sudo")] + QString(" ") + paths[QString("netctl")] +
QString(" start ") + profile->text().remove(QString("&"));
else
commandLine = paths[QString("netctl")] + QString(" start ") +
profile->text().remove(QString("&"));
command.startDetached(commandLine);
}
} }
@ -159,6 +168,18 @@ void Netctl::stopProfileSlot()
} }
void Netctl::switchToProfileSlot(QAction *profile)
{
QProcess command;
QString commandLine;
commandLine = QString("");
sendNotification(QString("Info"), i18n("Switch to profile %1", profile->text().remove(QString("&"))));
commandLine = paths[QString("netctl-auto")] + QString(" switch-to ") +
profile->text().remove(QString("&"));
command.startDetached(commandLine);
}
void Netctl::restartProfileSlot() void Netctl::restartProfileSlot()
{ {
QProcess command; QProcess command;
@ -181,35 +202,55 @@ QList<QAction*> Netctl::contextualActions()
contextMenu[QString("title")]->setIcon(QIcon(paths[QString("inactive")])); contextMenu[QString("title")]->setIcon(QIcon(paths[QString("inactive")]));
contextMenu[QString("title")]->setText(info[QString("name")] + QString(" ") + info[QString("status")]); contextMenu[QString("title")]->setText(info[QString("name")] + QString(" ") + info[QString("status")]);
if (status) { if (info[QString("status")] == QString("(netctl-auto)")) {
contextMenu[QString("start")]->setText(i18n("Start another profile")); contextMenu[QString("start")]->setVisible(false);
contextMenu[QString("stop")]->setVisible(true);
contextMenu[QString("stop")]->setText(i18n("Stop %1", info[QString("name")]));
contextMenu[QString("restart")]->setVisible(true);
contextMenu[QString("restart")]->setText(i18n("Restart %1", info[QString("name")]));
contextMenu[QString("enable")]->setVisible(true);
if (info[QString("status")].contains(QString("enabled")))
contextMenu[QString("enable")]->setText(i18n("Disable %1", info[QString("name")]));
else
contextMenu[QString("enable")]->setText(i18n("Enable %1", info[QString("name")]));
}
else {
contextMenu[QString("start")]->setText(i18n("Start profile"));
contextMenu[QString("stop")]->setVisible(false); contextMenu[QString("stop")]->setVisible(false);
contextMenu[QString("switch")]->setVisible(true);
contextMenu[QString("restart")]->setVisible(false); contextMenu[QString("restart")]->setVisible(false);
contextMenu[QString("enable")]->setVisible(false); contextMenu[QString("enable")]->setVisible(false);
switchToProfileMenu->clear();
for (int i=0; i<profileList.count(); i++) {
QAction *profile = new QAction(profileList[i], this);
switchToProfileMenu->addAction(profile);
}
}
else {
contextMenu[QString("start")]->setVisible(true);
contextMenu[QString("stop")]->setVisible(true);
contextMenu[QString("switch")]->setVisible(false);
contextMenu[QString("restart")]->setVisible(true);
contextMenu[QString("enable")]->setVisible(true);
if (status) {
contextMenu[QString("start")]->setText(i18n("Start another profile"));
contextMenu[QString("stop")]->setVisible(true);
contextMenu[QString("stop")]->setText(i18n("Stop %1", info[QString("name")]));
contextMenu[QString("restart")]->setVisible(true);
contextMenu[QString("restart")]->setText(i18n("Restart %1", info[QString("name")]));
contextMenu[QString("enable")]->setVisible(true);
if (info[QString("status")].contains(QString("enabled")))
contextMenu[QString("enable")]->setText(i18n("Disable %1", info[QString("name")]));
else
contextMenu[QString("enable")]->setText(i18n("Enable %1", info[QString("name")]));
}
else {
contextMenu[QString("start")]->setText(i18n("Start profile"));
contextMenu[QString("stop")]->setVisible(false);
contextMenu[QString("restart")]->setVisible(false);
contextMenu[QString("enable")]->setVisible(false);
}
startProfileMenu->clear();
for (int i=0; i<profileList.count(); i++) {
QAction *profile = new QAction(profileList[i], this);
startProfileMenu->addAction(profile);
}
} }
if (useWifi) if (useWifi)
contextMenu[QString("wifi")]->setVisible(true); contextMenu[QString("wifi")]->setVisible(true);
else else
contextMenu[QString("wifi")]->setVisible(false); contextMenu[QString("wifi")]->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;
} }
@ -234,6 +275,14 @@ void Netctl::createActions()
connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot())); connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
menuActions.append(contextMenu[QString("stop")]); menuActions.append(contextMenu[QString("stop")]);
contextMenu[QString("switch")] = new QAction(i18n("Switch to profile"), this);
contextMenu[QString("switch")]->setIcon(QIcon::fromTheme("dialog-apply"));
switchToProfileMenu = new QMenu(NULL);
contextMenu[QString("switch")]->setMenu(switchToProfileMenu);
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this,
SLOT(switchToProfileSlot(QAction *)));
menuActions.append(contextMenu[QString("switch")]);
contextMenu[QString("restart")] = new QAction(i18n("Restart profile"), this); contextMenu[QString("restart")] = new QAction(i18n("Restart profile"), this);
contextMenu[QString("restart")]->setIcon(QIcon::fromTheme("stock-refresh")); contextMenu[QString("restart")]->setIcon(QIcon::fromTheme("stock-refresh"));
connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot())); connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
@ -406,6 +455,14 @@ void Netctl::selectNetctlExe()
} }
void Netctl::selectNetctlAutoExe()
{
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiWidConfig.lineEdit_netctlAuto->setText(url.path());
}
void Netctl::selectSudoExe() void Netctl::selectSudoExe()
{ {
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*"); KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
@ -435,6 +492,7 @@ 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")]);
uiWidConfig.lineEdit_netctl->setText(paths[QString("netctl")]); uiWidConfig.lineEdit_netctl->setText(paths[QString("netctl")]);
uiWidConfig.lineEdit_netctlAuto->setText(paths[QString("netctlAuto")]);
if (useSudo) if (useSudo)
uiWidConfig.checkBox_sudo->setCheckState(Qt::Checked); uiWidConfig.checkBox_sudo->setCheckState(Qt::Checked);
else else
@ -491,6 +549,7 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
connect(uiWidConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe())); connect(uiWidConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe()));
connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe())); connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe()));
connect(uiWidConfig.pushButton_netctlAuto, SIGNAL(clicked()), this, SLOT(selectNetctlAutoExe()));
connect(uiWidConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectSudoExe())); connect(uiWidConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectSudoExe()));
connect(uiWidConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selecWifiExe())); connect(uiWidConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selecWifiExe()));
connect(uiAppConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon())); connect(uiAppConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon()));
@ -509,6 +568,7 @@ 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());
cg.writeEntry("netctlPath", uiWidConfig.lineEdit_netctl->text()); cg.writeEntry("netctlPath", uiWidConfig.lineEdit_netctl->text());
cg.writeEntry("netctlAutoPath", uiWidConfig.lineEdit_netctlAuto->text());
if (uiWidConfig.checkBox_sudo->checkState() == 0) if (uiWidConfig.checkBox_sudo->checkState() == 0)
cg.writeEntry("useSudo", false); cg.writeEntry("useSudo", false);
else else
@ -553,6 +613,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("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("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu"); paths[QString("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu");
paths[QString("wifi")] = cg.readEntry("wifiPath", "/usr/bin/netctl-gui -t 3"); paths[QString("wifi")] = cg.readEntry("wifiPath", "/usr/bin/netctl-gui -t 3");
useSudo = cg.readEntry("useSudo", true); useSudo = cg.readEntry("useSudo", true);

View File

@ -62,12 +62,14 @@ private slots:
void selectGuiExe(); void selectGuiExe();
void selectInactiveIcon(); void selectInactiveIcon();
void selectNetctlExe(); void selectNetctlExe();
void selectNetctlAutoExe();
void selectSudoExe(); void selectSudoExe();
void selectWifiExe(); void selectWifiExe();
// context menu // context menu
void enableProfileSlot(); void enableProfileSlot();
void startProfileSlot(QAction *profile); void startProfileSlot(QAction *profile);
void stopProfileSlot(); void stopProfileSlot();
void switchToProfileSlot(QAction *profile);
void restartProfileSlot(); void restartProfileSlot();
protected: protected:
@ -88,6 +90,7 @@ private:
void createActions(); void createActions();
QList<QAction*> menuActions; QList<QAction*> menuActions;
QMenu *startProfileMenu; QMenu *startProfileMenu;
QMenu *switchToProfileMenu;
QMap<QString, QAction*> contextMenu; QMap<QString, QAction*> contextMenu;
// data engine // data engine
Plasma::DataEngine *netctlEngine; Plasma::DataEngine *netctlEngine;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>480</width> <width>480</width>
<height>341</height> <height>339</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -19,8 +19,8 @@
<property name="windowTitle"> <property name="windowTitle">
<string notr="true">Configuration Window</string> <string notr="true">Configuration Window</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0"> <item>
<widget class="QLabel" name="label_info"> <widget class="QLabel" name="label_info">
<property name="text"> <property name="text">
<string/> <string/>
@ -30,106 +30,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item>
<widget class="QCheckBox" name="checkBox_showNetDev">
<property name="text">
<string>Show network devices</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="layout_wifi">
<item>
<widget class="QCheckBox" name="checkBox_wifi">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Show 'Start WiFi menu'</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wifi"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_wifi">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_showBigInterface">
<property name="text">
<string>Show more detailed interface</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="checkBox_showIntIp">
<property name="text">
<string>Show internal IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_gui">
<item>
<widget class="QLabel" name="label_gui">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to GUI</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gui"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_gui">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_autoUpdate"> <layout class="QHBoxLayout" name="layout_autoUpdate">
<item> <item>
<widget class="QLabel" name="label_autoUpdate"> <widget class="QLabel" name="label_autoUpdate">
@ -187,23 +88,46 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="0"> <item>
<widget class="QCheckBox" name="checkBox_showExtIp"> <layout class="QHBoxLayout" name="layout_gui">
<property name="text"> <item>
<string>Show external IP</string> <widget class="QLabel" name="label_gui">
</property> <property name="minimumSize">
<property name="checked"> <size>
<bool>true</bool> <width>150</width>
</property> <height>23</height>
</widget> </size>
</property>
<property name="text">
<string>Path to GUI</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gui"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_gui">
<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 row="3" column="0"> <item>
<layout class="QHBoxLayout" name="layout_netctl"> <layout class="QHBoxLayout" name="layout_netctl">
<item> <item>
<widget class="QLabel" name="label_netctl"> <widget class="QLabel" name="label_netctl">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>150</width>
<height>23</height> <height>23</height>
</size> </size>
</property> </property>
@ -230,7 +154,40 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item>
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to netctl-auto</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctlAuto"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_sudo"> <layout class="QHBoxLayout" name="layout_sudo">
<item> <item>
<widget class="QCheckBox" name="checkBox_sudo"> <widget class="QCheckBox" name="checkBox_sudo">
@ -266,7 +223,83 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="10" column="0"> <item>
<layout class="QHBoxLayout" name="layout_wifi">
<item>
<widget class="QCheckBox" name="checkBox_wifi">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Show 'Start WiFi menu'</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wifi"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_wifi">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showBigInterface">
<property name="text">
<string>Show more detailed interface</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showNetDev">
<property name="text">
<string>Show network devices</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showExtIp">
<property name="text">
<string>Show external IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showIntIp">
<property name="text">
<string>Show internal IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_configuration"> <spacer name="verticalSpacer_configuration">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>