Prefetch messages when adding room && wire setting.

This commit is contained in:
Black Hat 2018-07-20 13:50:25 +08:00
parent 6f6a7da414
commit c330bb4ff5
5 changed files with 28 additions and 8 deletions

View File

@ -26,7 +26,7 @@ Page {
id: roomListForm
Layout.fillHeight: true
Layout.preferredWidth: settingPage.miniMode ? 80 : page.width * 0.4
Layout.preferredWidth: setting.miniMode ? 80 : page.width * 0.35
Layout.minimumWidth: 80
Layout.maximumWidth: 360

View File

@ -92,8 +92,6 @@ Item {
model: MessageEventModel{
id: messageEventModel
room: currentRoom
onRoomChanged: room.timelineSize === 0 ? room.getPreviousContent(50) : {}
}
delegate: MessageDelegate {}

View File

@ -12,7 +12,7 @@ import "qrc:/qml/component"
Item {
property alias listModel: roomListProxyModel.sourceModel
property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex)
readonly property bool mini: settingPage.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode".
ColumnLayout {
anchors.fill: parent

View File

@ -15,19 +15,26 @@ ApplicationWindow {
visible: true
width: 960
height: 640
minimumWidth: 480
minimumHeight: 320
minimumWidth: 640
minimumHeight: 480
title: qsTr("Matrique")
Material.theme: settingPage.darkTheme ? Material.Dark : Material.Light
Material.theme: setting.darkTheme ? Material.Dark : Material.Light
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
Settings.Settings {
id: setting
property alias windowWidth: window.width
property alias windowHeight: window.height
property alias homeserver: matriqueController.homeserver
property alias userID: matriqueController.userID
property alias token: matriqueController.token
property alias darkTheme: settingPage.darkTheme
property alias miniMode: settingPage.miniMode
}
Platform.SystemTrayIcon {
@ -36,7 +43,21 @@ ApplicationWindow {
visible: true
iconSource: "qrc:/asset/img/icon.png"
onActivated: {
menu: Platform.Menu {
MenuItem {
text: "Hide/Show"
onTriggered: window.active ? window.hide() : raiseWindow()
}
MenuItem {
text: "Quit"
onTriggered: Qt.quit()
}
}
onActivated: window.active ? window.hide() : raiseWindow()
function raiseWindow() {
window.show()
window.raise()
window.requestActivate()

View File

@ -43,6 +43,7 @@ void RoomListModel::doAddRoom(QMatrixClient::Room* r) {
if (auto* room = r) {
m_rooms.append(room);
connectRoomSignals(room);
if (room->timelineSize() == 0) room->getPreviousContent(50);
} else {
qCritical() << "Attempt to add nullptr to the room list";
Q_ASSERT(false);