import QtQuick 2.0 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QZXing 3.1 Dialog { id: control property string _shareUrl property string _compName parent: Overlay.overlay x: (parent.width - width) * 0.5 y: (parent.height - height) * 0.5 modal: true title: "Share these results" onClosed: { shareComponentLoader.sourceComponent = null } contentItem: Loader { id: shareComponentLoader asynchronous: false sourceComponent: null } Component { id: shareComponent StackLayout { id: stackLayout currentIndex: 0 RowLayout { id: menuRow Repeater { id: buttonRepeater property var buttons: [ ["\uf0c1", "Link", serverConn.shareResultsAsUrl], ["\uf029", "QR-code", function() { stackLayout.currentIndex = 1 } ], ["\uf1c1", "Poster", serverConn.shareResultsAsPoster], ] model: buttons delegate: Button { flat: true font.family: fa5solid.name text: "" + modelData[0] + "

" + modelData[1] + " " onClicked: buttonRepeater.buttons[index][2](_shareUrl, _compName) } } } Image { id: qrCodeImage property int size: stackLayout.currentIndex === 1 ? (app.landscape() ? app.height * 0.8 : app.width * 0.8):menuRow.height Layout.preferredHeight: size Layout.preferredWidth: size sourceSize.width: size sourceSize.height: size fillMode: Image.PreserveAspectFit source: "image://QZXing/encode/" + _shareUrl + "?border=true&correctionLevel=H" Behavior on size { NumberAnimation { duration: 200 } } } } } function appear(shareUrl, compName) { _shareUrl = shareUrl _compName = compName shareComponentLoader.sourceComponent = shareComponent control.open() } }