Skip to content

Commit

Permalink
- bug fix: lock device immediately after app startup
Browse files Browse the repository at this point in the history
- timeout is a constant
- little improvement on settings page
  • Loading branch information
steffen-foerster committed Oct 16, 2014
1 parent 080daaa commit ad6789e
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 65 deletions.
13 changes: 2 additions & 11 deletions qml/components/Settings1View.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,8 @@ Item {
}
}

Slider {
width: parent.width
minimumValue: 5.0
maximumValue: 60.0
value: Settings.get(Settings.keys.SCAN_DURATION)
stepSize: 5
label: qsTr("Scan duration")
valueText: qsTr("%1 seconds").arg(value)
onSliderValueChanged: {
Settings.set(Settings.keys.SCAN_DURATION, value)
}
SectionHeader {
text: qsTr("History")
}

Slider {
Expand Down
2 changes: 1 addition & 1 deletion qml/harbour-barcode.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ApplicationWindow
id: window

function getVersion() {
return "0.7.0"
return "0.7.1"
}

function openInDefaultApp(url) {
Expand Down
38 changes: 14 additions & 24 deletions qml/pages/AutoScanPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Page {
property bool flagAutoScan: true
property bool flagScanByCover: false

property int seconds
property int scanDuration: 20
property int scanTimeout: 60

property int viewFinder_x: scanPage.width / 6
property int viewFinder_y: Theme.paddingLarge * 2
Expand Down Expand Up @@ -95,16 +94,14 @@ Page {
}

function startScan() {
seconds = scanDuration

// hide marker image
viewFinder.children[0].source = ""
viewFinder.children[0].visible = false

setMarkerColor()

stateScanning()
scanner.startScanning(scanDuration * 1000)
scanner.startScanning(scanTimeout * 1000)
}

function abortScan() {
Expand All @@ -126,14 +123,12 @@ Page {

function stateInactive() {
state = "INACTIVE"
labelUpdateTimer.running = false
statusText.text = ""
actionButton.enabled = false
}

function stateReady() {
state = "READY"
labelUpdateTimer.running = false
actionButton.text = qsTr("Scan")
actionButton.visible = true
actionButton.enabled = true
Expand All @@ -142,8 +137,7 @@ Page {

function stateScanning() {
state = "SCANNING"
labelUpdateTimer.running = true
statusText.text = qsTr("Scan in progress for %1 seconds!").arg(seconds)
statusText.text = qsTr("Scan in progress ...")
clickableResult.clear()
actionButton.text = qsTr("Abort")
}
Expand All @@ -169,7 +163,6 @@ Page {
console.log("Page is ACTIVE")

// update changeable values
scanPage.scanDuration = Settings.get(Settings.keys.SCAN_DURATION)
zoomSlider.value = Settings.get(Settings.keys.DIGITAL_ZOOM)

createScanner()
Expand All @@ -193,16 +186,6 @@ Page {
}
}

Timer {
id: labelUpdateTimer
interval: 1000;
repeat: true
onTriggered: {
seconds --
statusText.text = qsTr("Scan in progress for %1 seconds!").arg(seconds)
}
}

Connections {
target: Qt.application
onActiveChanged: {
Expand All @@ -226,19 +209,26 @@ Page {

onCameraStarted: {
console.log("camera is started")

if (!Qt.application.active) {
// use case: start app => lock device immediately => signal Qt.application.onActiveChanged is not emitted
console.log("WARN: device immediately locked")
destroyScanner()
return
}

stateReady()

if (flagScanByCover || flagAutoScan && Settings.getBoolean(Settings.keys.SCAN_ON_START)) {
flagAutoScan = false
flagScanByCover = false

startScan();
}

flagAutoScan = false
flagScanByCover = false
}

onDecodingFinished: {
console.log("decoding finished, code: ", code)
labelUpdateTimer.running = false
statusText.text = ""
if (scanPage.state !== "ABORT") {
if (code.length > 0) {
Expand Down
19 changes: 16 additions & 3 deletions qml/pages/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,22 @@ Page {
title: qsTr("Settings %1/2").arg(mainView.currentIndex + 1)
}

Rectangle {
id: settingsContent
color: Theme.rgba(Theme.highlightColor, 0.1)

anchors {
topMargin: Screen.width * 1/3
top: pageTitle.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
}

Rectangle {
anchors {
topMargin: Theme.paddingLarge * 3
topMargin: Screen.width * 1/3
top: pageTitle.bottom
}
color: Theme.highlightColor
Expand All @@ -54,12 +67,12 @@ Page {

itemWidth: width
itemHeight: height
height: window.height - (pageTitle.height + Theme.paddingLarge * 4
height: Screen.height - (pageTitle.height + (Screen.width * 1/3 + Theme.paddingLarge)
+ viewIndicator.height + tabHeader.childrenRect.height)
clip:true

anchors {
topMargin: Theme.paddingLarge * 4
topMargin: (Screen.width * 1/3 + Theme.paddingLarge)
top: pageTitle.bottom
left: parent.left
right: parent.right
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-barcode.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Name: harbour-barcode
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Code Reader
Version: 0.7.0
Version: 0.7.1
Release: 1
Group: Qt/Qt
License: LICENSE
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-barcode.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: harbour-barcode
Summary: Code Reader
Version: 0.7.0
Version: 0.7.1
Release: 1
# The contents of the Group field must be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
Expand Down
14 changes: 11 additions & 3 deletions translations/harbour-barcode-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<name>AutoScanPage</name>
<message>
<source>Scan in progress for %1 seconds!</source>
<translation>Scanvorgang läuft, %1 Sekunden!</translation>
<translation type="obsolete">Scanvorgang läuft, %1 Sekunden!</translation>
</message>
<message>
<source>No code detected! Try again.</source>
Expand Down Expand Up @@ -94,6 +94,10 @@
<source>History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan in progress ...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HistoryPage</name>
Expand Down Expand Up @@ -138,11 +142,11 @@
</message>
<message>
<source>Scan duration</source>
<translation type="unfinished">Dauer eines Scans</translation>
<translation type="obsolete">Dauer eines Scans</translation>
</message>
<message>
<source>%1 seconds</source>
<translation type="unfinished">%1 Sekunden</translation>
<translation type="obsolete">%1 Sekunden</translation>
</message>
<message>
<source>deactivated</source>
Expand All @@ -164,6 +168,10 @@
<source>Max history size (saved values: %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>History</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Settings2View</name>
Expand Down
14 changes: 11 additions & 3 deletions translations/harbour-barcode-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<name>AutoScanPage</name>
<message>
<source>Scan in progress for %1 seconds!</source>
<translation>Lecture en cours (%1 secondes restantes)</translation>
<translation type="obsolete">Lecture en cours (%1 secondes restantes)</translation>
</message>
<message>
<source>No code detected! Try again.</source>
Expand Down Expand Up @@ -90,6 +90,10 @@
<source>History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan in progress ...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HistoryPage</name>
Expand Down Expand Up @@ -134,11 +138,11 @@
</message>
<message>
<source>Scan duration</source>
<translation type="unfinished">Durée de la lecture</translation>
<translation type="obsolete">Durée de la lecture</translation>
</message>
<message>
<source>%1 seconds</source>
<translation type="unfinished">%1 secondes</translation>
<translation type="obsolete">%1 secondes</translation>
</message>
<message>
<source>deactivated</source>
Expand All @@ -160,6 +164,10 @@
<source>Max history size (saved values: %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>History</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Settings2View</name>
Expand Down
14 changes: 11 additions & 3 deletions translations/harbour-barcode-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<name>AutoScanPage</name>
<message>
<source>Scan in progress for %1 seconds!</source>
<translation>Scansione in corso per %1 secondi!</translation>
<translation type="obsolete">Scansione in corso per %1 secondi!</translation>
</message>
<message>
<source>No code detected! Try again.</source>
Expand Down Expand Up @@ -95,6 +95,10 @@
<source>History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan in progress ...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HistoryPage</name>
Expand Down Expand Up @@ -139,11 +143,11 @@
</message>
<message>
<source>Scan duration</source>
<translation type="unfinished">Durata scansione</translation>
<translation type="obsolete">Durata scansione</translation>
</message>
<message>
<source>%1 seconds</source>
<translation type="unfinished">%1 secondi</translation>
<translation type="obsolete">%1 secondi</translation>
</message>
<message>
<source>deactivated</source>
Expand All @@ -165,6 +169,10 @@
<source>Max history size (saved values: %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>History</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Settings2View</name>
Expand Down
14 changes: 11 additions & 3 deletions translations/harbour-barcode-sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<name>AutoScanPage</name>
<message>
<source>Scan in progress for %1 seconds!</source>
<translation>Skanning har pågått i %1 sekunder!</translation>
<translation type="obsolete">Skanning har pågått i %1 sekunder!</translation>
</message>
<message>
<source>No code detected! Try again.</source>
Expand Down Expand Up @@ -94,6 +94,10 @@
<source>History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan in progress ...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HistoryPage</name>
Expand Down Expand Up @@ -138,11 +142,11 @@
</message>
<message>
<source>Scan duration</source>
<translation type="unfinished">Skanningsförlopp</translation>
<translation type="obsolete">Skanningsförlopp</translation>
</message>
<message>
<source>%1 seconds</source>
<translation type="unfinished">%1 sekunder</translation>
<translation type="obsolete">%1 sekunder</translation>
</message>
<message>
<source>deactivated</source>
Expand All @@ -164,6 +168,10 @@
<source>Max history size (saved values: %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>History</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Settings2View</name>
Expand Down
Loading

0 comments on commit ad6789e

Please sign in to comment.