Genesis commit.

Not really, but a lot of renaming.
This commit is contained in:
Black Hat 2018-09-17 21:01:02 +08:00
parent 317a6d6ec8
commit 81a7172f29
31 changed files with 145 additions and 153 deletions

View File

@ -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;

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.eu.encom.matrique</id>
<launchable type="desktop-id">org.eu.encom.matrique.desktop</launchable>
<id>org.eu.encom.spectral</id>
<launchable type="desktop-id">org.eu.encom.spectral.desktop</launchable>
<metadata_license>GFDL</metadata_license>
<project_license>GPL-3.0</project_license>
<name>Matrique</name>
<name>Spectral</name>
<summary>IM client for the Matrix protocol</summary>
<description>
<p>
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.
</p>
<p>
The source code is generally available at https://gitlab.com/b0/matrique
The source code is generally available at https://gitlab.com/b0/spectral
</p>
</description>
<screenshots>
<screenshot type="default">
<caption>Overview</caption>
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.matrique/screenshots/overview.png</image>
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/overview.png</image>
</screenshot>
<screenshot>
<caption>Room Config</caption>
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.matrique/screenshots/room_config.png</image>
<image>https://raw.githubusercontent.com/encombhat/flathub/org.eu.encom.spectral/screenshots/room_config.png</image>
</screenshot>
</screenshots>
<developer_name>Black Hat</developer_name>
@ -30,9 +30,9 @@
<category>Internet</category>
<category>Qt</category>
</categories>
<url type="homepage">https://gitlab.com/b0/matrique</url>
<url type="bugtracker">https://gitlab.com/b0/matrique/issues</url>
<url type="help">https://doc.matrique.encom.eu.org</url>
<url type="homepage">https://gitlab.com/b0/spectral</url>
<url type="bugtracker">https://gitlab.com/b0/spectral/issues</url>
<url type="help">https://doc.spectral.encom.eu.org</url>
<content_rating type="oars-1.0">
<content_attribute id="social-chat">intense</content_attribute>
<content_attribute id="social-audio">intense</content_attribute>

View File

@ -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"

View File

@ -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 {

View File

@ -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." }
}
}

View File

@ -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

View File

@ -1,5 +1,5 @@
import QtQuick 2.9
import Matrique.Settings 0.1
import Spectral.Settings 0.1
MouseArea {
signal primaryClicked()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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"

View File

@ -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)
})
}
}

View File

@ -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

View File

@ -22,7 +22,7 @@
<file>asset/img/icon.ico</file>
<file>asset/img/icon.icns</file>
<file>qml/component/AutoMouseArea.qml</file>
<file>qml/MatriqueSettings.qml</file>
<file>qml/SpectralSettings.qml</file>
<file>qml/menu/MessageContextMenu.qml</file>
<file>qml/menu/RoomContextMenu.qml</file>
<file>qml/component/GenericBubble.qml</file>

View File

@ -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

View File

@ -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<MatriqueRoom>();
Connection::setUserType<MatriqueUser>();
Connection::setRoomType<SpectralRoom>();
Connection::setUserType<SpectralUser>();
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();

View File

