Save collapsed categories
This commit is contained in:
@@ -60,11 +60,11 @@ int main(int argc, char *argv[])
|
|||||||
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
||||||
|
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
NeoChatConfig config;
|
auto config = NeoChatConfig::self();
|
||||||
|
|
||||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Controller", &Controller::instance());
|
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Controller", &Controller::instance());
|
||||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Clipboard", &clipboard);
|
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Clipboard", &clipboard);
|
||||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Config", &config);
|
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Config", config);
|
||||||
qmlRegisterType<AccountListModel>("org.kde.neochat", 1, 0, "AccountListModel");
|
qmlRegisterType<AccountListModel>("org.kde.neochat", 1, 0, "AccountListModel");
|
||||||
qmlRegisterType<RoomListModel>("org.kde.neochat", 1, 0, "RoomListModel");
|
qmlRegisterType<RoomListModel>("org.kde.neochat", 1, 0, "RoomListModel");
|
||||||
qmlRegisterType<UserListModel>("org.kde.neochat", 1, 0, "UserListModel");
|
qmlRegisterType<UserListModel>("org.kde.neochat", 1, 0, "UserListModel");
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||||
|
<kcfgfile name="neochatrc" />
|
||||||
<group name="General">
|
<group name="General">
|
||||||
<entry name="CollapsedSections" type="StringList">
|
<entry name="CollapsedSections" type="IntList">
|
||||||
<label>Collapsed sections in the room list</label>
|
<label>Collapsed sections in the room list</label>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="OpenRoom" type="String">
|
<entry name="OpenRoom" type="String">
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ Mutators=true
|
|||||||
DefaultValueGetters=true
|
DefaultValueGetters=true
|
||||||
GenerateProperties=true
|
GenerateProperties=true
|
||||||
ParentInConstructor=true
|
ParentInConstructor=true
|
||||||
|
Singleton=true
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "neochatconfig.h"
|
||||||
|
|
||||||
#include "events/roomevent.h"
|
#include "events/roomevent.h"
|
||||||
|
|
||||||
@@ -20,6 +21,10 @@
|
|||||||
RoomListModel::RoomListModel(QObject *parent)
|
RoomListModel::RoomListModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
|
const auto collaposedSections = NeoChatConfig::collapsedSections();
|
||||||
|
for (auto collapsedSection : collaposedSections) {
|
||||||
|
m_categoryVisibility[collapsedSection] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomListModel::~RoomListModel()
|
RoomListModel::~RoomListModel()
|
||||||
@@ -311,6 +316,15 @@ QString RoomListModel::categoryName(int section) const
|
|||||||
void RoomListModel::setCategoryVisible(int category, bool visible)
|
void RoomListModel::setCategoryVisible(int category, bool visible)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
auto collaposedSections = NeoChatConfig::collapsedSections();
|
||||||
|
if (visible) {
|
||||||
|
collaposedSections.removeAll(category);
|
||||||
|
} else {
|
||||||
|
collaposedSections.push_back(category);
|
||||||
|
}
|
||||||
|
NeoChatConfig::setCollapsedSections(collaposedSections);
|
||||||
|
NeoChatConfig::self()->save();
|
||||||
|
|
||||||
m_categoryVisibility[category] = visible;
|
m_categoryVisibility[category] = visible;
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user