on my laptop with freshly installed leap 16.0 running KDE 6.4.2
I would like to port my (very simple) plasmoids from plasma5 to plasma6, the plsmoid should show the standard out result of a command.
I tried something and get something that doesn’t give errors but I cannot get the result
this is the code of the plsma5 plasmoid:
import QtQuick 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
Rectangle {
radius: 20
opacity: 0.5
width: 500
height: 80
id: mainitem
property string userName
PlasmaComponents.Label {
text: i18n(userName)
font.pointSize : 30
color: "red"
}
PlasmaCore.DataSource {
id: whoamisource
engine: "executable"
connectedSources: ["hostname"]
onNewData:{
mainitem.userName = qsTr("host= ") + data.stdout
}
}
}
this is the plasma6 plasmoid that gives no error and no result:
import QtQuick
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents
import org.kde.plasma.plasma5support as Plasma5Support
PlasmoidItem {
id: root
Rectangle {
radius: 20
opacity: 0.5
width: 500
height: 80
id: mainitem
property string userName
}
// Full representation (when on desktop)
fullRepresentation: PlasmaComponents.Label {
text: i18n(userName)
font.pixelSize: 40
color: "red"
}
Plasma5Support.DataSource {
id: executableSource
engine: "executable"
connectedSources: ["whoami"]
onNewData: {
mainitem.userName = data["stdout"]
}
}
}
could somebody help me to have the same result of plasma5 plasmoid with plasma6 plasmoid?
1 Like
Tested it locally for you: you have ported correctly, just change text: i18n(userName) to text: mainitem.userName, it’s as silly as that, just an unqualified access error : D
You also don’t really need i18n for the username since the resulting string won’t/shouldn’t be translatable.
And to remove the annoying warning about “injection of parameters into signal handlers” you can just use: onNewData: (connectedSources, data) => mainitem.userName = data["stdout"].
1 Like
Everything in my Plasma repo was made with Google Gemini; test it for yourself and form your own opinions.
1 Like
maaanythanks, this works
[code]
import QtQuick 2.0
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.plasma5support as Plasma5Support
import QtQuick.Controls 2.5
import org.kde.kirigami 2.4 as Kirigami
PlasmoidItem {
id: root
Rectangle {
radius: 20
opacity: 0.5
width: 500
height: 80
id: mainitem
property string userName
}
// Full representation (when on desktop)
fullRepresentation: PlasmaComponents3.Label {
text: mainitem.userName
font.pixelSize: 40
color: "red"
}
Plasma5Support.DataSource {
id: executableSource
engine: "executable"
connectedSources: ["whoami"]
onNewData: (connectedSources, data) => mainitem.userName = data["stdout"]
}
}
[/code]
I tested with plasmawindowed, but I cannot use on desktop becouse if I try to put the plasmoid on the desktop plasma6 says that it is not compatible with plasma6 and doesn’t allow me to drag on desktop
I literally just copied that to the local plasmoid I used for testing here and it works fine.
Did you also change the metadata.json? If it’s not modified to use Plasma 6, the plasmoid will be considered a Plasma 5 thing by default.
Example:
{
"KPackageStructure": "Plasma/Applet",
"KPlugin": {
"Authors": ["Konqi the Konqueror"],
"BugReportUrl": "https://example.com",
"Icon": "start-here-kde",
"Id": "org.kde.someplasmoid",
"License": "GPL-2.0+",
"Name": "Some Plasmoid",
"Description": "A plasmoid test"
},
"X-Plasma-API-Minimum-Version": "6.0",
"X-Plasma-Provides": [
"org.kde.someplasmoid"
]
}
me too copyed in /home/eros/.local/share/plasma/plasmoids/
the folder name is “org.kde.pla.hostname.6” like in metadata.json
and yes I changed the metadata.json in this way
[code]
{
“KPackageStructure”: “Plasma/Applet”,
“KPlugin”: {
“Authors”: [
{
“Email”: “pier_andreit@yahoo.it”,
“Name”: “pier”
}
],
“Category”: “Utilities”,
“Description”: “Plasmoid for viewing hostname”,
“Icon”: “arrow-up-double”,
“Id”: “org.kde.pla.hostname.6”,
“License”: “GPL-2.0+”,
“Name”: “pla.hostname.6”,
“Version”: “0.1”,
“Website”: “https://tuosito.it”
},
“Plasma”: {
“APIStyle”: “declarative”
}
}
[/code]
maaanythanks, I modified in this way and this works 
[code]
{
“KPackageStructure”: “Plasma/Applet”,
“KPlugin”: {
“Authors”: [
{
“Email”: “pier_andreit@yahoo.it”,
“Name”: “pier”
}
],
“Category”: “Utilities”,
“Description”: “Plasmoid for viewing hostname”,
“Icon”: “arrow-up-double”,
“Id”: “org.kde.pla.hostname.6”,
“License”: “GPL-2.0+”,
“Name”: “pla.hostname.6”,
“Version”: “0.1”,
“Website”: “https://tuosito.it”
},
“X-Plasma-API-Minimum-Version”: “6.0”,
“X-Plasma-Provides”: [
“org.kde.pla.hostname.6””
]
}
[/code]
1 Like