@ -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 *>("MatriqueRoom*");
qRegisterMetaType<SpectralRoom *>("SpectralRoom*");
qRegisterMetaType<User *>("User*");
qRegisterMetaType<MessageEventType>("MessageEventType");
qRegisterMetaType<MatriqueRoom *>("MatriqueRoom");
qRegisterMetaType<SpectralRoom *>("SpectralRoom");
qmlRegisterType<ImageItem>("Matrique", 0, 1, "ImageItem");
qmlRegisterType<Controller>("Matrique", 0, 1, "Controller");
qmlRegisterType<AccountListModel>("Matrique", 0, 1, "AccountListModel");
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
qmlRegisterType<UserListModel>("Matrique", 0, 1, "UserListModel");
qmlRegisterType<MessageEventModel>("Matrique", 0, 1, "MessageEventModel");
qmlRegisterType<EmojiModel>("Matrique", 0, 1, "EmojiModel");
qmlRegisterUncreatableType<RoomMessageEvent>("Matrique", 0, 1,
qmlRegisterType<ImageItem>("Spectral", 0, 1, "ImageItem");
qmlRegisterType<Controller>("Spectral", 0, 1, "Controller");
qmlRegisterType<AccountListModel>("Spectral", 0, 1, "AccountListModel");
qmlRegisterType<RoomListModel>("Spectral", 0, 1, "RoomListModel");
qmlRegisterType<UserListModel>("Spectral", 0, 1, "UserListModel");
qmlRegisterType<MessageEventModel>("Spectral", 0, 1, "MessageEventModel");
qmlRegisterType<EmojiModel>("Spectral", 0, 1, "EmojiModel");
qmlRegisterUncreatableType<RoomMessageEvent>("Spectral", 0, 1,
"RoomMessageEvent", "ENUM");
qmlRegisterUncreatableType<RoomType>("Matrique", 0, 1, "RoomType", "ENUM");
qmlRegisterSingletonType(QUrl("qrc:/qml/MatriqueSettings.qml"),
"Matrique.Settings", 0, 1, "MSettings");
qmlRegisterUncreatableType<RoomType>("Spectral", 0, 1, "RoomType", "ENUM");
qmlRegisterSingletonType(QUrl("qrc:/qml/SpectralSettings.qml"),
"Spectral.Settings", 0, 1, "MSettings");
QQmlApplicationEngine engine;

View File

@ -1,6 +0,0 @@
#include "matriqueuser.h"
MatriqueUser::MatriqueUser(QString userId, Connection* connection)
: User(userId, connection) {
connect(this, &User::avatarChanged, this, &MatriqueUser::inheritedAvatarChanged);
}

View File

@ -42,12 +42,12 @@ MessageEventModel::MessageEventModel(QObject* parent)
qmlRegisterType<FileTransferInfo>();
qRegisterMetaType<FileTransferInfo>();
qmlRegisterUncreatableType<EventStatus>(
"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();

View File

@ -1,14 +1,14 @@
#ifndef MESSAGEEVENTMODEL_H
#define MESSAGEEVENTMODEL_H
#include "matriqueroom.h"
#include "spectralroom.h"
#include "room.h"
#include <QtCore/QAbstractListModel>
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;

View File

@ -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<MatriqueRoom*>(r)) {
if (auto* room = static_cast<SpectralRoom*>(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<MatriqueRoom*>(room));
refresh(static_cast<SpectralRoom*>(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<MatriqueRoom*>(room);
auto* newRoom = static_cast<SpectralRoom*>(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<int>& roles) {
void RoomListModel::refresh(SpectralRoom* room, const QVector<int>& 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<int>& 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));
}

View File

@ -3,7 +3,7 @@
#include "connection.h"
#include "events/roomevent.h"
#include "matriqueroom.h"
#include "spectralroom.h"
#include "room.h"
#include <QtCore/QAbstractListModel>
@ -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<int, QByteArray> 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<int>& roles = {});
void refresh(SpectralRoom* room, const QVector<int>& roles = {});
private:
Connection* m_connection = nullptr;
QList<MatriqueRoom*> m_rooms;
void connectRoomSignals(MatriqueRoom* room);
QList<SpectralRoom*> 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);
};

View File

@ -1,4 +1,4 @@
#include "matriqueroom.h"
#include "spectralroom.h"
#include "connection.h"
#include "user.h"
@ -10,16 +10,16 @@
#include <QFileDialog>
#include <QMimeDatabase>
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<User*> 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<User*> 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<SetTypingJob>(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<RoomMessageEvent>()) {
@ -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",
"<mx-reply><blockquote><a href=\"https://matrix.to/#/" + id() + "/" +
eventId + "\">In reply to</a> <a href=\"https://matrix.to/#/" +

View File

@ -1,5 +1,5 @@
#ifndef MATRIQUEROOM_H
#define MATRIQUEROOM_H
#ifndef SpectralRoom_H
#define SpectralRoom_H
#include "room.h"
@ -8,7 +8,7 @@
using namespace QMatrixClient;
class MatriqueRoom : public Room {
class SpectralRoom : public Room {
Q_OBJECT
Q_PROPERTY(QImage avatar READ getAvatar NOTIFY avatarChanged)
Q_PROPERTY(bool hasUsersTyping READ hasUsersTyping NOTIFY typingChanged)
@ -16,7 +16,7 @@ class MatriqueRoom : public Room {
Q_PROPERTY(QString cachedInput READ cachedInput WRITE setCachedInput NOTIFY
cachedInputChanged)
public:
explicit MatriqueRoom(Connection* connection, QString roomId,
explicit SpectralRoom(Connection* connection, QString roomId,
JoinState joinState = {});
QImage getAvatar() { return avatar(128); }
@ -62,4 +62,4 @@ class MatriqueRoom : public Room {
void sendReply(QString userId, QString eventId, QString replyContent, QString sendContent);
};
#endif // MATRIQUEROOM_H
#endif // SpectralRoom_H

6
src/spectraluser.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "spectraluser.h"
SpectralUser::SpectralUser(QString userId, Connection* connection)
: User(userId, connection) {
connect(this, &User::avatarChanged, this, &SpectralUser::inheritedAvatarChanged);
}

View File

@ -1,5 +1,5 @@
#ifndef MATRIQUEUSER_H
#define MATRIQUEUSER_H
#ifndef SpectralUser_H
#define SpectralUser_H
#include "user.h"
#include "room.h"
@ -8,11 +8,11 @@
using namespace QMatrixClient;
class MatriqueUser : public User {
class SpectralUser : public User {
Q_OBJECT
Q_PROPERTY(QImage avatar READ getAvatar NOTIFY inheritedAvatarChanged)
public:
MatriqueUser(QString userId, Connection* connection);
SpectralUser(QString userId, Connection* connection);
QImage getAvatar() { return avatar(128); }
@ -20,4 +20,4 @@ class MatriqueUser : public User {
void inheritedAvatarChanged(User* user, const Room* roomContext); // https://bugreports.qt.io/browse/QTBUG-7684
};
#endif // MATRIQUEUSER_H
#endif // SpectralUser_H