diff --git a/src/models/sortfilterroomtreemodel.cpp b/src/models/sortfilterroomtreemodel.cpp
index b32fc58ca..93ed073aa 100644
--- a/src/models/sortfilterroomtreemodel.cpp
+++ b/src/models/sortfilterroomtreemodel.cpp
@@ -7,6 +7,7 @@
#include "neochatconfig.h"
#include "neochatconnection.h"
#include "neochatroomtype.h"
+#include "roommanager.h"
#include "roomtreemodel.h"
#include "spacehierarchycache.h"
@@ -32,6 +33,12 @@ SortFilterRoomTreeModel::SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QOb
});
connect(NeoChatConfig::self(), &NeoChatConfig::CollapsedChanged, this, &SortFilterRoomTreeModel::invalidateFilter);
+ connect(NeoChatConfig::self(), &NeoChatConfig::AllRoomsInHomeChanged, this, [this]() {
+ invalidateFilter();
+ if (NeoChatConfig::self()->allRoomsInHome()) {
+ RoomManager::instance().resetState();
+ }
+ });
}
void SortFilterRoomTreeModel::setRoomSortOrder(SortFilterRoomTreeModel::RoomSortOrder sortOrder)
@@ -154,6 +161,11 @@ bool SortFilterRoomTreeModel::filterAcceptsRow(int source_row, const QModelIndex
return false;
}
+ static auto config = NeoChatConfig::self();
+ if (config->allRoomsInHome() && RoomManager::instance().currentSpace().isEmpty()) {
+ return acceptRoom;
+ }
+
if (m_activeSpaceId.isEmpty()) {
if (!SpaceHierarchyCache::instance().isChild(sourceModel()->data(index, RoomTreeModel::RoomIdRole).toString())) {
return acceptRoom;
diff --git a/src/neochatconfig.kcfg b/src/neochatconfig.kcfg
index 10d20ab41..f03e97d7c 100644
--- a/src/neochatconfig.kcfg
+++ b/src/neochatconfig.kcfg
@@ -5,6 +5,10 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+
+
+ false
+
diff --git a/src/roommanager.cpp b/src/roommanager.cpp
index e39b07d3a..df4653f54 100644
--- a/src/roommanager.cpp
+++ b/src/roommanager.cpp
@@ -8,6 +8,7 @@
#include "controller.h"
#include "eventhandler.h"
#include "models/timelinemodel.h"
+#include "neochatconfig.h"
#include "neochatconnection.h"
#include "neochatroom.h"
#include "spacehierarchycache.h"
@@ -421,6 +422,11 @@ void RoomManager::setCurrentRoom(const QString &roomId)
if (parentSpaces.contains(m_currentSpaceId)) {
return;
}
+ static auto config = NeoChatConfig::self();
+ if (config->allRoomsInHome()) {
+ setCurrentSpace({}, false);
+ return;
+ }
if (const auto &parent = m_connection->room(m_currentRoom->canonicalParent())) {
for (const auto &parentParent : SpaceHierarchyCache::instance().parentSpaces(parent->id())) {
if (SpaceHierarchyCache::instance().parentSpaces(parentParent).isEmpty()) {
@@ -445,4 +451,10 @@ QString RoomManager::currentSpace() const
return m_currentSpaceId;
}
+void RoomManager::resetState()
+{
+ setCurrentRoom({});
+ setCurrentSpace({});
+}
+
#include "moc_roommanager.cpp"
diff --git a/src/roommanager.h b/src/roommanager.h
index fa66f767f..1a91373e6 100644
--- a/src/roommanager.h
+++ b/src/roommanager.h
@@ -238,6 +238,11 @@ public:
*/
void setConnection(NeoChatConnection *connection);
+ /**
+ * Closes the current room and space; for situations, where it is unclear which room should be opened.
+ */
+ void resetState();
+
Q_SIGNALS:
/** Ask the user whether the room should be joined. */
void askJoinRoom(const QString &nameOrId);
diff --git a/src/settings/NeoChatGeneralPage.qml b/src/settings/NeoChatGeneralPage.qml
index af7612789..913856c1f 100644
--- a/src/settings/NeoChatGeneralPage.qml
+++ b/src/settings/NeoChatGeneralPage.qml
@@ -64,6 +64,22 @@ FormCard.FormCardPage {
Config.save();
}
}
+
+ FormCard.FormDelegateSeparator {
+ above: automaticallyDelegate
+ below: categorizeDelegate
+ }
+ FormCard.FormCheckDelegate {
+ id: categorizeDelegate
+ text: i18n("Show all rooms in \"Home\" tab")
+ checked: Config.allRoomsInHome
+ enabled: !Config.isAllRoomsInHomeImmutable
+ onToggled: {
+ Config.allRoomsInHome = checked;
+ Config.save();
+ }
+ }
+
}
FormCard.FormHeader {
title: i18n("Room list sort order")