Make notifications show the window again

fixes #1329
This commit is contained in:
Nicolas Werner 2023-02-01 18:24:25 +01:00
parent 673ca9d6a3
commit 7734c4735a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
2 changed files with 13 additions and 1 deletions

View file

@ -144,9 +144,13 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
Q_UNUSED(eventid) Q_UNUSED(eventid)
auto exWin = MainWindow::instance()->windowForRoom(roomid); auto exWin = MainWindow::instance()->windowForRoom(roomid);
if (exWin) { if (exWin) {
exWin->setVisible(true);
exWin->raise();
exWin->requestActivate(); exWin->requestActivate();
} else { } else {
view_manager_->rooms()->setCurrentRoom(roomid); view_manager_->rooms()->setCurrentRoom(roomid);
MainWindow::instance()->setVisible(true);
MainWindow::instance()->raise();
MainWindow::instance()->requestActivate(); MainWindow::instance()->requestActivate();
} }
}); });
@ -1621,9 +1625,13 @@ ChatPage::sendNotificationReply(const QString &roomid, const QString &eventid, c
view_manager_->queueReply(roomid, eventid, body); view_manager_->queueReply(roomid, eventid, body);
auto exWin = MainWindow::instance()->windowForRoom(roomid); auto exWin = MainWindow::instance()->windowForRoom(roomid);
if (exWin) { if (exWin) {
exWin->setVisible(true);
exWin->raise();
exWin->requestActivate(); exWin->requestActivate();
} else { } else {
view_manager_->rooms()->setCurrentRoom(roomid); view_manager_->rooms()->setCurrentRoom(roomid);
MainWindow::instance()->setVisible(true);
MainWindow::instance()->raise();
MainWindow::instance()->requestActivate(); MainWindow::instance()->requestActivate();
} }
} }

View file

@ -233,9 +233,13 @@ TimelineViewManager::showEvent(const QString &room_id, const QString &event_id)
if (auto room = rooms_->getRoomById(room_id)) { if (auto room = rooms_->getRoomById(room_id)) {
auto exWin = MainWindow::instance()->windowForRoom(room_id); auto exWin = MainWindow::instance()->windowForRoom(room_id);
if (exWin) { if (exWin) {
exWin->setVisible(true);
exWin->raise();
exWin->requestActivate(); exWin->requestActivate();
} else if (rooms_->currentRoom() != room) { } else {
rooms_->setCurrentRoom(room_id); rooms_->setCurrentRoom(room_id);
MainWindow::instance()->setVisible(true);
MainWindow::instance()->raise();
MainWindow::instance()->requestActivate(); MainWindow::instance()->requestActivate();
nhlog::ui()->info("Activated room {}", room_id.toStdString()); nhlog::ui()->info("Activated room {}", room_id.toStdString());
} }