From 81e5061831a9d06c2f45223711b79588001b3360 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 9 Sep 2025 17:11:11 +0200 Subject: [PATCH] Fix-up QR code scanning actions I cleaned up how resolving QR codes work, I made sure to test both user and room links and everything works great. A more awkward bug I fixed is a workaround around a quirk in Kirigami.Dialog, but actually regresses QR codes. Because the QR code scanner is currently an extra window (at least on desktop) the UserDetailDialog will reparent itself to the soon-to-be-destroyed scanner window. --- src/app/qml/Main.qml | 6 +++++- src/app/roommanager.cpp | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/qml/Main.qml b/src/app/qml/Main.qml index 6c5b0444e..c2cd7b98b 100644 --- a/src/app/qml/Main.qml +++ b/src/app/qml/Main.qml @@ -358,7 +358,11 @@ Kirigami.ApplicationWindow { user: user, connection: root.connection, }) as UserDetailDialog; - dialog.parent = QmlUtils.focusedWindowItem(); // Kirigami Dialogs overwrite the parent, so we need to set it again + // FIXME: The reason why we don't want the focusedWindowItem for the room null case (aka QR codes) is because it will parent it to the soon-to-be-destroyed window item. + // But this won't be a problem if we turn it into a Kirigami.Dialog or some other in-scene item, which it really should be. + if (room != null) { + dialog.parent = QmlUtils.focusedWindowItem(); // Kirigami Dialogs overwrite the parent, so we need to set it again + } dialog.open(); } diff --git a/src/app/roommanager.cpp b/src/app/roommanager.cpp index f77fc1e79..5ef75a6f9 100644 --- a/src/app/roommanager.cpp +++ b/src/app/roommanager.cpp @@ -209,9 +209,16 @@ void RoomManager::resolveResource(Uri uri, const QString &action) return; } - if (uri.type() == Uri::NonMatrix && action == "qr"_L1) { - Q_EMIT externalUrl(uri.toUrl()); - return; + if (action == "qr"_L1) { + if (uri.type() == Uri::NonMatrix) { + Q_EMIT externalUrl(uri.toUrl()); + return; + } + if (uri.type() != Uri::UserId) { + uri.setAction(QStringLiteral("join")); + } else { + uri.setAction(action); + } } // For matrix URIs: