|
|
|
|
@ -5,35 +5,35 @@ Item {
|
|
|
|
|
id: root |
|
|
|
|
property string qrdata |
|
|
|
|
property bool render: true // init to false, then set true if render needs delay |
|
|
|
|
property var qrprops: QRIP.getDimensions(qrdata) |
|
|
|
|
property bool enableToggleText: false // if true, clicking the QR code shows the encoded text |
|
|
|
|
property bool isTextState: false // internal state, if the above is enabled |
|
|
|
|
|
|
|
|
|
property bool enable_toggle_text: false // if true, clicking the QR code shows the encoded text |
|
|
|
|
property bool is_in_text_state: false // internal state, if the above is enabled |
|
|
|
|
property var _qrprops: QRIP.getDimensions(qrdata) |
|
|
|
|
|
|
|
|
|
width: r.width |
|
|
|
|
height: r.height |
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
id: r |
|
|
|
|
width: qrprops.modules * qrprops.box_size |
|
|
|
|
width: _qrprops.modules * _qrprops.box_size |
|
|
|
|
height: width |
|
|
|
|
color: 'white' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Image { |
|
|
|
|
source: qrdata && render ? 'image://qrgen/' + qrdata : '' |
|
|
|
|
visible: !is_in_text_state |
|
|
|
|
visible: !isTextState |
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
visible: root.render && qrprops.valid |
|
|
|
|
visible: root.render && _qrprops.valid |
|
|
|
|
color: 'white' |
|
|
|
|
x: (parent.width - width) / 2 |
|
|
|
|
y: (parent.height - height) / 2 |
|
|
|
|
width: qrprops.icon_modules * qrprops.box_size |
|
|
|
|
height: qrprops.icon_modules * qrprops.box_size |
|
|
|
|
width: _qrprops.icon_modules * _qrprops.box_size |
|
|
|
|
height: _qrprops.icon_modules * _qrprops.box_size |
|
|
|
|
|
|
|
|
|
Image { |
|
|
|
|
visible: qrprops.valid |
|
|
|
|
visible: _qrprops.valid |
|
|
|
|
source: '../../../icons/electrum.png' |
|
|
|
|
x: 1 |
|
|
|
|
y: 1 |
|
|
|
|
@ -43,14 +43,14 @@ Item {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Label { |
|
|
|
|
visible: !qrprops.valid |
|
|
|
|
visible: !_qrprops.valid |
|
|
|
|
text: qsTr('Data too big for QR') |
|
|
|
|
anchors.centerIn: parent |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Label { |
|
|
|
|
visible: is_in_text_state |
|
|
|
|
visible: isTextState |
|
|
|
|
text: qrdata |
|
|
|
|
wrapMode: Text.WrapAnywhere |
|
|
|
|
elide: Text.ElideRight |
|
|
|
|
@ -58,6 +58,10 @@ Item {
|
|
|
|
|
horizontalAlignment: Qt.AlignHCenter |
|
|
|
|
verticalAlignment: Qt.AlignVCenter |
|
|
|
|
color: 'black' |
|
|
|
|
font.family: FixedFont |
|
|
|
|
font.pixelSize: text.length < 64 |
|
|
|
|
? constants.fontSizeXLarge |
|
|
|
|
: constants.fontSizeMedium |
|
|
|
|
width: r.width |
|
|
|
|
height: r.height |
|
|
|
|
} |
|
|
|
|
@ -65,8 +69,8 @@ Item {
|
|
|
|
|
MouseArea { |
|
|
|
|
anchors.fill: parent |
|
|
|
|
onClicked: { |
|
|
|
|
if (enable_toggle_text) { |
|
|
|
|
root.is_in_text_state = !root.is_in_text_state |
|
|
|
|
if (enableToggleText) { |
|
|
|
|
root.isTextState = !root.isTextState |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|