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
wilder-5.22
David Redondo 5 years ago committed by Nate Graham
parent eb17117d5b
commit 5efae6f4e4
  1. 2
      applets/systemmonitor/systemmonitor/CMakeLists.txt
  2. 15
      applets/systemmonitor/systemmonitor/package/contents/ui/main.qml
  3. 10
      applets/systemmonitor/systemmonitor/systemmonitor.cpp
  4. 1
      applets/systemmonitor/systemmonitor/systemmonitor.h

@ -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;

Loading…
Cancel
Save