Only ask for URL opening confirmation for QR codes

BUG: 484870
This commit is contained in:
Tobias Fella
2024-04-01 16:42:07 +02:00
parent 6cfab9e3ea
commit bb776d5c2b
2 changed files with 8 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ Kirigami.Page {
formats: Prison.Format.QRCode | Prison.Format.Aztec formats: Prison.Format.QRCode | Prison.Format.Aztec
onResultChanged: { onResultChanged: {
if (result.text.length > 0 && result.text != scanner.previousText) { if (result.text.length > 0 && result.text != scanner.previousText) {
RoomManager.resolveResource(result.text, ""); RoomManager.resolveResource(result.text, "qr");
scanner.previousText = result.text; scanner.previousText = result.text;
} }
root.closeDialog(); root.closeDialog();

View File

@@ -11,6 +11,7 @@
#include "neochatconnection.h" #include "neochatconnection.h"
#include "neochatroom.h" #include "neochatroom.h"
#include "spacehierarchycache.h" #include "spacehierarchycache.h"
#include "urlhelper.h"
#include <KLocalizedString> #include <KLocalizedString>
#include <QDesktopServices> #include <QDesktopServices>
@@ -124,6 +125,11 @@ void RoomManager::resolveResource(const QString &idOrUri, const QString &action)
return; return;
} }
if (uri.type() == Uri::NonMatrix && action == "qr"_ls) {
Q_EMIT externalUrl(uri.toUrl());
return;
}
if (uri.type() != Uri::NonMatrix) { if (uri.type() != Uri::NonMatrix) {
if (!m_connection) { if (!m_connection) {
return; return;
@@ -325,7 +331,7 @@ void RoomManager::knockRoom(Quotient::Connection *account, const QString &roomAl
bool RoomManager::visitNonMatrix(const QUrl &url) bool RoomManager::visitNonMatrix(const QUrl &url)
{ {
Q_EMIT externalUrl(url); UrlHelper().openUrl(url);
return true; return true;
} }