From 81a7172f298f986d5c8e6468bdeefc7c529742a7 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 17 Sep 2018 21:01:02 +0800 Subject: [PATCH] Genesis commit. Not really, but a lot of renaming. --- org.eu.encom.matrique.desktop | 9 ---- ...a.xml => org.eu.encom.spectral.appdata.xml | 20 ++++---- qml/Login.qml | 2 +- qml/Room.qml | 6 +-- qml/Setting.qml | 10 ++-- ...riqueSettings.qml => SpectralSettings.qml} | 0 qml/component/AutoLabel.qml | 2 +- qml/component/AutoMouseArea.qml | 2 +- qml/component/EmojiPicker.qml | 2 +- qml/component/GenericBubble.qml | 2 +- qml/component/MaterialIcon.qml | 2 +- qml/component/MessageDelegate.qml | 8 ++-- qml/component/RoomDrawer.qml | 4 +- qml/component/StateDelegate.qml | 2 +- qml/form/RoomForm.qml | 6 +-- qml/form/RoomListForm.qml | 4 +- qml/main.qml | 26 +++++----- qml/menu/RoomContextMenu.qml | 2 +- res.qrc | 2 +- matrique.pro => spectral.pro | 14 +++--- src/controller.cpp | 12 ++--- src/main.cpp | 30 ++++++------ src/matriqueuser.cpp | 6 --- src/messageeventmodel.cpp | 4 +- src/messageeventmodel.h | 10 ++-- src/roomlistmodel.cpp | 22 ++++----- src/roomlistmodel.h | 16 +++---- src/{matriqueroom.cpp => spectralroom.cpp} | 47 ++++++++++--------- src/{matriqueroom.h => spectralroom.h} | 10 ++-- src/spectraluser.cpp | 6 +++ src/{matriqueuser.h => spectraluser.h} | 10 ++-- 31 files changed, 145 insertions(+), 153 deletions(-) delete mode 100644 org.eu.encom.matrique.desktop rename org.eu.encom.matrique.appdata.xml => org.eu.encom.spectral.appdata.xml (74%) rename qml/{MatriqueSettings.qml => SpectralSettings.qml} (100%) rename matrique.pro => spectral.pro (91%) delete mode 100644 src/matriqueuser.cpp rename src/{matriqueroom.cpp => spectralroom.cpp} (75%) rename src/{matriqueroom.h => spectralroom.h} (90%) create mode 100644 src/spectraluser.cpp rename src/{matriqueuser.h => spectraluser.h} (68%) diff --git a/org.eu.encom.matrique.desktop b/org.eu.encom.matrique.desktop deleted file mode 100644 index eb91ba4..0000000 --- a/org.eu.encom.matrique.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Matrique -GenericName=Matrix Client -Comment=IM client for the Matrix protocol -Exec=matrique -Terminal=false -Icon=org.eu.encom.matrique -Type=Application -Categories=Network;InstantMessaging; diff --git a/org.eu.encom.matrique.appdata.xml b/org.eu.encom.spectral.appdata.xml similarity index 74% rename from org.eu.encom.matrique.appdata.xml rename to org.eu.encom.spectral.appdata.xml index 7f47d9e..74a0215 100644 --- a/org.eu.encom.matrique.appdata.xml +++ b/org.eu.encom.spectral.appdata.xml @@ -1,27 +1,27 @@ - org.eu.encom.matrique - org.eu.encom.matrique.desktop + org.eu.encom.spectral + org.eu.encom.spectral.desktop GFDL GPL-3.0 - Matrique + Spectral IM client for the Matrix protocol

- Matrique is a glossy cross-platform client for Matrix, the decentralized communication protocol for instant messaging. + Spectral is a glossy cross-platform client for Matrix, the decentralized communication protocol for instant messaging.

- The source code is generally available at https://gitlab.com/b0/matrique + The source code is generally available at https://gitlab.com/b0/spectral

