diff --git a/CMakeLists.txt b/CMakeLists.txt index f3463d861..d8bd55e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/include/libQuotient b/include/libQuotient index de378851e..fadce11be 160000 --- a/include/libQuotient +++ b/include/libQuotient @@ -1 +1 @@ -Subproject commit de378851ef9f6a89bb1f4fffa88681cc0e83d93f +Subproject commit fadce11be92abe76cecfe6356b3b38f25dd93e8d diff --git a/src/matriximageprovider.h b/src/matriximageprovider.h index 980ed3fc7..030ea41ad 100644 --- a/src/matriximageprovider.h +++ b/src/matriximageprovider.h @@ -10,14 +10,14 @@ #include #include -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 m_connection; + QAtomicPointer m_connection; }; #endif // MatrixImageProvider_H diff --git a/src/notifications/managermac.mm b/src/notifications/managermac.mm index 921bc8a23..345328853 100644 --- a/src/notifications/managermac.mm +++ b/src/notifications/managermac.mm @@ -4,9 +4,7 @@ #include -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 diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 36ecc93b8..9bf6ff691 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -8,7 +8,7 @@ #include -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 { diff --git a/src/spectralroom.cpp b/src/spectralroom.cpp index 29daccf51..b51186cf6 100644 --- a/src/spectralroom.cpp +++ b/src/spectralroom.cpp @@ -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)"); diff --git a/src/userlistmodel.h b/src/userlistmodel.h index 18b848b7e..0e83d37b1 100644 --- a/src/userlistmodel.h +++ b/src/userlistmodel.h @@ -6,16 +6,16 @@ #include #include -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 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 m_users; int findUserPos(User* user) const;