Remember last opened room
This commit is contained in:
13
qml/main.qml
13
qml/main.qml
@@ -34,6 +34,16 @@ Kirigami.ApplicationWindow {
|
|||||||
signal leaveRoom(string room);
|
signal leaveRoom(string room);
|
||||||
signal openRoom(string room);
|
signal openRoom(string room);
|
||||||
|
|
||||||
|
function loadInitialRoom() {
|
||||||
|
if (Config.openRoom) {
|
||||||
|
const room = Controller.activeConnection.room(Config.openRoom);
|
||||||
|
pageStack.push(roomPage, { 'currentRoom': room, });
|
||||||
|
} else {
|
||||||
|
// TODO create welcome page
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function enterRoom(room) {
|
function enterRoom(room) {
|
||||||
if (currentRoom != null) {
|
if (currentRoom != null) {
|
||||||
currentRoom = null;
|
currentRoom = null;
|
||||||
@@ -41,6 +51,8 @@ Kirigami.ApplicationWindow {
|
|||||||
}
|
}
|
||||||
var item = pageStack.push(roomPage, { 'currentRoom': room, });
|
var item = pageStack.push(roomPage, { 'currentRoom': room, });
|
||||||
currentRoom = room;
|
currentRoom = room;
|
||||||
|
Config.openRoom = room.id;
|
||||||
|
Config.save();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +114,7 @@ Kirigami.ApplicationWindow {
|
|||||||
pageStack.replace("qrc:/imports/NeoChat/Page/LoginPage.qml", {});
|
pageStack.replace("qrc:/imports/NeoChat/Page/LoginPage.qml", {});
|
||||||
} else {
|
} else {
|
||||||
pageStack.replace(roomListComponent, {'activeConnection': Controller.activeConnection});
|
pageStack.replace(roomListComponent, {'activeConnection': Controller.activeConnection});
|
||||||
|
roomManager.loadInitialRoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<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">
|
||||||
<label>Latest opened room.</label>
|
<label>Latest opened room</label>
|
||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
</kcfg>
|
</kcfg>
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
RoomListModel::RoomListModel(QObject *parent)
|
RoomListModel::RoomListModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
const auto collaposedSections = NeoChatConfig::collapsedSections();
|
const auto collapsedSections = NeoChatConfig::collapsedSections();
|
||||||
for (auto collapsedSection : collaposedSections) {
|
for (auto collapsedSection : collapsedSections) {
|
||||||
m_categoryVisibility[collapsedSection] = false;
|
m_categoryVisibility[collapsedSection] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,13 +316,13 @@ 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();
|
auto collapsedSections = NeoChatConfig::collapsedSections();
|
||||||
if (visible) {
|
if (visible) {
|
||||||
collaposedSections.removeAll(category);
|
collapsedSections.removeAll(category);
|
||||||
} else {
|
} else {
|
||||||
collaposedSections.push_back(category);
|
collapsedSections.push_back(category);
|
||||||
}
|
}
|
||||||
NeoChatConfig::setCollapsedSections(collaposedSections);
|
NeoChatConfig::setCollapsedSections(collapsedSections);
|
||||||
NeoChatConfig::self()->save();
|
NeoChatConfig::self()->save();
|
||||||
|
|
||||||
m_categoryVisibility[category] = visible;
|
m_categoryVisibility[category] = visible;
|
||||||
|
|||||||
Reference in New Issue
Block a user