Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct update time interval #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions plasmoid/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Item {
id: execute_ds
engine: "executable"

property var tick
property var tick: 0

// what data is requested from the systemmonitor data source
connectedSources: {
Expand Down Expand Up @@ -78,11 +78,12 @@ Item {
values[i] = normalize(orig_values, data.stdout, i)
}
}
var current_tick = Math.floor(Date.now() / 1000)
if (tick != current_tick) {
var current_tick = Date.now()
var time_spent = current_tick - tick
if (time_spent > interval ) {
valuesChanged()
orig_valuesChanged()
tick = current_tick
tick = tick + (Math.floor(time_spent / interval) * interval)
}
}

Expand All @@ -95,7 +96,7 @@ Item {
id: systemmonitor
engine: "systemmonitor"

property var tick
property var tick: 0

// what data is requested from the systemmonitor data source
connectedSources: {
Expand Down Expand Up @@ -126,11 +127,12 @@ Item {
values[i] = normalize(orig_values, data.value, i)
}
}
var current_tick = Math.floor(Date.now() / 1000)
if (tick != current_tick) {
var current_tick = Date.now()
var time_spent = current_tick - tick
if (time_spent > interval ) {
valuesChanged()
orig_valuesChanged()
tick = current_tick
tick = tick + (Math.floor(time_spent / interval) * interval)
}
}

Expand Down