diff --git a/contents/ui/CompactView.qml b/contents/ui/CompactView.qml deleted file mode 100644 index 6b4f767..0000000 --- a/contents/ui/CompactView.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.15 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents -import "logic/CpuReader.js" as Reader - -Row { - id: root - - property int temperature: 0 - signal clicked() - - spacing: 4 - - PlasmaCore.IconItem { - source: "cpu" - width: 16; height: 16 - anchors.verticalCenter: parent.verticalCenter - } - - PlasmaComponents.Label { - text: root.temperature + "°C" - color: Reader.tempColor(root.temperature) - anchors.verticalCenter: parent.verticalCenter - } - - MouseArea { - anchors.fill: parent - onClicked: root.clicked() - } -} diff --git a/contents/ui/FullView.qml b/contents/ui/FullView.qml index 8f674b1..858e79f 100644 --- a/contents/ui/FullView.qml +++ b/contents/ui/FullView.qml @@ -1,6 +1,5 @@ import QtQuick 2.15 import org.kde.plasma.core 2.0 as PlasmaCore -import "components" as Components Column { id: root @@ -14,7 +13,7 @@ Column { Item { width: 1; height: 4 } - Components.TemperatureDisplay { + TemperatureDisplay { temperature: root.temperature anchors.horizontalCenter: parent.horizontalCenter } @@ -27,7 +26,7 @@ Column { anchors.horizontalCenter: parent.horizontalCenter } - Components.PerfLimiter { + PerfLimiter { currentPerf: root.currentPerf anchors.horizontalCenter: parent.horizontalCenter onPerfChangeRequested: root.perfChangeRequested(newValue) diff --git a/contents/ui/components/PerfLimiter.qml b/contents/ui/PerfLimiter.qml similarity index 98% rename from contents/ui/components/PerfLimiter.qml rename to contents/ui/PerfLimiter.qml index b94dd00..629bf1a 100644 --- a/contents/ui/components/PerfLimiter.qml +++ b/contents/ui/PerfLimiter.qml @@ -2,7 +2,7 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import "../logic/CpuWriter.js" as Writer +import "logic/CpuWriter.js" as Writer Column { id: root diff --git a/contents/ui/components/TemperatureDisplay.qml b/contents/ui/TemperatureDisplay.qml similarity index 93% rename from contents/ui/components/TemperatureDisplay.qml rename to contents/ui/TemperatureDisplay.qml index df3ddd7..f31ba2c 100644 --- a/contents/ui/components/TemperatureDisplay.qml +++ b/contents/ui/TemperatureDisplay.qml @@ -1,6 +1,6 @@ import QtQuick 2.15 import org.kde.plasma.components 2.0 as PlasmaComponents -import "../logic/CpuReader.js" as Reader +import "logic/CpuReader.js" as Reader Column { id: root diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 1697c74..a6650bf 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -1,6 +1,7 @@ import QtQuick 2.15 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents import "logic/CpuReader.js" as Reader import "logic/CpuWriter.js" as Writer @@ -47,9 +48,29 @@ Item { if (cmd) writeSource.connectSource(cmd) } - Plasmoid.compactRepresentation: CompactView { - temperature: root.temperature + Plasmoid.compactRepresentation: MouseArea { + implicitWidth: compactRow.implicitWidth + implicitHeight: compactRow.implicitHeight onClicked: plasmoid.expanded = !plasmoid.expanded + + Row { + id: compactRow + spacing: 4 + anchors.centerIn: parent + + PlasmaCore.IconItem { + source: "cpu" + width: units.iconSizes.small + height: units.iconSizes.small + anchors.verticalCenter: parent.verticalCenter + } + + PlasmaComponents.Label { + text: root.temperature + "°C" + color: Reader.tempColor(root.temperature) + anchors.verticalCenter: parent.verticalCenter + } + } } Plasmoid.fullRepresentation: FullView { diff --git a/metadata.desktop b/metadata.desktop index 8c01e51..e619477 100644 --- a/metadata.desktop +++ b/metadata.desktop @@ -1,14 +1,15 @@ [Desktop Entry] Name=CPU Control -Comment=Control CPU performance mode +Comment=Monitor CPU temperature and control performance limit Icon=cpu Type=Service X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml +X-KDE-FormFactors=panel,desktop X-KDE-PluginInfo-Name=org.kde.plasma.cpucontrol X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Author=Andres Garcia X-KDE-PluginInfo-Email=andresgarcia0313@gmail.com -X-KDE-PluginInfo-Version=1.0.0 +X-KDE-PluginInfo-Version=2.0.0 X-KDE-PluginInfo-License=MIT diff --git a/metadata.json b/metadata.json index 5131b5d..afb4fa9 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "KPlugin": { "Id": "org.kde.plasma.cpucontrol", "Name": "CPU Control", - "Description": "Control CPU performance mode", + "Description": "Monitor CPU temperature and control performance limit", "Icon": "cpu", "Authors": [ { @@ -12,9 +12,12 @@ ], "Category": "System Information", "License": "MIT", - "Version": "1.0.0", - "Website": "https://github.com/andresgarcia0313" + "Version": "2.0.0", + "Website": "https://github.com/andresgarcia0313", + "ServiceTypes": ["Plasma/Applet"], + "FormFactors": ["panel", "desktop"], + "EnabledByDefault": true }, - "KPackageStructure": "Plasma/Applet", - "X-Plasma-API-Minimum-Version": "6.0" + "X-Plasma-API": "declarativeappletscript", + "X-Plasma-MainScript": "ui/main.qml" }