From 05d60bc059d7a7dc8a396a62eb4f0dec8da61da8 Mon Sep 17 00:00:00 2001 From: Luis Bocanegra Date: Tue, 26 Mar 2024 21:00:48 -0600 Subject: [PATCH] Get username using KCoreAddons --- .../package/contents/ui/FullRepresentation.qml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/plasmoid/package/contents/ui/FullRepresentation.qml b/src/plasmoid/package/contents/ui/FullRepresentation.qml index 66da2a3..86a9cae 100644 --- a/src/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/src/plasmoid/package/contents/ui/FullRepresentation.qml @@ -8,6 +8,7 @@ import QtQuick.Controls import QtQuick.Layouts import "components" as Components +import org.kde.coreaddons 1.0 as KCoreAddons import org.kde.kirigami as Kirigami import org.kde.kquickcontrols import org.kde.plasma.components as PlasmaComponents3 @@ -27,7 +28,7 @@ ColumnLayout { property bool backendRunning: true property string homeDir: StandardPaths.writableLocation( StandardPaths.HomeLocation).toString().substring(7) - property string username: "" + property string username: kuser.loginName property string execName: 'kde-material-you-colors' property string execPath: "" @@ -62,6 +63,10 @@ ColumnLayout { property Item parentMain + KCoreAddons.KUser { + id: kuser + } + Connections { target: parentMain function onTogglePauseMode() { @@ -124,16 +129,9 @@ ColumnLayout { execPath = temp } - function getUsername() { - var parts = homeDir.split('/'); - if (parts.length > 2 && parts[1] === "home") { - username = parts[2]; - } - } Component.onCompleted: { findExecutablePath() - getUsername() } P5Support.DataSource {