Overview - https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.matrique/screenshots/overview.png + https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/overview.png Room Config - https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.matrique/screenshots/room_config.png + https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/room_config.png Black Hat @@ -30,9 +30,9 @@ Internet Qt - https://gitlab.com/b0/matrique - https://gitlab.com/b0/matrique/issues - https://doc.matrique.encom.eu.org + https://gitlab.com/b0/spectral + https://gitlab.com/b0/spectral/issues + https://doc.spectral.encom.eu.org intense intense diff --git a/qml/Login.qml b/qml/Login.qml index 1fb0e10..5efad37 100644 --- a/qml/Login.qml +++ b/qml/Login.qml @@ -4,7 +4,7 @@ import QtGraphicalEffects 1.0 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 import Qt.labs.settings 1.0 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 import "component" diff --git a/qml/Room.qml b/qml/Room.qml index bcf1ca2..2e38817 100644 --- a/qml/Room.qml +++ b/qml/Room.qml @@ -2,8 +2,8 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 -import Matrique 0.1 -import Matrique.Settings 0.1 +import Spectral 0.1 +import Spectral.Settings 0.1 import "form" @@ -16,7 +16,7 @@ Page { id: roomListModel onRoomAdded: room.getPreviousContent(20) - onNewMessage: if (!window.active) matriqueController.showMessage(roomName, content, icon) + onNewMessage: if (!window.active) spectralController.showMessage(roomName, content, icon) } Rectangle { diff --git a/qml/Setting.qml b/qml/Setting.qml index 3c0f2b9..46c2070 100644 --- a/qml/Setting.qml +++ b/qml/Setting.qml @@ -2,8 +2,8 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 import QtQuick.Layouts 1.3 -import Matrique 0.1 -import Matrique.Settings 0.1 +import Spectral 0.1 +import Spectral.Settings 0.1 import "component" import "form" @@ -81,7 +81,7 @@ Page { color: "white" } - SwipeDelegate.onClicked: matriqueController.logout(connection) + SwipeDelegate.onClicked: spectralController.logout(connection) } onClicked: expanded = !expanded @@ -116,7 +116,7 @@ Page { MouseArea { anchors.fill: parent - onClicked: matriqueController.setColor(connection.localUserId, modelData) + onClicked: spectralController.setColor(connection.localUserId, modelData) } } } @@ -246,7 +246,7 @@ Page { source: "qrc:/asset/img/icon.png" } - Label { text: "Matrique, an IM client for the Matrix protocol." } + Label { text: "Spectral, an IM client for the Matrix protocol." } Label { text: "Released under GNU General Public License, version 3." } } } diff --git a/qml/MatriqueSettings.qml b/qml/SpectralSettings.qml similarity index 100% rename from qml/MatriqueSettings.qml rename to qml/SpectralSettings.qml diff --git a/qml/component/AutoLabel.qml b/qml/component/AutoLabel.qml index 684f892..94b93cc 100644 --- a/qml/component/AutoLabel.qml +++ b/qml/component/AutoLabel.qml @@ -1,7 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 Label { property bool coloredBackground diff --git a/qml/component/AutoMouseArea.qml b/qml/component/AutoMouseArea.qml index 7d0cc0e..d5e8d10 100644 --- a/qml/component/AutoMouseArea.qml +++ b/qml/component/AutoMouseArea.qml @@ -1,5 +1,5 @@ import QtQuick 2.9 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 MouseArea { signal primaryClicked() diff --git a/qml/component/EmojiPicker.qml b/qml/component/EmojiPicker.qml index 3939cbe..120afac 100644 --- a/qml/component/EmojiPicker.qml +++ b/qml/component/EmojiPicker.qml @@ -2,7 +2,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 -import Matrique 0.1 +import Spectral 0.1 Popup { property var textArea diff --git a/qml/component/GenericBubble.qml b/qml/component/GenericBubble.qml index 5d8e3b9..18761f9 100644 --- a/qml/component/GenericBubble.qml +++ b/qml/component/GenericBubble.qml @@ -1,7 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 Control { property bool highlighted: false diff --git a/qml/component/MaterialIcon.qml b/qml/component/MaterialIcon.qml index 87c3315..9e7a1d9 100644 --- a/qml/component/MaterialIcon.qml +++ b/qml/component/MaterialIcon.qml @@ -1,7 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 Text { property alias icon: materialLabel.text diff --git a/qml/component/MessageDelegate.qml b/qml/component/MessageDelegate.qml index 7b18870..f72e399 100644 --- a/qml/component/MessageDelegate.qml +++ b/qml/component/MessageDelegate.qml @@ -2,8 +2,8 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 -import Matrique 0.1 -import Matrique.Settings 0.1 +import Spectral 0.1 +import Spectral.Settings 0.1 import "qrc:/js/util.js" as Util RowLayout { @@ -206,7 +206,7 @@ RowLayout { onClicked: { if (downloadable.downloaded) - matriqueController.playAudio(progressInfo.localPath) + spectralController.playAudio(progressInfo.localPath) else { playOnFinished = true @@ -218,7 +218,7 @@ RowLayout { background: DownloadableContent { id: downloadable - onDownloadedChanged: downloaded && playOnFinished ? matriqueController.playAudio(progressInfo.localPath) : {} + onDownloadedChanged: downloaded && playOnFinished ? spectralController.playAudio(progressInfo.localPath) : {} Component.onCompleted: { messageRow.saveFileAs.connect(saveFileAs) diff --git a/qml/component/RoomDrawer.qml b/qml/component/RoomDrawer.qml index 8da9397..5a97ad6 100644 --- a/qml/component/RoomDrawer.qml +++ b/qml/component/RoomDrawer.qml @@ -2,7 +2,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 import QtQuick.Layouts 1.3 -import Matrique 0.1 +import Spectral 0.1 import "qrc:/js/util.js" as Util @@ -30,7 +30,7 @@ Drawer { Layout.alignment: Qt.AlignHCenter hint: room ? room.displayName : "No name" - image: matriqueController.safeImage(room ? room.avatar : null) + image: spectralController.safeImage(room ? room.avatar : null) } Label { diff --git a/qml/component/StateDelegate.qml b/qml/component/StateDelegate.qml index 376763f..809505b 100644 --- a/qml/component/StateDelegate.qml +++ b/qml/component/StateDelegate.qml @@ -2,7 +2,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 Label { Layout.alignment: Qt.AlignHCenter diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index e60f61e..ff9899e 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -3,8 +3,8 @@ import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 import QtGraphicalEffects 1.0 -import Matrique 0.1 -import Matrique.Settings 0.1 +import Spectral 0.1 +import Spectral.Settings 0.1 import "qrc:/qml/component" import "qrc:/qml/menu" @@ -63,7 +63,7 @@ Item { Layout.fillHeight: true hint: currentRoom ? currentRoom.displayName : "No name" - image: matriqueController.safeImage(currentRoom ? currentRoom.avatar : null) + image: spectralController.safeImage(currentRoom ? currentRoom.avatar : null) } ColumnLayout { diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 8d72919..8f1ae5c 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -4,9 +4,9 @@ import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import QtQuick.Controls.Material 2.2 import QtQml.Models 2.3 -import Matrique 0.1 +import Spectral 0.1 import SortFilterProxyModel 0.2 -import Matrique.Settings 0.1 +import Spectral.Settings 0.1 import "qrc:/qml/component" import "qrc:/qml/menu" diff --git a/qml/main.qml b/qml/main.qml index 1d6eea7..62062fd 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -4,8 +4,8 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls.Material 2.2 import Qt.labs.settings 1.0 import QtGraphicalEffects 1.0 -import Matrique 0.1 -import Matrique.Settings 0.1 +import Spectral 0.1 +import Spectral.Settings 0.1 import "component" import "form" @@ -22,16 +22,16 @@ ApplicationWindow { id: window visible: true - title: qsTr("Matrique") + title: qsTr("Spectral") Material.theme: MSettings.darkTheme ? Material.Dark : Material.Light - Material.accent: matriqueController.color(currentConnection ? currentConnection.localUserId : "") + Material.accent: spectralController.color(currentConnection ? currentConnection.localUserId : "") FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" } Controller { - id: matriqueController + id: spectralController onShowWindow: { window.show() @@ -43,11 +43,11 @@ ApplicationWindow { AccountListModel { id: accountListModel - controller: matriqueController + controller: spectralController } Popup { - property bool busy: matriqueController.busy + property bool busy: spectralController.busy x: (window.width - width) / 2 y: (window.height - height) / 2 @@ -67,7 +67,7 @@ ApplicationWindow { Component { id: loginPage - Login { controller: matriqueController } + Login { controller: spectralController } } Room { @@ -130,7 +130,7 @@ ApplicationWindow { image: user.avatar } - highlightColor: matriqueController.color(user.id) + highlightColor: spectralController.color(user.id) page: roomPage @@ -187,7 +187,7 @@ ApplicationWindow { } } - onAccepted: matriqueController.createRoom(currentConnection, addRoomDialogNameTextField.text, addRoomDialogTopicTextField.text) + onAccepted: spectralController.createRoom(currentConnection, addRoomDialogNameTextField.text, addRoomDialogTopicTextField.text) } } MenuItem { @@ -213,7 +213,7 @@ ApplicationWindow { placeholderText: "#matrix:matrix.org" } - onAccepted: matriqueController.joinRoom(currentConnection, joinRoomDialogTextField.text) + onAccepted: spectralController.joinRoom(currentConnection, joinRoomDialogTextField.text) } } @@ -292,8 +292,8 @@ ApplicationWindow { } Component.onCompleted: { - matriqueController.initiated.connect(function() { - if (matriqueController.accountCount == 0) stackView.push(loginPage) + spectralController.initiated.connect(function() { + if (spectralController.accountCount == 0) stackView.push(loginPage) }) } } diff --git a/qml/menu/RoomContextMenu.qml b/qml/menu/RoomContextMenu.qml index 451a990..1f7848e 100644 --- a/qml/menu/RoomContextMenu.qml +++ b/qml/menu/RoomContextMenu.qml @@ -1,6 +1,6 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 -import Matrique 0.1 +import Spectral 0.1 Menu { property var model: null diff --git a/res.qrc b/res.qrc index 0095a76..716c908 100644 --- a/res.qrc +++ b/res.qrc @@ -22,7 +22,7 @@ asset/img/icon.ico asset/img/icon.icns qml/component/AutoMouseArea.qml - qml/MatriqueSettings.qml + qml/SpectralSettings.qml qml/menu/MessageContextMenu.qml qml/menu/RoomContextMenu.qml qml/component/GenericBubble.qml diff --git a/matrique.pro b/spectral.pro similarity index 91% rename from matrique.pro rename to spectral.pro index 0fabc98..f498eaa 100644 --- a/matrique.pro +++ b/spectral.pro @@ -5,7 +5,7 @@ CONFIG += object_parallel_to_source # Enable this to use QtQuick Compiler. #CONFIG += qtquickcompiler -TARGET = matrique +TARGET = spectral packagesExist(QMatrixClient) { message("Found libQMatrixClient via pkg-config.") @@ -33,11 +33,11 @@ SOURCES += src/main.cpp \ src/imageprovider.cpp \ src/messageeventmodel.cpp \ src/emojimodel.cpp \ - src/matriqueroom.cpp \ + src/spectralroom.cpp \ src/userlistmodel.cpp \ src/imageitem.cpp \ src/accountlistmodel.cpp \ - src/matriqueuser.cpp + src/spectraluser.cpp RESOURCES += \ res.qrc @@ -58,9 +58,9 @@ win32:target.path = $$PREFIX !isEmpty(target.path): INSTALLS += target unix:!mac { - metainfo.files = $$PWD/org.eu.encom.matrique.appdata.xml + metainfo.files = $$PWD/org.eu.encom.spectral.appdata.xml metainfo.path = $$PREFIX/share/metainfo - desktop.files = $$PWD/org.eu.encom.matrique.desktop + desktop.files = $$PWD/org.eu.encom.spectral.desktop desktop.path = $$PREFIX/share/applications icons.files = $$PWD/icons/hicolor/* icons.path = $$PREFIX/share/icons/hicolor @@ -95,8 +95,8 @@ HEADERS += \ src/imageprovider.h \ src/messageeventmodel.h \ src/emojimodel.h \ - src/matriqueroom.h \ + src/spectralroom.h \ src/userlistmodel.h \ src/imageitem.h \ src/accountlistmodel.h \ - src/matriqueuser.h + src/spectraluser.h diff --git a/src/controller.cpp b/src/controller.cpp index ff7feae..5d6e884 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -1,7 +1,7 @@ #include "controller.h" -#include "matriqueroom.h" -#include "matriqueuser.h" +#include "spectralroom.h" +#include "spectraluser.h" #include "settings.h" #include "events/eventcontent.h" @@ -28,7 +28,7 @@ Controller::Controller(QObject* parent) : QObject(parent) { tray->setIcon(QIcon(":/asset/img/icon.png")); - tray->setToolTip("Matrique"); + tray->setToolTip("Spectral"); connect(tray, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason r) { if (r != QSystemTrayIcon::Context) emit showWindow(); @@ -39,8 +39,8 @@ Controller::Controller(QObject* parent) : QObject(parent) { tray->setContextMenu(trayMenu); tray->show(); - Connection::setRoomType(); - Connection::setUserType(); + Connection::setRoomType(); + Connection::setUserType(); QTimer::singleShot(0, this, SLOT(invokeLogin())); } @@ -67,7 +67,7 @@ void Controller::loginWithCredentials(QString serverAddr, QString user, account.clearAccessToken(); // Drop the legacy - just in case account.setHomeserver(m_connection->homeserver()); account.setDeviceId(m_connection->deviceId()); - account.setDeviceName("Matrique"); + account.setDeviceName("Spectral"); if (!saveAccessToken(account, m_connection->accessToken())) qWarning() << "Couldn't save access token"; account.sync(); diff --git a/src/main.cpp b/src/main.cpp index 9c692dc..06b16fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,7 @@ #include "emojimodel.h" #include "imageitem.h" #include "imageprovider.h" -#include "matriqueroom.h" +#include "spectralroom.h" #include "messageeventmodel.h" #include "room.h" #include "roomlistmodel.h" @@ -28,27 +28,27 @@ int main(int argc, char *argv[]) { app.setOrganizationName("ENCOM"); app.setOrganizationDomain("encom.eu.org"); - app.setApplicationName("Matrique"); + app.setApplicationName("Spectral"); app.setQuitOnLastWindowClosed(false); - qRegisterMetaType("MatriqueRoom*"); + qRegisterMetaType("SpectralRoom*"); qRegisterMetaType("User*"); qRegisterMetaType("MessageEventType"); - qRegisterMetaType("MatriqueRoom"); + qRegisterMetaType("SpectralRoom"); - qmlRegisterType("Matrique", 0, 1, "ImageItem"); - qmlRegisterType("Matrique", 0, 1, "Controller"); - qmlRegisterType("Matrique", 0, 1, "AccountListModel"); - qmlRegisterType("Matrique", 0, 1, "RoomListModel"); - qmlRegisterType("Matrique", 0, 1, "UserListModel"); - qmlRegisterType("Matrique", 0, 1, "MessageEventModel"); - qmlRegisterType("Matrique", 0, 1, "EmojiModel"); - qmlRegisterUncreatableType("Matrique", 0, 1, + qmlRegisterType("Spectral", 0, 1, "ImageItem"); + qmlRegisterType("Spectral", 0, 1, "Controller"); + qmlRegisterType("Spectral", 0, 1, "AccountListModel"); + qmlRegisterType("Spectral", 0, 1, "RoomListModel"); + qmlRegisterType("Spectral", 0, 1, "UserListModel"); + qmlRegisterType("Spectral", 0, 1, "MessageEventModel"); + qmlRegisterType("Spectral", 0, 1, "EmojiModel"); + qmlRegisterUncreatableType("Spectral", 0, 1, "RoomMessageEvent", "ENUM"); - qmlRegisterUncreatableType("Matrique", 0, 1, "RoomType", "ENUM"); - qmlRegisterSingletonType(QUrl("qrc:/qml/MatriqueSettings.qml"), - "Matrique.Settings", 0, 1, "MSettings"); + qmlRegisterUncreatableType("Spectral", 0, 1, "RoomType", "ENUM"); + qmlRegisterSingletonType(QUrl("qrc:/qml/SpectralSettings.qml"), + "Spectral.Settings", 0, 1, "MSettings"); QQmlApplicationEngine engine; diff --git a/src/matriqueuser.cpp b/src/matriqueuser.cpp deleted file mode 100644 index a8bf365..0000000 --- a/src/matriqueuser.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "matriqueuser.h" - -MatriqueUser::MatriqueUser(QString userId, Connection* connection) - : User(userId, connection) { - connect(this, &User::avatarChanged, this, &MatriqueUser::inheritedAvatarChanged); -} diff --git a/src/messageeventmodel.cpp b/src/messageeventmodel.cpp index 65531a9..40c009f 100644 --- a/src/messageeventmodel.cpp +++ b/src/messageeventmodel.cpp @@ -42,12 +42,12 @@ MessageEventModel::MessageEventModel(QObject* parent) qmlRegisterType(); qRegisterMetaType(); qmlRegisterUncreatableType( - "Matrique", 0, 1, "EventStatus", "EventStatus is not an creatable type"); + "Spectral", 0, 1, "EventStatus", "EventStatus is not an creatable type"); } MessageEventModel::~MessageEventModel() {} -void MessageEventModel::setRoom(MatriqueRoom* room) { +void MessageEventModel::setRoom(SpectralRoom* room) { if (room == m_currentRoom) return; beginResetModel(); diff --git a/src/messageeventmodel.h b/src/messageeventmodel.h index 7b54207..3359fd5 100644 --- a/src/messageeventmodel.h +++ b/src/messageeventmodel.h @@ -1,14 +1,14 @@ #ifndef MESSAGEEVENTMODEL_H #define MESSAGEEVENTMODEL_H -#include "matriqueroom.h" +#include "spectralroom.h" #include "room.h" #include class MessageEventModel : public QAbstractListModel { Q_OBJECT - Q_PROPERTY(MatriqueRoom* room READ getRoom WRITE setRoom NOTIFY roomChanged) + Q_PROPERTY(SpectralRoom* room READ getRoom WRITE setRoom NOTIFY roomChanged) public: enum EventRoles { @@ -37,8 +37,8 @@ class MessageEventModel : public QAbstractListModel { explicit MessageEventModel(QObject* parent = nullptr); ~MessageEventModel(); - MatriqueRoom* getRoom() { return m_currentRoom; } - void setRoom(MatriqueRoom* room); + SpectralRoom* getRoom() { return m_currentRoom; } + void setRoom(SpectralRoom* room); int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, @@ -50,7 +50,7 @@ class MessageEventModel : public QAbstractListModel { void refreshRow(int row); private: - MatriqueRoom* m_currentRoom = nullptr; + SpectralRoom* m_currentRoom = nullptr; QString lastReadEventId; int rowBelowInserted = -1; bool movingEvent = 0; diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index af50d3f..fc06720 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -27,7 +27,7 @@ void RoomListModel::setConnection(Connection* connection) { m_connection = connection; - for (MatriqueRoom* room : m_rooms) room->disconnect(this); + for (SpectralRoom* room : m_rooms) room->disconnect(this); connect(connection, &Connection::connected, this, &RoomListModel::doResetModel); @@ -49,10 +49,10 @@ void RoomListModel::doResetModel() { endResetModel(); } -MatriqueRoom* RoomListModel::roomAt(int row) { return m_rooms.at(row); } +SpectralRoom* RoomListModel::roomAt(int row) { return m_rooms.at(row); } void RoomListModel::doAddRoom(Room* r) { - if (auto* room = static_cast(r)) { + if (auto* room = static_cast(r)) { m_rooms.append(room); connectRoomSignals(room); emit roomAdded(room); @@ -62,7 +62,7 @@ void RoomListModel::doAddRoom(Room* r) { } } -void RoomListModel::connectRoomSignals(MatriqueRoom* room) { +void RoomListModel::connectRoomSignals(SpectralRoom* room) { connect(room, &Room::displaynameChanged, this, [=] { namesChanged(room); }); connect(room, &Room::unreadMessagesChanged, this, [=] { unreadMessagesChanged(room); }); @@ -94,7 +94,7 @@ void RoomListModel::updateRoom(Room* room, Room* prev) { // the previously left room (in both cases prev has the previous state). if (prev == room) { qCritical() << "RoomListModel::updateRoom: room tried to replace itself"; - refresh(static_cast(room)); + refresh(static_cast(room)); return; } if (prev && room->id() != prev->id()) { @@ -103,10 +103,10 @@ void RoomListModel::updateRoom(Room* room, Room* prev) { // That doesn't look right but technically we still can do it. } // Ok, we're through with pre-checks, now for the real thing. - auto* newRoom = static_cast(room); + auto* newRoom = static_cast(room); const auto it = std::find_if( m_rooms.begin(), m_rooms.end(), - [=](const MatriqueRoom* r) { return r == prev || r == newRoom; }); + [=](const SpectralRoom* r) { return r == prev || r == newRoom; }); if (it != m_rooms.end()) { const int row = it - m_rooms.begin(); // There's no guarantee that prev != newRoom @@ -146,7 +146,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const { qDebug() << "UserListModel: something wrong here..."; return QVariant(); } - MatriqueRoom* room = m_rooms.at(index.row()); + SpectralRoom* room = m_rooms.at(index.row()); if (role == NameRole) return room->displayName(); if (role == AvatarRole) { if (!room->avatarUrl().isEmpty()) return room->avatar(64, 64); @@ -167,12 +167,12 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const { return QVariant(); } -void RoomListModel::namesChanged(MatriqueRoom* room) { +void RoomListModel::namesChanged(SpectralRoom* room) { int row = m_rooms.indexOf(room); emit dataChanged(index(row), index(row)); } -void RoomListModel::refresh(MatriqueRoom* room, const QVector& roles) { +void RoomListModel::refresh(SpectralRoom* room, const QVector& roles) { const auto it = std::find(m_rooms.begin(), m_rooms.end(), room); if (it == m_rooms.end()) { qCritical() << "Room" << room->id() << "not found in the room list"; @@ -182,7 +182,7 @@ void RoomListModel::refresh(MatriqueRoom* room, const QVector& roles) { emit dataChanged(idx, idx, roles); } -void RoomListModel::unreadMessagesChanged(MatriqueRoom* room) { +void RoomListModel::unreadMessagesChanged(SpectralRoom* room) { int row = m_rooms.indexOf(room); emit dataChanged(index(row), index(row)); } diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 1091245..68fabd5 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -3,7 +3,7 @@ #include "connection.h" #include "events/roomevent.h" -#include "matriqueroom.h" +#include "spectralroom.h" #include "room.h" #include @@ -47,7 +47,7 @@ class RoomListModel : public QAbstractListModel { void setConnection(Connection* connection); void doResetModel(); - Q_INVOKABLE MatriqueRoom* roomAt(int row); + Q_INVOKABLE SpectralRoom* roomAt(int row); QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -57,22 +57,22 @@ class RoomListModel : public QAbstractListModel { QHash roleNames() const; private slots: - void namesChanged(MatriqueRoom* room); - void unreadMessagesChanged(MatriqueRoom* room); + void namesChanged(SpectralRoom* room); + void unreadMessagesChanged(SpectralRoom* room); void doAddRoom(Room* room); void updateRoom(Room* room, Room* prev); void deleteRoom(Room* room); - void refresh(MatriqueRoom* room, const QVector& roles = {}); + void refresh(SpectralRoom* room, const QVector& roles = {}); private: Connection* m_connection = nullptr; - QList m_rooms; - void connectRoomSignals(MatriqueRoom* room); + QList m_rooms; + void connectRoomSignals(SpectralRoom* room); signals: void connectionChanged(); - void roomAdded(MatriqueRoom* room); + void roomAdded(SpectralRoom* room); void newMessage(const QString& roomName, const QString& content, const QIcon& icon); }; diff --git a/src/matriqueroom.cpp b/src/spectralroom.cpp similarity index 75% rename from src/matriqueroom.cpp rename to src/spectralroom.cpp index e6976c9..037eb9e 100644 --- a/src/matriqueroom.cpp +++ b/src/spectralroom.cpp @@ -1,4 +1,4 @@ -#include "matriqueroom.h" +#include "spectralroom.h" #include "connection.h" #include "user.h" @@ -10,16 +10,16 @@ #include #include -MatriqueRoom::MatriqueRoom(Connection* connection, QString roomId, +SpectralRoom::SpectralRoom(Connection* connection, QString roomId, JoinState joinState) : Room(connection, std::move(roomId), joinState) { - connect(this, &MatriqueRoom::notificationCountChanged, this, - &MatriqueRoom::countChanged); - connect(this, &MatriqueRoom::highlightCountChanged, this, - &MatriqueRoom::countChanged); + connect(this, &SpectralRoom::notificationCountChanged, this, + &SpectralRoom::countChanged); + connect(this, &SpectralRoom::highlightCountChanged, this, + &SpectralRoom::countChanged); } -void MatriqueRoom::chooseAndUploadFile() { +void SpectralRoom::chooseAndUploadFile() { auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as")); if (!localFile.isEmpty()) { uploadFile(localFile.toString(), localFile, getMIME(localFile)); @@ -32,7 +32,7 @@ void MatriqueRoom::chooseAndUploadFile() { } } -void MatriqueRoom::postFile(const QUrl& localFile, const QUrl& mxcUrl) { +void SpectralRoom::postFile(const QUrl& localFile, const QUrl& mxcUrl) { const QString mime = getMIME(localFile); const QString fileName = localFile.fileName(); QString msgType = "m.file"; @@ -46,21 +46,21 @@ void MatriqueRoom::postFile(const QUrl& localFile, const QUrl& mxcUrl) { postJson("m.room.message", json); } -QString MatriqueRoom::getMIME(const QUrl& fileUrl) const { +QString SpectralRoom::getMIME(const QUrl& fileUrl) const { return QMimeDatabase().mimeTypeForFile(fileUrl.toLocalFile()).name(); } -void MatriqueRoom::saveFileAs(QString eventId) { +void SpectralRoom::saveFileAs(QString eventId) { auto fileName = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save File as"), fileNameToDownload(eventId)); if (!fileName.isEmpty()) downloadFile(eventId, QUrl::fromLocalFile(fileName)); } -void MatriqueRoom::acceptInvitation() { connection()->joinRoom(id()); } +void SpectralRoom::acceptInvitation() { connection()->joinRoom(id()); } -void MatriqueRoom::forget() { connection()->forgetRoom(id()); } +void SpectralRoom::forget() { connection()->forgetRoom(id()); } -bool MatriqueRoom::hasUsersTyping() { +bool SpectralRoom::hasUsersTyping() { QList users = usersTyping(); if (users.isEmpty()) return false; int count = users.length(); @@ -68,7 +68,7 @@ bool MatriqueRoom::hasUsersTyping() { return count != 0; } -QString MatriqueRoom::getUsersTyping() { +QString SpectralRoom::getUsersTyping() { QString usersTypingStr; QList users = usersTyping(); users.removeOne(localUser()); @@ -80,12 +80,12 @@ QString MatriqueRoom::getUsersTyping() { return usersTypingStr; } -void MatriqueRoom::sendTypingNotification(bool isTyping) { +void SpectralRoom::sendTypingNotification(bool isTyping) { connection()->callApi(BackgroundRequest, localUser()->id(), id(), isTyping, 10000); } -QString MatriqueRoom::lastEvent() { +QString SpectralRoom::lastEvent() { if (timelineSize() == 0) return ""; const RoomEvent* lastEvent = messageEvents().rbegin()->get(); if (lastEvent->contentJson().value("body").toString() == "") return ""; @@ -93,11 +93,11 @@ QString MatriqueRoom::lastEvent() { lastEvent->contentJson().value("body").toString(); } -bool MatriqueRoom::isEventHighlighted(const RoomEvent* e) const { +bool SpectralRoom::isEventHighlighted(const RoomEvent* e) const { return highlights.contains(e); } -void MatriqueRoom::checkForHighlights(const QMatrixClient::TimelineItem& ti) { +void SpectralRoom::checkForHighlights(const QMatrixClient::TimelineItem& ti) { auto localUserId = localUser()->id(); if (ti->senderId() == localUserId) return; if (auto* e = ti.viewAs()) { @@ -108,30 +108,31 @@ void MatriqueRoom::checkForHighlights(const QMatrixClient::TimelineItem& ti) { } } -void MatriqueRoom::onAddNewTimelineEvents(timeline_iter_t from) { +void SpectralRoom::onAddNewTimelineEvents(timeline_iter_t from) { std::for_each(from, messageEvents().cend(), [this](const TimelineItem& ti) { checkForHighlights(ti); }); } -void MatriqueRoom::onAddHistoricalTimelineEvents(rev_iter_t from) { +void SpectralRoom::onAddHistoricalTimelineEvents(rev_iter_t from) { std::for_each(from, messageEvents().crend(), [this](const TimelineItem& ti) { checkForHighlights(ti); }); } -void MatriqueRoom::countChanged() { +void SpectralRoom::countChanged() { if (displayed() && !hasUnreadMessages()) { resetNotificationCount(); resetHighlightCount(); } } -void MatriqueRoom::sendReply(QString userId, QString eventId, +void SpectralRoom::sendReply(QString userId, QString eventId, QString replyContent, QString sendContent) { QJsonObject json{ {"msgtype", "m.text"}, {"body", "> <" + userId + "> " + replyContent + "\n\n" + sendContent}, {"format", "org.matrix.custom.html"}, - {"m.relates_to", QJsonObject{{"m.in_reply_to", QJsonObject{{"event_id", eventId}}}}}, + {"m.relates_to", + QJsonObject{{"m.in_reply_to", QJsonObject{{"event_id", eventId}}}}}, {"formatted_body", "
In reply to