mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-22 15:48:26 +00:00
Created overloaded function for encodeData to use the QZXingEncoderConfig. The old implementation of encodeData now translates its arguments into a QZXingEncoderConfig and calls the overloaded function. Updated regex in QZXingImageProvider to be aware of the new configuration of border. Updated BarcodeEncoder example UI to allow the control of the border option.
120 lines
3.3 KiB
QML
120 lines
3.3 KiB
QML
import QtQuick 2.0
|
|
import QtQuick.Controls 2.0
|
|
import QtQuick.Layouts 1.3
|
|
|
|
ApplicationWindow {
|
|
id: mainWindow
|
|
visible: true
|
|
width: 640
|
|
height: 480
|
|
|
|
minimumWidth: formatGroupBox.width +
|
|
errorCorrectionlevelGroupBox.width +
|
|
borderStatus.width +
|
|
5 * advancedOptions.spacing
|
|
|
|
property bool isAdvancedOptionsEnabled: advancedSwitch.position;
|
|
|
|
ColumnLayout {
|
|
id: mainLayout
|
|
anchors {
|
|
fill: parent
|
|
margins: 10
|
|
}
|
|
TextField {
|
|
id: inputField
|
|
Layout.fillWidth: true
|
|
selectByMouse: true
|
|
text: "Hello world!"
|
|
}
|
|
|
|
Row {
|
|
Layout.fillWidth: true
|
|
|
|
Label {
|
|
id: resultLabel
|
|
text: "Result barcode image"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
Rectangle {
|
|
height: 1
|
|
width: parent.width - resultLabel.width - advancedSwitch.width
|
|
}
|
|
|
|
Switch {
|
|
id: advancedSwitch
|
|
text: "Advanced"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|
|
|
|
Row {
|
|
id: advancedOptions
|
|
Layout.fillWidth: true
|
|
visible: mainWindow.isAdvancedOptionsEnabled
|
|
clip: true
|
|
|
|
spacing: 5
|
|
|
|
GroupBox {
|
|
id: formatGroupBox
|
|
title: "Format"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
ComboBox {
|
|
id: formatCombo
|
|
model: ["qrcode"]
|
|
}
|
|
}
|
|
|
|
GroupBox {
|
|
id: errorCorrectionlevelGroupBox
|
|
title: "Error Correction Level"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
ComboBox {
|
|
id: errorCorrectionlevelCombo
|
|
model: ["L", "M", "Q", "H"]
|
|
}
|
|
}
|
|
|
|
Switch {
|
|
id: borderStatus
|
|
text: "Border"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
id: barcodeRectangle
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
border.width: 1
|
|
border.color: "#bdbebf"
|
|
clip: true
|
|
|
|
property int imageWidth: Math.min(height, width) * 0.7;
|
|
|
|
Image{
|
|
id:resultImage
|
|
anchors.centerIn: parent
|
|
sourceSize.width: barcodeRectangle.imageWidth
|
|
sourceSize.height: barcodeRectangle.imageWidth
|
|
|
|
source: mainLayout.getImageRequestString()
|
|
//cache: false;
|
|
}
|
|
}
|
|
|
|
function getImageRequestString() {
|
|
if(mainWindow.isAdvancedOptionsEnabled) {
|
|
return "image://QZXing/encode/" + inputField.text +
|
|
"?correctionLevel=" + errorCorrectionlevelCombo.currentText +
|
|
"&format=" + formatCombo.currentText +
|
|
"&border=" + borderStatus.position;
|
|
}
|
|
else
|
|
return "image://QZXing/encode/" + inputField.text;
|
|
}
|
|
}
|
|
}
|