mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
move method from original one
This commit is contained in:
parent
7972f2d6d3
commit
cbac07b29e
@ -40,21 +40,24 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
|||||||
# install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
# install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||||
# install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
# install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||||
# plasma_install_package(plasmoid org.kde.plasma.netctl)
|
# plasma_install_package(plasmoid org.kde.plasma.netctl)
|
||||||
find_package (Qt5 REQUIRED COMPONENTS Core Qml Widgets)
|
find_package (Qt5 REQUIRED COMPONENTS Core DBus Qml Widgets)
|
||||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||||
find_package(KF5 REQUIRED I18n Service WidgetsAddons KIO CoreAddons Notifications Plasma)
|
find_package(KF5 REQUIRED COMPONENTS I18n Service WidgetsAddons KIO CoreAddons Notifications Plasma)
|
||||||
|
find_package(KF5I18n CONFIG REQUIRED)
|
||||||
|
|
||||||
include (KDEInstallDirs)
|
include (KDEInstallDirs)
|
||||||
include (KDECMakeSettings)
|
include (KDECMakeSettings)
|
||||||
include (KDECompilerSettings)
|
include (KDECompilerSettings)
|
||||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Qml_DEFINITIONS})
|
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Qml_DEFINITIONS})
|
||||||
|
|
||||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||||
|
${Qt5DBus_INCLUDE_DIRS}
|
||||||
${Qt5Qml_INCLUDE_DIRS})
|
${Qt5Qml_INCLUDE_DIRS})
|
||||||
set (Kf5_INCLUDE ${ConfigCore_INCLUDE_DIR}
|
set (Kf5_INCLUDE ${ConfigCore_INCLUDE_DIR}
|
||||||
${CoreAddons_INCLUDE_DIR}
|
${CoreAddons_INCLUDE_DIR}
|
||||||
${I18n_INCLUDE_DIR}
|
${I18n_INCLUDE_DIR}
|
||||||
|
${INTERFACE_INCLUDE_DIRECTORIES}
|
||||||
${Notifications_INCLUDE_DIR}
|
${Notifications_INCLUDE_DIR}
|
||||||
${Plasma_INCLUDE_DIR}
|
${Plasma_INCLUDE_DIR}
|
||||||
${Service_INCLUDE_DIR})
|
${Service_INCLUDE_DIR})
|
||||||
@ -62,20 +65,21 @@ set (Kf5_INCLUDE ${ConfigCore_INCLUDE_DIR}
|
|||||||
set (PLUGIN_NAME netctlplugin)
|
set (PLUGIN_NAME netctlplugin)
|
||||||
add_subdirectory (plugin)
|
add_subdirectory (plugin)
|
||||||
|
|
||||||
set(dir plasmoid)
|
# set(dir plasmoid)
|
||||||
set(component org.kde.plasma.netctl)
|
# set(component org.kde.plasma.netctl)
|
||||||
set(root ${ARGV2})
|
# set(root ${ARGV2})
|
||||||
set(type ${ARGV3})
|
# set(type ${ARGV3})
|
||||||
if(NOT root)
|
# if(NOT root)
|
||||||
set(root plasmoids)
|
# set(root plasmoids)
|
||||||
endif()
|
# endif()
|
||||||
if(NOT type)
|
# if(NOT type)
|
||||||
set(type applet)
|
# set(type applet)
|
||||||
endif()
|
# endif()
|
||||||
install(DIRECTORY ${dir}/ DESTINATION ${PLASMA_DATA_INSTALL_DIR}/${root}/${component}
|
# install(DIRECTORY ${dir}/ DESTINATION ${PLASMA_DATA_INSTALL_DIR}/${root}/${component}
|
||||||
PATTERN CMakeLists.txt EXCLUDE
|
# PATTERN CMakeLists.txt EXCLUDE
|
||||||
PATTERN README.txt EXCLUDE
|
# PATTERN README.txt EXCLUDE
|
||||||
PATTERN Messages.sh EXCLUDE
|
# PATTERN Messages.sh EXCLUDE
|
||||||
PATTERN dummydata EXCLUDE)
|
# PATTERN dummydata EXCLUDE)
|
||||||
|
#
|
||||||
install(FILES ${dir}/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-${type}-${component}.desktop)
|
# install(FILES ${dir}/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-${type}-${component}.desktop)
|
||||||
|
plasma_install_package (plasmoid org.kde.plasma.netctl)
|
||||||
|
@ -16,20 +16,70 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.0 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.private.netctl 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: aboutPage
|
id: aboutPage
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
Grid {
|
||||||
|
QtControls.TabView {
|
||||||
|
QtControls.Tab {
|
||||||
|
title: i18n("About")
|
||||||
|
|
||||||
QtLayouts.ColumnLayout {
|
QtLayouts.ColumnLayout {
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
QtLayouts.Layout.fillWidth: true
|
||||||
text: i18n("Some text")
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: NetctlAdds.getAboutText("header")
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
text: NetctlAdds.getAboutText("description")
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
textFormat: Text.RichText
|
||||||
|
text: NetctlAdds.getAboutText("links")
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
font.capitalization: Font.SmallCaps
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
textFormat: Text.RichText
|
||||||
|
text: NetctlAdds.getAboutText("copy")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Tab {
|
||||||
|
title: i18n("Acknowledgment")
|
||||||
|
|
||||||
|
QtLayouts.ColumnLayout {
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
text: NetctlAdds.getAboutText("translators")
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
textFormat: Text.RichText
|
||||||
|
text: NetctlAdds.getAboutText("3rdparty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,13 +97,14 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ui
|
||||||
Grid {
|
Grid {
|
||||||
id: mainGrid
|
id: mainGrid
|
||||||
columns: 2
|
columns: 2
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: icon
|
id: icon
|
||||||
source: iconPath["inactive"]
|
source: iconPath["false"]
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
|
@ -9,7 +9,8 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||||
|
|
||||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Qt5Core_LIBRARIES} ${Qt5Qml_LIBRARIES} ${I18n_LIBRARIES} ${Plasma_LIBRARIES})
|
target_link_libraries (${PLUGIN_NAME} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Qml_LIBRARIES} ${I18n_LIBRARIES} ${Plasma_LIBRARIES}
|
||||||
|
KF5::I18n KF5::Notifications)
|
||||||
|
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
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 qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
@ -40,6 +45,83 @@ NetctlAdds::~NetctlAdds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool NetctlAdds::checkHelperStatus(const bool useHelper)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
if (useHelper)
|
||||||
|
return !sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty();
|
||||||
|
else
|
||||||
|
return useHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::startHelper(const QString cmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QProcess command;
|
||||||
|
|
||||||
|
command.startDetached(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||||
|
|
||||||
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
|
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||||
|
DBUS_HELPER_INTERFACE, cmd);
|
||||||
|
if (!args.isEmpty())
|
||||||
|
request.setArguments(args);
|
||||||
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
|
QList<QVariant> arguments = response.arguments();
|
||||||
|
if (arguments.size() == 0)
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
|
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString NetctlAdds::getAboutText(const QString type)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
if (type == QString("header"))
|
||||||
|
text = QString(NAME);
|
||||||
|
else if (type == QString("description"))
|
||||||
|
text = i18n("KDE widget which interacts with netctl.");
|
||||||
|
else if (type == QString("links"))
|
||||||
|
text = i18n("Links:") + QString("<br>") +
|
||||||
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) +
|
||||||
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(i18n("Repository")) +
|
||||||
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) +
|
||||||
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) +
|
||||||
|
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages"));
|
||||||
|
else if (type == QString("copy"))
|
||||||
|
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
||||||
|
i18n("This software is licensed under %1", QString(LICENSE)) + QString("</small>");
|
||||||
|
else if (type == QString("translators"))
|
||||||
|
text = i18n("Translators: %1", QString(TRANSLATORS));
|
||||||
|
else if (type == QString("3rdparty")) {
|
||||||
|
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||||
|
for (int i=0; i<trdPartyList.count(); i++)
|
||||||
|
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||||
|
.arg(trdPartyList[i].split(QChar(','))[0])
|
||||||
|
.arg(trdPartyList[i].split(QChar(','))[1])
|
||||||
|
.arg(trdPartyList[i].split(QChar(','))[2]);
|
||||||
|
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::getInfo(const QString current, const QString status)
|
QString NetctlAdds::getInfo(const QString current, const QString status)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -69,3 +151,147 @@ QString NetctlAdds::parsePattern(const QString pattern, const QMap<QString, QVar
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::runCmd(const QString cmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
|
|
||||||
|
QProcess command;
|
||||||
|
|
||||||
|
command.startDetached(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||||
|
|
||||||
|
KNotification::event(eventId, QString("Netctl ::: ") + eventId, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// context menu
|
||||||
|
void NetctlAdds::enableProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
||||||
|
const QString cmd, const QString sudoCmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString enableStatus = QString("");
|
||||||
|
if (dict[QString("status")].toString().contains(QString("enabled"))) {
|
||||||
|
enableStatus = QString(" disable ");
|
||||||
|
sendNotification(QString("Info"), i18n("Set profile %1 disabled", dict[QString("current")].toString()));
|
||||||
|
} else {
|
||||||
|
enableStatus = QString(" enable ");
|
||||||
|
sendNotification(QString("Info"), i18n("Set profile %1 enabled", dict[QString("current")].toString()));
|
||||||
|
}
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(dict[QString("current")].toString());
|
||||||
|
sendDBusRequest(QString("Enable"), args);
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = sudoCmd + QString(" ") + cmd + enableStatus + dict[QString("current")].toString();
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::restartProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
||||||
|
const QString cmd, const QString sudoCmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Restart profile %1", dict[QString("current")].toString()));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(dict[QString("current")].toString());
|
||||||
|
sendDBusRequest(QString("Restart"), args);
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" restart ") + dict[QString("current")].toString();
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::startProfileSlot(QString profile, const bool status,
|
||||||
|
const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
|
profile.remove(QChar('&'));
|
||||||
|
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(profile);
|
||||||
|
if (status)
|
||||||
|
sendDBusRequest(QString("SwitchTo"), args);
|
||||||
|
else
|
||||||
|
sendDBusRequest(QString("Start"), args);
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = sudoCmd + QString(" ") + cmd;
|
||||||
|
if (status)
|
||||||
|
commandLine += QString(" switch-to ") + profile;
|
||||||
|
else
|
||||||
|
commandLine += QString(" start ") + profile;
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::stopProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
||||||
|
const QString cmd, const QString sudoCmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Stop profile %1", dict[QString("current")].toString()));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(dict[QString("current")].toString());
|
||||||
|
sendDBusRequest(QString("Start"), args);
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" stop ") + dict[QString("current")].toString();
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
sendNotification(QString("Info"), i18n("Stop all profiles"));
|
||||||
|
if (useHelper)
|
||||||
|
sendDBusRequest(QString("StopAll"), QList<QVariant>());
|
||||||
|
else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" stop-all");
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::switchToProfileSlot(QString profile, const bool useHelper,
|
||||||
|
const QString cmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
|
||||||
|
profile.remove(QChar('&'));
|
||||||
|
sendNotification(QString("Info"), i18n("Switch to profile %1", profile));
|
||||||
|
if (useHelper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(profile);
|
||||||
|
sendDBusRequest(QString("autoStart"), args);
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
QString commandLine = cmd + QString(" switch-to ") + profile;
|
||||||
|
command.startDetached(commandLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,11 +32,42 @@ public:
|
|||||||
NetctlAdds(QObject *parent = 0);
|
NetctlAdds(QObject *parent = 0);
|
||||||
~NetctlAdds();
|
~NetctlAdds();
|
||||||
|
|
||||||
|
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 QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict);
|
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);
|
||||||
|
// context menu
|
||||||
|
Q_INVOKABLE void enableProfileSlot(const QMap<QString, QVariant> dict,
|
||||||
|
const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
|
const QString sudoCmd = QString(""));
|
||||||
|
Q_INVOKABLE void restartProfileSlot(const QMap<QString, QVariant> dict,
|
||||||
|
const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
|
const QString sudoCmd = QString(""));
|
||||||
|
Q_INVOKABLE void startProfileSlot(QString profile, const bool status,
|
||||||
|
const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
|
const QString sudoCmd = QString(""));
|
||||||
|
Q_INVOKABLE void stopProfileSlot(const QMap<QString, QVariant> dict,
|
||||||
|
const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
|
const QString sudoCmd = QString(""));
|
||||||
|
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
|
const QString sudoCmd = QString(""));
|
||||||
|
Q_INVOKABLE void switchToProfileSlot(QString profile,
|
||||||
|
const bool useHelper = true,
|
||||||
|
const QString cmd = QString("/usr/bin/netctl-auto"));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
// helper
|
||||||
|
bool checkHelperStatus(const bool useHelper = true);
|
||||||
|
void startHelper(const QString cmd = QString("/usr/bin/netctlgui-helper"));
|
||||||
|
// dbus
|
||||||
|
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user