Add option to show all rooms in "uncategorized" tab
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="neochatrc" />
|
||||
<group name="General">
|
||||
<entry name="AllRoomsInHome" type="bool">
|
||||
<label>Show all rooms in the home tab</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="CollapsedSections" type="IntList">
|
||||
<label>Collapsed sections in the room list</label>
|
||||
</entry>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user