3 files changed, 17 insertions, 1 deletions
diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml
index 8328f4a5..a1fbfa41 100644
--- a/resources/qml/UserProfile.qml
+++ b/resources/qml/UserProfile.qml
@@ -10,12 +10,19 @@ 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
palette: colors
color: colors.window
+ Shortcut {
+ sequence: StandardKey.Cancel
+ onActivated: userProfileDialog.close()
+ }
+
ColumnLayout {
id: contentL
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 0915a849..4c365dca 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 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);
- 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..93451976 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<MainWindow>(
+ "im.nheko", 1, 0, "MainWindow", [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return MainWindow::instance();
+ });
qmlRegisterSingletonType<TimelineViewManager>(
"im.nheko", 1, 0, "TimelineManager", [](QQmlEngine *, QJSEngine *) -> QObject * {
return self;
|