Activate window that already has the room open if possible

imageformats
Nicolas Werner 3 years ago
parent 62bf1b253e
commit 87070289fd
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 2
      resources/qml/RoomList.qml
  2. 18
      src/ChatPage.cpp
  3. 4
      src/MainWindow.cpp
  4. 2
      src/MainWindow.h
  5. 5
      src/timeline/TimelineViewManager.cpp

@ -82,7 +82,7 @@ Page {
minimumHeight: 150
palette: Nheko.colors
color: Nheko.colors.window
title: room.roomName
title: room.plainRoomName
modality: Qt.NonModal
flags: Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowTitleHint

@ -152,16 +152,26 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
this,
[this](const QString &roomid, const QString &eventid) {
Q_UNUSED(eventid)
view_manager_->rooms()->setCurrentRoom(roomid);
MainWindow::instance()->requestActivate();
auto exWin = MainWindow::instance()->windowForRoom(roomid);
if (exWin) {
exWin->requestActivate();
} else {
view_manager_->rooms()->setCurrentRoom(roomid);
MainWindow::instance()->requestActivate();
}
});
connect(&notificationsManager,
&NotificationsManager::sendNotificationReply,
this,
[this](const QString &roomid, const QString &eventid, const QString &body) {
view_manager_->rooms()->setCurrentRoom(roomid);
view_manager_->queueReply(roomid, eventid, body);
MainWindow::instance()->requestActivate();
auto exWin = MainWindow::instance()->windowForRoom(roomid);
if (exWin) {
exWin->requestActivate();
} else {
view_manager_->rooms()->setCurrentRoom(roomid);
MainWindow::instance()->requestActivate();
}
});
connect(

@ -445,8 +445,8 @@ MainWindow::removePerRoomWindow(const QString &room, QWindow *window)
{
roomWindows_.remove(room, window);
}
const QWindow *
MainWindow::windowForRoom(const QString &room) const
QWindow *
MainWindow::windowForRoom(const QString &room)
{
auto currMainWindowRoom = ChatPage::instance()->timelineManager()->rooms()->currentRoom();
if ((currMainWindowRoom && currMainWindowRoom->roomId() == room) ||

@ -61,7 +61,7 @@ public:
Q_INVOKABLE void addPerRoomWindow(const QString &room, QWindow *window);
Q_INVOKABLE void removePerRoomWindow(const QString &room, QWindow *window);
const QWindow *windowForRoom(const QString &room) const;
QWindow *windowForRoom(const QString &room);
QString focusedRoom() const;
protected:

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

Loading…
Cancel
Save