Commit 5efae6f4 authored by David Redondo's avatar David Redondo 🏎 Committed by Nate Graham
Browse files

Add action to open the system monitor from the applet

It's also accessible by middle clicking on it
BUG:432588
FIXED-IN:5.22
parent eb17117d
......@@ -16,6 +16,8 @@ target_link_libraries(plasma_applet_systemmonitor
KF5::ConfigCore
KF5::ConfigGui
KF5::Declarative
KF5::KIOGui
KF5::Notifications
KSysGuard::SysGuard
KSysGuard::Sensors
KSysGuard::SensorFaces
......
......@@ -52,4 +52,19 @@ Item {
}
Plasmoid.configurationRequired: plasmoid.nativeInterface.faceController.highPrioritySensorIds.length == 0 && plasmoid.nativeInterface.faceController.lowPrioritySensorIds.length == 0 && plasmoid.nativeInterface.faceController.totalSensor.length == 0
MouseArea {
parent: plasmoid
anchors.fill: plasmoid
acceptedButtons: Qt.MiddleButton
onClicked: action_openSystemMonitor()
}
function action_openSystemMonitor() {
Plasmoid.nativeInterface.openSystemMonitor()
}
Component.onCompleted: {
Plasmoid.setAction("openSystemMonitor", i18nc("@action", "Open System Monitor..."), "utilities-system-monitor")
}
}
......@@ -31,7 +31,10 @@
#include <KConfigLoader>
#include <KDeclarative/QmlObjectSharedEngine>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KNotifications/KNotificationJobUiDelegate>
#include <KService>
SystemMonitor::SystemMonitor(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
......@@ -91,6 +94,13 @@ void SystemMonitor::configChanged()
}
}
void SystemMonitor::openSystemMonitor()
{
auto job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName("org.kde.plasma-systemmonitor"));
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->start();
}
K_EXPORT_PLASMA_APPLET_WITH_JSON(systemmonitor, SystemMonitor, "metadata.json")
#include "systemmonitor.moc"
......@@ -49,6 +49,7 @@ public:
~SystemMonitor() override;
void init() override;
Q_INVOKABLE void openSystemMonitor();
KSysGuard::SensorFaceController *faceController() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment