nemo-keepalive's Introduction
This project has migrated to https://git.merproject.org/mer-core/nemo-keepalive as part of the Mer/Nemo merge work
nemo-keepalive's People
nemo-keepalive's Issues
Make BackgroundJob behave more like Timer: add triggeredOnStart and repeat properties, and suppress additional triggered signals after enabled has been set to false
Currently BackgroundJob always triggers immediately when enabled is set to true. There's also no way to tell BackgroundJob to behave like a single-shot timer. Though it's certainly possible to work around this, by keeping track of whether the BackgroundJob has already triggered once and disabling it when you've done the work that needs to be done, it would be helpful if you could add the two boolean properties triggeredOnStart
and repeat
that work the QtQuick Timer type's properties of the same name.
Additionally, if enabled is set to false after finished()
has already been called, BackgroundJob will still trigger once more. For a demonstration of this behaviour, take a look at this code, adapted from examples/qml/backgroundjob.qml (the only change is the removal of line 41, which normally hides the text when the BackgroundJob is disabled):
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.keepalive 1.0
ApplicationWindow {
initialPage: Page {
Timer {
id: timer
interval: 1000
repeat: true
property int run_periods
onTriggered: {
if (--run_periods == 0) {
backgroundJob.finished()
stop()
}
}
}
BackgroundJob {
id: backgroundJob
frequency: BackgroundJob.ThirtySeconds
onTriggered: {
timer.run_periods = 5
timer.running = true
}
}
Column {
width: parent.width
spacing: Theme.paddingLarge
anchors.centerIn: parent
Label {
anchors.horizontalCenter: parent.horizontalCenter
text: backgroundJob.running ? "running job " + timer.run_periods : "job waiting"
}
Button {
text: backgroundJob.enabled ? "Disable" : "Enable"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
backgroundJob.enabled = !backgroundJob.enabled
}
}
}
}
}
If you press the "Disable" Button while the Label displays "job waiting", the Timer will nevertheless be started again a few seconds later by the BackgroundJob, after which backgroundJob.running will be perpetually set to true, i.e. "running job 0" will be displayed.
This seems like very strange behaviour to me. I would definitely not expect the BackgroundJob to trigger again in spite of its enabled property being set to false.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.