From cd998d1c35d9d65aa04ca64f0f94f34a57db8335 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 16 Jan 2021 15:33:33 -0500 Subject: [PATCH 1/4] Center user info dialog on the screen --- resources/qml/UserProfile.qml | 2 ++ src/MainWindow.h | 7 ++++++- src/timeline/TimelineViewManager.cpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml index 8328f4a5..fce6e6ff 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml @@ -10,6 +10,8 @@ ApplicationWindow { property var profile + x: MainWindow.x + (MainWindow.width / 2) - (width / 2) + y: MainWindow.y + (MainWindow.height / 2) - (height / 2) height: 650 width: 420 minimumHeight: 420 diff --git a/src/MainWindow.h b/src/MainWindow.h index 0915a849..707118ed 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -61,10 +61,15 @@ class MainWindow : public QMainWindow { Q_OBJECT + Q_PROPERTY(int x READ x) + Q_PROPERTY(int y READ y) + Q_PROPERTY(int width READ width) + Q_PROPERTY(int height READ height) + public: explicit MainWindow(QWidget *parent = nullptr); - static MainWindow *instance() { return instance_; }; + static MainWindow *instance() { return instance_; } void saveCurrentWindowSize(); void openLeaveRoomDialog(const QString &room_id); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 97af0065..1317dc2a 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -128,6 +128,10 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par "UserProfile needs to be instantiated on the C++ side"); static auto self = this; + qmlRegisterSingletonType( + "im.nheko", 1, 0, "MainWindow", [](QQmlEngine *, QJSEngine *) -> QObject * { + return MainWindow::instance(); + }); qmlRegisterSingletonType( "im.nheko", 1, 0, "TimelineManager", [](QQmlEngine *, QJSEngine *) -> QObject * { return self; From d8ebc0b3dcdc988cb8c5ee495072272a1bdb28ca Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 29 Jan 2021 17:34:56 -0500 Subject: [PATCH 2/4] Fix warning about non-NOTIFYable property --- src/MainWindow.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.h b/src/MainWindow.h index 707118ed..4c365dca 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -61,10 +61,10 @@ class MainWindow : public QMainWindow { Q_OBJECT - Q_PROPERTY(int x READ x) - Q_PROPERTY(int y READ y) - Q_PROPERTY(int width READ width) - Q_PROPERTY(int height READ height) + Q_PROPERTY(int x READ x CONSTANT) + Q_PROPERTY(int y READ y CONSTANT) + Q_PROPERTY(int width READ width CONSTANT) + Q_PROPERTY(int height READ height CONSTANT) public: explicit MainWindow(QWidget *parent = nullptr); From c3fa59201892aab9b109e051d12b809a8e6f291a Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 29 Jan 2021 18:17:44 -0500 Subject: [PATCH 3/4] make lint --- src/timeline/TimelineViewManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 1317dc2a..93451976 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -129,9 +129,9 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par static auto self = this; qmlRegisterSingletonType( - "im.nheko", 1, 0, "MainWindow", [](QQmlEngine *, QJSEngine *) -> QObject * { - return MainWindow::instance(); - }); + "im.nheko", 1, 0, "MainWindow", [](QQmlEngine *, QJSEngine *) -> QObject * { + return MainWindow::instance(); + }); qmlRegisterSingletonType( "im.nheko", 1, 0, "TimelineManager", [](QQmlEngine *, QJSEngine *) -> QObject * { return self; From 58dc79074c3fc8f94857af128c1021486deb22e2 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Fri, 29 Jan 2021 18:18:39 -0500 Subject: [PATCH 4/4] Close user profile dialog on Esc --- resources/qml/UserProfile.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml index fce6e6ff..a1fbfa41 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml @@ -18,6 +18,11 @@ ApplicationWindow { palette: colors color: colors.window + Shortcut { + sequence: StandardKey.Cancel + onActivated: userProfileDialog.close() + } + ColumnLayout { id: contentL