Add accept/reject and use .cache
This commit is contained in:
parent
6f527402e0
commit
43e0ccaf2f
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Controls.Material 2.2
|
import QtQuick.Controls.Material 2.2
|
||||||
|
import Qt.labs.platform 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property bool openOnFinished: false
|
property bool openOnFinished: false
|
||||||
|
@ -27,7 +28,7 @@ Item {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
openOnFinished = true
|
openOnFinished = true
|
||||||
currentRoom.downloadFile(eventId)
|
currentRoom.downloadFile(eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_") + ".tmp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,15 +89,36 @@ Item {
|
||||||
pattern: searchField.text
|
pattern: searchField.text
|
||||||
caseSensitivity: Qt.CaseInsensitive
|
caseSensitivity: Qt.CaseInsensitive
|
||||||
}
|
}
|
||||||
proxyRoles: [
|
proxyRoles: ExpressionRole {
|
||||||
ExpressionRole { name: "isFavorite"; expression: category === "Favorites" },
|
name: "display"
|
||||||
ExpressionRole { name: "isDirectChat"; expression: category === "People" },
|
expression: {
|
||||||
ExpressionRole { name: "isLowPriority"; expression: category === "Low Priorities" }
|
switch (category) {
|
||||||
]
|
case 1: return "Invited"
|
||||||
|
case 2: return "Favorites"
|
||||||
|
case 3: return "Rooms"
|
||||||
|
case 4: return "People"
|
||||||
|
case 5: return "Low Priorities"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sorters: [
|
sorters: [
|
||||||
RoleSorter { roleName: "isFavorite"; sortOrder: Qt.DescendingOrder },
|
ExpressionSorter {
|
||||||
RoleSorter { roleName: "isLowPriority" },
|
expression: {
|
||||||
RoleSorter { roleName: "isDirectChat" },
|
var leftCategory = modelLeft.category
|
||||||
|
var rightCategory = modelRight.category
|
||||||
|
if (leftCategory === 1) return true
|
||||||
|
if (rightCategory === 1) return false
|
||||||
|
if (leftCategory === 2) return true
|
||||||
|
if (rightCategory === 2) return false
|
||||||
|
if (leftCategory === 5) return false
|
||||||
|
if (rightCategory === 5) return true
|
||||||
|
if (leftCategory === 4) return false
|
||||||
|
if (rightCategory === 4) return true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
StringSorter { roleName: "name" }
|
StringSorter { roleName: "name" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -126,7 +147,7 @@ Item {
|
||||||
height: 80
|
height: 80
|
||||||
onPressed: listView.currentIndex = index
|
onPressed: listView.currentIndex = index
|
||||||
onPressAndHold: roomListMenu.popup()
|
onPressAndHold: roomListMenu.popup()
|
||||||
onClicked: enterRoom()
|
onClicked: category === RoomType.Invited ? inviteDialog.open() : enterRoom()
|
||||||
|
|
||||||
ToolTip.visible: mini && hovered
|
ToolTip.visible: mini && hovered
|
||||||
ToolTip.text: name
|
ToolTip.text: name
|
||||||
|
@ -180,7 +201,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
section.property: "category"
|
section.property: "display"
|
||||||
section.criteria: ViewSection.FullString
|
section.criteria: ViewSection.FullString
|
||||||
section.delegate: Label {
|
section.delegate: Label {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -197,6 +218,24 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: inviteDialog
|
||||||
|
parent: ApplicationWindow.overlay
|
||||||
|
|
||||||
|
x: (window.width - width) / 2
|
||||||
|
y: (window.height - height) / 2
|
||||||
|
width: 360
|
||||||
|
|
||||||
|
title: "Action Required"
|
||||||
|
modal: true
|
||||||
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||||
|
|
||||||
|
contentItem: Label { text: "Accept this invitation?" }
|
||||||
|
|
||||||
|
onAccepted: matriqueController.acceptRoom(currentRoom)
|
||||||
|
onRejected: matriqueController.rejectRoom(currentRoom)
|
||||||
|
}
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: roomListMenu
|
id: roomListMenu
|
||||||
|
|
||||||
|
|
|
@ -145,3 +145,10 @@ void Controller::saveFileAs(Room* room, QString eventId) {
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
room->downloadFile(eventId, QUrl::fromLocalFile(fileName));
|
room->downloadFile(eventId, QUrl::fromLocalFile(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::acceptRoom(Room* room) { room->setJoinState(JoinState::Join); }
|
||||||
|
|
||||||
|
void Controller::rejectRoom(Room* room) {
|
||||||
|
room->setJoinState(JoinState::Leave);
|
||||||
|
forgetRoom(room->id());
|
||||||
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
#include "roomlistmodel.h"
|
#include "roomlistmodel.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
using namespace QMatrixClient;
|
using namespace QMatrixClient;
|
||||||
|
|
||||||
|
@ -111,6 +111,8 @@ class Controller : public QObject {
|
||||||
void createDirectChat(const QString& userID);
|
void createDirectChat(const QString& userID);
|
||||||
void copyToClipboard(const QString& text);
|
void copyToClipboard(const QString& text);
|
||||||
void saveFileAs(Room* room, QString eventId);
|
void saveFileAs(Room* room, QString eventId);
|
||||||
|
void acceptRoom(Room* room);
|
||||||
|
void rejectRoom(Room* room);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLLER_H
|
#endif // CONTROLLER_H
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "emojimodel.h"
|
||||||
#include "imageprovider.h"
|
#include "imageprovider.h"
|
||||||
#include "messageeventmodel.h"
|
#include "messageeventmodel.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "roomlistmodel.h"
|
#include "roomlistmodel.h"
|
||||||
#include "emojimodel.h"
|
|
||||||
|
|
||||||
#include "csapi/joining.h"
|
#include "csapi/joining.h"
|
||||||
#include "csapi/leaving.h"
|
#include "csapi/leaving.h"
|
||||||
|
@ -30,7 +30,9 @@ int main(int argc, char *argv[]) {
|
||||||
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
|
qmlRegisterType<RoomListModel>("Matrique", 0, 1, "RoomListModel");
|
||||||
qmlRegisterType<MessageEventModel>("Matrique", 0, 1, "MessageEventModel");
|
qmlRegisterType<MessageEventModel>("Matrique", 0, 1, "MessageEventModel");
|
||||||
qmlRegisterType<EmojiModel>("Matrique", 0, 1, "EmojiModel");
|
qmlRegisterType<EmojiModel>("Matrique", 0, 1, "EmojiModel");
|
||||||
qmlRegisterUncreatableType<RoomMessageEvent>("Matrique", 0, 1, "RoomMessageEvent", "ENUM");
|
qmlRegisterUncreatableType<RoomMessageEvent>("Matrique", 0, 1,
|
||||||
|
"RoomMessageEvent", "ENUM");
|
||||||
|
qmlRegisterUncreatableType<RoomType>("Matrique", 0, 1, "RoomType", "ENUM");
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const {
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEventModel::~MessageEventModel() {}
|
|
||||||
|
|
||||||
MessageEventModel::MessageEventModel(QObject* parent)
|
MessageEventModel::MessageEventModel(QObject* parent)
|
||||||
: QAbstractListModel(parent), m_currentRoom(nullptr) {
|
: QAbstractListModel(parent), m_currentRoom(nullptr) {
|
||||||
using namespace QMatrixClient;
|
using namespace QMatrixClient;
|
||||||
|
@ -44,6 +42,8 @@ MessageEventModel::MessageEventModel(QObject* parent)
|
||||||
"Matrique", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
"Matrique", 0, 1, "EventStatus", "EventStatus is not an creatable type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageEventModel::~MessageEventModel() {}
|
||||||
|
|
||||||
void MessageEventModel::setRoom(QMatrixClient::Room* room) {
|
void MessageEventModel::setRoom(QMatrixClient::Room* room) {
|
||||||
if (room == m_currentRoom) return;
|
if (room == m_currentRoom) return;
|
||||||
|
|
||||||
|
@ -588,7 +588,8 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
}
|
}
|
||||||
if (evt.isRedacted())
|
if (evt.isRedacted())
|
||||||
return Settings().value("UI/show_redacted").toBool()
|
return Settings().value("UI/show_redacted").toBool()
|
||||||
? EventStatus::Redacted : EventStatus::Hidden;
|
? EventStatus::Redacted
|
||||||
|
: EventStatus::Hidden;
|
||||||
|
|
||||||
if (evt.isStateEvent() &&
|
if (evt.isStateEvent() &&
|
||||||
static_cast<const StateEventBase&>(evt).repeatsState() &&
|
static_cast<const StateEventBase&>(evt).repeatsState() &&
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtGui/QBrush>
|
#include <QtGui/QBrush>
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
|
#include <QtQuick>
|
||||||
|
|
||||||
RoomListModel::RoomListModel(QObject* parent) : QAbstractListModel(parent) {}
|
RoomListModel::RoomListModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||||
|
|
||||||
|
@ -136,33 +137,22 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
Room* room = m_rooms.at(index.row());
|
Room* room = m_rooms.at(index.row());
|
||||||
if (role == NameRole) {
|
if (role == NameRole) return room->displayName();
|
||||||
return room->displayName();
|
|
||||||
}
|
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
if (room->avatarUrl().toString() != "") {
|
if (room->avatarUrl().toString() != "") {
|
||||||
return room->avatarUrl();
|
return room->avatarUrl();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
if (role == TopicRole) {
|
if (role == TopicRole) return room->topic();
|
||||||
return room->topic();
|
|
||||||
}
|
|
||||||
if (role == CategoryRole) {
|
if (role == CategoryRole) {
|
||||||
// if (!room->isDirectChat())
|
if (room->joinState() == JoinState::Invite) return RoomType::Invited;
|
||||||
// qDebug() << room->displayName() << "is not direct.";
|
if (room->isFavourite()) return RoomType::Favorite;
|
||||||
if (room->isFavourite()) return "Favorites";
|
if (room->isDirectChat()) return RoomType::Direct;
|
||||||
if (room->isDirectChat()) return "People";
|
if (room->isLowPriority()) return RoomType::Deprioritized;
|
||||||
if (room->isLowPriority()) return "Low Priorities";
|
return RoomType::Normal;
|
||||||
return "Rooms";
|
|
||||||
}
|
|
||||||
if (role == HighlightRole) {
|
|
||||||
if (room->highlightCount() > 0) return QBrush(QColor("orange"));
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
if (role == UnreadCountRole) {
|
|
||||||
return room->unreadCount();
|
|
||||||
}
|
}
|
||||||
|
if (role == UnreadCountRole) return room->unreadCount();
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +182,6 @@ QHash<int, QByteArray> RoomListModel::roleNames() const {
|
||||||
roles[AvatarRole] = "avatar";
|
roles[AvatarRole] = "avatar";
|
||||||
roles[TopicRole] = "topic";
|
roles[TopicRole] = "topic";
|
||||||
roles[CategoryRole] = "category";
|
roles[CategoryRole] = "category";
|
||||||
roles[HighlightRole] = "highlight";
|
|
||||||
roles[UnreadCountRole] = "unreadCount";
|
roles[UnreadCountRole] = "unreadCount";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,20 @@
|
||||||
|
|
||||||
using namespace QMatrixClient;
|
using namespace QMatrixClient;
|
||||||
|
|
||||||
|
class RoomType : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Types {
|
||||||
|
Invited = 1,
|
||||||
|
Favorite,
|
||||||
|
Normal,
|
||||||
|
Direct,
|
||||||
|
Deprioritized,
|
||||||
|
};
|
||||||
|
REGISTER_ENUM(Types)
|
||||||
|
};
|
||||||
|
|
||||||
class RoomListModel : public QAbstractListModel {
|
class RoomListModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Connection* connection READ getConnection WRITE setConnection)
|
Q_PROPERTY(Connection* connection READ getConnection WRITE setConnection)
|
||||||
|
@ -17,8 +31,7 @@ class RoomListModel : public QAbstractListModel {
|
||||||
AvatarRole,
|
AvatarRole,
|
||||||
TopicRole,
|
TopicRole,
|
||||||
CategoryRole,
|
CategoryRole,
|
||||||
HighlightRole,
|
UnreadCountRole,
|
||||||
UnreadCountRole
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RoomListModel(QObject* parent = 0);
|
RoomListModel(QObject* parent = 0);
|
||||||
|
|
Loading…
Reference in New Issue