summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt14
-rw-r--r--im.nheko.Nheko.yaml2
-rw-r--r--resources/qml/MessageView.qml15
-rw-r--r--resources/qml/Reactions.qml1
-rw-r--r--resources/qml/RoomList.qml5
-rw-r--r--resources/qml/Root.qml12
-rw-r--r--resources/qml/components/PowerlevelIndicator.qml42
-rw-r--r--resources/qml/dialogs/FallbackAuthDialog.qml63
-rw-r--r--resources/qml/dialogs/RoomMembers.qml37
-rw-r--r--src/ChatPage.cpp2
-rw-r--r--src/FallbackAuth.cpp29
-rw-r--r--src/FallbackAuth.h32
-rw-r--r--src/UserSettingsPage.h9
-rw-r--r--src/dialogs/FallbackAuth.cpp75
-rw-r--r--src/dialogs/FallbackAuth.h30
-rw-r--r--src/encryption/VerificationManager.h1
-rw-r--r--src/timeline/TimelineModel.cpp26
-rw-r--r--src/timeline/TimelineModel.h3
-rw-r--r--src/timeline/TimelineViewManager.h1
-rw-r--r--src/ui/NhekoGlobalObject.cpp1
-rw-r--r--src/ui/UIA.cpp21
-rw-r--r--src/ui/UIA.h2
22 files changed, 247 insertions, 176 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt

