mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-22 01:59:56 +00:00
port widget to dbus
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
set(SUBPROJECT plasma_applet_awesome-widget)
|
||||
message(STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
configure_file(metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||
configure_file(metadata.json ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.json)
|
||||
|
||||
add_subdirectory(plugin)
|
||||
plasma_install_package(package org.kde.plasma.awesomewidget)
|
||||
|
@ -1,26 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Awesome Widget
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"KPackageStructure": "Plasma/Applet",
|
||||
"KPlugin": {
|
||||
"Authors": [
|
||||
{
|
||||
@ -18,12 +19,8 @@
|
||||
"Id": "org.kde.plasma.awesomewidget",
|
||||
"License": "GPLv3",
|
||||
"Name": "Awesome Widget",
|
||||
"ServiceTypes": [
|
||||
"Plasma/Applet"
|
||||
],
|
||||
"Version": "@PROJECT_VERSION@",
|
||||
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
||||
},
|
||||
"X-Plasma-API": "declarativeappletscript",
|
||||
"X-Plasma-MainScript": "ui/main.qml"
|
||||
"X-Plasma-API-Minimum-Version": "6.0"
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.15
|
||||
|
||||
import org.kde.plasma.configuration 2.0
|
||||
|
||||
|
@ -7,150 +7,150 @@
|
||||
|
||||
<group name="Widget">
|
||||
<!-- widget -->
|
||||
<entry name="text" type="string">
|
||||
<entry name="text" type="String">
|
||||
<default>[cpu: $cpu%] [mem: $mem%] [swap: $swap%] [$netdev: $down/$upKB/s]</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
||||
<group name="Advanced">
|
||||
<!-- advanced -->
|
||||
<entry name="background" type="bool">
|
||||
<entry name="background" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="translateStrings" type="bool">
|
||||
<entry name="translateStrings" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="wrapNewLines" type="bool">
|
||||
<entry name="wrapNewLines" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="wrapText" type="bool">
|
||||
<entry name="wrapText" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="notify" type="bool">
|
||||
<entry name="notify" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="checkUpdates" type="bool">
|
||||
<entry name="checkUpdates" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="optimize" type="bool">
|
||||
<entry name="optimize" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="height" type="int">
|
||||
<entry name="height" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="width" type="int">
|
||||
<entry name="width" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="interval" type="int">
|
||||
<entry name="interval" type="Int">
|
||||
<default>1000</default>
|
||||
</entry>
|
||||
<entry name="queueLimit" type="int">
|
||||
<entry name="queueLimit" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="tempUnits" type="string">
|
||||
<entry name="tempUnits" type="String">
|
||||
<default>Celsius</default>
|
||||
</entry>
|
||||
<entry name="customTime" type="string">
|
||||
<entry name="customTime" type="String">
|
||||
<default>$hh:$mm</default>
|
||||
</entry>
|
||||
<entry name="customUptime" type="string">
|
||||
<entry name="customUptime" type="String">
|
||||
<default>$dd,$hh,$mm</default>
|
||||
</entry>
|
||||
<entry name="acOnline" type="string">
|
||||
<entry name="acOnline" type="String">
|
||||
<default>(*)</default>
|
||||
</entry>
|
||||
<entry name="acOffline" type="string">
|
||||
<entry name="acOffline" type="String">
|
||||
<default>( )</default>
|
||||
</entry>
|
||||
<entry name="telemetryCount" type="int">
|
||||
<entry name="telemetryCount" type="Int">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="telemetryRemote" type="bool">
|
||||
<entry name="telemetryRemote" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="telemetryId" type="string">
|
||||
<entry name="telemetryId" type="String">
|
||||
<default></default>
|
||||
</entry>
|
||||
</group>
|
||||
|
||||
<group name="Tooltip">
|
||||
<entry name="tooltipNumber" type="int">
|
||||
<entry name="tooltipNumber" type="Int">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="useTooltipBackground" type="bool">
|
||||
<entry name="useTooltipBackground" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="tooltipBackground" type="string">
|
||||
<entry name="tooltipBackground" type="String">
|
||||
<default>#ffffff</default>
|
||||
</entry>
|
||||
<entry name="cpuTooltip" type="bool">
|
||||
<entry name="cpuTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="cpuTooltipColor" type="string">
|
||||
<entry name="cpuTooltipColor" type="String">
|
||||
<default>#ff0000</default>
|
||||
</entry>
|
||||
<entry name="cpuclTooltip" type="bool">
|
||||
<entry name="cpuclTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="cpuclTooltipColor" type="string">
|
||||
<entry name="cpuclTooltipColor" type="String">
|
||||
<default>#00ff00</default>
|
||||
</entry>
|
||||
<entry name="memTooltip" type="bool">
|
||||
<entry name="memTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="memTooltipColor" type="string">
|
||||
<entry name="memTooltipColor" type="String">
|
||||
<default>#0000ff</default>
|
||||
</entry>
|
||||
<entry name="swapTooltip" type="bool">
|
||||
<entry name="swapTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="swapTooltipColor" type="string">
|
||||
<entry name="swapTooltipColor" type="String">
|
||||
<default>#ffff00</default>
|
||||
</entry>
|
||||
<entry name="downkbTooltip" type="bool">
|
||||
<entry name="downkbTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="downkbTooltipColor" type="string">
|
||||
<entry name="downkbTooltipColor" type="String">
|
||||
<default>#00ffff</default>
|
||||
</entry>
|
||||
<entry name="upkbTooltipColor" type="string">
|
||||
<entry name="upkbTooltipColor" type="String">
|
||||
<default>#ff00ff</default>
|
||||
</entry>
|
||||
<entry name="batTooltip" type="bool">
|
||||
<entry name="batTooltip" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="batTooltipColor" type="string">
|
||||
<entry name="batTooltipColor" type="String">
|
||||
<default>#008800</default>
|
||||
</entry>
|
||||
<entry name="batInTooltipColor" type="string">
|
||||
<entry name="batInTooltipColor" type="String">
|
||||
<default>#880000</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
||||
<group name="Appearance">
|
||||
<!-- appearance -->
|
||||
<entry name="textAlign" type="string">
|
||||
<entry name="textAlign" type="String">
|
||||
<default>center</default>
|
||||
</entry>
|
||||
<entry name="fontFamily" type="string">
|
||||
<entry name="fontFamily" type="String">
|
||||
<default>Terminus</default>
|
||||
</entry>
|
||||
<entry name="fontSize" type="int">
|
||||
<entry name="fontSize" type="Int">
|
||||
<default>12</default>
|
||||
</entry>
|
||||
<entry name="fontColor" type="string">
|
||||
<entry name="fontColor" type="String">
|
||||
<default>#000000</default>
|
||||
</entry>
|
||||
<entry name="fontWeight" type="string">
|
||||
<entry name="fontWeight" type="String">
|
||||
<default>normal</default>
|
||||
</entry>
|
||||
<entry name="fontStyle" type="string">
|
||||
<entry name="fontStyle" type="String">
|
||||
<default>normal</default>
|
||||
</entry>
|
||||
<entry name="textStyle" type="string">
|
||||
<entry name="textStyle" type="String">
|
||||
<default>normal</default>
|
||||
</entry>
|
||||
<entry name="textStyleColor" type="string">
|
||||
<entry name="textStyleColor" type="String">
|
||||
<default>#000000</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.15
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
@ -165,7 +165,7 @@ Item {
|
||||
]
|
||||
text: i18n("Temperature units")
|
||||
value: plasmoid.configuration.tempUnits
|
||||
onValueEdited: cfg_tempUnits = newValue
|
||||
onValueEdited: newValue => cfg_tempUnits = newValue
|
||||
}
|
||||
|
||||
LineSelector {
|
||||
@ -192,13 +192,11 @@ Item {
|
||||
value: plasmoid.configuration.acOffline
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
height: implicitHeight
|
||||
GroupBox {
|
||||
width: parent.width
|
||||
title: i18n("Actions")
|
||||
|
||||
Column {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
ButtonSelector {
|
||||
value: i18n("Drop key cache")
|
||||
@ -226,13 +224,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
height: implicitHeight
|
||||
GroupBox {
|
||||
width: parent.width
|
||||
title: i18n("Telemetry")
|
||||
|
||||
Column {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
CheckBoxSelector {
|
||||
id: telemetryRemote
|
||||
|
@ -15,13 +15,13 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.15
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
import "."
|
||||
|
||||
|
||||
Item {
|
||||
PlasmoidItem {
|
||||
id: appearancePage
|
||||
// backend
|
||||
AWActions {
|
||||
@ -75,7 +75,7 @@ Item {
|
||||
model: General.fontWeightModel
|
||||
text: i18n("Font weight")
|
||||
value: plasmoid.configuration.fontWeight
|
||||
onValueEdited: cfg_fontWeight = newValue
|
||||
onValueEdited: newValue => cfg_fontWeight = newValue
|
||||
}
|
||||
|
||||
ComboBoxSelector {
|
||||
@ -83,7 +83,7 @@ Item {
|
||||
model: General.fontStyleModel
|
||||
text: i18n("Font style")
|
||||
value: plasmoid.configuration.fontStyle
|
||||
onValueEdited: cfg_fontStyle = newValue
|
||||
onValueEdited: newValue => cfg_fontStyle = newValue
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
@ -97,7 +97,7 @@ Item {
|
||||
model: General.textStyleModel
|
||||
text: i18n("Style")
|
||||
value: plasmoid.configuration.textStyle
|
||||
onValueEdited: cfg_textStyle = newValue
|
||||
onValueEdited: newValue => cfg_textStyle = newValue
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
|
@ -15,14 +15,14 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
|
||||
Item {
|
||||
PlasmoidItem {
|
||||
id: dataenginePage
|
||||
// backend
|
||||
AWKeys {
|
||||
@ -55,7 +55,7 @@ Item {
|
||||
LineSelector {
|
||||
text: i18n("ACPI path")
|
||||
value: cfg_dataengine["ACPIPATH"]
|
||||
onValueEdited: cfg_dataengine["ACPIPATH"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["ACPIPATH"] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ Item {
|
||||
]
|
||||
text: i18n("GPU device")
|
||||
value: cfg_dataengine["GPUDEV"]
|
||||
onValueEdited: cfg_dataengine["GPUDEV"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["GPUDEV"] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,13 +99,13 @@ Item {
|
||||
id: hdd
|
||||
text: i18n("HDD")
|
||||
value: cfg_dataengine["HDDDEV"]
|
||||
onValueEdited: cfg_dataengine["HDDDEV"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["HDDDEV"] = newValue
|
||||
}
|
||||
|
||||
LineSelector {
|
||||
text: i18n("hddtemp cmd")
|
||||
value: cfg_dataengine["HDDTEMPCMD"]
|
||||
onValueEdited: cfg_dataengine["HDDTEMPCMD"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["HDDTEMPCMD"] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ Item {
|
||||
stepSize: 1
|
||||
text: i18n("Player data symbols")
|
||||
value: cfg_dataengine["PLAYERSYMBOLS"]
|
||||
onValueEdited: cfg_dataengine["PLAYERSYMBOLS"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["PLAYERSYMBOLS"] = newValue
|
||||
}
|
||||
|
||||
ComboBoxSelector {
|
||||
@ -143,7 +143,7 @@ Item {
|
||||
]
|
||||
text: i18n("Music player")
|
||||
value: cfg_dataengine["PLAYER"]
|
||||
onValueEdited: cfg_dataengine["PLAYER"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["PLAYER"] = newValue
|
||||
}
|
||||
|
||||
ComboBoxSelector {
|
||||
@ -194,7 +194,7 @@ Item {
|
||||
LineSelector {
|
||||
text: i18n("MPD address")
|
||||
value: cfg_dataengine["MPDADDRESS"]
|
||||
onValueEdited: cfg_dataengine["MPDADDRESS"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["MPDADDRESS"] = newValue
|
||||
}
|
||||
|
||||
IntegerSelector {
|
||||
@ -203,7 +203,7 @@ Item {
|
||||
stepSize: 1
|
||||
text: i18n("MPD port")
|
||||
value: cfg_dataengine["MPDPORT"]
|
||||
onValueEdited: cfg_dataengine["MPDPORT"] = newValue
|
||||
onValueEdited: newValue => cfg_dataengine["MPDPORT"] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,19 +15,18 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Dialogs 1.2 as QtDialogs
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Dialogs
|
||||
import QtQuick.Layouts
|
||||
import org.kde.plasma.core as PlasmaCore
|
||||
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 org.kde.plasma.private.awesomewidget 1.0
|
||||
import "."
|
||||
|
||||
|
||||
Item {
|
||||
PlasmoidItem {
|
||||
id: main
|
||||
// backend
|
||||
AWKeys {
|
||||
@ -74,17 +73,12 @@ Item {
|
||||
signal sizeUpdate
|
||||
|
||||
|
||||
// init
|
||||
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
|
||||
Plasmoid.compactRepresentation: Plasmoid.fullRepresentation
|
||||
|
||||
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.fillWidth: PlasmoidItem.formFactor != PlasmaCore.Planar
|
||||
Layout.fillHeight: PlasmoidItem.formFactor != PlasmaCore.Planar
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||
|
||||
Plasmoid.icon: "utilities-system-monitor"
|
||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||
Plasmoid.associatedApplication: "ksysguard"
|
||||
|
||||
|
||||
// ui
|
||||
@ -119,11 +113,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
QtDialogs.Dialog {
|
||||
Dialog {
|
||||
id: tagSelector
|
||||
title: i18n("Select tag")
|
||||
|
||||
QtControls.ComboBox {
|
||||
ComboBox {
|
||||
id: tagSelectorBox
|
||||
width: parent.width
|
||||
editable: true
|
||||
@ -140,17 +134,29 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Plasmoid.contextualActions: [
|
||||
PlasmaCore.Action {
|
||||
text: i18n("Request key")
|
||||
icon.name: "utilities-system-monitor"
|
||||
},
|
||||
PlasmaCore.Action {
|
||||
text: i18n("Show README")
|
||||
icon.name: "text-x-readme"
|
||||
},
|
||||
PlasmaCore.Action {
|
||||
text: i18n("Check updates")
|
||||
icon.name: "system-software-update"
|
||||
},
|
||||
PlasmaCore.Action {
|
||||
text: i18n("Report bug")
|
||||
icon.name: "tools-report-bug"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
|
||||
// actions
|
||||
// it makes no sense to use this field with optimization enable
|
||||
if (!plasmoid.configuration.optimize)
|
||||
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
||||
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
||||
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
||||
plasmoid.setAction("reportBug", i18n("Report bug"), "tools-report-bug")
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
// connect data
|
||||
@ -160,14 +166,14 @@ Item {
|
||||
if (plasmoid.configuration.checkUpdates) return awActions.checkUpdates(false)
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
onNeedTextUpdate: newText => {
|
||||
if (debug) console.debug()
|
||||
|
||||
text.text = newText
|
||||
sizeUpdate()
|
||||
}
|
||||
|
||||
onNeedToolTipUpdate: {
|
||||
onNeedToolTipUpdate: newText => {
|
||||
if (debug) console.debug()
|
||||
|
||||
tooltip.text = newText
|
||||
|
@ -3,25 +3,25 @@
|
||||
|
||||
|
||||
# common QML constants
|
||||
singleton General 1.0 file:///usr//awesomewidgets/qml/General.qml
|
||||
singleton General 1.0 file:///usr/share/awesomewidgets/qml/General.qml
|
||||
|
||||
# custom QML UI classes
|
||||
AboutTab file:///usr//awesomewidgets/qml/AboutTab.qml
|
||||
AWExtensions file:///usr//awesomewidgets/qml/AWExtensions.qml
|
||||
AWInfoLabel file:///usr//awesomewidgets/qml/AWInfoLabel.qml
|
||||
AWTagSelector file:///usr//awesomewidgets/qml/AWTagSelector.qml
|
||||
AWTextEditor file:///usr//awesomewidgets/qml/AWTextEditor.qml
|
||||
BugReport file:///usr//awesomewidgets/qml/BugReport.qml
|
||||
ButtonSelector file:///usr//awesomewidgets/qml/ButtonSelector.qml
|
||||
CheckBoxSelector file:///usr//awesomewidgets/qml/CheckBoxSelector.qml
|
||||
ColorSelector file:///usr//awesomewidgets/qml/ColorSelector.qml
|
||||
ComboBoxSelector file:///usr//awesomewidgets/qml/ComboBoxSelector.qml
|
||||
ExportDialog file:///usr//awesomewidgets/qml/ExportDialog.qml
|
||||
FontSelector file:///usr//awesomewidgets/qml/FontSelector.qml
|
||||
HtmlDefaultFunctionsBar file:///usr//awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
|
||||
HtmlEditorButton file:///usr//awesomewidgets/qml/HtmlEditorButton.qml
|
||||
HtmlEditorColor file:///usr//awesomewidgets/qml/HtmlEditorColor.qml
|
||||
HtmlEditorFont file:///usr//awesomewidgets/qml/HtmlEditorFont.qml
|
||||
ImportDialog file:///usr//awesomewidgets/qml/ImportDialog.qml
|
||||
IntegerSelector file:///usr//awesomewidgets/qml/IntegerSelector.qml
|
||||
LineSelector file:///usr//awesomewidgets/qml/LineSelector.qml
|
||||
AboutTab file:///usr/share/awesomewidgets/qml/AboutTab.qml
|
||||
AWExtensions file:///usr/share/awesomewidgets/qml/AWExtensions.qml
|
||||
AWInfoLabel file:///usr/share/awesomewidgets/qml/AWInfoLabel.qml
|
||||
AWTagSelector file:///usr/share/awesomewidgets/qml/AWTagSelector.qml
|
||||
AWTextEditor file:///usr/share/awesomewidgets/qml/AWTextEditor.qml
|
||||
BugReport file:///usr/share/awesomewidgets/qml/BugReport.qml
|
||||
ButtonSelector file:///usr/share/awesomewidgets/qml/ButtonSelector.qml
|
||||
CheckBoxSelector file:///usr/share/awesomewidgets/qml/CheckBoxSelector.qml
|
||||
ColorSelector file:///usr/share/awesomewidgets/qml/ColorSelector.qml
|
||||
ComboBoxSelector file:///usr/share/awesomewidgets/qml/ComboBoxSelector.qml
|
||||
ExportDialog file:///usr/share/awesomewidgets/qml/ExportDialog.qml
|
||||
FontSelector file:///usr/share/awesomewidgets/qml/FontSelector.qml
|
||||
HtmlDefaultFunctionsBar file:///usr/share/awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
|
||||
HtmlEditorButton file:///usr/share/awesomewidgets/qml/HtmlEditorButton.qml
|
||||
HtmlEditorColor file:///usr/share/awesomewidgets/qml/HtmlEditorColor.qml
|
||||
HtmlEditorFont file:///usr/share/awesomewidgets/qml/HtmlEditorFont.qml
|
||||
ImportDialog file:///usr/share/awesomewidgets/qml/ImportDialog.qml
|
||||
IntegerSelector file:///usr/share/awesomewidgets/qml/IntegerSelector.qml
|
||||
LineSelector file:///usr/share/awesomewidgets/qml/LineSelector.qml
|
||||
|
@ -15,8 +15,8 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
@ -46,7 +46,7 @@ Item {
|
||||
property alias cfg_memTooltipColor: memTooltipColor.value
|
||||
property alias cfg_swapTooltip: swapTooltip.checked
|
||||
property alias cfg_swapTooltipColor: swapTooltipColor.value
|
||||
property alias cfg_downkbTooltip: downkbTooltip.checked
|
||||
property alias cfg_downkbTooltip: networkTooltip.checked
|
||||
property alias cfg_downkbTooltipColor: downkbTooltipColor.value
|
||||
property alias cfg_upkbTooltipColor: upkbTooltipColor.value
|
||||
property alias cfg_batTooltip: batTooltip.checked
|
||||
@ -57,7 +57,8 @@ Item {
|
||||
Column {
|
||||
id: pageColumn
|
||||
anchors.fill: parent
|
||||
QtControls.Label {
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
@ -74,80 +75,109 @@ Item {
|
||||
value: plasmoid.configuration.tooltipNumber
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: useTooltipBackground
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("Background")
|
||||
|
||||
property alias checked: useTooltipBackgroundLabel.checked
|
||||
label: CheckBox {
|
||||
id: useTooltipBackgroundLabel
|
||||
text: i18n("Background")
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
id: tooltipBackground
|
||||
enabled: useTooltipBackgroundLabel.checked
|
||||
text: i18n("Background color")
|
||||
value: plasmoid.configuration.tooltipBackground
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: cpuTooltip
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("CPU")
|
||||
|
||||
property alias checked: cpuTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: cpuTooltipLabel
|
||||
text: i18n("CPU")
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
id: cpuTooltipColor
|
||||
enabled: cpuTooltipLabel.checked
|
||||
text: i18n("CPU color")
|
||||
value: plasmoid.configuration.cpuTooltipColor
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: cpuclTooltip
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("CPU clock")
|
||||
|
||||
property alias checked: cpuclTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: cpuclTooltipLabel
|
||||
text: i18n("CPU clock")
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
id: cpuclTooltipColor
|
||||
enabled: cpuclTooltipLabel.checked
|
||||
text: i18n("CPU clock color")
|
||||
value: plasmoid.configuration.cpuclTooltipColor
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: memTooltip
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("Memory")
|
||||
|
||||
property alias checked: memTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: memTooltipLabel
|
||||
text: i18n("Memory")
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
id: memTooltipColor
|
||||
enabled: memTooltipLabel.checked
|
||||
text: i18n("Memory color")
|
||||
value: plasmoid.configuration.memTooltipColor
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: swapTooltip
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("Swap")
|
||||
|
||||
property alias checked: swapTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: swapTooltipLabel
|
||||
text: i18n("Swap")
|
||||
}
|
||||
|
||||
ColorSelector {
|
||||
id: swapTooltipColor
|
||||
enabled: swapTooltipLabel.checked
|
||||
text: i18n("Swap color")
|
||||
value: plasmoid.configuration.swapTooltipColor
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
id: downkbTooltip
|
||||
height: implicitHeight
|
||||
GroupBox {
|
||||
id: networkTooltip
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("Network")
|
||||
|
||||
property alias checked: networkTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: networkTooltipLabel
|
||||
text: i18n("Network")
|
||||
}
|
||||
|
||||
Column {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
enabled: networkTooltipLabel.checked
|
||||
ColorSelector {
|
||||
id: downkbTooltipColor
|
||||
text: i18n("Download speed color")
|
||||
@ -161,15 +191,19 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.GroupBox {
|
||||
GroupBox {
|
||||
id: batTooltip
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
checkable: true
|
||||
title: i18n("Battery")
|
||||
|
||||
property alias checked: batteryTooltipLabel.checked
|
||||
label: CheckBox {
|
||||
id: batteryTooltipLabel
|
||||
text: i18n("Battery")
|
||||
}
|
||||
|
||||
Column {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
enabled: batteryTooltipLabel.checked
|
||||
ColorSelector {
|
||||
id: batTooltipColor
|
||||
text: i18n("Battery active color")
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick 2.15
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
import "."
|
||||
@ -90,7 +90,7 @@ Item {
|
||||
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
onNeedTextUpdate: newText => {
|
||||
if (lock) return
|
||||
if (debug) console.debug()
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Awesome Widget
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
|
||||
X-KDE-PluginInfo-Version=3.5.1
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
26
sources/awesome-widget/package/metadata.json
Normal file
26
sources/awesome-widget/package/metadata.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"KPackageStructure": "Plasma/Applet",
|
||||
"KPlugin": {
|
||||
"Authors": [
|
||||
{
|
||||
"Email": "esalexeev@gmail.com",
|
||||
"Name": "Evgeniy Alekseev aka arcanis"
|
||||
}
|
||||
],
|
||||
"Category": "System Information",
|
||||
"Description": "A minimalistic Plasmoid",
|
||||
"Description[en]": "A minimalistic Plasmoid",
|
||||
"Description[es]": "Un script Plasmoïde minimaliste",
|
||||
"Description[pt_BR]": "Um script Plasmoid",
|
||||
"Description[ru]": "Минималистичный плазмоид",
|
||||
"Description[uk]": "Мінімалістичний плазмоїд",
|
||||
"EnabledByDefault": true,
|
||||
"Icon": "utilities-system-monitor",
|
||||
"Id": "org.kde.plasma.awesomewidget",
|
||||
"License": "GPLv3",
|
||||
"Name": "Awesome Widget",
|
||||
"Version": "3.5.1",
|
||||
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
||||
},
|
||||
"X-Plasma-API-Minimum-Version": "6.0"
|
||||
}
|
@ -18,6 +18,6 @@ qt6_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
|
||||
target_link_libraries(${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf6_LIBRARIES})
|
||||
|
||||
install(TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||
install(TARGETS ${PLUGIN_NAME} DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/awesomewidget)
|
||||
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/awesomewidget)
|
||||
install(FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "awdebug.h"
|
||||
|
||||
@ -285,7 +284,6 @@ void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const
|
||||
QFile file(_fileName);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream out(&file);
|
||||
out.setCodec("UTF-8");
|
||||
out << _settings.value(_key).toString().toUtf8();
|
||||
out.flush();
|
||||
file.close();
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
#include "awdataengineaggregator.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
#include <QDBusConnection>
|
||||
#include <ksysguard/systemstats/DBusInterface.h>
|
||||
|
||||
#include "awdebug.h"
|
||||
|
||||
@ -27,20 +28,22 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent)
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_consumer = new Plasma::DataEngineConsumer();
|
||||
m_dataEngines["systemmonitor"] = m_consumer->dataEngine("systemmonitor");
|
||||
m_dataEngines["extsysmon"] = m_consumer->dataEngine("extsysmon");
|
||||
m_dataEngines["time"] = m_consumer->dataEngine("time");
|
||||
qDBusRegisterMetaType<KSysGuard::SensorData>();
|
||||
qDBusRegisterMetaType<KSysGuard::SensorInfo>();
|
||||
qDBusRegisterMetaType<KSysGuard::SensorDataList>();
|
||||
qDBusRegisterMetaType<QHash<QString, KSysGuard::SensorInfo>>();
|
||||
|
||||
// additional method required by systemmonitor structure
|
||||
m_newSourceConnection
|
||||
= connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this](const QString &source) {
|
||||
emit(deviceAdded(source));
|
||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000);
|
||||
});
|
||||
m_interface = new KSysGuard::SystemStats::DBusInterface(
|
||||
KSysGuard::SystemStats::ServiceName, KSysGuard::SystemStats::ObjectPath, QDBusConnection::sessionBus(), this);
|
||||
|
||||
// required to define Qt::QueuedConnection for signal-slot connection
|
||||
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
||||
connect(m_interface, SIGNAL(newSensorData(KSysGuard::SensorDataList)), this,
|
||||
SLOT(updateData(KSysGuard::SensorDataList)));
|
||||
connect(m_interface, SIGNAL(sensorMetaDataChanged(const QHash<QString, KSysGuard::SensorInfo> &)), this,
|
||||
SLOT(updateSensors(const QHash<QString, KSysGuard::SensorInfo> &)));
|
||||
connect(m_interface, SIGNAL(sensorAdded(const QString &)), this, SLOT(sensorAdded(const QString &)));
|
||||
connect(m_interface, SIGNAL(sensorRemoved(const QString &)), this, SLOT(sensorRemoved(const QString &)));
|
||||
|
||||
loadSources();
|
||||
}
|
||||
|
||||
|
||||
@ -54,62 +57,63 @@ AWDataEngineAggregator::~AWDataEngineAggregator()
|
||||
|
||||
void AWDataEngineAggregator::disconnectSources()
|
||||
{
|
||||
for (auto dataEngine : m_dataEngines.values())
|
||||
for (auto &source : dataEngine->sources())
|
||||
dataEngine->disconnectSource(source, parent());
|
||||
disconnect(m_newSourceConnection);
|
||||
m_interface->unsubscribe(m_sensors.keys());
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::reconnectSources(const int _interval)
|
||||
void AWDataEngineAggregator::loadSources()
|
||||
{
|
||||
qCDebug(LOG_AW) << "Reconnect sources with interval" << _interval;
|
||||
auto response = m_interface->allSensors();
|
||||
response.waitForFinished();
|
||||
|
||||
auto sensors = response.value();
|
||||
updateSensors(sensors);
|
||||
for (auto &sensor : sensors.keys())
|
||||
sensorAdded(sensor);
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::reconnectSources(const int interval)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Reconnect all sources with update interval" << interval;
|
||||
|
||||
disconnectSources();
|
||||
|
||||
m_dataEngines["systemmonitor"]->connectAllSources(parent(), (uint)_interval);
|
||||
m_dataEngines["extsysmon"]->connectAllSources(parent(), (uint)_interval);
|
||||
m_dataEngines["time"]->connectSource("Local", parent(), 1000);
|
||||
|
||||
m_newSourceConnection = connect(
|
||||
m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this, _interval](const QString &source) {
|
||||
emit(deviceAdded(source));
|
||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), (uint)_interval);
|
||||
});
|
||||
|
||||
#ifdef BUILD_FUTURE
|
||||
createQueuedConnection();
|
||||
#endif /* BUILD_FUTURE */
|
||||
m_interface->subscribe(m_sensors.keys());
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::dropSource(const QString &_source)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _source;
|
||||
qCDebug(LOG_AW) << "Disconnect source" << _source;
|
||||
|
||||
// HACK there is no possibility to check to which dataengine source
|
||||
// connected we will try to disconnect it from all engines
|
||||
for (auto dataEngine : m_dataEngines.values())
|
||||
dataEngine->disconnectSource(_source, parent());
|
||||
m_interface->unsubscribe({_source});
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::createQueuedConnection()
|
||||
void AWDataEngineAggregator::sensorAdded(const QString &_sensor)
|
||||
{
|
||||
// HACK additional method which forces QueuedConnection instead of Auto one
|
||||
// for more details refer to plasma-framework source code
|
||||
for (auto &dataEngine : m_dataEngines.keys()) {
|
||||
// different source set for different engines
|
||||
QStringList sources = dataEngine == "time" ? QStringList() << "Local" : m_dataEngines[dataEngine]->sources();
|
||||
// reconnect sources
|
||||
for (auto &source : sources) {
|
||||
Plasma::DataContainer *container = m_dataEngines[dataEngine]->containerForSource(source);
|
||||
// disconnect old connections first
|
||||
disconnect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)));
|
||||
// and now reconnect with Qt::QueuedConnection type
|
||||
connect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)), Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
qCDebug(LOG_AW) << "New sensor added" << _sensor;
|
||||
|
||||
m_interface->subscribe({_sensor});
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::sensorRemoved(const QString &_sensor)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Sensor" << _sensor << "has been removed";
|
||||
|
||||
m_sensors.remove(_sensor);
|
||||
m_interface->unsubscribe({_sensor});
|
||||
}
|
||||
|
||||
void AWDataEngineAggregator::updateData(KSysGuard::SensorDataList _data)
|
||||
{
|
||||
emit(dataUpdated(m_sensors, _data));
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors)
|
||||
{
|
||||
for (auto sensor = _sensors.cbegin(); sensor != _sensors.cend(); ++sensor)
|
||||
m_sensors.insert(sensor.key(), sensor.value());
|
||||
}
|
||||
|
@ -19,10 +19,17 @@
|
||||
#ifndef AWDATAENGINEAGGREGATOR_H
|
||||
#define AWDATAENGINEAGGREGATOR_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <Plasma/DataEngineConsumer>
|
||||
#include <ksysguard/systemstats/SensorInfo.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
|
||||
|
||||
namespace KSysGuard::SystemStats
|
||||
{
|
||||
class DBusInterface;
|
||||
}
|
||||
|
||||
|
||||
class AWDataEngineAggregator : public QObject
|
||||
@ -33,19 +40,23 @@ public:
|
||||
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
||||
~AWDataEngineAggregator() override;
|
||||
void disconnectSources();
|
||||
void reconnectSources(int _interval);
|
||||
void loadSources();
|
||||
void reconnectSources(const int interval);
|
||||
|
||||
signals:
|
||||
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
||||
void deviceAdded(const QString &_source);
|
||||
|
||||
public slots:
|
||||
void dropSource(const QString &_source);
|
||||
void sensorAdded(const QString &_sensor);
|
||||
void sensorRemoved(const QString &_sensor);
|
||||
void updateData(KSysGuard::SensorDataList _data);
|
||||
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
|
||||
|
||||
private:
|
||||
void createQueuedConnection();
|
||||
Plasma::DataEngineConsumer *m_consumer = nullptr;
|
||||
QHash<QString, Plasma::DataEngine *> m_dataEngines;
|
||||
QMetaObject::Connection m_newSourceConnection;
|
||||
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
|
||||
QHash<QString, KSysGuard::SensorInfo> m_sensors;
|
||||
};
|
||||
|
||||
|
||||
|
@ -76,20 +76,20 @@ QStringList AWDataEngineMapper::keysFromSource(const QString &_source) const
|
||||
|
||||
// HACK units required to define should the value be calculated as temperature
|
||||
// or fan data
|
||||
QStringList AWDataEngineMapper::registerSource(const QString &_source, const QString &_units, const QStringList &_keys)
|
||||
QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||
|
||||
// regular expressions
|
||||
auto cpuRegExp = QRegularExpression("cpu/cpu.*/TotalLoad");
|
||||
auto cpuclRegExp = QRegularExpression("cpu/cpu.*/clock");
|
||||
auto hddrRegExp = QRegularExpression("disk/.*/Rate/rblk");
|
||||
auto hddwRegExp = QRegularExpression("disk/.*/Rate/wblk");
|
||||
auto mountFillRegExp = QRegularExpression("partitions/.*/filllevel");
|
||||
auto mountFreeRegExp = QRegularExpression("partitions/.*/freespace");
|
||||
auto mountUsedRegExp = QRegularExpression("partitions/.*/usedspace");
|
||||
auto netRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/data$");
|
||||
auto netTotalRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
|
||||
auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
|
||||
auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
|
||||
auto hddrRegExp = QRegularExpression("^disk/.*/read$");
|
||||
auto hddwRegExp = QRegularExpression("^disk/.*/write$");
|
||||
auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
|
||||
auto mountFreeRegExp = QRegularExpression("^disk/.*/free$");
|
||||
auto mountUsedRegExp = QRegularExpression("^disk/.*/used$");
|
||||
auto netRegExp = QRegularExpression("^network/.*/(download|upload)$");
|
||||
auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$");
|
||||
|
||||
if (_source == "battery/ac") {
|
||||
// AC
|
||||
@ -102,24 +102,24 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float
|
||||
: AWKeysAggregator::FormatterType::IntegerThree;
|
||||
} else if (_source == "cpu/system/TotalLoad") {
|
||||
} else if (_source == "cpu/all/usage") {
|
||||
// cpu
|
||||
m_map.insert(_source, "cpu");
|
||||
m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source.contains(cpuRegExp)) {
|
||||
// cpus
|
||||
QString key = _source;
|
||||
key.remove("cpu/").remove("/TotalLoad");
|
||||
key.remove("cpu/").remove("/usage");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source == "cpu/system/AverageClock") {
|
||||
} else if (_source == "cpu/all/averageFrequency") {
|
||||
// cpucl
|
||||
m_map.insert(_source, "cpucl");
|
||||
m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer;
|
||||
} else if (_source.contains(cpuclRegExp)) {
|
||||
// cpucls
|
||||
QString key = _source;
|
||||
key.remove("cpu/cpu").remove("/clock");
|
||||
key.remove("cpu/cpu").remove("/frequency");
|
||||
key = QString("cpucl%1").arg(key);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
||||
@ -144,7 +144,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(hddrRegExp)) {
|
||||
// read speed
|
||||
QString device = _source;
|
||||
device.remove("/Rate/rblk");
|
||||
device.remove("disk/").remove("/read");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddr%1").arg(index);
|
||||
@ -154,7 +154,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(hddwRegExp)) {
|
||||
// write speed
|
||||
QString device = _source;
|
||||
device.remove("/Rate/wblk");
|
||||
device.remove("disk/").remove("/write");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddw%1").arg(index);
|
||||
@ -172,7 +172,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountFillRegExp)) {
|
||||
// fill level
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/filllevel");
|
||||
device.remove("disk/").remove("/usedPercent");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hdd%1").arg(index);
|
||||
@ -185,7 +185,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountFreeRegExp)) {
|
||||
// free space
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/freespace");
|
||||
device.remove("disk/").remove("/free");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
@ -200,7 +200,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountUsedRegExp)) {
|
||||
// used
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/usedspace");
|
||||
device.remove("disk/").remove("/used");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
@ -222,14 +222,14 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
}
|
||||
} else if (_source.startsWith("cpu/system/loadavg")) {
|
||||
} else if (_source.startsWith("cpu/loadaverages/loadaverage")) {
|
||||
// load average
|
||||
QString time = _source;
|
||||
time.remove("cpu/system/loadavg");
|
||||
time.remove("cpu/loadaverages/loadaverage");
|
||||
QString key = QString("la%1").arg(time);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols;
|
||||
} else if (_source == "mem/physical/application") {
|
||||
} else if (_source == "memory/physical/application") {
|
||||
// app memory
|
||||
// mb
|
||||
m_map.insert(_source, "memmb");
|
||||
@ -237,7 +237,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "memgb");
|
||||
m_formatter["memgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/physical/free") {
|
||||
} else if (_source == "memory/physical/free") {
|
||||
// free memory
|
||||
// mb
|
||||
m_map.insert(_source, "memfreemb");
|
||||
@ -245,7 +245,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "memfreegb");
|
||||
m_formatter["memfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/physical/used") {
|
||||
} else if (_source == "memory/physical/used") {
|
||||
// used memory
|
||||
// mb
|
||||
m_map.insert(_source, "memusedmb");
|
||||
@ -269,7 +269,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.contains(netRegExp)) {
|
||||
// network speed
|
||||
QString type = _source.contains("receiver") ? "down" : "up";
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
@ -287,7 +287,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
}
|
||||
} else if (_source.contains(netTotalRegExp)) {
|
||||
// network data total
|
||||
QString type = _source.contains("receiver") ? "down" : "up";
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
@ -329,7 +329,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
key.remove("quotes/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Quotes;
|
||||
} else if (_source == "mem/swap/free") {
|
||||
} else if (_source == "memory/swap/free") {
|
||||
// free swap
|
||||
// mb
|
||||
m_map.insert(_source, "swapfreemb");
|
||||
@ -337,7 +337,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "swapfreegb");
|
||||
m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/swap/used") {
|
||||
} else if (_source == "memory/swap/used") {
|
||||
// used swap
|
||||
// mb
|
||||
m_map.insert(_source, "swapmb");
|
||||
@ -349,13 +349,13 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// temperature
|
||||
int index = m_devices["temp"].indexOf(_source);
|
||||
// HACK on DE initialization there are no units key
|
||||
if (_units.isEmpty())
|
||||
if (_units == KSysGuard::UnitInvalid)
|
||||
return QStringList({QString("temp%1").arg(index)});
|
||||
if (index > -1) {
|
||||
QString key = QString("temp%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _units == "°C" ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
}
|
||||
} else if (_source == "Local") {
|
||||
// time
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef AWDATAENGINEMAPPER_H
|
||||
#define AWDATAENGINEMAPPER_H
|
||||
|
||||
#include <ksysguard/formatter/Unit.h>
|
||||
|
||||
#include <QMultiHash>
|
||||
#include <QObject>
|
||||
|
||||
@ -38,7 +40,7 @@ public:
|
||||
[[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const;
|
||||
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
||||
// set methods
|
||||
QStringList registerSource(const QString &_source, const QString &_units, const QStringList &_keys);
|
||||
QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys);
|
||||
void setDevices(const QHash<QString, QStringList> &_devices);
|
||||
|
||||
private:
|
||||
|
@ -58,11 +58,15 @@ AWKeys::AWKeys(QObject *_parent)
|
||||
// update key data if required
|
||||
connect(m_keyOperator, SIGNAL(updateKeys(const QStringList &)), this, SLOT(reinitKeys(const QStringList &)));
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTextData()));
|
||||
|
||||
// transfer signal from AWDataAggregator object to QML ui
|
||||
connect(m_dataAggregator, SIGNAL(toolTipPainted(const QString &)), this,
|
||||
SIGNAL(needToolTipToBeUpdated(const QString &)));
|
||||
|
||||
connect(this, SIGNAL(dropSourceFromDataengine(const QString &)), m_dataEngineAggregator,
|
||||
SLOT(dropSource(const QString &)));
|
||||
connect(m_dataEngineAggregator, SIGNAL(dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &, const KSysGuard::SensorDataList &)),
|
||||
this, SLOT(dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &, const KSysGuard::SensorDataList &)));
|
||||
// transfer signal from dataengine to update source list
|
||||
connect(m_dataEngineAggregator, SIGNAL(deviceAdded(const QString &)), m_keyOperator,
|
||||
SLOT(addDevice(const QString &)));
|
||||
@ -185,9 +189,9 @@ QString AWKeys::valueByKey(const QString &_key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Requested value for key" << _key;
|
||||
|
||||
QString trueKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key;
|
||||
auto realKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key;
|
||||
|
||||
return m_aggregator->formatter(m_values[trueKey], trueKey, true);
|
||||
return m_aggregator->formatter(m_values[realKey], realKey, true);
|
||||
}
|
||||
|
||||
|
||||
@ -199,10 +203,15 @@ void AWKeys::editItem(const QString &_type)
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data)
|
||||
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
|
||||
{
|
||||
// run concurrent data update
|
||||
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, _data);
|
||||
for (auto &single : _data) {
|
||||
if (_sensors.contains(single.sensorProperty)) {
|
||||
setDataBySource(single.sensorProperty, _sensors.value(single.sensorProperty), single);
|
||||
}
|
||||
// TODO use QtConcurrent::map or something like that
|
||||
// QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, "ss", sensor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +248,7 @@ void AWKeys::updateTextData()
|
||||
// do not do it in parallel to avoid race condition
|
||||
m_mutex.lock();
|
||||
calculateValues();
|
||||
QString text = parsePattern(m_keyOperator->pattern());
|
||||
auto text = parsePattern(m_keyOperator->pattern());
|
||||
// update tooltip values under lock
|
||||
m_dataAggregator->dataUpdate(m_values);
|
||||
m_mutex.unlock();
|
||||
@ -257,16 +266,16 @@ void AWKeys::calculateValues()
|
||||
for (auto &device : mountDevices) {
|
||||
int index = mountDevices.indexOf(device);
|
||||
m_values[QString("hddtotmb%1").arg(index)]
|
||||
= m_values[QString("hddfreemb%1").arg(index)].toFloat() + m_values[QString("hddmb%1").arg(index)].toFloat();
|
||||
= m_values[QString("hddfreemb%1").arg(index)].toDouble() + m_values[QString("hddmb%1").arg(index)].toDouble();
|
||||
m_values[QString("hddtotgb%1").arg(index)]
|
||||
= m_values[QString("hddfreegb%1").arg(index)].toFloat() + m_values[QString("hddgb%1").arg(index)].toFloat();
|
||||
= m_values[QString("hddfreegb%1").arg(index)].toDouble() + m_values[QString("hddgb%1").arg(index)].toDouble();
|
||||
}
|
||||
|
||||
// memtot*
|
||||
m_values["memtotmb"] = m_values["memusedmb"].toInt() + m_values["memfreemb"].toInt();
|
||||
m_values["memtotgb"] = m_values["memusedgb"].toFloat() + m_values["memfreegb"].toFloat();
|
||||
m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong();
|
||||
m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble();
|
||||
// mem
|
||||
m_values["mem"] = 100.0f * m_values["memmb"].toFloat() / m_values["memtotmb"].toFloat();
|
||||
m_values["mem"] = 100.0f * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
|
||||
|
||||
// up, down, upkb, downkb, upunits, downunits
|
||||
int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString());
|
||||
@ -282,10 +291,10 @@ void AWKeys::calculateValues()
|
||||
m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)];
|
||||
|
||||
// swaptot*
|
||||
m_values["swaptotmb"] = m_values["swapmb"].toInt() + m_values["swapfreemb"].toInt();
|
||||
m_values["swaptotgb"] = m_values["swapgb"].toFloat() + m_values["swapfreegb"].toFloat();
|
||||
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong();
|
||||
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble();
|
||||
// swap
|
||||
m_values["swap"] = 100.0f * m_values["swapmb"].toFloat() / m_values["swaptotmb"].toFloat();
|
||||
m_values["swap"] = 100.0f * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
|
||||
|
||||
// user defined keys
|
||||
for (auto &key : m_keyOperator->userKeys())
|
||||
@ -323,7 +332,7 @@ void AWKeys::createDBusInterface()
|
||||
QString AWKeys::parsePattern(QString _pattern) const
|
||||
{
|
||||
// screen sign
|
||||
_pattern.replace("$$", QString(0x1d));
|
||||
_pattern.replace("$$", QChar(0x1d));
|
||||
|
||||
// lambdas
|
||||
for (auto &key : m_foundLambdas)
|
||||
@ -343,7 +352,7 @@ QString AWKeys::parsePattern(QString _pattern) const
|
||||
}
|
||||
|
||||
// prepare strings
|
||||
_pattern.replace(QString(0x1d), "$");
|
||||
_pattern.replace(QChar(0x1d), "$");
|
||||
if (m_wrapNewLines)
|
||||
_pattern.replace("\n", "<br>");
|
||||
|
||||
@ -351,25 +360,25 @@ QString AWKeys::parsePattern(QString _pattern) const
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setDataBySource(const QString &_sourceName, const QVariantMap &_data)
|
||||
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const KSysGuard::SensorData &_data)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data;
|
||||
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _data.payload;
|
||||
|
||||
// first list init
|
||||
QStringList tags = m_aggregator->keysFromSource(_sourceName);
|
||||
auto tags = m_aggregator->keysFromSource(_source);
|
||||
if (tags.isEmpty())
|
||||
tags = m_aggregator->registerSource(_sourceName, _data["units"].toString(), m_requiredKeys);
|
||||
tags = m_aggregator->registerSource(_source, _sensor.unit, m_requiredKeys);
|
||||
|
||||
// update data or drop source if there are no matches and exit
|
||||
if (tags.isEmpty()) {
|
||||
qCInfo(LOG_AW) << "Source" << _sourceName << "not found";
|
||||
return emit(dropSourceFromDataengine(_sourceName));
|
||||
qCInfo(LOG_AW) << "Source" << _source << "not found";
|
||||
return emit(dropSourceFromDataengine(_source));
|
||||
}
|
||||
|
||||
m_mutex.lock();
|
||||
// HACK workaround for time values which are stored in the different path
|
||||
std::for_each(tags.cbegin(), tags.cend(), [this, &_data, &_sourceName](const QString &tag) {
|
||||
m_values[tag] = _sourceName == "Local" ? _data["DateTime"] : _data["value"];
|
||||
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) {
|
||||
m_values[tag] = _data.payload;
|
||||
});
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
#ifndef AWKEYS_H
|
||||
#define AWKEYS_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include <ksysguard/systemstats/SensorInfo.h>
|
||||
|
||||
|
||||
class AWDataAggregator;
|
||||
class AWDataEngineAggregator;
|
||||
@ -56,9 +56,7 @@ public:
|
||||
Q_INVOKABLE void editItem(const QString &_type);
|
||||
|
||||
public slots:
|
||||
void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data);
|
||||
// dummy method required by DataEngine connections
|
||||
static void modelChanged(const QString &, QAbstractItemModel *){};
|
||||
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
||||
|
||||
signals:
|
||||
void dropSourceFromDataengine(const QString &_source);
|
||||
@ -74,7 +72,7 @@ private:
|
||||
void calculateValues();
|
||||
void createDBusInterface();
|
||||
[[nodiscard]] QString parsePattern(QString _pattern) const;
|
||||
void setDataBySource(const QString &_sourceName, const QVariantMap &_data);
|
||||
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const KSysGuard::SensorData &_data);
|
||||
// objects
|
||||
AWDataAggregator *m_dataAggregator = nullptr;
|
||||
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
||||
|
@ -64,19 +64,19 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
// case block
|
||||
switch (m_mapper->formatter(_key)) {
|
||||
case FormatterType::Float:
|
||||
output = QString("%1").arg(_data.toFloat(), 5, 'f', 1);
|
||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 1);
|
||||
break;
|
||||
case FormatterType::FloatTwoSymbols:
|
||||
output = QString("%1").arg(_data.toFloat(), 5, 'f', 2);
|
||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 2);
|
||||
break;
|
||||
case FormatterType::Integer:
|
||||
output = QString("%1").arg(_data.toFloat(), 4, 'f', 0);
|
||||
output = QString("%1").arg(_data.toDouble(), 4, 'f', 0);
|
||||
break;
|
||||
case FormatterType::IntegerFive:
|
||||
output = QString("%1").arg(_data.toFloat(), 5, 'f', 0);
|
||||
output = QString("%1").arg(_data.toDouble(), 5, 'f', 0);
|
||||
break;
|
||||
case FormatterType::IntegerThree:
|
||||
output = QString("%1").arg(_data.toFloat(), 3, 'f', 0);
|
||||
output = QString("%1").arg(_data.toDouble(), 3, 'f', 0);
|
||||
break;
|
||||
case FormatterType::List:
|
||||
output = _data.toStringList().join(',');
|
||||
@ -85,10 +85,10 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
output = _data.toBool() ? m_acOnline : m_acOffline;
|
||||
break;
|
||||
case FormatterType::MemGBFormat:
|
||||
output = QString("%1").arg(_data.toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
output = QString("%1").arg(_data.toDouble() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
break;
|
||||
case FormatterType::MemMBFormat:
|
||||
output = QString("%1").arg(_data.toFloat() / 1024.0, 5, 'f', 0);
|
||||
output = QString("%1").arg(_data.toDouble() / 1024.0, 5, 'f', 0);
|
||||
break;
|
||||
case FormatterType::NetSmartFormat:
|
||||
output = [](const float value) {
|
||||
@ -96,10 +96,10 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
return QString("%1").arg(value / 1024.0, 4, 'f', 1);
|
||||
else
|
||||
return QString("%1").arg(value, 4, 'f', 0);
|
||||
}(_data.toFloat());
|
||||
}(_data.toDouble());
|
||||
break;
|
||||
case FormatterType::NetSmartUnits:
|
||||
if (_data.toFloat() > 1024.0)
|
||||
if (_data.toDouble() > 1024.0)
|
||||
output = m_translate ? i18n("MB/s") : "MB/s";
|
||||
else
|
||||
output = m_translate ? i18n("KB/s") : "KB/s";
|
||||
@ -110,7 +110,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
output = output.rightJustified(8, QLatin1Char(' '), true);
|
||||
break;
|
||||
case FormatterType::Temperature:
|
||||
output = QString("%1").arg(temperature(_data.toFloat()), 5, 'f', 1);
|
||||
output = QString("%1").arg(temperature(_data.toDouble()), 5, 'f', 1);
|
||||
break;
|
||||
case FormatterType::Time:
|
||||
output = _data.toDateTime().toString();
|
||||
@ -150,7 +150,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
|
||||
source.replace("$m", QString("%1").arg(minutes));
|
||||
return source;
|
||||
}(m_mapper->formatter(_key) == FormatterType::Uptime ? "$ddd$hhh$mmm" : m_customUptime,
|
||||
static_cast<int>(_data.toFloat()));
|
||||
static_cast<int>(_data.toDouble()));
|
||||
break;
|
||||
case FormatterType::NoFormat:
|
||||
output = _data.toString();
|
||||
@ -234,7 +234,7 @@ void AWKeysAggregator::setTranslate(const bool _translate)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeysAggregator::registerSource(const QString &_source, const QString &_units, const QStringList &_keys)
|
||||
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit &_units, const QStringList &_keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef AWKEYSAGGREGATOR_H
|
||||
#define AWKEYSAGGREGATOR_H
|
||||
|
||||
#include <ksysguard/formatter/Unit.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
@ -81,7 +83,7 @@ public:
|
||||
void setTranslate(bool _translate);
|
||||
|
||||
public slots:
|
||||
QStringList registerSource(const QString &_source, const QString &_units, const QStringList &_keys);
|
||||
QStringList registerSource(const QString &_source, const KSysGuard::Unit &_units, const QStringList &_keys);
|
||||
|
||||
private:
|
||||
[[nodiscard]] float temperature(float temp) const;
|
||||
|
@ -105,9 +105,9 @@ QList<AWPatternFunctions::AWFunction> AWPatternFunctions::findFunctionCalls(cons
|
||||
metadata.args = QStringList();
|
||||
} else {
|
||||
// replace '$,' to 0x1d
|
||||
argsString.replace("$,", QString(0x1d));
|
||||
argsString.replace("$,", QChar(0x1d));
|
||||
QStringList args = argsString.split(',');
|
||||
std::for_each(args.begin(), args.end(), [](QString &arg) { arg.replace(QString(0x1d), ","); });
|
||||
std::for_each(args.begin(), args.end(), [](QString &arg) { arg.replace(QChar(0x1d), ","); });
|
||||
metadata.args = args;
|
||||
}
|
||||
// other variables
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "awdebug.h"
|
||||
|
||||
|
Reference in New Issue
Block a user