Commit 44893201 authored by Karel Slaný's avatar Karel Slaný

Inactivity period can be set from PIN settings page.

parent d21fda68
......@@ -53,6 +53,13 @@ Component {
pinConfirmField1.visible = false
pinConfirmField2.visible = false
errLineText.visible = false
lockIntervalLabel.visible = true
lockIntervalSpinBox.visible = true
lockIntervalLabel.enabled = currentPIN != ""
lockIntervalSpinBox.enabled = currentPIN != ""
lockIntervalSpinBox.setVal(settings.inactivityInterval())
} else if (actionName == "new") {
acceptElement.visible = true
topLineText.text = qsTr("Enter a new PIN code into both text fields:")
......@@ -64,6 +71,9 @@ Component {
pinConfirmField2.visible = true
errLineText.visible = false
lockIntervalLabel.visible = false
lockIntervalSpinBox.visible = false
pinConfirmField1.focus = true
} else if (actionName == "change") {
acceptElement.visible = true
......@@ -77,6 +87,9 @@ Component {
pinConfirmField2.visible = true
errLineText.visible = false
lockIntervalLabel.visible = false
lockIntervalSpinBox.visible = false
pinValueField.focus = true
} else if (actionName == "disable") {
acceptElement.visible = true
......@@ -89,6 +102,9 @@ Component {
pinConfirmField2.visible = false
errLineText.visible = false
lockIntervalLabel.visible = false
lockIntervalSpinBox.visible = false
pinValueField.focus = true
} else {
/* This line should not be reached. */
......@@ -148,8 +164,17 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
if (actionName == "unspecified") {
if (currentPIN == "") {
settings.setInactivityInterval(0)
locker.setInactivityInterval(0)
} else {
settings.setInactivityInterval(lockIntervalSpinBox.val())
locker.setInactivityInterval(lockIntervalSpinBox.val())
}
pageView.pop(StackView.Immediate)
/* set new pin code */
if (actionName == "new") {
} else if (actionName == "new") {
if (pinConfirmField1.text == "" || pinConfirmField2.text == "") {
errLineText.text = qsTr("Error: Both new PIN code fields must be filled in!")
errLineText.visible = true
......@@ -199,6 +224,10 @@ Component {
if (pinValueField.text == currentPIN) {
errLineText.visible = false
settings.updatePinSettings("")
settings.setInactivityInterval(0)
locker.setInactivityInterval(0)
pageView.pop(StackView.Immediate)
} else {
pinValueField.text = ""
......@@ -293,6 +322,75 @@ Component {
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
Label {
id: lockIntervalLabel
color: datovkaPalette.text
anchors.horizontalCenter: parent.horizontalCenter
width: myWidht * 0.5
text: qsTr("Lock after seconds of inactivity")
horizontalAlignment: Text.AlignHCenter
}
SpinBox {
/* Holds value in seconds. */
id: lockIntervalSpinBox
anchors.horizontalCenter: parent.horizontalCenter
/* Must be a non-decreasing list ending with infinity. */
property var items: [15, 30, 60, 90, 120, 150, 180, qsTr("don't lock")]
property int dfltIdx: 0
from: 0
to: items.length - 1 /* Last is infinite. */
//stepSize: 1
textFromValue: function(value) {
return items[value];
}
valueFromText: function(text) {
for (var i = 0; i < items.length; ++i) {
if (items[i].toLowerCase().indexOf(text.toLowerCase()) === 0) {
return i
}
}
return sb.value
}
function val() {
if (value < to) { /* Last is infinite. */
return items[value]
} else {
return 0 /* Infinity is treated as zero. */
}
}
function setVal(v) {
if (v <= 0) { /* infinite */
value = to
} else if (v < items[0]) { /* less than minimal */
value = from
} else if (v > items[to - 1]) { /* more than maximal */
value = to
} else {
for (var i = 0; i < (items.length - 1); ++i) {
if (v == items[i]) {
value = i
return
} else if (v < items[i]) {
value = i - 1
return
}
}
value = from
}
}
onValueChanged: {
/* Enable accept button. Always visible? */
acceptElement.visible = val() != settings.inactivityInterval()
}
}
}
}
}
......
......@@ -244,6 +244,11 @@ int main(int argc, char *argv[])
files.deleteExpiredFilesFromDbs(globSet.fileLifeTimeInDays);
}
/* Inactivity locking is disabled when equal to 0. */
if (globSet.pinInactTimeoutInSecs > 0) {
locker.setInactivityInterval(globSet.pinInactTimeoutInSecs);
}
/* Load counters. */
Accounts::loadModelCounters();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment