diff --git a/sources/dataengine/netctl.cpp b/sources/dataengine/netctl.cpp index 5400df6..b04703c 100644 --- a/sources/dataengine/netctl.cpp +++ b/sources/dataengine/netctl.cpp @@ -151,7 +151,7 @@ bool Netctl::sourceRequestEvent(const QString &name) } -QString Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto) +QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto) { if (debug) qDebug() << PDEBUG; getNetctlAutoStatus(cmdNetctlAuto); @@ -166,15 +166,14 @@ QString Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetc if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (process.exitCode != 0) if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; - currentProfile = QString(""); + QStringList currentProfile; QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output); QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts); for (int i=0; i()); + else { + QProcess command; + QString commandLine = QString(""); + if (useSudo) + commandLine = paths[QString("sudo")] + QString(" "); + commandLine += paths[QString("netctl")] + QString(" stop-all "); + command.startDetached(commandLine); + } +} + + void Netctl::switchToProfileSlot(QAction *profile) { if (debug) qDebug() << PDEBUG; @@ -405,6 +423,7 @@ QList Netctl::contextualActions() if (info[QString("status")] == QString("(netctl-auto)")) { contextMenu[QString("start")]->setVisible(false); contextMenu[QString("stop")]->setVisible(false); + contextMenu[QString("stopall")]->setVisible(false); contextMenu[QString("switch")]->setVisible(true); contextMenu[QString("restart")]->setVisible(false); contextMenu[QString("enable")]->setVisible(false); @@ -414,11 +433,21 @@ QList Netctl::contextualActions() switchToProfileMenu->addAction(profile); } } else { - contextMenu[QString("start")]->setVisible(true); - contextMenu[QString("stop")]->setVisible(status); - contextMenu[QString("switch")]->setVisible(false); - contextMenu[QString("restart")]->setVisible(status); - contextMenu[QString("enable")]->setVisible(status); + if (info[QString("current")].contains(QChar('|'))) { + contextMenu[QString("start")]->setVisible(true); + contextMenu[QString("stop")]->setVisible(false); + contextMenu[QString("stopall")]->setVisible(true); + contextMenu[QString("switch")]->setVisible(false); + contextMenu[QString("restart")]->setVisible(false); + contextMenu[QString("enable")]->setVisible(false); + } else { + contextMenu[QString("start")]->setVisible(true); + contextMenu[QString("stop")]->setVisible(status); + contextMenu[QString("stopall")]->setVisible(false); + contextMenu[QString("switch")]->setVisible(false); + contextMenu[QString("restart")]->setVisible(status); + contextMenu[QString("enable")]->setVisible(status); + } if (status) { contextMenu[QString("start")]->setText(i18n("Start another profile")); contextMenu[QString("stop")]->setText(i18n("Stop %1", info[QString("current")])); @@ -465,6 +494,11 @@ void Netctl::createActions() connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot())); menuActions.append(contextMenu[QString("stop")]); + contextMenu[QString("stopall")] = new QAction(i18n("Stop all profiles"), this); + contextMenu[QString("stopall")]->setIcon(QIcon::fromTheme("dialog-close")); + connect(contextMenu[QString("stopall")], SIGNAL(triggered(bool)), this, SLOT(stopAllProfilesSlot())); + menuActions.append(contextMenu[QString("stopall")]); + contextMenu[QString("switch")] = new QAction(i18n("Switch to profile"), this); contextMenu[QString("switch")]->setIcon(QIcon::fromTheme("dialog-apply")); switchToProfileMenu = new QMenu(NULL); diff --git a/sources/plasmoid/netctl.h b/sources/plasmoid/netctl.h index a2fc6dd..04a8a47 100644 --- a/sources/plasmoid/netctl.h +++ b/sources/plasmoid/netctl.h @@ -87,6 +87,7 @@ private slots: void restartProfileSlot(); void startProfileSlot(QAction *profile); void stopProfileSlot(); + void stopAllProfilesSlot(); void switchToProfileSlot(QAction *profile); // helper void checkHelperStatus();