mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-14 14:25:52 +00:00
+ add de page
* rewrite de configuration to use qsettings - remove cppcheck + add notifyrc
This commit is contained in:
@ -33,6 +33,12 @@ ConfigModel {
|
||||
source: "appearance.qml"
|
||||
}
|
||||
|
||||
ConfigCategory {
|
||||
name: i18n("DataEngine")
|
||||
icon: "/usr/share/pixmaps/netctl-gui-widget.png"
|
||||
source: "dataengine.qml"
|
||||
}
|
||||
|
||||
ConfigCategory {
|
||||
name: i18n("About")
|
||||
icon: "help-about"
|
||||
|
144
sources/plasmoid-kf5/plasmoid/contents/ui/dataengine.qml
Normal file
144
sources/plasmoid-kf5/plasmoid/contents/ui/dataengine.qml
Normal file
@ -0,0 +1,144 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.0 as QtControls
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
import QtQuick.Layouts 1.0 as QtLayouts
|
||||
|
||||
import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
|
||||
Item {
|
||||
id: dataenginePage
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
property variant cfg_dataengine: NetctlAdds.readDataEngineConfiguration()
|
||||
|
||||
QtLayouts.ColumnLayout {
|
||||
QtLayouts.RowLayout {
|
||||
QtControls.Label {
|
||||
text: i18n("Path to netctl")
|
||||
}
|
||||
QtControls.TextField {
|
||||
id: netctlPath
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
text: cfg_dataengine["NETCTLCMD"]
|
||||
}
|
||||
QtControls.Button {
|
||||
text: i18n("Browse")
|
||||
onClicked: netctlFileDialog.visible = true
|
||||
}
|
||||
|
||||
QtDialogs.FileDialog {
|
||||
id: netctlFileDialog
|
||||
title: i18n("Select a path")
|
||||
folder: "/usr/bin"
|
||||
nameFilters: [ "All files (*)" ]
|
||||
selectExisting: true
|
||||
onAccepted: netctlPath.text = netctlFileDialog.fileUrl
|
||||
}
|
||||
}
|
||||
|
||||
QtLayouts.RowLayout {
|
||||
QtControls.Label {
|
||||
text: i18n("Path to netctl-auto")
|
||||
}
|
||||
QtControls.TextField {
|
||||
id: netctlAutoPath
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
text: cfg_dataengine["NETCTLAUTOCMD"]
|
||||
}
|
||||
QtControls.Button {
|
||||
text: i18n("Browse")
|
||||
onClicked: netctlAutoFileDialog.visible = true
|
||||
}
|
||||
|
||||
QtDialogs.FileDialog {
|
||||
id: netctlAutoFileDialog
|
||||
title: i18n("Select a path")
|
||||
folder: "/usr/bin"
|
||||
nameFilters: [ "All files (*)" ]
|
||||
selectExisting: true
|
||||
onAccepted: netctlAutoPath.text = netctlAutoFileDialog.fileUrl
|
||||
}
|
||||
}
|
||||
|
||||
QtLayouts.RowLayout {
|
||||
QtControls.CheckBox {
|
||||
id: extIp4
|
||||
text: i18n("Check external IPv4")
|
||||
checked: cfg_dataengine["EXTIP4"] == "true"
|
||||
}
|
||||
QtControls.TextField {
|
||||
id: extIp4Path
|
||||
enabled: extIp4.checked
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
text: cfg_dataengine["EXTIP4CMD"]
|
||||
}
|
||||
QtControls.Button {
|
||||
enabled: extIp4.checked
|
||||
text: i18n("Browse")
|
||||
onClicked: extIp4FileDialog.visible = true
|
||||
}
|
||||
|
||||
QtDialogs.FileDialog {
|
||||
id: extIp4FileDialog
|
||||
title: i18n("Select a path")
|
||||
folder: "/usr/bin"
|
||||
nameFilters: [ "All files (*)" ]
|
||||
selectExisting: true
|
||||
onAccepted: extIp4Path.text = extIp4FileDialog.fileUrl
|
||||
}
|
||||
}
|
||||
|
||||
QtLayouts.RowLayout {
|
||||
QtControls.CheckBox {
|
||||
id: extIp6
|
||||
text: i18n("Check external IPv6")
|
||||
checked: cfg_dataengine["EXTIP6"] == "true"
|
||||
}
|
||||
QtControls.TextField {
|
||||
id: extIp6Path
|
||||
enabled: extIp6.checked
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
text: cfg_dataengine["EXTIP6CMD"]
|
||||
}
|
||||
QtControls.Button {
|
||||
enabled: extIp6.checked
|
||||
text: i18n("Browse")
|
||||
onClicked: extIp6FileDialog.visible = true
|
||||
}
|
||||
|
||||
QtDialogs.FileDialog {
|
||||
id: extIp6FileDialog
|
||||
title: i18n("Select a path")
|
||||
folder: "/usr/bin"
|
||||
nameFilters: [ "All files (*)" ]
|
||||
selectExisting: true
|
||||
onAccepted: extIp6Path.text = extIp6FileDialog.fileUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
cfg_dataengine["EXTIP4"] = extIp4.checked ? "true" : "false"
|
||||
cfg_dataengine["EXTIP6"] = extIp6.checked ? "true" : "false"
|
||||
NetctlAdds.writeDataEngineConfiguration(cfg_dataengine)
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Qml_LIBRARIES} ${I18n_LIBRARIES} ${Plasma_LIBRARIES}
|
||||
@ -14,3 +15,4 @@ target_link_libraries (${PLUGIN_NAME} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES}
|
||||
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
@ -135,6 +137,14 @@ QString NetctlAdds::getInfo(const QString current, const QString status)
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdds::isDebugEnabled()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::parsePattern(const QString pattern, const QMap<QString, QVariant> dict)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -293,3 +303,51 @@ void NetctlAdds::switchToProfileSlot(QString profile, const bool useHelper,
|
||||
command.startDetached(commandLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> NetctlAdds::readDataEngineConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> configuration;
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("netctl.conf"));
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl"));
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto"));
|
||||
settings.endGroup();
|
||||
settings.beginGroup(QString("External IP"));
|
||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false"));
|
||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com"));
|
||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false"));
|
||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com"));
|
||||
settings.endGroup();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/netctl.conf");
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
settings.setValue(QString("NETCTLCMD"), configuration[QString("NETCTLCMD")].toString());
|
||||
settings.setValue(QString("NETCTLAUTOCMD"), configuration[QString("NETCTLAUTOCMD")].toString());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("External IP"));
|
||||
settings.setValue(QString("EXTIP4"), configuration[QString("EXTIP4")].toString());
|
||||
settings.setValue(QString("EXTIP4CMD"), configuration[QString("EXTIP4CMD")].toString());
|
||||
settings.setValue(QString("EXTIP6"), configuration[QString("EXTIP6")].toString());
|
||||
settings.setValue(QString("EXTIP6CMD"), configuration[QString("EXTIP6CMD")].toString());
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
|
||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||
Q_INVOKABLE QString getInfo(const QString current, const QString status);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict);
|
||||
Q_INVOKABLE void runCmd(const QString cmd);
|
||||
Q_INVOKABLE void sendNotification(const QString eventId, const QString message);
|
||||
@ -60,6 +61,9 @@ public:
|
||||
Q_INVOKABLE void switchToProfileSlot(QString profile,
|
||||
const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl-auto"));
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
|
||||
private:
|
||||
bool debug = false;
|
||||
|
Reference in New Issue
Block a user