diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-05-06 00:36:38 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-05-06 00:36:53 +0200 |
commit | b75ef07896b83dc50a11a7af525bff381d50b565 (patch) | |
tree | 5573ff6b667c3648454266e5716cf33288b68491 /src/timeline | |
parent | Translated using Weblate (Finnish) (diff) | |
download | nheko-b75ef07896b83dc50a11a7af525bff381d50b565.tar.xz |
Add basic support for multiple windows
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/RoomlistModel.cpp | 28 | ||||
-rw-r--r-- | src/timeline/RoomlistModel.h | 5 | ||||
-rw-r--r-- | src/timeline/TimelineModel.cpp | 2 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 10 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.h | 3 |
5 files changed, 34 insertions, 14 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index ea4f6fa8..1e0b4c23 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -692,6 +692,34 @@ RoomlistModel::leave(QString roomid, QString reason) } } +RoomPreview +RoomlistModel::getRoomPreviewById(QString roomid) const +{ + RoomPreview preview{}; + + if (invites.contains(roomid) || previewedRooms.contains(roomid)) { + std::optional<RoomInfo> i; + if (invites.contains(roomid)) { + i = invites.value(roomid); + preview.isInvite_ = true; + } else { + i = previewedRooms.value(roomid); + preview.isInvite_ = false; + } + + if (i) { + preview.roomid_ = roomid; + preview.roomName_ = QString::fromStdString(i->name); + preview.roomTopic_ = QString::fromStdString(i->topic); + preview.roomAvatarUrl_ = QString::fromStdString(i->avatar_url); + } else { + preview.roomid_ = roomid; + } + } + + return preview; +} + void RoomlistModel::setCurrentRoom(QString roomid) { diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index 9546d434..43713d8b 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -89,6 +89,7 @@ public: else return {}; } + RoomPreview getRoomPreviewById(QString roomid) const; public slots: void initializeRooms(); @@ -185,6 +186,10 @@ public slots: { return roomlistmodel->getRoomById(id).data(); } + RoomPreview getRoomPreviewById(QString roomid) const + { + return roomlistmodel->getRoomPreviewById(roomid); + } void nextRoomWithActivity(); void nextRoom(); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 4309fb24..77cf6294 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1072,7 +1072,7 @@ TimelineModel::setCurrentIndex(int index) if (index != oldIndex) emit currentIndexChanged(index); - if (MainWindow::instance() != QGuiApplication::focusWindow()) + if (MainWindow::instance()->activeRoom() != roomId()) return; if (!currentId.startsWith('m')) { diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 3bccd8f3..b37e24b0 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -138,10 +138,6 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent) isInitialSync_ = true; emit initialSyncChanged(true); }); - connect(qobject_cast<QApplication *>(QApplication::instance()), - &QApplication::focusWindowChanged, - this, - &TimelineViewManager::focusChanged); connect(parent, &ChatPage::connectionLost, this, [this] { isConnected_ = false; emit isConnectedChanged(false); @@ -152,12 +148,6 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent) }); } -bool -TimelineViewManager::isWindowFocused() const -{ - return MainWindow::instance() == QApplication::focusWindow(); -} - void TimelineViewManager::openRoomMembers(TimelineModel *room) { diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 08943e8c..020bdac5 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -41,7 +41,6 @@ class TimelineViewManager : public QObject Q_PROPERTY( bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged) - Q_PROPERTY(bool isWindowFocused READ isWindowFocused NOTIFY focusChanged) Q_PROPERTY(bool isConnected READ isConnected NOTIFY isConnectedChanged) public: @@ -54,7 +53,6 @@ public: void clearAll() { rooms_->clear(); } Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } - bool isWindowFocused() const; bool isConnected() const { return isConnected_; } Q_INVOKABLE void openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId); Q_INVOKABLE void openImagePackSettings(QString roomid); @@ -82,7 +80,6 @@ signals: void inviteUsers(QString roomId, QStringList users); void showRoomList(); void narrowViewChanged(); - void focusChanged(); void focusInput(); void openRoomMembersDialog(MemberList *members, TimelineModel *room); void openRoomSettingsDialog(RoomSettings *settings); |