QMatrixClient -> Quotient

This commit is contained in:
Black Hat
2019-08-15 22:52:12 +08:00
parent 0067ce7e2e
commit 086891ef4e
7 changed files with 51 additions and 44 deletions

View File

@@ -46,6 +46,9 @@ find_package(Qt5 5.12 REQUIRED Widgets Network Quick Qml Gui Svg Multimedia)
if(LINUX)
find_package(Qt5DBus REQUIRED)
endif(LINUX)
if (APPLE)
find_package(Qt5MacExtras REQUIRED)
endif(APPLE)
# Qt5_Prefix is only used to show Qt path in message()
# Qt5_BinDir is where all the binary tools for Qt are
if (QT_QMAKE_EXECUTABLE)
@@ -79,7 +82,7 @@ endif ()
if (NOT USE_INTREE_LIBQMC)
find_package(Quotient 0.6 REQUIRED)
if (NOT Quotient_FOUND)
message( WARNING "libQMatrixClient not found; configuration will most likely fail.")
message( WARNING "libQuotient not found; configuration will most likely fail.")
endif ()
endif ()
@@ -110,7 +113,7 @@ endif()
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
message( STATUS "Using Qt ${Qt5_VERSION} at ${Qt5_Prefix}" )
if (USE_INTREE_LIBQMC)
message( STATUS "Using in-tree libQMatrixClient")
message( STATUS "Using in-tree libQuotient")
if (GIT_FOUND)
execute_process(COMMAND
"${GIT_EXECUTABLE}" rev-parse -q HEAD
@@ -120,7 +123,7 @@ if (USE_INTREE_LIBQMC)
message( STATUS " Library git SHA1: ${LIB_GIT_SHA1}")
endif (GIT_FOUND)
else ()
message( STATUS "Using libQMatrixClient ${Quotient_VERSION} at ${Quotient_DIR}")
message( STATUS "Using libQuotient ${Quotient_VERSION} at ${Quotient_DIR}")
endif ()
message( STATUS "=============================================================================" )
@@ -209,7 +212,9 @@ target_link_libraries(${PROJECT_NAME}
target_compile_definitions(${PROJECT_NAME} PRIVATE
GIT_SHA1="${GIT_SHA1}" LIB_GIT_SHA1="${LIB_GIT_SHA1}")
if(LINUX)
if (APPLE)
target_link_libraries(${PROJECT_NAME} Qt5::MacExtras)
elseif(LINUX)
target_link_libraries(${PROJECT_NAME} Qt5::DBus)
endif()

View File

@@ -10,14 +10,14 @@
#include <QtCore/QAtomicPointer>
#include <QtCore/QReadWriteLock>
namespace QMatrixClient {
namespace Quotient {
class Connection;
}
class ThumbnailResponse : public QQuickImageResponse {
Q_OBJECT
public:
ThumbnailResponse(QMatrixClient::Connection* c,
ThumbnailResponse(Quotient::Connection* c,
QString mediaId,
const QSize& requestedSize);
~ThumbnailResponse() override = default;
@@ -28,11 +28,11 @@ class ThumbnailResponse : public QQuickImageResponse {
void doCancel();
private:
QMatrixClient::Connection* c;
Quotient::Connection* c;
const QString mediaId;
const QSize requestedSize;
const QString localFile;
QMatrixClient::MediaThumbnailJob* job = nullptr;
Quotient::MediaThumbnailJob* job = nullptr;
QImage image;
QString errorStr;
@@ -45,7 +45,7 @@ class ThumbnailResponse : public QQuickImageResponse {
class MatrixImageProvider : public QObject, public QQuickAsyncImageProvider {
Q_OBJECT
Q_PROPERTY(QMatrixClient::Connection* connection READ connection WRITE
Q_PROPERTY(Quotient::Connection* connection READ connection WRITE
setConnection NOTIFY connectionChanged)
public:
explicit MatrixImageProvider() = default;
@@ -54,8 +54,8 @@ class MatrixImageProvider : public QObject, public QQuickAsyncImageProvider {
const QString& id,
const QSize& requestedSize) override;
QMatrixClient::Connection* connection() { return m_connection; }
void setConnection(QMatrixClient::Connection* connection) {
Quotient::Connection* connection() { return m_connection; }
void setConnection(Quotient::Connection* connection) {
m_connection.store(connection);
emit connectionChanged();
}
@@ -64,7 +64,7 @@ class MatrixImageProvider : public QObject, public QQuickAsyncImageProvider {
void connectionChanged();
private:
QAtomicPointer<QMatrixClient::Connection> m_connection;
QAtomicPointer<Quotient::Connection> m_connection;
};
#endif // MatrixImageProvider_H

View File

@@ -4,9 +4,7 @@
#include <QApplication>
NotificationsManager::NotificationsManager(QObject* parent) : QObject(parent) {
}
NotificationsManager::NotificationsManager(QObject* parent) : QObject(parent) {}
void NotificationsManager::postNotification(const QString& roomId,
const QString& eventId,
@@ -20,35 +18,40 @@ void NotificationsManager::postNotification(const QString& roomId,
UNUserNotificationCenter* center =
[UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions options = UNAuthorizationOptionAlert + UNAuthorizationOptionSound;
UNAuthorizationOptions options =
UNAuthorizationOptionAlert + UNAuthorizationOptionSound;
[center requestAuthorizationWithOptions:options
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!granted) {
NSLog(@"Something went wrong");
}
}];
completionHandler:^(BOOL granted,
NSError* _Nullable error) {
if (!granted) {
NSLog(@"Something went wrong");
}
}];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:300
repeats:NO];
UNTimeIntervalNotificationTrigger* trigger =
[UNTimeIntervalNotificationTrigger triggerWithTimeInterval:0 repeats:NO];
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = roomName.toNSString();
content.subtitle = QString("%1 sent a message").arg(senderName).toNSString();
content.body = text.toNSString();
content.sound = [UNNotificationSound defaultSound];
NSString *identifier = QApplication::applicationName().toNSString();
NSString* identifier = QApplication::applicationName().toNSString();
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:content trigger:trigger];
UNNotificationRequest* request =
[UNNotificationRequest requestWithIdentifier:identifier
content:content
trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Something went wrong: %@",error);
}
}];
[center addNotificationRequest:request
withCompletionHandler:^(NSError* _Nullable error) {
if (error != nil) {
NSLog(@"Something went wrong: %@", error);
}
}];
}
// unused

View File

@@ -8,7 +8,7 @@
#include <QtCore/QAbstractListModel>
using namespace QMatrixClient;
using namespace Quotient;
class RoomType : public QObject {
Q_OBJECT
@@ -21,7 +21,7 @@ class RoomType : public QObject {
Normal,
Deprioritized,
};
REGISTER_ENUM(Types)
Q_ENUMS(Types)
};
class RoomListModel : public QAbstractListModel {

View File

@@ -263,7 +263,6 @@ QString SpectralRoom::eventToString(const RoomEvent& evt,
case MembershipType::Invite:
if (e.repeatsState())
return tr("reinvited %1 to the room").arg(subjectName);
FALLTHROUGH;
case MembershipType::Join: {
if (e.repeatsState())
return tr("joined the room (repeated)");

View File

@@ -6,16 +6,16 @@
#include <QObject>
#include <QtCore/QAbstractListModel>
namespace QMatrixClient {
namespace Quotient {
class Connection;
class Room;
class User;
} // namespace QMatrixClient
} // namespace Quotient
class UserListModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(
QMatrixClient::Room* room READ room WRITE setRoom NOTIFY roomChanged)
Quotient::Room* room READ room WRITE setRoom NOTIFY roomChanged)
public:
enum EventRoles {
NameRole = Qt::UserRole + 1,
@@ -24,12 +24,12 @@ class UserListModel : public QAbstractListModel {
ObjectRole
};
using User = QMatrixClient::User;
using User = Quotient::User;
UserListModel(QObject* parent = nullptr);
QMatrixClient::Room* room() const { return m_currentRoom; }
void setRoom(QMatrixClient::Room* room);
Quotient::Room* room() const { return m_currentRoom; }
void setRoom(Quotient::Room* room);
User* userAt(QModelIndex index) const;
QVariant data(const QModelIndex& index, int role = NameRole) const override;
@@ -44,10 +44,10 @@ class UserListModel : public QAbstractListModel {
void userAdded(User* user);
void userRemoved(User* user);
void refresh(User* user, QVector<int> roles = {});
void avatarChanged(User* user, const QMatrixClient::Room* context);
void avatarChanged(User* user, const Quotient::Room* context);
private:
QMatrixClient::Room* m_currentRoom;
Quotient::Room* m_currentRoom;
QList<User*> m_users;
int findUserPos(User* user) const;