Update libqmatrixclient && add a progress bar.

This commit is contained in:
Black Hat
2018-09-30 22:13:54 +08:00
parent 6ecef7608c
commit 56b820e1a8
4 changed files with 35 additions and 7 deletions

View File

@@ -100,6 +100,14 @@ Item {
} }
} }
ProgressBar {
Layout.fillWidth: true
z: 10
visible: currentRoom && currentRoom.busy
indeterminate: true
}
ListView { ListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@@ -122,11 +130,9 @@ Item {
onContentYChanged: { onContentYChanged: {
// Check whether we're about to bump into the ceiling in 2 seconds // Check whether we're about to bump into the ceiling in 2 seconds
var curVelocity = verticalVelocity // Snapshot the current speed var curVelocity = verticalVelocity // Snapshot the current speed
if(curVelocity < 0 && contentY + curVelocity*2 < originY) if(curVelocity < 0 && contentY + curVelocity * 2 < originY)
{ {
// Request the amount of messages enough to scroll at this currentRoom.getPreviousContent(50);
// rate for 3 more seconds
currentRoom.getPreviousContent(20);
} }
} }
@@ -159,8 +165,8 @@ Item {
console.log("Scrolling to position", lastScrollPosition) console.log("Scrolling to position", lastScrollPosition)
messageListView.currentIndex = lastScrollPosition messageListView.currentIndex = lastScrollPosition
} }
if (messageListView.contentY < messageListView.originY + 10) if (messageListView.contentY < messageListView.originY + 10 || currentRoom.timelineSize === 0)
currentRoom.getPreviousContent(100) currentRoom.getPreviousContent(50)
} }
console.log("Model timeline reset") console.log("Model timeline reset")
} }

View File

@@ -17,6 +17,8 @@ SpectralRoom::SpectralRoom(Connection* connection, QString roomId,
&SpectralRoom::countChanged); &SpectralRoom::countChanged);
connect(this, &SpectralRoom::highlightCountChanged, this, connect(this, &SpectralRoom::highlightCountChanged, this,
&SpectralRoom::countChanged); &SpectralRoom::countChanged);
connect(this, &Room::addedMessages, this,
[=] { setBusy(false); });
} }
void SpectralRoom::chooseAndUploadFile() { void SpectralRoom::chooseAndUploadFile() {
@@ -175,3 +177,8 @@ void SpectralRoom::saveViewport(int topIndex, int bottomIndex) {
setFirstDisplayedEvent(maxTimelineIndex() - topIndex); setFirstDisplayedEvent(maxTimelineIndex() - topIndex);
setLastDisplayedEvent(maxTimelineIndex() - bottomIndex); setLastDisplayedEvent(maxTimelineIndex() - bottomIndex);
} }
void SpectralRoom::getPreviousContent(int limit) {
setBusy(true);
Room::getPreviousContent(limit);
}

View File

@@ -15,6 +15,8 @@ class SpectralRoom : public Room {
Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged) Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged)
Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY
cachedInputChanged) cachedInputChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
public: public:
explicit SpectralRoom(Connection* connection, QString roomId, explicit SpectralRoom(Connection* connection, QString roomId,
JoinState joinState = {}); JoinState joinState = {});
@@ -29,6 +31,14 @@ class SpectralRoom : public Room {
} }
} }
bool busy() { return m_busy; }
void setBusy(bool value) {
if (m_busy != value) {
m_busy = value;
emit busyChanged();
}
}
bool hasUsersTyping(); bool hasUsersTyping();
QString getUsersTyping(); QString getUsersTyping();
@@ -42,10 +52,14 @@ class SpectralRoom : public Room {
Q_INVOKABLE int savedBottomVisibleIndex() const; Q_INVOKABLE int savedBottomVisibleIndex() const;
Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex); Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex);
Q_INVOKABLE void getPreviousContent(int limit = 10);
private: private:
QString m_cachedInput; QString m_cachedInput;
QSet<const QMatrixClient::RoomEvent*> highlights; QSet<const QMatrixClient::RoomEvent*> highlights;
bool m_busy;
QString getMIME(const QUrl& fileUrl) const; QString getMIME(const QUrl& fileUrl) const;
void postFile(const QUrl& localFile, const QUrl& mxcUrl); void postFile(const QUrl& localFile, const QUrl& mxcUrl);
@@ -59,6 +73,7 @@ class SpectralRoom : public Room {
signals: signals:
void cachedInputChanged(); void cachedInputChanged();
void busyChanged();
public slots: public slots:
void chooseAndUploadFile(); void chooseAndUploadFile();