From c76cda0cbe1368dbf653ad8c50c1b932e69f7c0a Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 5 Mar 2022 03:25:24 +0100 Subject: Set font properly When setting the default font, actually set the default font. When setting a different font, change the application font. fixes #801 fixes #232 fixes #224 --- src/UserSettingsPage.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index c7ac790a..1a24834e 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -79,15 +79,17 @@ UserSettings::load(std::optional profile) sortByImportance_ = settings.value(QStringLiteral("user/sort_by_unread"), true).toBool(); readReceipts_ = settings.value(QStringLiteral("user/read_receipts"), true).toBool(); theme_ = settings.value(QStringLiteral("user/theme"), defaultTheme_).toString(); - font_ = settings.value(QStringLiteral("user/font_family"), "default").toString(); - avatarCircles_ = settings.value(QStringLiteral("user/avatar_circles"), true).toBool(); - useIdenticon_ = settings.value(QStringLiteral("user/use_identicon"), true).toBool(); - decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool(); - privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool(); + + font_ = settings.value(QStringLiteral("user/font_family"), "").toString(); + + avatarCircles_ = settings.value(QStringLiteral("user/avatar_circles"), true).toBool(); + useIdenticon_ = settings.value(QStringLiteral("user/use_identicon"), true).toBool(); + decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool(); + privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool(); privacyScreenTimeout_ = settings.value(QStringLiteral("user/privacy_screen_timeout"), 0).toInt(); mobileMode_ = settings.value(QStringLiteral("user/mobile_mode"), false).toBool(); - emojiFont_ = settings.value(QStringLiteral("user/emoji_font_family"), "default").toString(); + emojiFont_ = settings.value(QStringLiteral("user/emoji_font_family"), "emoji").toString(); baseFontSize_ = settings.value(QStringLiteral("user/font_size"), QFont().pointSizeF()).toDouble(); auto tempPresence = @@ -419,6 +421,12 @@ UserSettings::setFontSize(double size) if (size == baseFontSize_) return; baseFontSize_ = size; + + const static auto defaultFamily = QFont().defaultFamily(); + QFont f((font_.isEmpty() || font_ == QStringLiteral("default")) ? defaultFamily : font_); + f.setPointSizeF(fontSize()); + QApplication::setFont(f); + emit fontSizeChanged(size); save(); } @@ -429,6 +437,12 @@ UserSettings::setFontFamily(QString family) if (family == font_) return; font_ = family; + + const static auto defaultFamily = QFont().defaultFamily(); + QFont f((family.isEmpty() || family == QStringLiteral("default")) ? defaultFamily : family); + f.setPointSizeF(fontSize()); + QApplication::setFont(f); + emit fontChanged(family); save(); } @@ -440,7 +454,7 @@ UserSettings::setEmojiFontFamily(QString family) return; if (family == tr("Default")) { - emojiFont_ = QStringLiteral("default"); + emojiFont_ = QStringLiteral("emoji"); } else { emojiFont_ = family; } -- cgit 1.5.1 From 12a6da012a591950278b40d614e035031adc7f08 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 5 Mar 2022 19:38:13 +0100 Subject: If you replace the txn id, replace a string the length of the txn id... --- src/timeline/EventStore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 4151356f..1293245c 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -208,7 +208,7 @@ EventStore::EventStore(std::string room_id, QObject *) size_t index = related_text->content.formatted_body.find(txn_id); if (index != std::string::npos) { related_text->content.formatted_body.replace( - index, event_id.length(), event_id); + index, txn_id.length(), event_id); } } -- cgit 1.5.1 From 9482ac4e7acd23b1873450be977c50526677b1a3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 6 Mar 2022 19:51:17 +0100 Subject: Allow explicit selection of SSO method fixes #975 --- CMakeLists.txt | 4 +- io.github.NhekoReborn.Nheko.yaml | 6 +-- resources/qml/components/FlatButton.qml | 37 +++++++++++++----- resources/qml/pages/LoginPage.qml | 41 +++++++++++--------- src/LoginPage.cpp | 67 +++++++++++++++++++++++---------- src/LoginPage.h | 27 ++++++++++++- 6 files changed, 129 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index 9393432a..d350e71a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,7 +405,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG 25857f17272809ce2359f214d76fa11d46b1fa7e + GIT_TAG e1b75074b501d2d3e0100d1170b3edef8a00799c ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") @@ -692,7 +692,7 @@ if(USE_BUNDLED_COEURL) FetchContent_Declare( coeurl GIT_REPOSITORY https://nheko.im/Nheko-Reborn/coeurl.git - GIT_TAG v0.1.1 + GIT_TAG v0.1.2 ) FetchContent_MakeAvailable(coeurl) target_link_libraries(nheko PUBLIC coeurl::coeurl) diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 562be71f..31248a28 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -177,8 +177,8 @@ modules: - -Ddefault_library=static name: coeurl sources: - - commit: fa108b25a92b0e037723debc4388a300e737dc2d - tag: v0.1.1 + - commit: 1c530c153687c9072619f00ad77fff9960bdb048 + tag: v0.1.2 type: git url: https://nheko.im/nheko-reborn/coeurl.git - config-opts: @@ -189,7 +189,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: 25857f17272809ce2359f214d76fa11d46b1fa7e + - commit: e1b75074b501d2d3e0100d1170b3edef8a00799c #tag: v0.6.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/resources/qml/components/FlatButton.qml b/resources/qml/components/FlatButton.qml index 72184d28..2c9ea061 100644 --- a/resources/qml/components/FlatButton.qml +++ b/resources/qml/components/FlatButton.qml @@ -6,6 +6,7 @@ import QtGraphicalEffects 1.12 import QtQuick 2.9 import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.2 import im.nheko 1.0 // FIXME(Nico): Don't use hardcoded colors. @@ -16,6 +17,8 @@ Button { implicitWidth: Math.ceil(control.contentItem.implicitWidth + control.contentItem.implicitHeight) hoverEnabled: true + property string iconImage: "" + DropShadow { anchors.fill: control.background horizontalOffset: 3 @@ -27,16 +30,30 @@ Button { source: control.background } - contentItem: Text { - text: control.text - //font: control.font - font.capitalization: Font.AllUppercase - font.pointSize: Math.ceil(fontMetrics.font.pointSize * 1.5) - //font.capitalization: Font.AllUppercase - color: Nheko.colors.light - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight + contentItem: RowLayout { + spacing: 0 + anchors.centerIn: parent + Image { + Layout.leftMargin: Nheko.paddingMedium + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + Layout.preferredHeight: fontMetrics.font.pixelSize * 1.5 + Layout.preferredWidth: fontMetrics.font.pixelSize * 1.5 + visible: !!iconImage + source: iconImage + } + + Text { + Layout.alignment: Qt.AlignHCenter + text: control.text + //font: control.font + font.capitalization: Font.AllUppercase + font.pointSize: Math.ceil(fontMetrics.font.pointSize * 1.5) + //font.capitalization: Font.AllUppercase + color: Nheko.colors.light + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } } background: Rectangle { diff --git a/resources/qml/pages/LoginPage.qml b/resources/qml/pages/LoginPage.qml index 4d3a52b3..87234a22 100644 --- a/resources/qml/pages/LoginPage.qml +++ b/resources/qml/pages/LoginPage.qml @@ -61,7 +61,7 @@ Item { onEditingFinished: login.mxid = text ToolTip.text: qsTr("Your login name. A mxid should start with @ followed by the user id. After the user id you need to include your server name after a :.\nYou can also put your homeserver address there, if your server doesn't support .well-known lookup.\nExample: @user:server.my\nIf Nheko fails to discover your homeserver, it will show you a field to enter the server manually.") - Keys.forwardTo: [pwBtn, ssoBtn] + Keys.forwardTo: [pwBtn, ssoRepeater] } @@ -89,7 +89,7 @@ Item { echoMode: TextInput.Password ToolTip.text: qsTr("Your password.") visible: login.passwordSupported - Keys.forwardTo: [pwBtn, ssoBtn] + Keys.forwardTo: [pwBtn, ssoRepeater] } MatrixTextField { @@ -98,7 +98,7 @@ Item { label: qsTr("Device name") placeholderText: login.initialDeviceName() ToolTip.text: qsTr("A name for this device, which will be shown to others, when verifying your devices. If none is provided a default is used.") - Keys.forwardTo: [pwBtn, ssoBtn] + Keys.forwardTo: [pwBtn, ssoRepeater] } MatrixTextField { @@ -112,7 +112,7 @@ Item { text: login.homeserver onEditingFinished: login.homeserver = text ToolTip.text: qsTr("The address that can be used to contact you homeservers client API.\nExample: https://server.my:8787") - Keys.forwardTo: [pwBtn, ssoBtn] + Keys.forwardTo: [pwBtn, ssoRepeater] } Item { @@ -150,21 +150,28 @@ Item { Keys.onReturnPressed: pwBtn.pwLogin() Keys.enabled: pwBtn.enabled && login.passwordSupported } - FlatButton { - id: ssoBtn - visible: login.ssoSupported - enabled: login.homeserverValid && matrixIdLabel.text == login.mxid && login.homeserver == hsLabel.text - Layout.alignment: Qt.AlignHCenter - text: qsTr("SSO LOGIN") - function ssoLogin() { - login.onLoginButtonClicked(Login.SSO, matrixIdLabel.text, passwordLabel.text, deviceNameLabel.text) + + Repeater { + id: ssoRepeater + + model: login.identityProviders + + delegate: FlatButton { + id: ssoBtn + visible: login.ssoSupported + enabled: login.homeserverValid && matrixIdLabel.text == login.mxid && login.homeserver == hsLabel.text + Layout.alignment: Qt.AlignHCenter + text: modelData.name + iconImage: modelData.avatarUrl.replace("mxc://", "image://MxcImage/") + function ssoLogin() { + login.onLoginButtonClicked(Login.SSO, matrixIdLabel.text, modelData.id, deviceNameLabel.text) + } + onClicked: ssoBtn.ssoLogin() + Keys.onEnterPressed: ssoBtn.ssoLogin() + Keys.onReturnPressed: ssoBtn.ssoLogin() + Keys.enabled: ssoBtn.enabled && !login.passwordSupported } - onClicked: ssoBtn.ssoLogin() - Keys.onEnterPressed: ssoBtn.ssoLogin() - Keys.onReturnPressed: ssoBtn.ssoLogin() - Keys.enabled: ssoBtn.enabled && !login.passwordSupported } - } } diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp index 6bed446e..cdc2262f 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp @@ -19,6 +19,7 @@ #include "UserSettingsPage.h" Q_DECLARE_METATYPE(LoginPage::LoginMethod) +Q_DECLARE_METATYPE(SSOProvider) using namespace mtx::identifiers; @@ -28,6 +29,7 @@ LoginPage::LoginPage(QObject *parent) { [[maybe_unused]] static auto ignored = qRegisterMetaType("LoginPage::LoginMethod"); + [[maybe_unused]] static auto ignored2 = qRegisterMetaType(); connect(this, &LoginPage::versionOkCb, this, &LoginPage::versionOk, Qt::QueuedConnection); connect(this, &LoginPage::versionErrorCb, this, &LoginPage::versionError, Qt::QueuedConnection); @@ -166,22 +168,47 @@ LoginPage::checkHomeserverVersion() return; } - http::client()->get_login( - [this](mtx::responses::LoginFlows flows, mtx::http::RequestErr err) { - if (err || flows.flows.empty()) - emit versionOkCb(true, false); - - bool ssoSupported = false; - bool passwordSupported = false; - for (const auto &flow : flows.flows) { - if (flow.type == mtx::user_interactive::auth_types::sso) { - ssoSupported = true; - } else if (flow.type == mtx::user_interactive::auth_types::password) { - passwordSupported = true; - } - } - emit versionOkCb(passwordSupported, ssoSupported); - }); + http::client()->get_login([this](mtx::responses::LoginFlows flows, + mtx::http::RequestErr err) { + if (err || flows.flows.empty()) + emit versionOkCb(true, false, {}); + + QVariantList idps; + bool ssoSupported = false; + bool passwordSupported = false; + for (const auto &flow : flows.flows) { + if (flow.type == mtx::user_interactive::auth_types::sso) { + ssoSupported = true; + + for (const auto &idp : flow.identity_providers) { + SSOProvider prov; + if (idp.brand == "apple") + prov.name_ = tr("Sign in with Apple"); + else if (idp.brand == "facebook") + prov.name_ = tr("Continue with Facebook"); + else if (idp.brand == "google") + prov.name_ = tr("Sign in with Google"); + else if (idp.brand == "twitter") + prov.name_ = tr("Sign in with Twitter"); + else + prov.name_ = tr("Login using %1").arg(QString::fromStdString(idp.name)); + + prov.avatarUrl_ = QString::fromStdString(idp.icon); + prov.id_ = QString::fromStdString(idp.id); + idps.push_back(QVariant::fromValue(prov)); + } + + if (flow.identity_providers.empty()) { + SSOProvider prov; + prov.name_ = tr("SSO LOGIN"); + idps.push_back(QVariant::fromValue(prov)); + } + } else if (flow.type == mtx::user_interactive::auth_types::password) { + passwordSupported = true; + } + } + emit versionOkCb(passwordSupported, ssoSupported, idps); + }); }); } @@ -198,10 +225,11 @@ LoginPage::versionError(const QString &error) } void -LoginPage::versionOk(bool passwordSupported, bool ssoSupported) +LoginPage::versionOk(bool passwordSupported, bool ssoSupported, QVariantList idps) { passwordSupported_ = passwordSupported; ssoSupported_ = ssoSupported; + identityProviders_ = idps; lookingUpHs_ = false; homeserverValid_ = true; @@ -287,8 +315,9 @@ LoginPage::onLoginButtonClicked(LoginMethod loginMethod, sso->deleteLater(); }); - QDesktopServices::openUrl( - QString::fromStdString(http::client()->login_sso_redirect(sso->url()))); + // password doubles as the idp id for SSO login + QDesktopServices::openUrl(QString::fromStdString( + http::client()->login_sso_redirect(sso->url(), password.toStdString()))); } loggingIn_ = true; diff --git a/src/LoginPage.h b/src/LoginPage.h index 9a1b9653..47896fda 100644 --- a/src/LoginPage.h +++ b/src/LoginPage.h @@ -7,6 +7,7 @@ #pragma once #include +#include namespace mtx { namespace responses { @@ -14,6 +15,23 @@ struct Login; } } +struct SSOProvider +{ + Q_GADGET + Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT) + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString id READ id CONSTANT) + +public: + [[nodiscard]] QString avatarUrl() const { return avatarUrl_; } + [[nodiscard]] QString name() const { return name_.toHtmlEscaped(); } + [[nodiscard]] QString id() const { return id_; } + + QString avatarUrl_; + QString name_; + QString id_; +}; + class LoginPage : public QObject { Q_OBJECT @@ -30,6 +48,8 @@ class LoginPage : public QObject Q_PROPERTY(bool ssoSupported READ ssoSupported NOTIFY versionLookedUp) Q_PROPERTY(bool homeserverNeeded READ homeserverNeeded NOTIFY versionLookedUp) + Q_PROPERTY(QVariantList identityProviders READ identityProviders NOTIFY versionLookedUp) + public: enum class LoginMethod { @@ -51,6 +71,7 @@ public: bool ssoSupported() const { return ssoSupported_; } bool homeserverNeeded() const { return homeserverNeeded_; } bool homeserverValid() const { return homeserverValid_; } + QVariantList identityProviders() const { return identityProviders_; } QString homeserver() { return homeserver_; } QString mxid() { return mxid_; } @@ -89,7 +110,7 @@ signals: //! Used to trigger the corresponding slot outside of the main thread. void versionErrorCb(const QString &err); - void versionOkCb(bool passwordSupported, bool ssoSupported); + void versionOkCb(bool passwordSupported, bool ssoSupported, QVariantList identityProviders); void loginOk(const mtx::responses::Login &res); @@ -116,7 +137,7 @@ public slots: // Callback for errors produced during server probing void versionError(const QString &error_message); // Callback for successful server probing - void versionOk(bool passwordSupported, bool ssoSupported); + void versionOk(bool passwordSupported, bool ssoSupported, QVariantList identityProviders); private: void checkHomeserverVersion(); @@ -137,6 +158,8 @@ private: QString mxidError_; QString error_; + QVariantList identityProviders_; + bool passwordSupported_ = true; bool ssoSupported_ = false; -- cgit 1.5.1 From e390c398626b5f6e885078de9ab14186e3c0c27e Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 6 Mar 2022 14:46:52 +0100 Subject: Allow to specify reason for removed message # Previous commits: # 5949173b Add function to force focus on InputDialog input field # 9482ac4e Allow explicit selection of SSO method # ab05e2d8 Mobile message input (#962) # 12a6da01 If you replace the txn id, replace a string the length of the txn id... --- resources/qml/MessageView.qml | 24 +++++++++++++++++++++++- src/timeline/TimelineModel.cpp | 8 +++++--- src/timeline/TimelineModel.h | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index a717cb31..55860ad6 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -7,6 +7,7 @@ import "./components" import "./delegates" import "./emoji" import "./ui" +import "./dialogs" import Qt.labs.platform 1.1 as Platform import QtQuick 2.15 import QtQuick.Controls 2.15 @@ -585,6 +586,21 @@ Item { open(); } + Component { + id: removeReason + InputDialog { + id: removeReasonDialog + + property string eventId + + title: qsTr("Reason for removal") + prompt: qsTr("Enter reason for removal or hit enter for no reason:") + onAccepted: function(text) { + room.redactEvent(eventId, text); + } + } + } + Platform.MenuItem { visible: messageContextMenu.text enabled: visible @@ -665,7 +681,13 @@ Item { Platform.MenuItem { visible: (room ? room.permissions.canRedact() : false) || messageContextMenu.isSender text: qsTr("Remo&ve message") - onTriggered: room.redactEvent(messageContextMenu.eventId) + onTriggered: function() { + var dialog = removeReason.createObject(timelineRoot); + dialog.eventId = messageContextMenu.eventId; + dialog.show(); + dialog.forceActiveFocus(); + timelineRoot.destroyOnClose(dialog); + } } Platform.MenuItem { diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 903f137f..8e6c7235 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1240,7 +1240,7 @@ TimelineModel::showReadReceipts(QString id) } void -TimelineModel::redactEvent(const QString &id) +TimelineModel::redactEvent(const QString &id, const QString &reason) { if (!id.isEmpty()) { auto edits = events.edits(id.toStdString()); @@ -1255,7 +1255,8 @@ TimelineModel::redactEvent(const QString &id) } emit dataAtIdChanged(id); - }); + }, + reason.toStdString()); // redact all edits to prevent leaks for (const auto &e : edits) { @@ -1271,7 +1272,8 @@ TimelineModel::redactEvent(const QString &id) } emit dataAtIdChanged(id); - }); + }, + reason.toStdString()); } } } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index e4e3fa9d..f47203f0 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -272,7 +272,7 @@ public: Q_INVOKABLE void unpin(const QString &id); Q_INVOKABLE void pin(const QString &id); Q_INVOKABLE void showReadReceipts(QString id); - Q_INVOKABLE void redactEvent(const QString &id); + Q_INVOKABLE void redactEvent(const QString &id, const QString &reason = ""); Q_INVOKABLE int idToIndex(const QString &id) const; Q_INVOKABLE QString indexToId(int index) const; Q_INVOKABLE void openMedia(const QString &eventId); -- cgit 1.5.1 From 083562a7d8befa38ba9c3736b64e1530c04c1ed3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 6 Mar 2022 15:59:32 +0100 Subject: Add GUI for specifying kick/ban reason This replaces the are-you-sure dialog and also shows up when using /-commands. Closes: https://github.com/Nheko-Reborn/nheko/issues/239 # Previous commits: # e390c398 Allow to specify reason for removed message # 5949173b Add function to force focus on InputDialog input field # 9482ac4e Allow explicit selection of SSO method # ab05e2d8 Mobile message input (#962) --- src/ChatPage.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index cdaf7260..3743eae0 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -785,11 +785,18 @@ ChatPage::kickUser(QString userid, QString reason) { auto room = currentRoom(); - if (QMessageBox::question(nullptr, - tr("Confirm kick"), - tr("Do you really want to kick %1 (%2)?") - .arg(cache::displayName(room, userid), userid)) != QMessageBox::Yes) + bool confirmed; + reason = + QInputDialog::getText(nullptr, + tr("Reason for the kick"), + tr("Enter reason for kicking %1 (%2) or hit enter for no reason:") + .arg(cache::displayName(room, userid), userid), + QLineEdit::Normal, + reason, + &confirmed); + if (!confirmed) { return; + } http::client()->kick_user( room.toStdString(), @@ -809,12 +816,18 @@ ChatPage::banUser(QString userid, QString reason) { auto room = currentRoom(); - if (QMessageBox::question( - nullptr, - tr("Confirm ban"), - tr("Do you really want to ban %1 (%2)?").arg(cache::displayName(room, userid), userid)) != - QMessageBox::Yes) + bool confirmed; + reason = + QInputDialog::getText(nullptr, + tr("Reason for the ban"), + tr("Enter reason for banning %1 (%2) or hit enter for no reason:") + .arg(cache::displayName(room, userid), userid), + QLineEdit::Normal, + reason, + &confirmed); + if (!confirmed) { return; + } http::client()->ban_user( room.toStdString(), -- cgit 1.5.1 From ac1d6782547223bbd58137cc84ea331477f2438d Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 7 Mar 2022 05:26:12 +0100 Subject: Fix server switching to https after bootstrap fixes #878 --- CMakeLists.txt | 2 +- io.github.NhekoReborn.Nheko.yaml | 2 +- resources/qml/Root.qml | 3 ++- src/LoginPage.cpp | 6 ++++-- src/MainWindow.cpp | 3 +-- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index d350e71a..81d13be5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,7 +405,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG e1b75074b501d2d3e0100d1170b3edef8a00799c + GIT_TAG a3fec0ae53762a8a482cde50c9709671bcf0548d ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 31248a28..84743987 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -189,7 +189,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: e1b75074b501d2d3e0100d1170b3edef8a00799c + - commit: a3fec0ae53762a8a482cde50c9709671bcf0548d #tag: v0.6.2 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index 14e6770b..c8c05a3e 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -222,7 +222,8 @@ Pane { } function destroyOnClose(obj) { - obj.closing.connect(() => obj.destroy()); + if (obj.closing != undefined) obj.closing.connect(() => obj.destroy()); + else if (obj.closed != undefined) obj.closed.connect(() => obj.destroy()); } function destroyOnClosed(obj) { diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp index cdc2262f..6a83376c 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp @@ -163,6 +163,8 @@ LoginPage::checkHomeserverVersion() return; } + nhlog::net()->error("Error requesting versions: {}", *err); + emit versionErrorCb( tr("An unknown error occured. Make sure the homeserver domain is valid.")); return; @@ -276,7 +278,7 @@ LoginPage::onLoginButtonClicked(LoginMethod loginMethod, if (res.well_known) { http::client()->set_server(res.well_known->homeserver.base_url); - nhlog::net()->info("Login requested to user server: " + + nhlog::net()->info("Login requested to use server: " + res.well_known->homeserver.base_url); } @@ -301,7 +303,7 @@ LoginPage::onLoginButtonClicked(LoginMethod loginMethod, if (res.well_known) { http::client()->set_server(res.well_known->homeserver.base_url); - nhlog::net()->info("Login requested to user server: " + + nhlog::net()->info("Login requested to use server: " + res.well_known->homeserver.base_url); } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f3893998..73e556f7 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -338,8 +338,7 @@ MainWindow::showChatPage() { auto userid = QString::fromStdString(http::client()->user_id().to_string()); auto device_id = QString::fromStdString(http::client()->device_id()); - auto homeserver = QString::fromStdString(http::client()->server() + ":" + - std::to_string(http::client()->port())); + auto homeserver = QString::fromStdString(http::client()->server_url()); auto token = QString::fromStdString(http::client()->access_token()); userSettings_.data()->setUserId(userid); -- cgit 1.5.1