QR codes rework
This commit is contained in:
parent
b341224c92
commit
1d51419a11
26 changed files with 595 additions and 2052 deletions
|
|
@ -10,7 +10,13 @@ Item {
|
|||
property var page: PageEnum.Start
|
||||
property var logic: UiLogic
|
||||
|
||||
property bool pageActive: false
|
||||
|
||||
signal activated(bool reset)
|
||||
signal deactivated()
|
||||
|
||||
onActivated: pageActive = true
|
||||
onDeactivated: pageActive = false
|
||||
|
||||
// width: GC.screenWidth
|
||||
// height: GC.screenHeight
|
||||
|
|
|
|||
163
client/ui/qml/Pages/PageQrDecoder.qml
Normal file
163
client/ui/qml/Pages/PageQrDecoder.qml
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import PageEnum 1.0
|
||||
import QtMultimedia 5.5
|
||||
import QZXing 3.2
|
||||
|
||||
import "./"
|
||||
import "../Controls"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
id: root
|
||||
page: PageEnum.QrDecoder
|
||||
logic: QrDecoderLogic
|
||||
|
||||
onDeactivated: {
|
||||
console.debug("Stopping QR decoder")
|
||||
loader.sourceComponent = undefined
|
||||
}
|
||||
|
||||
BackButton {
|
||||
}
|
||||
Caption {
|
||||
id: caption
|
||||
text: qsTr("Import configuration")
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: QrDecoderLogic
|
||||
function onStartDecode() {
|
||||
console.debug("Starting QR decoder")
|
||||
loader.sourceComponent = component
|
||||
}
|
||||
function onStopDecode() {
|
||||
console.debug("Stopping QR decoder")
|
||||
loader.sourceComponent = undefined
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
|
||||
anchors.top: caption.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
|
||||
Component {
|
||||
id: component
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
Camera
|
||||
{
|
||||
id:camera
|
||||
focus {
|
||||
focusMode: CameraFocus.FocusContinuous
|
||||
focusPointMode: CameraFocus.FocusPointAuto
|
||||
}
|
||||
}
|
||||
|
||||
VideoOutput
|
||||
{
|
||||
id: videoOutput
|
||||
source: camera
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
autoOrientation: true
|
||||
fillMode: VideoOutput.PreserveAspectFit
|
||||
filters: [ zxingFilter ]
|
||||
|
||||
|
||||
Rectangle {
|
||||
color: "black"
|
||||
opacity: 0.5
|
||||
width: videoOutput.contentRect.width *0.15
|
||||
height: videoOutput.contentRect.height
|
||||
x: (videoOutput.width - videoOutput.contentRect.width)/2
|
||||
anchors.verticalCenter: videoOutput.verticalCenter
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "black"
|
||||
opacity: 0.5
|
||||
width: videoOutput.contentRect.width *0.15
|
||||
height: videoOutput.contentRect.height
|
||||
x: videoOutput.width/2 + videoOutput.contentRect.width/2 - videoOutput.contentRect.width *0.15
|
||||
anchors.verticalCenter: videoOutput.verticalCenter
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "black"
|
||||
opacity: 0.5
|
||||
width: videoOutput.contentRect.width *0.7
|
||||
height: videoOutput.contentRect.height *0.15
|
||||
x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width *0.15
|
||||
y: (videoOutput.height - videoOutput.contentRect.height)/2
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "black"
|
||||
opacity: 0.5
|
||||
width: videoOutput.contentRect.width *0.7
|
||||
height: videoOutput.contentRect.height *0.15
|
||||
x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width *0.15
|
||||
y: videoOutput.height/2 + videoOutput.contentRect.height/2 - videoOutput.contentRect.height *0.15
|
||||
}
|
||||
|
||||
LabelType {
|
||||
width: parent.width
|
||||
text: qsTr("Decoded QR chunks " + QrDecoderLogic.receivedChunksCount + "/" + QrDecoderLogic.totalChunksCount)
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
visible: QrDecoderLogic.totalChunksCount > 0
|
||||
anchors.horizontalCenter: videoOutput.horizontalCenter
|
||||
y: videoOutput.height/2 + videoOutput.contentRect.height/2
|
||||
}
|
||||
}
|
||||
|
||||
QZXingFilter
|
||||
{
|
||||
id: zxingFilter
|
||||
orientation: videoOutput.orientation
|
||||
captureRect: {
|
||||
// setup bindings
|
||||
videoOutput.contentRect;
|
||||
videoOutput.sourceRect;
|
||||
return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
|
||||
0.15, 0.15, 0.7, 0.7 //0, 0, 1.0, 1.0
|
||||
)));
|
||||
}
|
||||
|
||||
decoder {
|
||||
enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
||||
|
||||
onTagFound: {
|
||||
QrDecoderLogic.onDetectedQrCode(tag)
|
||||
}
|
||||
|
||||
tryHarder: true
|
||||
}
|
||||
|
||||
property int framesDecoded: 0
|
||||
property real timePerFrameDecode: 0
|
||||
|
||||
onDecodingFinished:
|
||||
{
|
||||
timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
|
||||
framesDecoded++;
|
||||
if(succeeded)
|
||||
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ PageBase {
|
|||
|
||||
BackButton {
|
||||
id: back_from_start
|
||||
visible: pageLoader.depth > 1
|
||||
}
|
||||
|
||||
Caption {
|
||||
|
|
@ -103,12 +104,43 @@ PageBase {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: 210
|
||||
anchors.top: lineEdit_start_existing_code.bottom
|
||||
anchors.topMargin: 40
|
||||
anchors.topMargin: 10
|
||||
text: qsTr("Connect")
|
||||
onClicked: {
|
||||
StartPageLogic.onPushButtonImport()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BlueButtonType {
|
||||
id: qr_code_import_open
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: new_sever_import.bottom
|
||||
anchors.topMargin: 40
|
||||
|
||||
text: qsTr("Open file")
|
||||
visible: StartPageLogic.pushButtonConnectVisible
|
||||
onClicked: {
|
||||
StartPageLogic.onPushButtonImportOpenFile()
|
||||
}
|
||||
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||
}
|
||||
|
||||
BlueButtonType {
|
||||
id: qr_code_import
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: qr_code_import_open.bottom
|
||||
anchors.topMargin: 10
|
||||
|
||||
text: qsTr("Scan QR code")
|
||||
visible: StartPageLogic.pushButtonConnectVisible
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.QrDecoder)
|
||||
}
|
||||
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -224,8 +256,6 @@ PageBase {
|
|||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
|
||||
|
||||
BlueButtonType {
|
||||
id: new_sever_connect
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ PageBase {
|
|||
height: width
|
||||
|
||||
visible: !VpnLogic.pushButtonConnectVisible
|
||||
paused: VpnLogic.pushButtonConnectVisible
|
||||
paused: VpnLogic.pushButtonConnectVisible && !root.pageActive
|
||||
//VisibleBehavior on visible { }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ PageShareProtocolBase {
|
|||
contentHeight: content.height + 20
|
||||
clip: true
|
||||
|
||||
Behavior on contentY{
|
||||
NumberAnimation {
|
||||
duration: 300
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
enabled: logic.pageEnabled
|
||||
|
|
@ -73,6 +80,7 @@ New encryption keys pair will be generated.")
|
|||
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
|
||||
enabled = true
|
||||
genConfigProcess = false
|
||||
fl.contentY = tfShareCode.mapToItem(fl.contentItem, 0, 0).y
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,19 +122,32 @@ New encryption keys pair will be generated.")
|
|||
}
|
||||
|
||||
Image {
|
||||
id: label_share_code
|
||||
id: image_share_code
|
||||
Layout.topMargin: 20
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: width
|
||||
smooth: false
|
||||
source: ShareConnectionLogic.shareAmneziaQrCodeText
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length > 0
|
||||
|
||||
Timer {
|
||||
property int idx: 0
|
||||
interval: 1000
|
||||
running: root.pageActive && ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
idx++
|
||||
if (idx >= ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength) {
|
||||
idx = 0
|
||||
}
|
||||
image_share_code.source = ShareConnectionLogic.shareAmneziaQrCodeTextSeries[idx]
|
||||
}
|
||||
}
|
||||
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
|
||||
}
|
||||
|
||||
LabelType {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Config too long to be displayed as QR code")
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length == 0 && tfShareCode.textArea.length > 0
|
||||
text: qsTr("Scan QR code using AmneziaVPN mobile")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ Window {
|
|||
UiLogic.onCloseWindow()
|
||||
}
|
||||
|
||||
//flags: Qt.FramelessWindowHint
|
||||
title: "AmneziaVPN"
|
||||
|
||||
function gotoPage(type, page, reset, slide) {
|
||||
|
|
@ -41,6 +40,9 @@ Window {
|
|||
|
||||
console.debug("QML gotoPage " + type + " " + page + " " + p_obj)
|
||||
|
||||
if (pageLoader.depth > 0) {
|
||||
pageLoader.currentItem.deactivated()
|
||||
}
|
||||
|
||||
if (slide) {
|
||||
pageLoader.push(p_obj, {}, StackView.PushTransition)
|
||||
|
|
@ -59,10 +61,15 @@ Window {
|
|||
if (pageLoader.depth <= 1) {
|
||||
return
|
||||
}
|
||||
pageLoader.currentItem.deactivated()
|
||||
pageLoader.pop()
|
||||
}
|
||||
|
||||
function set_start_page(page, slide) {
|
||||
if (pageLoader.depth > 0) {
|
||||
pageLoader.currentItem.deactivated()
|
||||
}
|
||||
|
||||
pageLoader.clear()
|
||||
if (slide) {
|
||||
pageLoader.push(pages[page], {}, StackView.PushTransition)
|
||||
|
|
@ -104,8 +111,6 @@ Window {
|
|||
color: "white"
|
||||
}
|
||||
|
||||
//PageShareProtoAmnezia {}
|
||||
|
||||
StackView {
|
||||
id: pageLoader
|
||||
y: GC.isDesktop() ? titleBar.height : 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue