summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-09-03 19:34:17 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2020-09-16 23:49:17 +0200
commit77e241b9e57a3248e2efb16e6cb081a19a666db7 (patch)
treee1f44e5b252ce2931d41dc57b10671efee58e58c /src
parentPort top bar to Qml (diff)
downloadnheko-77e241b9e57a3248e2efb16e6cb081a19a666db7.tar.xz
Reenable top bar room settings menus on avatar or title clicks
Also fixes a bug with an empty room settings window introduced in the
port.
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp3
-rw-r--r--src/MainWindow.cpp13
-rw-r--r--src/MainWindow.h6
-rw-r--r--src/timeline/TimelineModel.h1
-rw-r--r--src/timeline/TimelineViewManager.cpp6
5 files changed, 14 insertions, 15 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 1339f353..cf1a6062 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -225,6 +225,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
                 }
         });
 
+        connect(room_list_, &RoomList::roomChanged, this, [this](QString room_id) {
+                this->current_room_ = room_id;
+        });
         connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::stopTyping);
         connect(room_list_, &RoomList::roomChanged, splitter, &Splitter::showChatView);
         connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::focusLineEdit);
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 90bffa70..29abed86 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -340,9 +340,7 @@ MainWindow::openUserProfile(const QString &user_id, const QString &room_id)
 void
 MainWindow::openRoomSettings(const QString &room_id)
 {
-        const auto roomToSearch = room_id.isEmpty() ? chat_page_->currentRoom() : "";
-
-        auto dialog = new dialogs::RoomSettings(roomToSearch, this);
+        auto dialog = new dialogs::RoomSettings(room_id, this);
 
         showDialog(dialog);
 }
@@ -350,8 +348,7 @@ MainWindow::openRoomSettings(const QString &room_id)
 void
 MainWindow::openMemberListDialog(const QString &room_id)
 {
-        const auto roomToSearch = room_id.isEmpty() ? chat_page_->currentRoom() : "";
-        auto dialog             = new dialogs::MemberList(roomToSearch, this);
+        auto dialog = new dialogs::MemberList(room_id, this);
 
         showDialog(dialog);
 }
@@ -359,11 +356,9 @@ MainWindow::openMemberListDialog(const QString &room_id)
 void
 MainWindow::openLeaveRoomDialog(const QString &room_id)
 {
-        auto roomToLeave = room_id.isEmpty() ? chat_page_->currentRoom() : room_id;
-
         auto dialog = new dialogs::LeaveRoom(this);
-        connect(dialog, &dialogs::LeaveRoom::leaving, this, [this, roomToLeave]() {
-                chat_page_->leaveRoom(roomToLeave);
+        connect(dialog, &dialogs::LeaveRoom::leaving, this, [this, room_id]() {
+                chat_page_->leaveRoom(room_id);
         });
 
         showDialog(dialog);
diff --git a/src/MainWindow.h b/src/MainWindow.h
index e3e04698..4f54a195 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -68,14 +68,14 @@ public:
         static MainWindow *instance() { return instance_; };
         void saveCurrentWindowSize();
 
-        void openLeaveRoomDialog(const QString &room_id = "");
+        void openLeaveRoomDialog(const QString &room_id);
         void openInviteUsersDialog(std::function<void(const QStringList &invitees)> callback);
         void openCreateRoomDialog(
           std::function<void(const mtx::requests::CreateRoom &request)> callback);
         void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
         void openLogoutDialog();
-        void openRoomSettings(const QString &room_id = "");
-        void openMemberListDialog(const QString &room_id = "");
+        void openRoomSettings(const QString &room_id);
+        void openMemberListDialog(const QString &room_id);
         void openUserProfile(const QString &user_id, const QString &room_id);
         void openReadReceiptsDialog(const QString &event_id);
 
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 34f2f78a..1e482be2 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -260,6 +260,7 @@ public slots:
         QString roomName() const;
         QString roomTopic() const;
         QString roomAvatarUrl() const;
+        QString roomId() const { return room_id_; }
 
 private slots:
         void addPendingMessage(mtx::events::collections::TimelineEvents event);
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index 32d8b0b2..06f0fa3d 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -253,17 +253,17 @@ TimelineViewManager::openInviteUsersDialog()
 void
 TimelineViewManager::openMemberListDialog() const
 {
-        MainWindow::instance()->openMemberListDialog();
+        MainWindow::instance()->openMemberListDialog(timeline_->roomId());
 }
 void
 TimelineViewManager::openLeaveRoomDialog() const
 {
-        MainWindow::instance()->openLeaveRoomDialog();
+        MainWindow::instance()->openLeaveRoomDialog(timeline_->roomId());
 }
 void
 TimelineViewManager::openRoomSettings() const
 {
-        MainWindow::instance()->openRoomSettings();
+        MainWindow::instance()->openRoomSettings(timeline_->roomId());
 }
 
 void