mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
kf5 update
* implement resizing * implement debug * implement notifications * update interface * correct work with helper
This commit is contained in:
parent
6ed45fa7a5
commit
54c5e7958a
@ -14,7 +14,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
|||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=netctl
|
X-KDE-PluginInfo-Name=netctl
|
||||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||||
X-KDE-PluginInfo-Website=http://arcanis.name/ru/projects/netctl-gui/
|
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
|
||||||
X-KDE-PluginInfo-Category=Network
|
X-KDE-PluginInfo-Category=Network
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
X-KDE-PluginInfo-License=GPLv3
|
X-KDE-PluginInfo-License=GPLv3
|
||||||
|
@ -12,7 +12,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
|||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=netctl
|
X-KDE-PluginInfo-Name=netctl
|
||||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||||
X-KDE-PluginInfo-Website=http://arcanis.name/ru/projects/netctl-gui/
|
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
|
||||||
X-KDE-PluginInfo-Category=Network
|
X-KDE-PluginInfo-Category=Network
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
X-KDE-PluginInfo-License=GPLv3
|
X-KDE-PluginInfo-License=GPLv3
|
||||||
|
@ -27,6 +27,8 @@ Item {
|
|||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
property bool debug: NetctlAdds.isDebugEnabled()
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
QtControls.TabView {
|
QtControls.TabView {
|
||||||
QtControls.Tab {
|
QtControls.Tab {
|
||||||
@ -82,4 +84,8 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[about::onCompleted]")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,15 @@ import QtQuick.Controls.Styles 1.3 as QtStyles
|
|||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
|
|
||||||
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: appearancePage
|
id: appearancePage
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
property bool debug: NetctlAdds.isDebugEnabled()
|
||||||
property variant weight: {
|
property variant weight: {
|
||||||
25: 0,
|
25: 0,
|
||||||
50: 1,
|
50: 1,
|
||||||
@ -269,4 +272,8 @@ Item {
|
|||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[about::onCompleted]")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ Item {
|
|||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
property bool debug: NetctlAdds.isDebugEnabled()
|
||||||
|
|
||||||
property variant cfg_dataengine: NetctlAdds.readDataEngineConfiguration()
|
property variant cfg_dataengine: NetctlAdds.readDataEngineConfiguration()
|
||||||
|
|
||||||
QtLayouts.ColumnLayout {
|
QtLayouts.ColumnLayout {
|
||||||
@ -136,6 +138,10 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[about::onCompleted]")
|
||||||
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
cfg_dataengine["EXTIP4"] = extIp4.checked ? "true" : "false"
|
cfg_dataengine["EXTIP4"] = extIp4.checked ? "true" : "false"
|
||||||
cfg_dataengine["EXTIP6"] = extIp6.checked ? "true" : "false"
|
cfg_dataengine["EXTIP6"] = extIp6.checked ? "true" : "false"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import org.kde.plasma.plasmoid 2.0
|
import org.kde.plasma.plasmoid 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
@ -29,7 +29,8 @@ Item {
|
|||||||
|
|
||||||
// variables
|
// variables
|
||||||
// internal
|
// internal
|
||||||
property variant weight: {
|
property bool debug: NetctlAdds.isDebugEnabled()
|
||||||
|
property variant fontWeight: {
|
||||||
"light": Font.Light,
|
"light": Font.Light,
|
||||||
"normal": Font.Normal,
|
"normal": Font.Normal,
|
||||||
"demibold": Font.DemiBold,
|
"demibold": Font.DemiBold,
|
||||||
@ -48,6 +49,7 @@ Item {
|
|||||||
"false": plasmoid.configuration.inactiveIconPath
|
"false": plasmoid.configuration.inactiveIconPath
|
||||||
}
|
}
|
||||||
property variant info: {
|
property variant info: {
|
||||||
|
"active": "false",
|
||||||
"current": "N\\A",
|
"current": "N\\A",
|
||||||
"extip4": "127.0.0.1",
|
"extip4": "127.0.0.1",
|
||||||
"extip6": "::1",
|
"extip6": "::1",
|
||||||
@ -59,11 +61,16 @@ Item {
|
|||||||
}
|
}
|
||||||
property string pattern: plasmoid.configuration.textPattern
|
property string pattern: plasmoid.configuration.textPattern
|
||||||
property bool status: false
|
property bool status: false
|
||||||
// contextual actions signals
|
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
||||||
|
// signals
|
||||||
|
signal needUpdate
|
||||||
signal netctlStateChanged
|
signal netctlStateChanged
|
||||||
|
|
||||||
// init
|
// init
|
||||||
Plasmoid.icon: icon.source
|
Plasmoid.icon: iconPath["false"]
|
||||||
|
Plasmoid.backgroundHints: "DefaultBackground"
|
||||||
|
Plasmoid.toolTipMainText: "Netctl"
|
||||||
|
Plasmoid.associatedApplication: plasmoid.configuration.guiPath
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
PlasmaCore.DataSource {
|
||||||
id: mainData
|
id: mainData
|
||||||
@ -72,31 +79,23 @@ Item {
|
|||||||
interval: plasmoid.configuration.autoUpdateInterval
|
interval: plasmoid.configuration.autoUpdateInterval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
|
var needToBeUpdated = false
|
||||||
if (data.value == "N\\A") return
|
if (data.value == "N\\A") return
|
||||||
|
if (info[sourceName] != data.value) needToBeUpdated = true
|
||||||
if (sourceName == "active") {
|
if (sourceName == "active") {
|
||||||
|
if (info[sourceName] != data.value)
|
||||||
|
// inverterd status
|
||||||
|
NetctlAdds.sendNotification("Info", i18n("Network status has been changed to '%1'",
|
||||||
|
status ? i18n("inactive") : i18n("active")))
|
||||||
status = data.value == "true"
|
status = data.value == "true"
|
||||||
icon.source = iconPath[data.value]
|
|
||||||
} else if (sourceName == "current") {
|
} else if (sourceName == "current") {
|
||||||
info["current"] = data.value
|
info["info"] = NetctlAdds.getInfo(data.value, info["status"])
|
||||||
// update
|
|
||||||
info["info"] = NetctlAdds.getInfo(info["current"], info["status"])
|
|
||||||
text.text = NetctlAdds.parsePattern(pattern, info)
|
|
||||||
netctlStateChanged()
|
|
||||||
} else if (sourceName == "extip4") {
|
|
||||||
info["extip4"] = data.value
|
|
||||||
} else if (sourceName == "extip6") {
|
|
||||||
info["extip6"] = data.value
|
|
||||||
} else if (sourceName == "interfaces") {
|
|
||||||
info["interfaces"] = data.value
|
|
||||||
} else if (sourceName == "intip4") {
|
|
||||||
info["intip4"] = data.value
|
|
||||||
} else if (sourceName == "intip6") {
|
|
||||||
info["intip6"] = data.value
|
|
||||||
} else if (sourceName == "profiles") {
|
|
||||||
info["profiles"] = data.value
|
|
||||||
} else if (sourceName == "status") {
|
|
||||||
info["status"] = data.value
|
|
||||||
}
|
}
|
||||||
|
// update
|
||||||
|
info[sourceName] = data.value
|
||||||
|
if (needToBeUpdated) needUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ Item {
|
|||||||
font.family: plasmoid.configuration.fontFamily
|
font.family: plasmoid.configuration.fontFamily
|
||||||
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
||||||
font.pointSize: plasmoid.configuration.fontSize
|
font.pointSize: plasmoid.configuration.fontSize
|
||||||
font.weight: weight[plasmoid.configuration.fontWeight]
|
font.weight: fontWeight[plasmoid.configuration.fontWeight]
|
||||||
horizontalAlignment: align[plasmoid.configuration.textAlign]
|
horizontalAlignment: align[plasmoid.configuration.textAlign]
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: "N\\A"
|
text: "N\\A"
|
||||||
@ -123,6 +122,9 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[main::onCompleted]")
|
||||||
|
|
||||||
|
// actions
|
||||||
plasmoid.setAction("titleAction", "netctl-gui", plasmoid.icon)
|
plasmoid.setAction("titleAction", "netctl-gui", plasmoid.icon)
|
||||||
plasmoid.setAction("startProfile", i18n("Start profile"), "dialog-apply")
|
plasmoid.setAction("startProfile", i18n("Start profile"), "dialog-apply")
|
||||||
plasmoid.setAction("stopProfile", i18n("Stop profile"), "dialog-close")
|
plasmoid.setAction("stopProfile", i18n("Stop profile"), "dialog-close")
|
||||||
@ -132,9 +134,35 @@ Item {
|
|||||||
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
||||||
// FIXME: icon from resources
|
// FIXME: icon from resources
|
||||||
plasmoid.setAction("startWifi", i18n("Show WiFi menu"))
|
plasmoid.setAction("startWifi", i18n("Show WiFi menu"))
|
||||||
|
// helper
|
||||||
|
if (plasmoid.configuration.useHelper) {
|
||||||
|
NetctlAdds.runCmd(plasmoid.configuration.helperPath)
|
||||||
|
plasmoid.configuration.useHelper = NetctlAdds.checkHelperStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onNeedUpdate: {
|
||||||
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
|
icon.source = iconPath[info["active"]]
|
||||||
|
Plasmoid.icon = iconPath[info["active"]]
|
||||||
|
text.text = NetctlAdds.parsePattern(pattern, info)
|
||||||
|
Plasmoid.toolTipSubText = info["info"]
|
||||||
|
netctlStateChanged()
|
||||||
|
// updae geometry
|
||||||
|
text.update()
|
||||||
|
icon.height = text.contentHeight
|
||||||
|
icon.width = text.contentHeight
|
||||||
|
icon.update()
|
||||||
|
height = text.contentHeight
|
||||||
|
width = icon.paintedWidth + text.contentWidth
|
||||||
|
update()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNetctlStateChanged: {
|
onNetctlStateChanged: {
|
||||||
|
if (debug) console.log("[main::onNetctlStateChanged]")
|
||||||
|
|
||||||
var titleAction = plasmoid.action("titleAction")
|
var titleAction = plasmoid.action("titleAction")
|
||||||
var startAction = plasmoid.action("startProfile")
|
var startAction = plasmoid.action("startProfile")
|
||||||
var stopAction = plasmoid.action("stopProfile")
|
var stopAction = plasmoid.action("stopProfile")
|
||||||
@ -147,7 +175,6 @@ Item {
|
|||||||
titleAction.iconSource = plasmoid.icon
|
titleAction.iconSource = plasmoid.icon
|
||||||
titleAction.text = info["current"] + " " + info["status"]
|
titleAction.text = info["current"] + " " + info["status"]
|
||||||
|
|
||||||
// FIXME: menu to actions
|
|
||||||
if (info["status"] == "(netctl-auto)") {
|
if (info["status"] == "(netctl-auto)") {
|
||||||
startAction.visible = false
|
startAction.visible = false
|
||||||
stopAction.visible = false
|
stopAction.visible = false
|
||||||
@ -155,7 +182,6 @@ Item {
|
|||||||
switchToAction.visible = true
|
switchToAction.visible = true
|
||||||
restartAction.visible = false
|
restartAction.visible = false
|
||||||
enableAction.visible = false
|
enableAction.visible = false
|
||||||
// MENU UPDATE
|
|
||||||
} else {
|
} else {
|
||||||
if (info["current"].indexOf("|") > -1) {
|
if (info["current"].indexOf("|") > -1) {
|
||||||
startAction.visible = true
|
startAction.visible = true
|
||||||
@ -182,53 +208,69 @@ Item {
|
|||||||
enableAction.text = i18n("Enable %1", info["current"])
|
enableAction.text = i18n("Enable %1", info["current"])
|
||||||
} else
|
} else
|
||||||
startAction.text = i18n("Start profile")
|
startAction.text = i18n("Start profile")
|
||||||
// MENU UPDATE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wifiAction.visible = plasmoid.configuration.useWifi
|
wifiAction.visible = plasmoid.configuration.useWifi
|
||||||
}
|
}
|
||||||
|
|
||||||
// actions
|
|
||||||
function action_titleAction() {
|
function action_titleAction() {
|
||||||
NetctlAdds.startApplication(plasmoid.configuration.guiPath)
|
if (debug) console.log("[main::action_titleAction]")
|
||||||
|
|
||||||
|
NetctlAdds.runCmd(plasmoid.configuration.guiPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_startProfile() {
|
function action_startProfile() {
|
||||||
// NetctlAdds.startProfileSlot(profile, status, plasmoid.configuration.useHelper,
|
if (debug) console.log("[main::action_startProfile]")
|
||||||
// plasmoid.configuration.netctlPath,
|
|
||||||
// plasmoid.configuration.sudoPath)
|
NetctlAdds.startProfileSlot(info["profiles"].split(","), status,
|
||||||
|
plasmoid.configuration.useHelper,
|
||||||
|
plasmoid.configuration.netctlPath,
|
||||||
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_stopProfile() {
|
function action_stopProfile() {
|
||||||
|
if (debug) console.log("[main::action_stopProfile]")
|
||||||
|
|
||||||
NetctlAdds.stopProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.stopProfileSlot(info, plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
plasmoid.configuration.sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_stopAllProfiles() {
|
function action_stopAllProfiles() {
|
||||||
|
if (debug) console.log("[main::action_stopAllProfiles]")
|
||||||
|
|
||||||
NetctlAdds.stopAllProfilesSlot(plasmoid.configuration.useHelper,
|
NetctlAdds.stopAllProfilesSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
plasmoid.configuration.sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_switchToProfile() {
|
function action_switchToProfile() {
|
||||||
// NetctlAdds.switchToProfileSlot(profile, plasmoid.configuration.useHelper,
|
if (debug) console.log("[main::action_switchToProfile]")
|
||||||
// plasmoid.configuration.netctlAutoPath)
|
|
||||||
|
NetctlAdds.switchToProfileSlot(info["profiles"].split(","),
|
||||||
|
plasmoid.configuration.useHelper,
|
||||||
|
plasmoid.configuration.netctlAutoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_restartProfile() {
|
function action_restartProfile() {
|
||||||
|
if (debug) console.log("[main::action_restartProfile]")
|
||||||
|
|
||||||
NetctlAdds.restartProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.restartProfileSlot(info, plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
plasmoid.configuration.sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_enableProfile() {
|
function action_enableProfile() {
|
||||||
|
if (debug) console.log("[main::action_enableProfile]")
|
||||||
|
|
||||||
NetctlAdds.enableProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.enableProfileSlot(info, plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
plasmoid.configuration.sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_startWifi() {
|
function action_startWifi() {
|
||||||
NetctlAdds.startApplication(plasmoid.configuration.wifiPath)
|
if (debug) console.log("[main::action_startWifi]")
|
||||||
|
|
||||||
|
NetctlAdds.runCmd(plasmoid.configuration.wifiPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,16 @@ import QtQuick.Controls 1.0 as QtControls
|
|||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
|
|
||||||
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: widgetPage
|
id: widgetPage
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
property bool debug: NetctlAdds.isDebugEnabled()
|
||||||
|
|
||||||
property alias cfg_autoUpdateInterval: autoUpdate.value
|
property alias cfg_autoUpdateInterval: autoUpdate.value
|
||||||
property alias cfg_guiPath: guiPath.text
|
property alias cfg_guiPath: guiPath.text
|
||||||
property alias cfg_useHelper: useHelper.checked
|
property alias cfg_useHelper: useHelper.checked
|
||||||
@ -212,4 +216,8 @@ Item {
|
|||||||
text: plasmoid.configuration.textPattern
|
text: plasmoid.configuration.textPattern
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[about::onCompleted]")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@ -47,25 +48,6 @@ NetctlAdds::~NetctlAdds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdds::checkHelperStatus(const bool useHelper)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
return (useHelper && !sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::startApplication(const QString cmd)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
|
||||||
|
|
||||||
QProcess command;
|
|
||||||
|
|
||||||
command.startDetached(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -86,6 +68,14 @@ QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVari
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool NetctlAdds::checkHelperStatus()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::getAboutText(const QString type)
|
QString NetctlAdds::getAboutText(const QString type)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -132,6 +122,7 @@ QString NetctlAdds::getInfo(const QString current, const QString status)
|
|||||||
for (int i=0; i<current.split(QChar('|')).count(); i++)
|
for (int i=0; i<current.split(QChar('|')).count(); i++)
|
||||||
profiles.append(current.split(QChar('|'))[i] +
|
profiles.append(current.split(QChar('|'))[i] +
|
||||||
QString(" (") + status.split(QChar('|'))[i] + QString(")"));
|
QString(" (") + status.split(QChar('|'))[i] + QString(")"));
|
||||||
|
if (profiles.isEmpty()) profiles.append(QString("N\\A"));
|
||||||
|
|
||||||
return profiles.join(QString(" | "));
|
return profiles.join(QString(" | "));
|
||||||
}
|
}
|
||||||
@ -166,6 +157,7 @@ void NetctlAdds::runCmd(const QString cmd)
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
|
|
||||||
QProcess command;
|
QProcess command;
|
||||||
|
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
||||||
|
|
||||||
command.startDetached(cmd);
|
command.startDetached(cmd);
|
||||||
}
|
}
|
||||||
@ -177,7 +169,8 @@ void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||||
|
|
||||||
KNotification::event(eventId, QString("Netctl ::: ") + eventId, message);
|
KNotification *notification = KNotification::event(eventId, QString("Netctl ::: ") + eventId, message);
|
||||||
|
notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,13 +218,17 @@ void NetctlAdds::restartProfileSlot(const QMap<QString, QVariant> dict, const bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::startProfileSlot(QString profile, const bool status,
|
void NetctlAdds::startProfileSlot(const QStringList profiles, const bool status,
|
||||||
const bool useHelper, const QString cmd, const QString sudoCmd)
|
const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profiles" << profiles;
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||||
|
profiles, 0, false, &ok);
|
||||||
|
if (!ok || profile.isEmpty()) return;
|
||||||
|
|
||||||
profile.remove(QChar('&'));
|
|
||||||
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
@ -285,13 +282,17 @@ void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::switchToProfileSlot(QString profile, const bool useHelper,
|
void NetctlAdds::switchToProfileSlot(const QStringList profiles, const bool useHelper,
|
||||||
const QString cmd)
|
const QString cmd)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
if (debug) qDebug() << PDEBUG << ":" << "Profiles" << profiles;
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||||
|
profiles, 0, false, &ok);
|
||||||
|
if (!ok || profile.isEmpty()) return;
|
||||||
|
|
||||||
profile.remove(QChar('&'));
|
|
||||||
sendNotification(QString("Info"), i18n("Switch to profile %1", profile));
|
sendNotification(QString("Info"), i18n("Switch to profile %1", profile));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
NetctlAdds(QObject *parent = 0);
|
NetctlAdds(QObject *parent = 0);
|
||||||
~NetctlAdds();
|
~NetctlAdds();
|
||||||
|
|
||||||
|
Q_INVOKABLE bool checkHelperStatus();
|
||||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||||
Q_INVOKABLE QString getInfo(const QString current, const QString status);
|
Q_INVOKABLE QString getInfo(const QString current, const QString status);
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
@ -47,7 +48,7 @@ public:
|
|||||||
const bool useHelper = true,
|
const bool useHelper = true,
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void startProfileSlot(QString profile, const bool status,
|
Q_INVOKABLE void startProfileSlot(const QStringList profiles, const bool status,
|
||||||
const bool useHelper = true,
|
const bool useHelper = true,
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
@ -58,7 +59,7 @@ public:
|
|||||||
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void switchToProfileSlot(QString profile,
|
Q_INVOKABLE void switchToProfileSlot(const QStringList profiles,
|
||||||
const bool useHelper = true,
|
const bool useHelper = true,
|
||||||
const QString cmd = QString("/usr/bin/netctl-auto"));
|
const QString cmd = QString("/usr/bin/netctl-auto"));
|
||||||
// dataengine
|
// dataengine
|
||||||
@ -67,10 +68,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
// helper
|
|
||||||
bool checkHelperStatus(const bool useHelper = true);
|
|
||||||
void startApplication(const QString cmd = QString("/usr/bin/true"));
|
|
||||||
// dbus
|
|
||||||
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user