mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-12 07:19:41 -04:00
refactor: (Framemode) Added DeferredAction for dbar/dock state handling
This commit is contained in:
55
quickshell/Common/DeferredAction.qml
Normal file
55
quickshell/Common/DeferredAction.qml
Normal file
@@ -0,0 +1,55 @@
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
visible: false
|
||||
width: 0
|
||||
height: 0
|
||||
|
||||
property int interval: 0
|
||||
property bool pending: false
|
||||
|
||||
signal triggered
|
||||
|
||||
function schedule() {
|
||||
if (!root.enabled || root.pending)
|
||||
return;
|
||||
root.pending = true;
|
||||
deferTimer.restart();
|
||||
}
|
||||
|
||||
function restart() {
|
||||
if (!root.enabled)
|
||||
return;
|
||||
root.pending = true;
|
||||
deferTimer.restart();
|
||||
}
|
||||
|
||||
function flush() {
|
||||
if (!root.pending)
|
||||
return;
|
||||
deferTimer.stop();
|
||||
root.pending = false;
|
||||
root.triggered();
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
deferTimer.stop();
|
||||
root.pending = false;
|
||||
}
|
||||
|
||||
onEnabledChanged: {
|
||||
if (!enabled)
|
||||
cancel();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: deferTimer
|
||||
interval: root.interval
|
||||
repeat: false
|
||||
onTriggered: root.flush()
|
||||
}
|
||||
|
||||
Component.onDestruction: cancel()
|
||||
}
|
||||
Reference in New Issue
Block a user