From 855a98c04501eede6dd3553b1acc5a8d036af743 Mon Sep 17 00:00:00 2001 From: mjk Date: Fri, 18 Feb 2022 21:41:28 +0000 Subject: OMEMO: Make QR code fixed-resolution and the quiet zone ISO-conformant --- plugins/omemo/src/ui/contact_details_dialog.vala | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'plugins/omemo/src') diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala index b268cc13..18884784 100644 --- a/plugins/omemo/src/ui/contact_details_dialog.vala +++ b/plugins/omemo/src/ui/contact_details_dialog.vala @@ -92,20 +92,14 @@ public class ContactDetailsDialog : Gtk.Dialog { copy_button.clicked.connect(() => {Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length);}); int sid = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id]; - Pixbuf qr_pixbuf = new QRcode(@"xmpp:$(account.bare_jid)?omemo-sid-$(sid)=$(fingerprint)", 2).to_pixbuf(); - qr_pixbuf = qr_pixbuf.scale_simple(150, 150, InterpType.NEAREST); - - Pixbuf pixbuf = new Pixbuf( - qr_pixbuf.colorspace, - qr_pixbuf.has_alpha, - qr_pixbuf.bits_per_sample, - 170, - 170 - ); - pixbuf.fill(uint32.MAX); - qr_pixbuf.copy_area(0, 0, 150, 150, pixbuf, 10, 10); - - qrcode_image.set_from_pixbuf(pixbuf); + + const int QUIET_ZONE_MODULES = 4; // MUST be at least 4 + const int MODULE_SIZE_PX = 4; // arbitrary + Pixbuf qr_pixbuf = new QRcode(@"xmpp:$(account.bare_jid)?omemo-sid-$(sid)=$(fingerprint)", 2).to_pixbuf(MODULE_SIZE_PX); + qrcode_image.set_from_pixbuf(qr_pixbuf); + qrcode_image.margin = QUIET_ZONE_MODULES*MODULE_SIZE_PX; + qrcode_popover.get_style_context().add_class("qrcode-container"); + show_qrcode_button.clicked.connect(qrcode_popover.popup); } -- cgit v1.2.3-70-g09d2