From c330bb4ff5378895dd9e1a6a871f1890ae0af41d Mon Sep 17 00:00:00 2001 From: Black Hat Date: Fri, 20 Jul 2018 13:50:25 +0800 Subject: [PATCH] Prefetch messages when adding room && wire setting. --- qml/Room.qml | 2 +- qml/form/RoomForm.qml | 2 -- qml/form/RoomListForm.qml | 2 +- qml/main.qml | 29 +++++++++++++++++++++++++---- src/roomlistmodel.cpp | 1 + 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/qml/Room.qml b/qml/Room.qml index 0672a89..d389a14 100644 --- a/qml/Room.qml +++ b/qml/Room.qml @@ -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 diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index 1da416e..fc18986 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -92,8 +92,6 @@ Item { model: MessageEventModel{ id: messageEventModel room: currentRoom - - onRoomChanged: room.timelineSize === 0 ? room.getPreviousContent(50) : {} } delegate: MessageDelegate {} diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 511c202..ade5c99 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -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 diff --git a/qml/main.qml b/qml/main.qml index 381ae94..6811a6e 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -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() diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index adc5097..1622bdb 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -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);