mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Activate window that already has the room open if possible
This commit is contained in:
parent
62bf1b253e
commit
87070289fd
5 changed files with 22 additions and 9 deletions
|
@ -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(¬ificationsManager,
|
||||
&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…
Reference in a new issue