mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-09 03:45:53 +00:00
plasmoid fixes
This commit is contained in:
@ -86,7 +86,7 @@ QStringList Netctl::sources() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getCmdOutput(const QString cmd)
|
QString Netctl::getCmdOutput(const QString cmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
@ -135,7 +135,7 @@ bool Netctl::sourceRequestEvent(const QString &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getExtIp(const QString cmd)
|
QString Netctl::getExtIp(const QString cmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
@ -144,34 +144,34 @@ QString Netctl::getExtIp(const QString cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses)
|
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (profiles.count() != statuses.count()) return QString("N\\A");
|
if (profiles.count() != statuses.count()) return QString("N\\A");
|
||||||
|
|
||||||
QStringList list;
|
QStringList list;
|
||||||
for (int i=0; i<profiles.count(); i++)
|
for (int i=0; i<profiles.count(); i++)
|
||||||
list.append(QString("%1 (%2)").arg(profiles[i]).arg(statuses[i]));
|
list.append(QString("%1 (%2)").arg(profiles.at(i)).arg(statuses.at(i)));
|
||||||
if (list.isEmpty()) list.append(QString("N\\A"));
|
if (list.isEmpty()) list.append(QString("N\\A"));
|
||||||
|
|
||||||
return list.join(QString(" | "));
|
return list.join(QString(" | "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getInterfaceList()
|
QStringList Netctl::getInterfaceList() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||||
QStringList interfacesList;
|
QStringList interfacesList;
|
||||||
for (int i=0; i<rawList.count(); i++)
|
foreach(QNetworkInterface interface, rawList)
|
||||||
interfacesList.append(rawList[i].name());
|
interfacesList.append(interface.name());
|
||||||
|
|
||||||
return interfacesList;
|
return interfacesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -181,11 +181,11 @@ QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
|||||||
else if (protocol == QAbstractSocket::IPv6Protocol)
|
else if (protocol == QAbstractSocket::IPv6Protocol)
|
||||||
intIp = QString("::1/128");
|
intIp = QString("::1/128");
|
||||||
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
||||||
for (int i=0; i<rawList.count(); i++) {
|
foreach(QHostAddress address, rawList) {
|
||||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
if (address == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
if (address == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||||
if (rawList[i].protocol() != protocol) continue;
|
if (address.protocol() != protocol) continue;
|
||||||
intIp = rawList[i].toString();
|
intIp = address.toString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,21 +197,24 @@ QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNet
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
netctlAutoStatus = true;
|
|
||||||
QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto));
|
QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto));
|
||||||
if (output.isEmpty()) {
|
if (output.isEmpty()) {
|
||||||
output = getCmdOutput(QString("%1 list").arg(cmdNetctl));
|
output = getCmdOutput(QString("%1 list").arg(cmdNetctl));
|
||||||
netctlAutoStatus = false;
|
netctlAutoStatus = false;
|
||||||
}
|
} else
|
||||||
|
netctlAutoStatus = true;
|
||||||
|
|
||||||
// parse
|
// parse
|
||||||
QStringList currentProfiles;
|
QStringList currentProfiles;
|
||||||
QStringList profileList = output.split(QChar('\n'));
|
// workaround for first element spaces on which are trimmed
|
||||||
|
QStringList profileList = QString(" %1").arg(output).split(QChar('\n'));
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
for (int i=0; i<profileList.count(); i++) {
|
||||||
bool isActive = (profileList[i][0] == QChar('*'));
|
bool isActive = (profileList.at(i)[0] == QChar('*'));
|
||||||
profileList[i].remove(0, 2);
|
profileList[i].remove(0, 2);
|
||||||
if (isActive) currentProfiles.append(profileList[i]);
|
if (isActive) currentProfiles.append(profileList.at(i));
|
||||||
}
|
}
|
||||||
|
profileList.sort();
|
||||||
|
currentProfiles.sort();
|
||||||
|
|
||||||
// return profiles
|
// return profiles
|
||||||
currentProfile = currentProfiles;
|
currentProfile = currentProfiles;
|
||||||
@ -220,7 +223,7 @@ QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNet
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl)
|
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -230,8 +233,8 @@ QStringList Netctl::getProfileStringStatus(const QString cmdNetctl)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<currentProfile.count(); i++) {
|
foreach(QString profile, currentProfile) {
|
||||||
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(currentProfile[i]));
|
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(profile));
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
status.append(process.exitCode == 0 ? QString("enabled") : QString("static"));
|
status.append(process.exitCode == 0 ? QString("enabled") : QString("static"));
|
||||||
@ -246,8 +249,8 @@ void Netctl::initSources()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QStringList sourcesList = sources();
|
QStringList sourcesList = sources();
|
||||||
for (int i=0; i<sourcesList.count(); i++)
|
foreach(QString source, sourcesList)
|
||||||
setData(sourcesList[i], QString("value"), QString("N\\A"));
|
setData(source, QString("value"), QString("N\\A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ class Netctl : public Plasma::DataEngine
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Netctl(QObject *parent, const QVariantList &args);
|
explicit Netctl(QObject *parent, const QVariantList &args);
|
||||||
~Netctl();
|
virtual ~Netctl();
|
||||||
QString getExtIp(const QString cmd);
|
QString getExtIp(const QString cmd) const;
|
||||||
QString getInfo(const QStringList profiles, const QStringList statuses);
|
QString getInfo(const QStringList profiles, const QStringList statuses) const;
|
||||||
QStringList getInterfaceList();
|
QStringList getInterfaceList() const;
|
||||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const;
|
||||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||||
QStringList getProfileStringStatus(const QString cmdNetctl);
|
QStringList getProfileStringStatus(const QString cmdNetctl) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void initSources();
|
void initSources();
|
||||||
@ -53,7 +53,7 @@ private:
|
|||||||
// configuration
|
// configuration
|
||||||
bool debug;
|
bool debug;
|
||||||
QVariantMap configuration;
|
QVariantMap configuration;
|
||||||
QString getCmdOutput(const QString cmd);
|
QString getCmdOutput(const QString cmd) const;
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,17 +19,21 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
|
|
||||||
import org.kde.plasma.netctl 1.0
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: aboutPage
|
id: aboutPage
|
||||||
|
// backend
|
||||||
|
NetctlAdds {
|
||||||
|
id: netctlAdds;
|
||||||
|
}
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: NetctlAdds.isDebugEnabled()
|
property bool debug: netctlAdds.isDebugEnabled()
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
id: pageColumn
|
||||||
@ -44,20 +48,20 @@ Item {
|
|||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: NetctlAdds.getAboutText("header")
|
text: netctlAdds.getAboutText("header")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: NetctlAdds.getAboutText("description")
|
text: netctlAdds.getAboutText("description")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: NetctlAdds.getAboutText("links")
|
text: netctlAdds.getAboutText("links")
|
||||||
onLinkActivated: Qt.openUrlExternally(link);
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +70,7 @@ Item {
|
|||||||
font.capitalization: Font.SmallCaps
|
font.capitalization: Font.SmallCaps
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: NetctlAdds.getAboutText("copy")
|
text: netctlAdds.getAboutText("copy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,14 +82,14 @@ Item {
|
|||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: NetctlAdds.getAboutText("translators")
|
text: netctlAdds.getAboutText("translators")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: NetctlAdds.getAboutText("3rdparty")
|
text: netctlAdds.getAboutText("3rdparty")
|
||||||
onLinkActivated: Qt.openUrlExternally(link);
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,21 @@ 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.netctl 1.0
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: appearancePage
|
id: appearancePage
|
||||||
|
// backend
|
||||||
|
NetctlAdds {
|
||||||
|
id: netctlAdds;
|
||||||
|
}
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: NetctlAdds.isDebugEnabled()
|
property bool debug: netctlAdds.isDebugEnabled()
|
||||||
property variant weight: {
|
property variant weight: {
|
||||||
25: 0,
|
25: 0,
|
||||||
50: 1,
|
50: 1,
|
||||||
@ -110,7 +114,10 @@ Item {
|
|||||||
id: selectFont
|
id: selectFont
|
||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.fontFamily
|
text: plasmoid.configuration.fontFamily
|
||||||
onClicked: fontDialog.visible = true
|
onClicked: {
|
||||||
|
fontDialog.setFont()
|
||||||
|
fontDialog.visible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,21 +315,28 @@ Item {
|
|||||||
id: colorDialog
|
id: colorDialog
|
||||||
title: i18n("Select a color")
|
title: i18n("Select a color")
|
||||||
color: selectColor.text
|
color: selectColor.text
|
||||||
onAccepted: {
|
onAccepted: selectColor.text = colorDialog.color
|
||||||
selectColor.text = colorDialog.color
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtDialogs.FontDialog {
|
QtDialogs.FontDialog {
|
||||||
id: fontDialog
|
id: fontDialog
|
||||||
title: i18n("Select a font")
|
title: i18n("Select a font")
|
||||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
|
onSetFont: {
|
||||||
|
fontDialog.font = Qt.font({
|
||||||
|
family: selectFont.text,
|
||||||
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
|
italic: fontStyle.currentIndex == 1,
|
||||||
|
weight: Font.Normal,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -21,19 +21,23 @@ import QtQuick.Dialogs 1.1 as QtDialogs
|
|||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
|
|
||||||
import org.kde.plasma.netctl 1.0
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: dataenginePage
|
id: dataenginePage
|
||||||
|
// backend
|
||||||
|
NetctlAdds {
|
||||||
|
id: netctlAdds;
|
||||||
|
}
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: NetctlAdds.isDebugEnabled()
|
property bool debug: netctlAdds.isDebugEnabled()
|
||||||
|
|
||||||
property variant cfg_dataengine: NetctlAdds.readDataEngineConfiguration()
|
property variant cfg_dataengine: netctlAdds.readDataEngineConfiguration()
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
id: pageColumn
|
||||||
@ -228,6 +232,6 @@ Item {
|
|||||||
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"
|
||||||
NetctlAdds.writeDataEngineConfiguration(cfg_dataengine)
|
netctlAdds.writeDataEngineConfiguration(cfg_dataengine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,19 @@ 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
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
import org.kde.plasma.netctl 1.0
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: main
|
id: main
|
||||||
|
// backend
|
||||||
|
NetctlAdds {
|
||||||
|
id: netctlAdds;
|
||||||
|
}
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
// internal
|
// internal
|
||||||
property bool debug: NetctlAdds.isDebugEnabled()
|
property bool debug: netctlAdds.isDebugEnabled()
|
||||||
property variant fontWeight: {
|
property variant fontWeight: {
|
||||||
"light": Font.Light,
|
"light": Font.Light,
|
||||||
"normal": Font.Normal,
|
"normal": Font.Normal,
|
||||||
@ -52,8 +56,9 @@ Item {
|
|||||||
}
|
}
|
||||||
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
||||||
// signals
|
// signals
|
||||||
signal needUpdate
|
signal needIconUpdate(string newIcon)
|
||||||
signal needMenuUpdate
|
signal needTextUpdate(string newText, string newToolTip)
|
||||||
|
signal needMenuUpdate(string current, string stringStatus, bool status)
|
||||||
|
|
||||||
// init
|
// init
|
||||||
Plasmoid.icon: iconPath["false"]
|
Plasmoid.icon: iconPath["false"]
|
||||||
@ -71,7 +76,7 @@ Item {
|
|||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
NetctlAdds.setDataBySource(sourceName, data)
|
netctlAdds.setDataBySource(sourceName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,28 +115,30 @@ Item {
|
|||||||
plasmoid.setAction("restartProfile", i18n("Restart profile"), "view-refresh")
|
plasmoid.setAction("restartProfile", i18n("Restart profile"), "view-refresh")
|
||||||
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
||||||
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi")
|
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi")
|
||||||
// helper
|
// init submodule
|
||||||
if (plasmoid.configuration.useHelper) {
|
Plasmoid.userConfiguringChanged(false)
|
||||||
NetctlAdds.runCmd(plasmoid.configuration.helperPath)
|
|
||||||
plasmoid.configuration.useHelper = NetctlAdds.checkHelperStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
NetctlAdds.needToBeUpdated.connect(needUpdate)
|
netctlAdds.needIconToBeUpdated.connect(needIconUpdate)
|
||||||
|
netctlAdds.needMenuUpdate.connect(needMenuUpdate)
|
||||||
|
netctlAdds.needTextToBeUpdated.connect(needTextUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onNeedIconUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.log("[main::onNeedIconUpdate]")
|
||||||
|
|
||||||
var iconStatus = NetctlAdds.valueByKey("active")
|
icon.source = iconPath[newIcon]
|
||||||
icon.source = iconPath[iconStatus]
|
Plasmoid.icon = iconPath[newIcon]
|
||||||
Plasmoid.icon = iconPath[iconStatus]
|
}
|
||||||
text.text = NetctlAdds.parsePattern(plasmoid.configuration.textPattern)
|
|
||||||
Plasmoid.toolTipSubText = NetctlAdds.valueByKey("info")
|
onNeedTextUpdate: {
|
||||||
needMenuUpdate()
|
if (debug) console.log("[main::onNeedTextUpdate]")
|
||||||
|
|
||||||
|
text.text = newText
|
||||||
|
Plasmoid.toolTipSubText = newToolTip
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedMenuUpdate: {
|
onNeedMenuUpdate: {
|
||||||
if (debug) console.log("[main::onNetctlStateChanged]")
|
if (debug) console.log("[main::onNeedMenuUpdate]")
|
||||||
|
|
||||||
var titleAction = plasmoid.action("titleAction")
|
var titleAction = plasmoid.action("titleAction")
|
||||||
var startAction = plasmoid.action("startProfile")
|
var startAction = plasmoid.action("startProfile")
|
||||||
@ -142,10 +149,6 @@ Item {
|
|||||||
var enableAction = plasmoid.action("enableProfile")
|
var enableAction = plasmoid.action("enableProfile")
|
||||||
var wifiAction = plasmoid.action("startWifi")
|
var wifiAction = plasmoid.action("startWifi")
|
||||||
|
|
||||||
var current = NetctlAdds.valueByKey("current")
|
|
||||||
var status = NetctlAdds.valueByKey("active") == "true"
|
|
||||||
var stringStatus = NetctlAdds.valueByKey("status")
|
|
||||||
|
|
||||||
titleAction.iconSource = plasmoid.icon
|
titleAction.iconSource = plasmoid.icon
|
||||||
titleAction.text = current + " " + stringStatus
|
titleAction.text = current + " " + stringStatus
|
||||||
|
|
||||||
@ -187,16 +190,29 @@ Item {
|
|||||||
wifiAction.visible = plasmoid.configuration.useWifi
|
wifiAction.visible = plasmoid.configuration.useWifi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
|
if (plasmoid.userConfiguring) return
|
||||||
|
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||||
|
|
||||||
|
// helper
|
||||||
|
if (plasmoid.configuration.useHelper) {
|
||||||
|
netctlAdds.runCmd(plasmoid.configuration.helperPath)
|
||||||
|
plasmoid.configuration.useHelper = netctlAdds.checkHelperStatus()
|
||||||
|
}
|
||||||
|
// init submodule
|
||||||
|
netctlAdds.setPattern(plasmoid.configuration.textPattern)
|
||||||
|
}
|
||||||
|
|
||||||
function action_titleAction() {
|
function action_titleAction() {
|
||||||
if (debug) console.log("[main::action_titleAction]")
|
if (debug) console.log("[main::action_titleAction]")
|
||||||
|
|
||||||
NetctlAdds.runCmd(plasmoid.configuration.guiPath)
|
netctlAdds.runCmd(plasmoid.configuration.guiPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_startProfile() {
|
function action_startProfile() {
|
||||||
if (debug) console.log("[main::action_startProfile]")
|
if (debug) console.log("[main::action_startProfile]")
|
||||||
|
|
||||||
NetctlAdds.startProfileSlot(plasmoid.configuration.useHelper,
|
netctlAdds.startProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -204,7 +220,7 @@ Item {
|
|||||||
function action_stopProfile() {
|
function action_stopProfile() {
|
||||||
if (debug) console.log("[main::action_stopProfile]")
|
if (debug) console.log("[main::action_stopProfile]")
|
||||||
|
|
||||||
NetctlAdds.stopProfileSlot(plasmoid.configuration.useHelper,
|
netctlAdds.stopProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -212,7 +228,7 @@ Item {
|
|||||||
function action_stopAllProfiles() {
|
function action_stopAllProfiles() {
|
||||||
if (debug) console.log("[main::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,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -220,14 +236,14 @@ Item {
|
|||||||
function action_switchToProfile() {
|
function action_switchToProfile() {
|
||||||
if (debug) console.log("[main::action_switchToProfile]")
|
if (debug) console.log("[main::action_switchToProfile]")
|
||||||
|
|
||||||
NetctlAdds.switchToProfileSlot(plasmoid.configuration.useHelper,
|
netctlAdds.switchToProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlAutoPath)
|
plasmoid.configuration.netctlAutoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_restartProfile() {
|
function action_restartProfile() {
|
||||||
if (debug) console.log("[main::action_restartProfile]")
|
if (debug) console.log("[main::action_restartProfile]")
|
||||||
|
|
||||||
NetctlAdds.restartProfileSlot(plasmoid.configuration.useHelper,
|
netctlAdds.restartProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -235,7 +251,7 @@ Item {
|
|||||||
function action_enableProfile() {
|
function action_enableProfile() {
|
||||||
if (debug) console.log("[main::action_enableProfile]")
|
if (debug) console.log("[main::action_enableProfile]")
|
||||||
|
|
||||||
NetctlAdds.enableProfileSlot(plasmoid.configuration.useHelper,
|
netctlAdds.enableProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -243,6 +259,6 @@ Item {
|
|||||||
function action_startWifi() {
|
function action_startWifi() {
|
||||||
if (debug) console.log("[main::action_startWifi]")
|
if (debug) console.log("[main::action_startWifi]")
|
||||||
|
|
||||||
NetctlAdds.runCmd(plasmoid.configuration.wifiPath)
|
netctlAdds.runCmd(plasmoid.configuration.wifiPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,20 @@ import QtQuick.Dialogs 1.1 as QtDialogs
|
|||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
|
|
||||||
import org.kde.plasma.netctl 1.0
|
import org.kde.plasma.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: widgetPage
|
id: widgetPage
|
||||||
|
NetctlAdds {
|
||||||
|
id: netctlAdds;
|
||||||
|
}
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: NetctlAdds.isDebugEnabled()
|
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
|
||||||
|
@ -14,7 +14,7 @@ X-Plasma-RemoteLocation=
|
|||||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=org.kde.plasma.netctl
|
X-KDE-PluginInfo-Name=org.kde.plasma.netctl
|
||||||
X-KDE-PluginInfo-Version=1.4.8
|
X-KDE-PluginInfo-Version=1.4.9
|
||||||
X-KDE-PluginInfo-Website=http://arcanis.name/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=
|
||||||
|
@ -21,13 +21,12 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
${Qt_INCLUDE}
|
${Qt_INCLUDE}
|
||||||
${Kf5_INCLUDE})
|
${Kf5_INCLUDE})
|
||||||
|
|
||||||
file (GLOB_RECURSE SUBPROJECT_SOURCE ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp
|
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp)
|
||||||
*.cpp)
|
|
||||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
|
|
||||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||||
|
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/netctl)
|
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/netctl)
|
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||||
|
@ -21,18 +21,9 @@
|
|||||||
#include "netctladds.h"
|
#include "netctladds.h"
|
||||||
|
|
||||||
|
|
||||||
static QObject *netctl_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
|
||||||
{
|
|
||||||
Q_UNUSED(engine);
|
|
||||||
Q_UNUSED(scriptEngine);
|
|
||||||
|
|
||||||
return new NetctlAdds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetctlPlugin::registerTypes(const char *uri)
|
void NetctlPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.netctl"));
|
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.netctl"));
|
||||||
|
|
||||||
qmlRegisterSingletonType<NetctlAdds>(uri, 1, 0, "NetctlAdds", netctl_singletontype_provider);
|
qmlRegisterType<NetctlAdds>(uri, 1, 0, "NetctlAdds");
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <pdebug/pdebug-time.h>
|
|
||||||
|
|
||||||
#include "netctladds.h"
|
#include "netctladds.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -36,13 +35,13 @@
|
|||||||
NetctlAdds::NetctlAdds(QObject *parent)
|
NetctlAdds::NetctlAdds(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
qInstallMessageHandler(debugString);
|
|
||||||
// debug
|
// debug
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
debug = (debugEnv == QString("yes"));
|
debug = (debugEnv == QString("yes"));
|
||||||
|
|
||||||
connect(this, SIGNAL(needToNotify(bool)), this, SLOT(notifyAboutStatusChanging(bool)));
|
connect(this, SIGNAL(needToNotify(bool)), this, SLOT(notifyAboutStatusChanging(bool)));
|
||||||
|
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(parsePattern()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +51,7 @@ NetctlAdds::~NetctlAdds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::notifyAboutStatusChanging(const bool currentStatus)
|
void NetctlAdds::notifyAboutStatusChanging(const bool currentStatus) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << currentStatus;
|
if (debug) qDebug() << PDEBUG << ":" << "Status" << currentStatus;
|
||||||
@ -64,7 +63,21 @@ void NetctlAdds::notifyAboutStatusChanging(const bool currentStatus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
void NetctlAdds::parsePattern() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString parsed = pattern;
|
||||||
|
foreach(QString value, values.keys())
|
||||||
|
parsed.replace(QString("$%1").arg(value), values[value]);
|
||||||
|
// fix newline
|
||||||
|
parsed.replace(QString("\n"), QString("<br>"));
|
||||||
|
|
||||||
|
return emit(needTextToBeUpdated(parsed, values[QString("info")]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantList NetctlAdds::sendDBusRequest(const QString cmd, const QVariantList args) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
@ -73,26 +86,24 @@ QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVari
|
|||||||
QDBusConnection bus = QDBusConnection::systemBus();
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||||
DBUS_HELPER_INTERFACE, cmd);
|
DBUS_HELPER_INTERFACE, cmd);
|
||||||
if (!args.isEmpty())
|
if (!args.isEmpty()) request.setArguments(args);
|
||||||
request.setArguments(args);
|
|
||||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
QList<QVariant> arguments = response.arguments();
|
QVariantList arguments = response.arguments();
|
||||||
if (arguments.size() == 0)
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
|
||||||
|
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdds::checkHelperStatus()
|
bool NetctlAdds::checkHelperStatus() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty();
|
return !sendDBusRequest(QString("Active")).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::getAboutText(const QString type)
|
QString NetctlAdds::getAboutText(const QString type) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
||||||
@ -120,9 +131,9 @@ QString NetctlAdds::getAboutText(const QString type)
|
|||||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<trdPartyList.count(); i++)
|
for (int i=0; i<trdPartyList.count(); i++)
|
||||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||||
.arg(trdPartyList[i].split(QChar(','))[0])
|
.arg(trdPartyList.at(i).split(QChar(',')).at(0))
|
||||||
.arg(trdPartyList[i].split(QChar(','))[1])
|
.arg(trdPartyList.at(i).split(QChar(',')).at(1))
|
||||||
.arg(trdPartyList[i].split(QChar(','))[2]);
|
.arg(trdPartyList.at(i).split(QChar(',')).at(2));
|
||||||
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +141,7 @@ QString NetctlAdds::getAboutText(const QString type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdds::isDebugEnabled()
|
bool NetctlAdds::isDebugEnabled() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -138,21 +149,7 @@ bool NetctlAdds::isDebugEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::parsePattern(const QString pattern)
|
void NetctlAdds::runCmd(const QString cmd) const
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QString parsed = pattern;
|
|
||||||
for (int i=0; i<values.keys().count(); i++)
|
|
||||||
parsed.replace(QString("$%1").arg(values.keys()[i]), valueByKey(values.keys()[i]));
|
|
||||||
// fix newline
|
|
||||||
parsed.replace(QString("\n"), QString("<br>"));
|
|
||||||
|
|
||||||
return parsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::runCmd(const QString cmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
@ -174,13 +171,26 @@ void NetctlAdds::setDataBySource(const QString sourceName, const QVariantMap dat
|
|||||||
values[sourceName] = data[QString("value")].toString();
|
values[sourceName] = data[QString("value")].toString();
|
||||||
|
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
emit(needToBeUpdated());
|
if (sourceName == QString("active")) {
|
||||||
if (sourceName == QString("active"))
|
|
||||||
emit(needToNotify(values[QString("active")] == QString("true")));
|
emit(needToNotify(values[QString("active")] == QString("true")));
|
||||||
|
emit(needIconToBeUpdated(values[QString("active")]));
|
||||||
|
}
|
||||||
|
emit(needToBeUpdated());
|
||||||
|
emit(needMenuUpdate(values[QString("current")], values[QString("status")],
|
||||||
|
values[QString("active")] == QString("true")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::setPattern(const QString _pattern)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Pattern" << _pattern;
|
||||||
|
|
||||||
|
pattern = _pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
||||||
{
|
{
|
||||||
// since it is a static method we need to identify is debug enabled again
|
// since it is a static method we need to identify is debug enabled again
|
||||||
@ -197,17 +207,8 @@ void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::valueByKey(const QString key)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
|
||||||
|
|
||||||
return values[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -220,82 +221,75 @@ void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, cons
|
|||||||
sendNotification(QString("Info"), i18n("Set profile %1 enabled", values[QString("current")]));
|
sendNotification(QString("Info"), i18n("Set profile %1 enabled", values[QString("current")]));
|
||||||
}
|
}
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QVariantList args;
|
||||||
args.append(values[QString("current")]);
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Enable"), args);
|
sendDBusRequest(QString("Enable"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
runCmd(QString("%1 %2%3%4").arg(sudoCmd).arg(cmd).arg(enableStatus).arg(values[QString("current")]));
|
||||||
QString commandLine = QString("%1 %2%3%4").arg(sudoCmd).arg(cmd).arg(enableStatus).arg(values[QString("current")]);
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::restartProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
void NetctlAdds::restartProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Restart profile %1", values[QString("current")]));
|
sendNotification(QString("Info"), i18n("Restart profile %1", values[QString("current")]));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QVariantList args;
|
||||||
args.append(values[QString("current")]);
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Restart"), args);
|
sendDBusRequest(QString("Restart"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
runCmd(QString("%1 %2 restart %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]));
|
||||||
QString commandLine = QString("%1 %2 restart %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]);
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::startProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
void NetctlAdds::startProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||||
bool ok;
|
bool ok;
|
||||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
QString profile = QInputDialog::getItem(nullptr, i18n("Select profile"), i18n("Profile:"),
|
||||||
profiles, 0, false, &ok);
|
profiles, 0, false, &ok);
|
||||||
if (!ok || profile.isEmpty()) return;
|
if (!ok || profile.isEmpty()) return;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QVariantList args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
if (values[QString("active")] == QString("true"))
|
if (values[QString("active")] == QString("true"))
|
||||||
sendDBusRequest(QString("SwitchTo"), args);
|
sendDBusRequest(QString("SwitchTo"), args);
|
||||||
else
|
else
|
||||||
sendDBusRequest(QString("Start"), args);
|
sendDBusRequest(QString("Start"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
|
||||||
QString commandLine = QString("%1 %2").arg(sudoCmd).arg(cmd);
|
QString commandLine = QString("%1 %2").arg(sudoCmd).arg(cmd);
|
||||||
if (values[QString("active")] == QString("true"))
|
if (values[QString("active")] == QString("true"))
|
||||||
commandLine += QString(" switch-to %1").arg(profile);
|
commandLine += QString(" switch-to %1").arg(profile);
|
||||||
else
|
else
|
||||||
commandLine += QString(" start %1").arg(profile);
|
commandLine += QString(" start %1").arg(profile);
|
||||||
command.startDetached(commandLine);
|
runCmd(commandLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::stopProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
void NetctlAdds::stopProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Stop profile %1", values[QString("current")]));
|
sendNotification(QString("Info"), i18n("Stop profile %1", values[QString("current")]));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QVariantList args;
|
||||||
args.append(values[QString("current")]);
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Start"), args);
|
sendDBusRequest(QString("Start"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
runCmd(QString("%1 %2 stop %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]));
|
||||||
QString commandLine = QString("%1 %2 stop %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]);
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -303,37 +297,33 @@ void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, co
|
|||||||
if (useHelper)
|
if (useHelper)
|
||||||
sendDBusRequest(QString("StopAll"), QList<QVariant>());
|
sendDBusRequest(QString("StopAll"), QList<QVariant>());
|
||||||
else {
|
else {
|
||||||
QProcess command;
|
runCmd(QString("%1 %2 stop-all").arg(sudoCmd).arg(cmd));
|
||||||
QString commandLine = QString("%1 %2 stop-all").arg(sudoCmd).arg(cmd);
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::switchToProfileSlot(const bool useHelper, const QString cmd)
|
void NetctlAdds::switchToProfileSlot(const bool useHelper, const QString cmd) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||||
bool ok;
|
bool ok;
|
||||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
QString profile = QInputDialog::getItem(nullptr, i18n("Select profile"), i18n("Profile:"),
|
||||||
profiles, 0, false, &ok);
|
profiles, 0, false, &ok);
|
||||||
if (!ok || profile.isEmpty()) return;
|
if (!ok || profile.isEmpty()) return;
|
||||||
|
|
||||||
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;
|
QVariantList args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
sendDBusRequest(QString("autoStart"), args);
|
sendDBusRequest(QString("autoStart"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
runCmd(QString("%1 switch-to %2").arg(cmd).arg(profile));
|
||||||
QString commandLine = QString("%1 switch-to %2").arg(cmd).arg(profile);
|
|
||||||
command.startDetached(commandLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap NetctlAdds::readDataEngineConfiguration()
|
QVariantMap NetctlAdds::readDataEngineConfiguration() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -359,7 +349,7 @@ QVariantMap NetctlAdds::readDataEngineConfiguration()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::writeDataEngineConfiguration(const QVariantMap configuration)
|
void NetctlAdds::writeDataEngineConfiguration(const QVariantMap configuration) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
@ -32,47 +32,52 @@ public:
|
|||||||
NetctlAdds(QObject *parent = 0);
|
NetctlAdds(QObject *parent = 0);
|
||||||
~NetctlAdds();
|
~NetctlAdds();
|
||||||
|
|
||||||
Q_INVOKABLE bool checkHelperStatus();
|
Q_INVOKABLE bool checkHelperStatus() const;
|
||||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled() const;
|
||||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
Q_INVOKABLE void runCmd(const QString cmd) const;
|
||||||
Q_INVOKABLE void runCmd(const QString cmd);
|
|
||||||
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data);
|
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data);
|
||||||
|
Q_INVOKABLE void setPattern(const QString _pattern);
|
||||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
||||||
Q_INVOKABLE QString valueByKey(const QString key);
|
|
||||||
// context menu
|
// context menu
|
||||||
Q_INVOKABLE void enableProfileSlot(const bool useHelper = true,
|
Q_INVOKABLE void enableProfileSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl"),
|
const QString cmd = QString("netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString("")) const;
|
||||||
Q_INVOKABLE void restartProfileSlot(const bool useHelper = true,
|
Q_INVOKABLE void restartProfileSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl"),
|
const QString cmd = QString("netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString("")) const;
|
||||||
Q_INVOKABLE void startProfileSlot(const bool useHelper = true,
|
Q_INVOKABLE void startProfileSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl"),
|
const QString cmd = QString("netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString("")) const;
|
||||||
Q_INVOKABLE void stopProfileSlot(const bool useHelper = true,
|
Q_INVOKABLE void stopProfileSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl"),
|
const QString cmd = QString("netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString("")) const;
|
||||||
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl"),
|
const QString cmd = QString("netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString("")) const;
|
||||||
Q_INVOKABLE void switchToProfileSlot(const bool useHelper = true,
|
Q_INVOKABLE void switchToProfileSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("netctl-auto"));
|
const QString cmd = QString("netctl-auto")) const;
|
||||||
// dataengine
|
// dataengine
|
||||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration();
|
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration);
|
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void needToBeUpdated();
|
void needIconToBeUpdated(const QString newIcon) const;
|
||||||
void needToNotify(const bool currentStatus);
|
void needMenuUpdate(const QString current, const QString status, const bool isActive) const;
|
||||||
|
void needTextToBeUpdated(const QString newText, const QString newToolTip) const;
|
||||||
|
void needToBeUpdated() const;
|
||||||
|
void needToNotify(const bool currentStatus) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void notifyAboutStatusChanging(const bool currentStatus);
|
void notifyAboutStatusChanging(const bool currentStatus) const;
|
||||||
|
void parsePattern() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
QVariantList sendDBusRequest(const QString cmd,
|
||||||
QMap<QString, QString> values;
|
const QVariantList args = QVariantList()) const;
|
||||||
|
QString pattern;
|
||||||
|
QHash<QString, QString> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module org.kde.plasma.netctl
|
module org.kde.plasma.private.netctl
|
||||||
|
|
||||||
plugin netctlplugin
|
plugin netctlplugin
|
||||||
|
Reference in New Issue
Block a user