summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-01-30 19:14:33 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-01-30 19:14:33 +0100
commit2613275461fcf46ceb401b99fc6179bd3b1445f2 (patch)
treea343d293021df5906282e09aafed5e2dde412161 /src
parentRemove a few unused includes (diff)
downloadnheko-2613275461fcf46ceb401b99fc6179bd3b1445f2.tar.xz
Reimplement error notifications
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp5
-rw-r--r--src/MainWindow.h2
-rw-r--r--src/ui/OverlayWidget.cpp79
-rw-r--r--src/ui/OverlayWidget.h26
4 files changed, 4 insertions, 108 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 64587075..83504d86 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -84,9 +84,8 @@ MainWindow::MainWindow(QWindow *parent)
     connect(chat_page_, &ChatPage::closing, this, [this] { switchToLoginPage(""); });
     connect(chat_page_, &ChatPage::unreadMessages, this, &MainWindow::setWindowTitle);
     connect(chat_page_, SIGNAL(unreadMessages(int)), trayIcon_, SLOT(setUnreadCount(int)));
-    connect(chat_page_, &ChatPage::showLoginPage, this, [this](const QString &msg) {
-        switchToLoginPage(msg);
-    });
+    connect(chat_page_, &ChatPage::showLoginPage, this, &MainWindow::switchToLoginPage);
+    connect(chat_page_, &ChatPage::showNotification, this, &MainWindow::showNotification);
 
     connect(userSettings_.get(), &UserSettings::trayChanged, trayIcon_, &TrayIcon::setVisible);
     connect(trayIcon_,
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 80ade988..7bc94328 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -70,6 +70,8 @@ signals:
     void reload();
     void secretsChanged();
 
+    void showNotification(QString msg);
+
     void switchToChatPage();
     void switchToWelcomePage();
     void switchToLoginPage(QString error);
diff --git a/src/ui/OverlayWidget.cpp b/src/ui/OverlayWidget.cpp
deleted file mode 100644
index b755a44c..00000000
--- a/src/ui/OverlayWidget.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Nheko Contributors
-// SPDX-FileCopyrightText: 2022 Nheko Contributors
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "OverlayWidget.h"
-
-#include <QPainter>
-#include <QStyleOption>
-
-OverlayWidget::OverlayWidget(QWidget *parent)
-  : QWidget(parent)
-{
-    if (parent) {
-        parent->installEventFilter(this);
-        setGeometry(overlayGeometry());
-        raise();
-    }
-}
-
-bool
-OverlayWidget::event(QEvent *event)
-{
-    if (!parent())
-        return QWidget::event(event);
-
-    switch (event->type()) {
-    case QEvent::ParentChange: {
-        parent()->installEventFilter(this);
-        setGeometry(overlayGeometry());
-        break;
-    }
-    case QEvent::ParentAboutToChange: {
-        parent()->removeEventFilter(this);
-        break;
-    }
-    default:
-        break;
-    }
-
-    return QWidget::event(event);
-}
-
-bool
-OverlayWidget::eventFilter(QObject *obj, QEvent *event)
-{
-    switch (event->type()) {
-    case QEvent::Move:
-    case QEvent::Resize:
-        setGeometry(overlayGeometry());
-        break;
-    default:
-        break;
-    }
-
-    return QWidget::eventFilter(obj, event);
-}
-
-QRect
-OverlayWidget::overlayGeometry() const
-{
-    QWidget *widget = parentWidget();
-
-    if (!widget)
-        return QRect();
-
-    return widget->rect();
-}
-
-void
-OverlayWidget::paintEvent(QPaintEvent *event)
-{
-    Q_UNUSED(event);
-
-    QStyleOption opt;
-    opt.initFrom(this);
-    QPainter p(this);
-    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
-}
diff --git a/src/ui/OverlayWidget.h b/src/ui/OverlayWidget.h
deleted file mode 100644
index 19ad0cc6..00000000
--- a/src/ui/OverlayWidget.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Nheko Contributors
-// SPDX-FileCopyrightText: 2022 Nheko Contributors
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#pragma once
-
-#include <QEvent>
-#include <QWidget>
-
-class QPainter;
-
-class OverlayWidget : public QWidget
-{
-    Q_OBJECT
-
-public:
-    explicit OverlayWidget(QWidget *parent = nullptr);
-
-protected:
-    bool event(QEvent *event) override;
-    bool eventFilter(QObject *obj, QEvent *event) override;
-
-    QRect overlayGeometry() const;
-    void paintEvent(QPaintEvent *event) override;
-};