Always open the user details dialog in the focused window
This fixes some odd UX where you tap on someone's user in a search or pinned messages window, but it opens in the NeoChat main window instead. Fixes #681
This commit is contained in:
@@ -325,11 +325,13 @@ Kirigami.ApplicationWindow {
|
||||
})
|
||||
}
|
||||
function showUserDetail(user, room) {
|
||||
Qt.createComponent("org.kde.neochat", "UserDetailDialog").createObject(root.QQC2.ApplicationWindow.window, {
|
||||
const dialog = Qt.createComponent("org.kde.neochat", "UserDetailDialog").createObject(root, {
|
||||
room: room,
|
||||
user: user,
|
||||
connection: root.connection
|
||||
}).open();
|
||||
connection: root.connection,
|
||||
});
|
||||
dialog.parent = QmlUtils.focusedWindowItem(); // Kirigami Dialogs overwrite the parent, so we need to set it again
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
function load() {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Quotient/connection.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QQuickWindow>
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
@@ -37,6 +38,16 @@ QColor QmlUtils::getUserColor(qreal hueF)
|
||||
return QColor::fromHslF(hueF, 1, -0.7 * lightness + 0.9, 1);
|
||||
}
|
||||
|
||||
QQuickItem *QmlUtils::focusedWindowItem()
|
||||
{
|
||||
const auto window = qobject_cast<QQuickWindow *>(QGuiApplication::focusWindow());
|
||||
if (window) {
|
||||
return window->contentItem();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Utils::isEmoji(const QString &text)
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickItem>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <Quotient/user.h>
|
||||
@@ -36,6 +37,7 @@ public:
|
||||
Q_INVOKABLE bool isValidJson(const QByteArray &json);
|
||||
Q_INVOKABLE QString escapeString(const QString &string);
|
||||
Q_INVOKABLE QColor getUserColor(qreal hueF);
|
||||
Q_INVOKABLE QQuickItem *focusedWindowItem();
|
||||
|
||||
private:
|
||||
QmlUtils() = default;
|
||||
|
||||
Reference in New Issue
Block a user