QRCodeReader for iOS
This commit is contained in:
parent
6744dce57e
commit
9aabe7c72e
7 changed files with 194 additions and 114 deletions
|
@ -75,7 +75,8 @@ HEADERS += \
|
||||||
logger.h \
|
logger.h \
|
||||||
loghandler.h \
|
loghandler.h \
|
||||||
loglevel.h \
|
loglevel.h \
|
||||||
constants.h
|
constants.h \
|
||||||
|
platforms/ios/QRCodeReader.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
configurators/cloak_configurator.cpp \
|
configurators/cloak_configurator.cpp \
|
||||||
|
@ -126,8 +127,8 @@ SOURCES += \
|
||||||
vpnconnection.cpp \
|
vpnconnection.cpp \
|
||||||
protocols/vpnprotocol.cpp \
|
protocols/vpnprotocol.cpp \
|
||||||
logger.cpp \
|
logger.cpp \
|
||||||
loghandler.cpp
|
loghandler.cpp \
|
||||||
|
platforms/ios/QRCodeReader.cpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources.qrc
|
resources.qrc
|
||||||
|
@ -296,10 +297,12 @@ ios {
|
||||||
platforms/ios/bigint.h \
|
platforms/ios/bigint.h \
|
||||||
platforms/ios/bigintipv6addr.h \
|
platforms/ios/bigintipv6addr.h \
|
||||||
platforms/ios/ipaddress.h \
|
platforms/ios/ipaddress.h \
|
||||||
platforms/ios/ipaddressrange.h \
|
platforms/ios/ipaddressrange.h
|
||||||
platforms/ios/QRCodeReader.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES -= \
|
||||||
|
platforms/ios/QRCodeReader.cpp
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
protocols/ios_vpnprotocol.mm \
|
protocols/ios_vpnprotocol.mm \
|
||||||
platforms/ios/iosnotificationhandler.mm \
|
platforms/ios/iosnotificationhandler.mm \
|
||||||
platforms/ios/json.cpp \
|
platforms/ios/json.cpp \
|
||||||
|
|
14
client/platforms/ios/QRCodeReader.cpp
Normal file
14
client/platforms/ios/QRCodeReader.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "QRCodeReader.h"
|
||||||
|
|
||||||
|
QRCodeReader::QRCodeReader()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect QRCodeReader::cameraSize() {
|
||||||
|
return QRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QRCodeReader::startReading() {}
|
||||||
|
void QRCodeReader::stopReading() {}
|
||||||
|
void QRCodeReader::setCameraSize(QRect) {};
|
|
@ -157,5 +157,6 @@
|
||||||
<file>images/svg/control_point_black_24dp.svg</file>
|
<file>images/svg/control_point_black_24dp.svg</file>
|
||||||
<file>images/svg/settings_suggest_black_24dp.svg</file>
|
<file>images/svg/settings_suggest_black_24dp.svg</file>
|
||||||
<file>ui/qml/Controls/SvgButtonType.qml</file>
|
<file>ui/qml/Controls/SvgButtonType.qml</file>
|
||||||
|
<file>ui/qml/Pages/PageQrDecoderIos.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -24,7 +24,7 @@ enum class Page {Start = 0, NewServer, NewServerProtocols, Vpn,
|
||||||
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguringProgress,
|
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguringProgress,
|
||||||
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
||||||
ServerContainers, ServersList, ShareConnection, Sites,
|
ServerContainers, ServersList, ShareConnection, Sites,
|
||||||
ProtocolSettings, ProtocolShare, QrDecoder, About};
|
ProtocolSettings, ProtocolShare, QrDecoder, QrDecoderIos, About};
|
||||||
Q_ENUM_NS(Page)
|
Q_ENUM_NS(Page)
|
||||||
|
|
||||||
static void declareQmlPageEnum() {
|
static void declareQmlPageEnum() {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import QtQuick.Controls 2.12
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
import QtMultimedia 5.5
|
import QtMultimedia 5.5
|
||||||
import QZXing 3.2
|
import QZXing 3.2
|
||||||
import QRCodeReader 1.0
|
|
||||||
|
|
||||||
import "./"
|
import "./"
|
||||||
import "../Controls"
|
import "../Controls"
|
||||||
|
@ -27,7 +26,7 @@ PageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: QrDecoderLogic
|
target: Qt.platform.os != "ios" ? QrDecoderLogic : nil
|
||||||
function onStartDecode() {
|
function onStartDecode() {
|
||||||
console.debug("Starting QR decoder")
|
console.debug("Starting QR decoder")
|
||||||
loader.sourceComponent = component
|
loader.sourceComponent = component
|
||||||
|
@ -53,125 +52,108 @@ PageBase {
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
QRCodeReader {
|
Camera
|
||||||
id: qrCodeReader
|
{
|
||||||
|
id:camera
|
||||||
onCodeReaded: {
|
focus {
|
||||||
QrDecoderLogic.onDetectedQrCode(code)
|
focusMode: CameraFocus.FocusContinuous
|
||||||
|
focusPointMode: CameraFocus.FocusPointAuto
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
qrCodeReader.setCameraSize(Qt.rect(loader.x,
|
|
||||||
loader.y,
|
|
||||||
loader.width,
|
|
||||||
loader.height))
|
|
||||||
qrCodeReader.startReading()
|
|
||||||
}
|
|
||||||
Component.onDestruction: qrCodeReader.stopReading()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Camera
|
VideoOutput
|
||||||
// {
|
{
|
||||||
// id:camera
|
id: videoOutput
|
||||||
// focus {
|
source: camera
|
||||||
// focusMode: CameraFocus.FocusContinuous
|
anchors.top: parent.top
|
||||||
// focusPointMode: CameraFocus.FocusPointAuto
|
anchors.bottom: parent.bottom
|
||||||
// }
|
anchors.left: parent.left
|
||||||
// }
|
anchors.right: parent.right
|
||||||
|
autoOrientation: true
|
||||||
// VideoOutput
|
fillMode: VideoOutput.PreserveAspectFit
|
||||||
// {
|
filters: [ zxingFilter ]
|
||||||
// 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 {
|
Rectangle {
|
||||||
// color: "black"
|
color: "black"
|
||||||
// opacity: 0.5
|
opacity: 0.5
|
||||||
// width: videoOutput.contentRect.width * 0.15
|
width: videoOutput.contentRect.width * 0.15
|
||||||
// height: videoOutput.contentRect.height
|
height: videoOutput.contentRect.height
|
||||||
// x: (videoOutput.width - videoOutput.contentRect.width)/2
|
x: (videoOutput.width - videoOutput.contentRect.width)/2
|
||||||
// anchors.verticalCenter: videoOutput.verticalCenter
|
anchors.verticalCenter: videoOutput.verticalCenter
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Rectangle {
|
Rectangle {
|
||||||
// color: "black"
|
color: "black"
|
||||||
// opacity: 0.5
|
opacity: 0.5
|
||||||
// width: videoOutput.contentRect.width * 0.15
|
width: videoOutput.contentRect.width * 0.15
|
||||||
// height: videoOutput.contentRect.height
|
height: videoOutput.contentRect.height
|
||||||
// x: videoOutput.width/2 + videoOutput.contentRect.width/2 - videoOutput.contentRect.width * 0.15
|
x: videoOutput.width/2 + videoOutput.contentRect.width/2 - videoOutput.contentRect.width * 0.15
|
||||||
// anchors.verticalCenter: videoOutput.verticalCenter
|
anchors.verticalCenter: videoOutput.verticalCenter
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Rectangle {
|
Rectangle {
|
||||||
// color: "black"
|
color: "black"
|
||||||
// opacity: 0.5
|
opacity: 0.5
|
||||||
// width: videoOutput.contentRect.width * 0.7
|
width: videoOutput.contentRect.width * 0.7
|
||||||
// height: videoOutput.contentRect.height * 0.15
|
height: videoOutput.contentRect.height * 0.15
|
||||||
// x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width * 0.15
|
x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width * 0.15
|
||||||
// y: (videoOutput.height - videoOutput.contentRect.height)/2
|
y: (videoOutput.height - videoOutput.contentRect.height)/2
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Rectangle {
|
Rectangle {
|
||||||
// color: "black"
|
color: "black"
|
||||||
// opacity: 0.5
|
opacity: 0.5
|
||||||
// width: videoOutput.contentRect.width * 0.7
|
width: videoOutput.contentRect.width * 0.7
|
||||||
// height: videoOutput.contentRect.height * 0.15
|
height: videoOutput.contentRect.height * 0.15
|
||||||
// x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width * 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
|
y: videoOutput.height/2 + videoOutput.contentRect.height/2 - videoOutput.contentRect.height * 0.15
|
||||||
// }
|
}
|
||||||
|
|
||||||
// LabelType {
|
LabelType {
|
||||||
// width: parent.width
|
width: parent.width
|
||||||
// text: qsTr("Decoded QR chunks " + QrDecoderLogic.receivedChunksCount + "/" + QrDecoderLogic.totalChunksCount)
|
text: qsTr("Decoded QR chunks " + QrDecoderLogic.receivedChunksCount + "/" + QrDecoderLogic.totalChunksCount)
|
||||||
// horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
// visible: QrDecoderLogic.totalChunksCount > 0
|
visible: QrDecoderLogic.totalChunksCount > 0
|
||||||
// anchors.horizontalCenter: videoOutput.horizontalCenter
|
anchors.horizontalCenter: videoOutput.horizontalCenter
|
||||||
// y: videoOutput.height/2 + videoOutput.contentRect.height/2
|
y: videoOutput.height/2 + videoOutput.contentRect.height/2
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// QZXingFilter
|
QZXingFilter
|
||||||
// {
|
{
|
||||||
// id: zxingFilter
|
id: zxingFilter
|
||||||
// orientation: videoOutput.orientation
|
orientation: videoOutput.orientation
|
||||||
// captureRect: {
|
captureRect: {
|
||||||
// // setup bindings
|
// setup bindings
|
||||||
// videoOutput.contentRect;
|
videoOutput.contentRect;
|
||||||
// videoOutput.sourceRect;
|
videoOutput.sourceRect;
|
||||||
// return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
|
return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
|
||||||
// 0.15, 0.15, 0.7, 0.7 //0, 0, 1.0, 1.0
|
0.15, 0.15, 0.7, 0.7 //0, 0, 1.0, 1.0
|
||||||
// )));
|
)));
|
||||||
// }
|
}
|
||||||
|
|
||||||
// decoder {
|
decoder {
|
||||||
// enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
||||||
|
|
||||||
// onTagFound: {
|
onTagFound: {
|
||||||
// QrDecoderLogic.onDetectedQrCode(tag)
|
QrDecoderLogic.onDetectedQrCode(tag)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// tryHarder: true
|
tryHarder: true
|
||||||
// }
|
}
|
||||||
|
|
||||||
// property int framesDecoded: 0
|
property int framesDecoded: 0
|
||||||
// property real timePerFrameDecode: 0
|
property real timePerFrameDecode: 0
|
||||||
|
|
||||||
// onDecodingFinished:
|
onDecodingFinished:
|
||||||
// {
|
{
|
||||||
// timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
|
timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
|
||||||
// framesDecoded++;
|
framesDecoded++;
|
||||||
// if(succeeded)
|
if(succeeded)
|
||||||
// console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
|
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
76
client/ui/qml/Pages/PageQrDecoderIos.qml
Normal file
76
client/ui/qml/Pages/PageQrDecoderIos.qml
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
import PageEnum 1.0
|
||||||
|
import QRCodeReader 1.0
|
||||||
|
|
||||||
|
import "./"
|
||||||
|
import "../Controls"
|
||||||
|
import "../Config"
|
||||||
|
|
||||||
|
PageBase {
|
||||||
|
id: root
|
||||||
|
page: PageEnum.QrDecoderIos
|
||||||
|
logic: QrDecoderLogic
|
||||||
|
|
||||||
|
onDeactivated: {
|
||||||
|
console.debug("Stopping QR decoder")
|
||||||
|
loader.sourceComponent = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
BackButton {
|
||||||
|
}
|
||||||
|
Caption {
|
||||||
|
id: caption
|
||||||
|
text: qsTr("Import configuration")
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Qt.platform.os == "ios" ? QrDecoderLogic : nil
|
||||||
|
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
|
||||||
|
|
||||||
|
QRCodeReader {
|
||||||
|
id: qrCodeReader
|
||||||
|
|
||||||
|
onCodeReaded: {
|
||||||
|
QrDecoderLogic.onDetectedQrCode(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
qrCodeReader.setCameraSize(Qt.rect(loader.x,
|
||||||
|
loader.y,
|
||||||
|
loader.width,
|
||||||
|
loader.height))
|
||||||
|
qrCodeReader.startReading()
|
||||||
|
}
|
||||||
|
Component.onDestruction: qrCodeReader.stopReading()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -135,7 +135,11 @@ PageBase {
|
||||||
text: qsTr("Scan QR code")
|
text: qsTr("Scan QR code")
|
||||||
visible: StartPageLogic.pushButtonConnectVisible
|
visible: StartPageLogic.pushButtonConnectVisible
|
||||||
onClicked: {
|
onClicked: {
|
||||||
UiLogic.goToPage(PageEnum.QrDecoder)
|
if (Qt.platform.os == "ios") {
|
||||||
|
UiLogic.goToPage(PageEnum.QrDecoderIos)
|
||||||
|
} else {
|
||||||
|
UiLogic.goToPage(PageEnum.QrDecoder)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
enabled: StartPageLogic.pushButtonConnectEnabled
|
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue