-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port lock desktop config in plasma to plasma 6
- Loading branch information
Showing
2 changed files
with
78 additions
and
76 deletions.
There are no files selected for viewing
141 changes: 68 additions & 73 deletions
141
usr/share/plasma/plasmoids/org.biglinux.lock_edit_plasma/contents/ui/main.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,90 @@ | ||
/* | ||
* SPDX-FileCopyleftText: 2022 Bruno Gonçalves <[email protected]> and Rafael Ruscher <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
import QtQuick 2.1 | ||
import QtQuick.Layouts 1.0 | ||
import org.kde.plasma.plasmoid 2.0 | ||
import org.kde.plasma.core 2.0 as PlasmaCore | ||
import org.kde.plasma.components 2.0 as PlasmaComponent | ||
|
||
Item { | ||
* SPDX-FileCopyrightText: 2022 Bruno Gonçalves <[email protected]> and Rafael Ruscher <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
import QtQuick | ||
import org.kde.plasma.plasmoid | ||
import org.kde.plasma.core as PlasmaCore | ||
import org.kde.kirigami as Kirigami | ||
import org.kde.plasma.plasma5support as Plasma5Support | ||
|
||
PlasmoidItem { | ||
id: root | ||
property string outputText | ||
|
||
PlasmaCore.DataSource { | ||
id: executable | ||
engine: "executable" | ||
connectedSources: [] | ||
onNewData: { | ||
var exitCode = data["exit code"] | ||
var exitStatus = data["exit status"] | ||
var stdout = data["stdout"] | ||
var stderr = data["stderr"] | ||
exited(sourceName, exitCode, exitStatus, stdout, stderr) | ||
disconnectSource(sourceName) // cmd finished | ||
} | ||
function exec(cmd) { | ||
if (cmd) { | ||
connectSource(cmd) | ||
} | ||
} | ||
signal exited(string cmd, int exitCode, int exitStatus, string stdout, string stderr) | ||
} | ||
|
||
property string outputText: 'true' | ||
Connections { | ||
target: executable | ||
onExited: { | ||
outputText = stdout | ||
timer.restart() | ||
} | ||
} | ||
|
||
function runCommand() { | ||
// Change to run your command | ||
// | ||
executable.exec('cat $HOME/.config/lockplasma') | ||
//executable.exec('qdbus org.kde.plasmashell /PlasmaShell org.freedesktop.DBus.Properties.Get "" editMode') | ||
|
||
} | ||
|
||
Timer { | ||
id: timer | ||
|
||
// Wait in ms | ||
interval: 7000 | ||
onTriggered: runCommand() | ||
Component.onCompleted: { | ||
triggered() | ||
} | ||
} | ||
function runCommand() { | ||
// Change to run your command | ||
executable.exec('cat $HOME/.config/lockplasma'); | ||
} | ||
|
||
Plasmoid.icon: outputText ? 'biglinux-lock' : 'biglinux-unlock' | ||
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation | ||
function toggle() { | ||
executable.exec('/usr/share/bigbashview/bcc/apps/biglinux-themes-gui/lock-desktop.run'); | ||
timer.interval = 500; | ||
} | ||
|
||
preferredRepresentation: fullRepresentation | ||
// Active = in systray and Passive in notification area | ||
Plasmoid.status: { | ||
//return PlasmaCore.Types.ActiveStatus; | ||
return PlasmaCore.Types.PassiveStatus; | ||
} | ||
} | ||
|
||
function toggle() { | ||
Plasma5Support.DataSource { | ||
id: "executable" | ||
signal exited(string sourceName, int exitCode, int exitStatus, string stdout, string stderr) | ||
function exec(cmd) { | ||
connectSource(cmd); | ||
} | ||
|
||
executable.exec('/usr/share/bigbashview/bcc/apps/biglinux-themes-gui/lock-desktop.run') | ||
timer.interval = 500 | ||
engine: "executable" | ||
connectedSources: [] | ||
onNewData: function(sourceName, data) { | ||
var exitCode = data["exit code"]; | ||
var exitStatus = data["exit status"]; | ||
var stdout = data["stdout"]; | ||
var stderr = data["stderr"]; | ||
exited(sourceName, exitCode, exitStatus, stdout, stderr); | ||
disconnectSource(sourceName); | ||
} | ||
} | ||
|
||
Connections { | ||
function onExited(sourceName, exitCode, exitStatus, stdout, stderr) { | ||
Qt.callLater(function() { | ||
root.outputText = stdout; | ||
}); | ||
timer.restart(); | ||
} | ||
|
||
target: executable | ||
} | ||
|
||
Timer { | ||
id: timer | ||
|
||
// Wait in ms | ||
interval: 7000 | ||
onTriggered: runCommand() | ||
Component.onCompleted: { | ||
triggered(); | ||
} | ||
} | ||
|
||
fullRepresentation: PlasmoidItem { | ||
Kirigami.Icon { | ||
id: icon | ||
source: outputText ? 'biglinux-lock' : 'biglinux-unlock' | ||
height: Math.min(parent.height, parent.width) | ||
width: Math.min(parent.height, parent.width) | ||
anchors.fill: parent | ||
} | ||
|
||
Plasmoid.compactRepresentation: PlasmaCore.IconItem { | ||
active: compactMouseArea.containsMouse | ||
source: plasmoid.icon | ||
|
||
MouseArea { | ||
id: compactMouseArea | ||
anchors.fill: parent | ||
hoverEnabled: true | ||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | ||
onClicked: toggle() | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters