A lot of improvements.

Fix laggish RoomListView when dragging.
Remove per-room timer and add timer in RoomForm.
Remove singleton module and use file as singleton.
Minor UI tweak in RoomListView.
Pass room to RoomListView via "currentRoom" delegate property and remove
RoomListForm-wide currentRoom.
Put menu files in a separate folder.
Show initial image in ImageStatus when avatar is not loaded.
Add about page.
Merge all setting pages into Setting.qml.
Add option to rearrange rooms by activity.
Add option to use RichText parser.
Add document url.
This commit is contained in:
Black Hat
2018-08-24 13:25:41 +08:00
parent 391473e559
commit cfa8043596
28 changed files with 247 additions and 287 deletions

View File

@@ -6,10 +6,10 @@
#include "controller.h"
#include "emojimodel.h"
#include "imageprovider.h"
#include "matriqueroom.h"
#include "messageeventmodel.h"
#include "room.h"
#include "roomlistmodel.h"
#include "matriqueroom.h"
#include "csapi/joining.h"
#include "csapi/leaving.h"
@@ -28,6 +28,7 @@ int main(int argc, char *argv[]) {
qRegisterMetaType<MatriqueRoom *>("MatriqueRoom*");
qRegisterMetaType<User *>("User*");
qRegisterMetaType<MessageEventType>("MessageEventType");
qRegisterMetaType<MatriqueRoom *>("MatriqueRoom");
qmlRegisterType<Controller>("Matrique", 0, 1, "Controller");
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
@@ -36,9 +37,10 @@ int main(int argc, char *argv[]) {
qmlRegisterUncreatableType<RoomMessageEvent>("Matrique", 0, 1,
"RoomMessageEvent", "ENUM");
qmlRegisterUncreatableType<RoomType>("Matrique", 0, 1, "RoomType", "ENUM");
qmlRegisterSingletonType(QUrl("qrc:/qml/MatriqueSettings.qml"),
"Matrique.Settings", 0, 1, "MSettings");
QQmlApplicationEngine engine;
engine.addImportPath("qrc:/qml");
ImageProvider *m_provider = new ImageProvider();

View File

@@ -12,25 +12,7 @@
MatriqueRoom::MatriqueRoom(Connection* connection, QString roomId,
JoinState joinState)
: Room(connection, std::move(roomId), joinState) {
m_timeoutTimer->setSingleShot(true);
m_timeoutTimer->setInterval(2000);
m_repeatTimer->setInterval(5000);
connect(m_timeoutTimer, &QTimer::timeout, [=] { setIsTyping(false); });
connect(m_repeatTimer, &QTimer::timeout,
[=] { sendTypingNotification(true); });
connect(this, &MatriqueRoom::isTypingChanged, [=] {
if (m_isTyping) {
m_timeoutTimer->start();
m_repeatTimer->start();
sendTypingNotification(true);
} else {
m_timeoutTimer->stop();
m_repeatTimer->stop();
sendTypingNotification(false);
}
});
}
: Room(connection, std::move(roomId), joinState) {}
void MatriqueRoom::chooseAndUploadFile() {
auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as"));
@@ -88,7 +70,7 @@ QString MatriqueRoom::getUsersTyping() {
for (User* user : users) {
usersTypingStr += user->displayname() + " ";
}
usersTypingStr += users.count() == 1 ? "is" : "are";
usersTypingStr += users.count() < 2 ? "is" : "are";
usersTypingStr += " typing.";
return usersTypingStr;
}

View File

@@ -10,8 +10,6 @@ using namespace QMatrixClient;
class MatriqueRoom : public Room {
Q_OBJECT
Q_PROPERTY(
bool isTyping READ isTyping WRITE setIsTyping NOTIFY isTypingChanged)
Q_PROPERTY(bool hasUsersTyping READ hasUsersTyping NOTIFY typingChanged)
Q_PROPERTY(QString usersTyping READ getUsersTyping NOTIFY typingChanged)
Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY
@@ -20,15 +18,6 @@ class MatriqueRoom : public Room {
explicit MatriqueRoom(Connection* connection, QString roomId,
JoinState joinState = {});
bool isTyping() { return m_isTyping; }
void setIsTyping(bool isTyping) {
if (isTyping) m_timeoutTimer->start();
if (isTyping != m_isTyping) {
m_isTyping = isTyping;
emit isTypingChanged();
}
}
const QString& cachedInput() const { return m_cachedInput; }
void setCachedInput(const QString& input) {
if (input != m_cachedInput) {
@@ -44,15 +33,11 @@ class MatriqueRoom : public Room {
private:
QString m_cachedInput;
bool m_isTyping;
QTimer* m_timeoutTimer = new QTimer();
QTimer* m_repeatTimer = new QTimer();
QString getMIME(const QUrl& fileUrl) const;
void postFile(const QUrl& localFile, const QUrl& mxcUrl);
signals:
void isTypingChanged();
void cachedInputChanged();
public slots:

View File

@@ -153,6 +153,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
}
if (role == UnreadCountRole) return room->unreadCount();
if (role == LastEventRole) return room->lastEvent();
if (role == CurrentRoomRole) return QVariant::fromValue(room);
return QVariant();
}
@@ -184,5 +185,6 @@ QHash<int, QByteArray> RoomListModel::roleNames() const {
roles[CategoryRole] = "category";
roles[UnreadCountRole] = "unreadCount";
roles[LastEventRole] = "lastEvent";
roles[CurrentRoomRole] = "currentRoom";
return roles;
}

View File

@@ -35,7 +35,8 @@ class RoomListModel : public QAbstractListModel {
TopicRole,
CategoryRole,
UnreadCountRole,
LastEventRole
LastEventRole,
CurrentRoomRole,
};
RoomListModel(QObject* parent = 0);