index 333e52ad..6334565d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -194,7 +194,7 @@ if(USE_BUNDLED_COEURL) FetchContent_Declare( coeurl GIT_REPOSITORY https://nheko.im/Nheko-Reborn/coeurl.git - GIT_TAG v0.3.0 + GIT_TAG 831e2ee8e9cf08ea1ee9736cde8370f9d0312abc ) FetchContent_MakeAvailable(coeurl) set(COEURL_TARGET_NAME coeurl::coeurl) @@ -350,10 +350,6 @@ configure_file(cmake/nheko.h config/nheko.h) # Declare source and header files. # set(SRC_FILES - # Dialogs - src/dialogs/FallbackAuth.cpp - src/dialogs/FallbackAuth.h - # Emoji src/emoji/Provider.cpp src/emoji/Provider.h @@ -463,6 +459,8 @@ set(SRC_FILES src/Config.h src/EventAccessors.cpp src/EventAccessors.h + src/FallbackAuth.cpp + src/FallbackAuth.h src/ImagePackListModel.cpp src/ImagePackListModel.h src/InviteesModel.cpp @@ -601,7 +599,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG 0a4cc9421a97bea81a8921f3f5e040f0a34278fc + GIT_TAG 928ac33a0d0359464ac37716559a687fdc39f0de ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") @@ -731,6 +729,7 @@ set(QML_SOURCES resources/qml/components/MainWindowDialog.qml resources/qml/components/NhekoTabButton.qml resources/qml/components/NotificationBubble.qml + resources/qml/components/PowerlevelIndicator.qml resources/qml/components/ReorderableListview.qml resources/qml/components/SpaceMenuLevel.qml resources/qml/components/TextButton.qml @@ -757,8 +756,9 @@ set(QML_SOURCES resources/qml/dialogs/ConfirmJoinRoomDialog.qml resources/qml/dialogs/CreateDirect.qml resources/qml/dialogs/CreateRoom.qml + resources/qml/dialogs/FallbackAuthDialog.qml resources/qml/dialogs/HiddenEventsDialog.qml - resources/qml/dialogs/EventExpirationDialog.qml + resources/qml/dialogs/EventExpirationDialog.qml resources/qml/dialogs/ImageOverlay.qml resources/qml/dialogs/ImagePackEditorDialog.qml resources/qml/dialogs/ImagePackSettingsDialog.qml diff --git a/im.nheko.Nheko.yaml b/im.nheko.Nheko.yaml
index 4fa8ccfb..cc2503a0 100644 --- a/im.nheko.Nheko.yaml +++ b/im.nheko.Nheko.yaml
@@ -214,7 +214,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: 0a4cc9421a97bea81a8921f3f5e040f0a34278fc + - commit: 928ac33a0d0359464ac37716559a687fdc39f0de #tag: v0.9.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index af3a3371..a0ff0ff1 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml
@@ -100,6 +100,7 @@ Item { required property string url required property string userId required property string userName + required property int userPowerlevel ListView.delayRemove: true anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined @@ -119,6 +120,7 @@ Item { property date timestamp: wrapper.timestamp property string userId: wrapper.userId property string userName: wrapper.userName + property int userPowerlevel: wrapper.userPowerlevel active: previousMessageUserId !== userId || previousMessageDay !== day || previousMessageIsStateEvent !== isStateEvent //asynchronous: true @@ -562,14 +564,25 @@ Item { target: room } + AbstractButton { id: userNameButton + PowerlevelIndicator { + id: powerlevelIndicator + anchors.left: parent.left + //anchors.horizontalCenter: parent.horizontalCenter + + powerlevel: userPowerlevel + permissions: room ? room.permissions : null + visible: isAdmin || isModerator + } + ToolTip.delay: Nheko.tooltipDelay ToolTip.text: userId ToolTip.visible: hovered + leftPadding: powerlevelIndicator.visible ? 16 : 0 leftInset: 0 - leftPadding: 0 rightInset: 0 rightPadding: 0 diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml
index 5ab58beb..eff62fc1 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml
@@ -77,6 +77,7 @@ Flow { source: modelData.key.startsWith("mxc://") ? (modelData.key.replace("mxc://", "image://MxcImage/") + "?scale") : "" visible: modelData.key.startsWith("mxc://") width: textMetrics.height + mipmap: true } Rectangle { id: divider diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index 92e7ef6d..20e5b95b 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml
@@ -727,6 +727,11 @@ Page { } } Platform.MenuItem { + text: qsTr("Mark as read") + onTriggered: Rooms.getRoomById(roomContextMenu.roomid).markRoomAsRead() + } + + Platform.MenuItem { text: qsTr("Room settings") onTriggered: TimelineManager.openRoomSettings(roomContextMenu.roomid) diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml
index fb0c6036..1e8a6a27 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml
@@ -385,6 +385,18 @@ Pane { console.error("Failed to create component: " + component.errorString()); } } + function onFallbackAuth(fallback) { + var component = Qt.createComponent("qrc:/resources/qml/dialogs/FallbackAuthDialog.qml"); + if (component.status == Component.Ready) { + var dialog = component.createObject(timelineRoot, { + "fallback": fallback + }); + dialog.show(); + destroyOnClose(dialog); + } else { + console.error("Failed to create component: " + component.errorString()); + } + } target: UIA } diff --git a/resources/qml/components/PowerlevelIndicator.qml b/resources/qml/components/PowerlevelIndicator.qml new file mode 100644
index 00000000..4b826284 --- /dev/null +++ b/resources/qml/components/PowerlevelIndicator.qml
@@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls +import im.nheko + +Image { + required property int powerlevel + required property var permissions + + readonly property bool isAdmin: permissions ? permissions.changeLevel(MtxEvent.PowerLevels) <= powerlevel : false + readonly property bool isModerator: permissions ? permissions.redactLevel() <= powerlevel : false + readonly property bool isDefault: permissions ? permissions.defaultLevel() <= powerlevel : false + + readonly property string sourceUrl: { + if (isAdmin) + return "image://colorimage/:/icons/icons/ui/ribbon_star.svg?"; + else if (isModerator) + return "image://colorimage/:/icons/icons/ui/ribbon.svg?"; + else + return "image://colorimage/:/icons/icons/ui/person.svg?"; + } + + sourceSize.width: 16 + sourceSize.height: 16 + source: sourceUrl + (ma.hovered ? palette.highlight : palette.buttonText) + ToolTip.visible: ma.hovered + ToolTip.text: { + if (isAdmin) + return qsTr("Administrator: %1").arg(powerlevel); + else if (isModerator) + return qsTr("Moderator: %1").arg(powerlevel); + else + return qsTr("User: %1").arg(powerlevel); + } + + HoverHandler { + id: ma + } +} diff --git a/resources/qml/dialogs/FallbackAuthDialog.qml b/resources/qml/dialogs/FallbackAuthDialog.qml new file mode 100644
index 00000000..d9a7ac8f --- /dev/null +++ b/resources/qml/dialogs/FallbackAuthDialog.qml
@@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls +import im.nheko + +ApplicationWindow { + id: fallbackRoot + + required property FallbackAuth fallback + + function accept() { + fallback.confirm(); + fallbackRoot.close(); + } + + function reject() { + fallback.cancel(); + fallbackRoot.close(); + } + + color: palette.window + title: qsTr("Fallback authentication") + flags: Qt.Tool | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + height: msg.implicitHeight + footer.implicitHeight + width: Math.max(msg.implicitWidth, footer.implicitWidth) + + Shortcut { + sequence: StandardKey.Cancel + onActivated: fallbackRoot.reject() + } + + Label { + id: msg + + anchors.fill: parent + padding: 8 + text: qsTr("Open the fallback, follow the steps, and confirm after completing them.") + } + + footer: DialogButtonBox { + onAccepted: fallbackRoot.accept() + onRejected: fallbackRoot.reject() + + Button { + text: qsTr("Open Fallback in Browser") + onClicked: fallback.openFallbackAuth() + } + + Button { + text: qsTr("Cancel") + DialogButtonBox.buttonRole: DialogButtonBox.RejectRole + } + + Button { + text: qsTr("Confirm") + DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole + } + } + +} diff --git a/resources/qml/dialogs/RoomMembers.qml b/resources/qml/dialogs/RoomMembers.qml
index bbf1605d..64f21381 100644 --- a/resources/qml/dialogs/RoomMembers.qml +++ b/resources/qml/dialogs/RoomMembers.qml
@@ -4,6 +4,7 @@ import ".." import "../ui" +import "../components" import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 @@ -159,39 +160,9 @@ ApplicationWindow { } - Image { - property bool isAdmin: room.permissions.changeLevel(MtxEvent.PowerLevels) <= model.powerlevel - property bool isModerator: room.permissions.redactLevel() <= model.powerlevel - //property bool isDefault: room.permissions.defaultLevel() <= model.powerlevel - - property string sourceUrl: { - if (isAdmin) - return "image://colorimage/:/icons/icons/ui/ribbon_star.svg?"; - else if (isModerator) - return "image://colorimage/:/icons/icons/ui/ribbon.svg?"; - else - return "image://colorimage/:/icons/icons/ui/person.svg?"; - } - - Layout.preferredWidth: 16 - Layout.preferredHeight: 16 - sourceSize.width: width - sourceSize.height: height - source: sourceUrl + (ma.hovered ? palette.highlight : palette.buttonText) - ToolTip.visible: ma.hovered - ToolTip.text: { - if (isAdmin) - return qsTr("Administrator: %1").arg(model.powerlevel); - else if (isModerator) - return qsTr("Moderator: %1").arg(model.powerlevel); - else - return qsTr("User: %1").arg(model.powerlevel); - } - - HoverHandler { - id: ma - } - + PowerlevelIndicator { + powerlevel: model.powerlevel + permissions: room.permissions } EncryptionIndicator { diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 4686b0f5..06d88303 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -1269,7 +1269,7 @@ ChatPage::getBackupVersion() nhlog::crypto()->info("Our backup key {} does not match the one " "used in the online backup {}", pubkey, - auth_data["public_key"]); + auth_data["public_key"].get<std::string>()); cache::client()->deleteBackupVersion(); return; } diff --git a/src/FallbackAuth.cpp b/src/FallbackAuth.cpp new file mode 100644
index 00000000..5b668310 --- /dev/null +++ b/src/FallbackAuth.cpp
@@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "FallbackAuth.h" + +#include <QDesktopServices> +#include <QUrl> + +#include "MatrixClient.h" + +FallbackAuth::FallbackAuth(const QString &session, const QString &authType, QObject *parent) + : QObject{parent} + , m_session{session} + , m_authType{authType} +{ +} + +void +FallbackAuth::openFallbackAuth() +{ + const auto url = QString("https://%1:%2/_matrix/client/r0/auth/%4/" + "fallback/web?session=%3") + .arg(QString::fromStdString(http::client()->server())) + .arg(http::client()->port()) + .arg(m_session, m_authType); + + QDesktopServices::openUrl(url); +} diff --git a/src/FallbackAuth.h b/src/FallbackAuth.h new file mode 100644
index 00000000..c3b042ce --- /dev/null +++ b/src/FallbackAuth.h
@@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include <QQmlEngine> + +class FallbackAuth : public QObject +{ + Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("") + + Q_PROPERTY(QString authType MEMBER m_authType CONSTANT) + Q_PROPERTY(QString session MEMBER m_session CONSTANT) + +public: + FallbackAuth(const QString &session, const QString &authType, QObject *parent = nullptr); + + Q_INVOKABLE void openFallbackAuth(); + Q_INVOKABLE void confirm() { emit confirmation(); } + Q_INVOKABLE void cancel() { emit cancelled(); } + +signals: + void confirmation(); + void cancelled(); + +private: + const QString m_session; + const QString m_authType; +}; diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index 4e2691e5..71eb039b 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h
@@ -12,15 +12,6 @@ #include <optional> -class Toggle; -class QLabel; -class QFormLayout; -class QComboBox; -class QFontComboBox; -class QSpinBox; -class QHBoxLayout; -class QVBoxLayout; - class UserSettings final : public QObject { Q_OBJECT diff --git a/src/dialogs/FallbackAuth.cpp b/src/dialogs/FallbackAuth.cpp deleted file mode 100644
index 9d59fc97..00000000 --- a/src/dialogs/FallbackAuth.cpp +++ /dev/null
@@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: Nheko Contributors -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include <QDesktopServices> -#include <QLabel> -#include <QPushButton> -#include <QUrl> -#include <QVBoxLayout> - -#include "dialogs/FallbackAuth.h" - -#include "Config.h" -#include "MatrixClient.h" - -using namespace dialogs; - -FallbackAuth::FallbackAuth(const QString &authType, const QString &session, QWidget *parent) - : QWidget(parent) -{ - setAutoFillBackground(true); - setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); - setWindowModality(Qt::WindowModal); - setAttribute(Qt::WA_DeleteOnClose, true); - - auto layout = new QVBoxLayout(this); - layout->setSpacing(conf::modals::WIDGET_SPACING); - layout->setContentsMargins(conf::modals::WIDGET_MARGIN, - conf::modals::WIDGET_MARGIN, - conf::modals::WIDGET_MARGIN, - conf::modals::WIDGET_MARGIN); - - auto buttonLayout = new QHBoxLayout(); - buttonLayout->setSpacing(8); - buttonLayout->setContentsMargins(0, 0, 0, 0); - - openBtn_ = new QPushButton(tr("Open Fallback in Browser"), this); - cancelBtn_ = new QPushButton(tr("Cancel"), this); - confirmBtn_ = new QPushButton(tr("Confirm"), this); - confirmBtn_->setDefault(true); - - buttonLayout->addStretch(1); - buttonLayout->addWidget(openBtn_); - buttonLayout->addWidget(cancelBtn_); - buttonLayout->addWidget(confirmBtn_); - - QFont font; - font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO); - - auto label = new QLabel( - tr("Open the fallback, follow the steps, and confirm after completing them."), this); - label->setFont(font); - - layout->addWidget(label); - layout->addLayout(buttonLayout); - - connect(openBtn_, &QPushButton::clicked, [session, authType]() { - const auto url = QString("https://%1:%2/_matrix/client/r0/auth/%4/" - "fallback/web?session=%3") - .arg(QString::fromStdString(http::client()->server())) - .arg(http::client()->port()) - .arg(session, authType); - - QDesktopServices::openUrl(url); - }); - - connect(confirmBtn_, &QPushButton::clicked, this, [this]() { - emit confirmation(); - emit close(); - }); - connect(cancelBtn_, &QPushButton::clicked, this, [this]() { - emit cancel(); - emit close(); - }); -} diff --git a/src/dialogs/FallbackAuth.h b/src/dialogs/FallbackAuth.h deleted file mode 100644
index 62092b08..00000000 --- a/src/dialogs/FallbackAuth.h +++ /dev/null
@@ -1,30 +0,0 @@ -// SPDX-FileCopyrightText: Nheko Contributors -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#pragma once - -#include <QWidget> - -class QPushButton; -class QLabel; - -namespace dialogs { - -class FallbackAuth final : public QWidget -{ - Q_OBJECT - -public: - FallbackAuth(const QString &authType, const QString &session, QWidget *parent = nullptr); - -signals: - void confirmation(); - void cancel(); - -private: - QPushButton *openBtn_; - QPushButton *confirmBtn_; - QPushButton *cancelBtn_; -}; -} // dialogs diff --git a/src/encryption/VerificationManager.h b/src/encryption/VerificationManager.h
index cdc8af30..24e1a206 100644 --- a/src/encryption/VerificationManager.h +++ b/src/encryption/VerificationManager.h
@@ -14,7 +14,6 @@ class DeviceVerificationFlow; class TimelineModel; -class TimelineModel; class TimelineViewManager; class RoomlistModel; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 752aedb0..b2a036c5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -535,6 +535,7 @@ TimelineModel::roleNames() const {IsSender, "isSender"}, {UserId, "userId"}, {UserName, "userName"}, + {UserPowerlevel, "userPowerlevel"}, {Day, "day"}, {Timestamp, "timestamp"}, {Url, "url"}, @@ -597,6 +598,14 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r return QVariant(QString::fromStdString(acc::sender(event))); case UserName: return QVariant(displayName(QString::fromStdString(acc::sender(event)))); + case UserPowerlevel: { + return static_cast<qlonglong>(mtx::events::state::PowerLevels{ + cache::client() + ->getStateEvent<mtx::events::state::PowerLevels>(room_id_.toStdString()) + .value_or(mtx::events::StateEvent<mtx::events::state::PowerLevels>{}) + .content} + .user_level(acc::sender(event))); + } case Day: { QDateTime prevDate = origin_server_ts(event); @@ -1284,13 +1293,20 @@ TimelineModel::updateLastMessage() void TimelineModel::setCurrentIndex(int index) { + setCurrentIndex(index, false); +} + +void +TimelineModel::setCurrentIndex(int index, bool ignoreInactiveState) +{ auto oldIndex = idToIndex(currentId); currentId = indexToId(index); if (index != oldIndex) emit currentIndexChanged(index); - if (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() || - MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow()) + if (!ignoreInactiveState && + (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() || + MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow())) return; if (!currentId.startsWith('m')) { @@ -1562,6 +1578,12 @@ TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids) } void +TimelineModel::markRoomAsRead() +{ + setCurrentIndex(0, true); +} + +void TimelineModel::updateLastReadId(const QString &currentRoomId) { if (currentRoomId == room_id_) { diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index fd1a4396..fccc99eb 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -241,6 +241,7 @@ public: IsSender, UserId, UserName, + UserPowerlevel, Day, Timestamp, Url, @@ -386,9 +387,11 @@ public: public slots: void setCurrentIndex(int index); + void setCurrentIndex(int index, bool ignoreInactiveState); int currentIndex() const { return idToIndex(currentId); } void eventShown(); void markEventsAsRead(const std::vector<QString> &event_ids); + void markRoomAsRead(); void updateLastReadId(const QString &currentRoomId); void lastReadIdOnWindowFocus(); void checkAfterFetch(); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 53179b44..f3bd04a2 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -7,7 +7,6 @@ #include <QHash> #include <QQuickItem> #include <QQuickTextDocument> -#include <QWidget> #include <mtx/common.hpp> #include <mtx/responses/messages.hpp> diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp
index 1bab73b5..54c4c1c9 100644 --- a/src/ui/NhekoGlobalObject.cpp +++ b/src/ui/NhekoGlobalObject.cpp
@@ -153,7 +153,6 @@ Nheko::createRoom(bool space, if (space) { req.creation_content = mtx::events::state::Create{}; req.creation_content->type = mtx::events::state::room_type::space; - req.creation_content->creator.clear(); req.creation_content->room_version.clear(); } diff --git a/src/ui/UIA.cpp b/src/ui/UIA.cpp
index 9654c9aa..4c1d35b9 100644 --- a/src/ui/UIA.cpp +++ b/src/ui/UIA.cpp
@@ -13,8 +13,6 @@ #include "Logging.h" #include "MatrixClient.h" -#include "ReCaptcha.h" -#include "dialogs/FallbackAuth.h" UIA * UIA::instance() @@ -132,23 +130,18 @@ UIA::genericHandler(QString context) } } else { // use fallback - auto dialog = new dialogs::FallbackAuth(QString::fromStdString(current_stage), - QString::fromStdString(u.session), - nullptr); - dialog->setWindowTitle(context); - - connect(dialog, &dialogs::FallbackAuth::confirmation, this, [h, u, dialog]() { - dialog->close(); - dialog->deleteLater(); + auto fallback = new FallbackAuth(QString::fromStdString(u.session), + QString::fromStdString(current_stage), + nullptr); + QQmlEngine::setObjectOwnership(fallback, QQmlEngine::JavaScriptOwnership); + connect(fallback, &FallbackAuth::confirmation, this, [h, u]() { h.next(mtx::user_interactive::Auth{u.session, mtx::user_interactive::auth::Fallback{}}); }); - - connect(dialog, &dialogs::FallbackAuth::cancel, this, [this]() { + connect(fallback, &FallbackAuth::cancelled, this, [this]() { emit error(tr("Registration aborted")); }); - - dialog->show(); + emit fallbackAuth(fallback); } }); }); diff --git a/src/ui/UIA.h b/src/ui/UIA.h
index 5b5eb9f4..2bff6948 100644 --- a/src/ui/UIA.h +++ b/src/ui/UIA.h
@@ -9,6 +9,7 @@ #include <mtxclient/http/client.hpp> +#include "FallbackAuth.h" #include "ReCaptcha.h" class UIA final : public QObject @@ -62,6 +63,7 @@ signals: void email(); void phoneNumber(); void reCaptcha(ReCaptcha *recaptcha); + void fallbackAuth(FallbackAuth *fallback); void confirm3pidToken(); void prompt3pidToken();