-
Notifications
You must be signed in to change notification settings - Fork 0
qml qt6: use ZXing-based camera #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
|
|
||
| <FrameLayout | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent"> | ||
|
|
||
| <FrameLayout | ||
| android:id="@+id/content_frame" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/hint" | ||
| android:layout_gravity="center|top" | ||
| android:text="Scan a QR code." | ||
| android:layout_width="wrap_content" | ||
| android:textColor="#ffffff" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/paste_btn" | ||
| android:layout_gravity="center|bottom" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="Paste from clipboard" /> | ||
|
|
||
| </FrameLayout> |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ Item { | |
|
|
||
| property string title: Daemon.currentWallet ? Daemon.currentWallet.name : qsTr('no wallet loaded') | ||
|
|
||
| property var _sendDialog | ||
| property string _intentUri | ||
|
|
||
| property string _request_amount | ||
|
|
@@ -34,21 +33,33 @@ Item { | |
| } | ||
|
|
||
| function openSendDialog() { | ||
| _sendDialog = sendDialog.createObject(mainView, {invoiceParser: invoiceParser}) | ||
| _sendDialog.open() | ||
| } | ||
|
|
||
| function closeSendDialog() { | ||
| if (_sendDialog) { | ||
| _sendDialog.doClose() | ||
| _sendDialog = null | ||
| } | ||
| var scanner = app.scanDialog.createObject(mainView, { | ||
| hint: qsTr('Scan an Invoice, an Address, an LNURL-pay, a PSBT or a Channel backup'), | ||
| }) | ||
| scanner.onFound.connect(function() { | ||
| var data = scanner.scanData | ||
| data = data.trim() | ||
| if (bitcoin.isRawTx(data)) { | ||
| app.stack.push(Qt.resolvedUrl('TxDetails.qml'), { rawtx: data }) | ||
| } else if (Daemon.currentWallet.isValidChannelBackup(data)) { | ||
| var dialog = app.messageDialog.createObject(app, { | ||
| title: qsTr('Import Channel backup?'), | ||
| yesno: true | ||
| }) | ||
| dialog.accepted.connect(function() { | ||
| Daemon.currentWallet.importChannelBackup(data) | ||
| }) | ||
| dialog.open() | ||
| } else { | ||
| invoiceParser.recipient = data | ||
| } | ||
| //scanner.destroy() // TODO | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need an explicit destroy somewhere to avoid a memleak?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
However, you don't really need to wrap the scanner in a Qt object and manage the lifecycle. Since there's at most 1 scanner active, you can basically also spawn the Activity from a
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last part would be something like this:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes I already had something like that a refactor prior, e.g. see
But just to confirm, if we do use this |
||
| }) | ||
| scanner.open() | ||
| } | ||
|
|
||
| function restartSendDialog() { | ||
| if (_sendDialog) { | ||
| _sendDialog.restart() | ||
| } | ||
| //openSendDialog() // note: ~infinite-loop on non-android due to directly pasting from clipboard | ||
| } | ||
|
|
||
| function showExport(data, helptext) { | ||
|
|
@@ -287,7 +298,6 @@ Item { | |
| } | ||
| } | ||
| onValidationSuccess: { | ||
| closeSendDialog() | ||
| var dialog = invoiceDialog.createObject(app, { | ||
| invoice: invoiceParser, | ||
| payImmediately: invoiceParser.isLnurlPay | ||
|
|
@@ -299,7 +309,6 @@ Item { | |
| } | ||
|
|
||
| onLnurlRetrieved: { | ||
| closeSendDialog() | ||
| var dialog = lnurlPayDialog.createObject(app, { | ||
| invoiceParser: invoiceParser | ||
| }) | ||
|
|
@@ -314,6 +323,10 @@ Item { | |
| } | ||
| } | ||
|
|
||
| Bitcoin { | ||
| id: bitcoin | ||
| } | ||
|
|
||
| Connections { | ||
| target: AppController | ||
| function onUriReceived(uri) { | ||
|
|
@@ -419,34 +432,6 @@ Item { | |
| } | ||
| } | ||
|
|
||
| Component { | ||
| id: sendDialog | ||
| SendDialog { | ||
| width: parent.width | ||
| height: parent.height | ||
|
|
||
| onTxFound: { | ||
| app.stack.push(Qt.resolvedUrl('TxDetails.qml'), { rawtx: data }) | ||
| close() | ||
| } | ||
| onChannelBackupFound: { | ||
| var dialog = app.messageDialog.createObject(app, { | ||
| title: qsTr('Import Channel backup?'), | ||
| yesno: true | ||
| }) | ||
| dialog.accepted.connect(function() { | ||
| Daemon.currentWallet.importChannelBackup(data) | ||
| close() | ||
| }) | ||
| dialog.rejected.connect(function() { | ||
| close() | ||
| }) | ||
| dialog.open() | ||
| } | ||
| onClosed: destroy() | ||
| } | ||
| } | ||
|
|
||
| function createRequest(lightning_only, reuse_address) { | ||
| var qamt = Config.unitsToSats(_request_amount) | ||
| Daemon.currentWallet.createRequest(qamt, _request_description, _request_expiry, lightning_only, reuse_address) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(temporary)