summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/MainWindow.cpp14
-rw-r--r--src/MainWindow.h2
-rw-r--r--src/Utils.cpp16
-rw-r--r--src/Utils.h2
4 files changed, 13 insertions, 21 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index ab2de2ba..a4661da7 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -423,22 +423,18 @@ MainWindow::openCreateRoomDialog(
 }
 
 bool
-MainWindow::hasActiveDialogs() const
-{
-    return false;
-}
-
-bool
 MainWindow::pageSupportsTray() const
 {
-    return false; //! welcome_page_->isVisible() && !login_page_->isVisible() &&
-                  //! !register_page_->isVisible();
+    return !http::client()->access_token().empty();
 }
 
 inline void
 MainWindow::showDialog(QWidget *dialog)
 {
-    // utils::centerWidget(dialog, this);
+    dialog->setWindowFlags(Qt::WindowType::Dialog | Qt::WindowType::WindowCloseButtonHint |
+                           Qt::WindowType::WindowTitleHint);
     dialog->raise();
     dialog->show();
+    utils::centerWidget(dialog, this);
+    dialog->window()->windowHandle()->setTransientParent(this);
 }
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 33e16271..1258bafb 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -83,8 +83,6 @@ private:
     void showDialog(QWidget *dialog);
     bool hasActiveUser();
     void restoreWindowSize();
-    //! Check if there is an open dialog.
-    bool hasActiveDialogs() const;
     //! Check if the current page supports the "minimize to tray" functionality.
     bool pageSupportsTray() const;
 
diff --git a/src/Utils.cpp b/src/Utils.cpp
index a9cfde22..0ac37d8e 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -17,6 +17,7 @@
 #include <QStringBuilder>
 #include <QTextBoundaryFinder>
 #include <QTextDocument>
+#include <QWindow>
 #include <QXmlStreamReader>
 
 #include <array>
@@ -770,20 +771,17 @@ utils::luminance(const QColor &col)
 }
 
 void
-utils::centerWidget(QWidget *widget, QWidget *parent)
+utils::centerWidget(QWidget *widget, QWindow *parent)
 {
-    auto findCenter = [childRect = widget->rect()](QRect hostRect) -> QPoint {
-        return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
-                      hostRect.center().y() - (childRect.height() * 0.5));
-    };
-
     if (parent) {
-        widget->move(parent->window()->frameGeometry().topLeft() +
-                     parent->window()->rect().center() - widget->rect().center());
+        widget->window()->windowHandle()->setTransientParent(parent);
         return;
     }
 
-    // Deprecated in 5.13: widget->move(findCenter(QApplication::desktop()->screenGeometry()));
+    auto findCenter = [childRect = widget->rect()](QRect hostRect) -> QPoint {
+        return QPoint(hostRect.center().x() - (childRect.width() * 0.5),
+                      hostRect.center().y() - (childRect.height() * 0.5));
+    };
     widget->move(findCenter(QGuiApplication::primaryScreen()->geometry()));
 }
 
diff --git a/src/Utils.h b/src/Utils.h
index 87ce1c34..0b6034ac 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -290,7 +290,7 @@ luminance(const QColor &col);
 
 //! Center a widget in relation to another widget.
 void
-centerWidget(QWidget *widget, QWidget *parent);
+centerWidget(QWidget *widget, QWindow *parent);
 
 void
 restoreCombobox(QComboBox *combo, const QString &value);