From a6b2be112b9a9450998985cbc5ec4ce10a5ae432 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 10 May 2022 03:19:53 +0200 Subject: [PATCH] More image dialog fixes --- resources/qml/Root.qml | 3 ++- resources/qml/delegates/ImageMessage.qml | 2 +- resources/qml/dialogs/ImageOverlay.qml | 13 ++++++------- resources/qml/dialogs/UserProfile.qml | 2 +- src/BlurhashProvider.h | 3 ++- src/CacheCryptoStructs.h | 3 ++- src/ColorImageProvider.h | 3 ++- src/EventAccessors.h | 4 ++-- src/InviteesModel.cpp | 3 ++- src/JdenticonProvider.cpp | 3 ++- src/MainWindow.h | 5 ++++- src/MxcImageProvider.h | 3 ++- src/dbus/NhekoDBusApi.cpp | 6 ++++-- src/dbus/NhekoDBusBackend.cpp | 3 ++- src/encryption/DeviceVerificationFlow.cpp | 2 +- src/encryption/VerificationManager.cpp | 3 ++- src/main.cpp | 3 ++- src/notifications/ManagerWin.cpp | 3 ++- src/timeline/CommunitiesModel.cpp | 3 ++- src/timeline/DelegateChooser.h | 3 ++- src/timeline/InputBar.h | 3 ++- src/timeline/PresenceEmitter.h | 3 ++- src/timeline/TimelineModel.cpp | 6 ++++-- src/timeline/TimelineModel.h | 3 ++- src/timeline/TimelineViewManager.cpp | 8 ++++++-- src/timeline/TimelineViewManager.h | 12 ++++++++++-- src/ui/HiddenEvents.h | 3 ++- src/ui/MxcAnimatedImage.cpp | 3 ++- src/ui/NhekoCursorShape.cpp | 3 ++- src/ui/UIA.h | 3 ++- src/ui/UserProfile.h | 9 ++++++--- src/voip/CallDevices.cpp | 3 ++- src/voip/CallDevices.h | 2 +- src/voip/WebRTCSession.cpp | 9 ++++++--- src/voip/WebRTCSession.h | 2 +- 35 files changed, 95 insertions(+), 50 deletions(-) diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index 72f30b7a..00600508 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -284,7 +284,7 @@ Pane { destroyOnClose(dialog); } - function onShowImageOverlay(room, eventId, url, proportionalHeight, originalWidth) { + function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) { var dialog = imageOverlay.createObject(timelineRoot, { "room": room, "eventId": eventId, @@ -292,6 +292,7 @@ Pane { "originalWidth": originalWidth ?? 0, "proportionalHeight": proportionalHeight ?? 0 }); + dialog.showFullScreen(); destroyOnClose(dialog); } diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 23cca019..12e8a465 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -67,7 +67,7 @@ AbstractButton { eventId: parent.eventId } - onClicked :Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId); + onClicked :Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId, originalWidth, proportionalHeight); Item { id: overlay diff --git a/resources/qml/dialogs/ImageOverlay.qml b/resources/qml/dialogs/ImageOverlay.qml index dff96f35..d245aca2 100644 --- a/resources/qml/dialogs/ImageOverlay.qml +++ b/resources/qml/dialogs/ImageOverlay.qml @@ -29,18 +29,17 @@ Window { } - Item { id: imgContainer - property int imgSrcWidth: (originalWidth && originalWidth > 200) ? originalWidth : Screen.width - property int imgSrcHeight: proportionalHeight ? imgSrcWidth * proportionalHeight : Screen.height + property int imgSrcWidth: (imageOverlay.originalWidth && imageOverlay.originalWidth > 100) ? imageOverlay.originalWidth : Screen.width + property int imgSrcHeight: imageOverlay.proportionalHeight ? imgSrcWidth * imageOverlay.proportionalHeight : Screen.height - height: Math.min(parent.height, imgSrcHeight) - width: Math.min(parent.width, imgSrcWidth) + height: Math.min(parent.height || Screen.height, imgSrcHeight) + width: Math.min(parent.width || Screen.width, imgSrcWidth) - x: (parent.width - width) - y: (parent.height - height) + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 Image { id: img diff --git a/resources/qml/dialogs/UserProfile.qml b/resources/qml/dialogs/UserProfile.qml index 60f1eb8d..d218e8fe 100644 --- a/resources/qml/dialogs/UserProfile.qml +++ b/resources/qml/dialogs/UserProfile.qml @@ -66,7 +66,7 @@ ApplicationWindow { displayName: profile.displayName userid: profile.userid Layout.alignment: Qt.AlignHCenter - onClicked: TimelineManager.openImageOverlay(null, profile.avatarUrl, "") + onClicked: TimelineManager.openImageOverlay(null, profile.avatarUrl, "", 0, 0) ImageButton { hoverEnabled: true diff --git a/src/BlurhashProvider.h b/src/BlurhashProvider.h index bbe28c2c..566e07ac 100644 --- a/src/BlurhashProvider.h +++ b/src/BlurhashProvider.h @@ -20,7 +20,8 @@ public: BlurhashRunnable(const QString &id, const QSize &requestedSize) : m_id(id) , m_requestedSize(requestedSize) - {} + { + } void run() override; signals: diff --git a/src/CacheCryptoStructs.h b/src/CacheCryptoStructs.h index 6c32667e..04e852b4 100644 --- a/src/CacheCryptoStructs.h +++ b/src/CacheCryptoStructs.h @@ -96,7 +96,8 @@ struct MegolmSessionIndex MegolmSessionIndex(std::string room_id_, const mtx::events::msg::Encrypted &e) : room_id(std::move(room_id_)) , session_id(e.session_id) - {} + { + } //! The room in which this session exists. std::string room_id; diff --git a/src/ColorImageProvider.h b/src/ColorImageProvider.h index e7fa1571..05cc1084 100644 --- a/src/ColorImageProvider.h +++ b/src/ColorImageProvider.h @@ -10,7 +10,8 @@ class ColorImageProvider : public QQuickImageProvider public: ColorImageProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) - {} + { + } QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; }; diff --git a/src/EventAccessors.h b/src/EventAccessors.h index 9d8a34e7..8e130c29 100644 --- a/src/EventAccessors.h +++ b/src/EventAccessors.h @@ -15,8 +15,8 @@ namespace nheko { struct nonesuch { - ~nonesuch() = delete; - nonesuch(nonesuch const &) = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const &) = delete; void operator=(nonesuch const &) = delete; }; diff --git a/src/InviteesModel.cpp b/src/InviteesModel.cpp index aa6d41d8..8e30847c 100644 --- a/src/InviteesModel.cpp +++ b/src/InviteesModel.cpp @@ -12,7 +12,8 @@ InviteesModel::InviteesModel(QObject *parent) : QAbstractListModel{parent} -{} +{ +} void InviteesModel::addUser(QString mxid) diff --git a/src/JdenticonProvider.cpp b/src/JdenticonProvider.cpp index 03c7cd82..22d2b887 100644 --- a/src/JdenticonProvider.cpp +++ b/src/JdenticonProvider.cpp @@ -83,7 +83,8 @@ JdenticonRunnable::JdenticonRunnable(const QString &key, , m_crop{crop} , m_radius{radius} , m_requestedSize(requestedSize.isValid() ? requestedSize : QSize(100, 100)) -{} +{ +} void JdenticonRunnable::run() diff --git a/src/MainWindow.h b/src/MainWindow.h index 3db18a98..529f68e0 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -56,7 +56,10 @@ public: void showChatPage(); #ifdef NHEKO_DBUS_SYS - bool dbusAvailable() const { return dbusAvailable_; } + bool dbusAvailable() const + { + return dbusAvailable_; + } #endif Q_INVOKABLE void addPerRoomWindow(const QString &room, QWindow *window); diff --git a/src/MxcImageProvider.h b/src/MxcImageProvider.h index 2a09df87..5d8330aa 100644 --- a/src/MxcImageProvider.h +++ b/src/MxcImageProvider.h @@ -29,7 +29,8 @@ public: , m_requestedSize(requestedSize) , m_crop(crop) , m_radius(radius) - {} + { + } void run(); diff --git a/src/dbus/NhekoDBusApi.cpp b/src/dbus/NhekoDBusApi.cpp index c6604633..cc19f0a0 100644 --- a/src/dbus/NhekoDBusApi.cpp +++ b/src/dbus/NhekoDBusApi.cpp @@ -44,7 +44,8 @@ RoomInfoItem::RoomInfoItem(const QString &roomId, , roomName_{title} , image_{image} , unreadNotifications_{unreadNotifications} -{} +{ +} RoomInfoItem::RoomInfoItem(const RoomInfoItem &other) : QObject{other.parent()} @@ -53,7 +54,8 @@ RoomInfoItem::RoomInfoItem(const RoomInfoItem &other) , roomName_{other.roomName_} , image_{other.image_} , unreadNotifications_{other.unreadNotifications_} -{} +{ +} RoomInfoItem & RoomInfoItem::operator=(const RoomInfoItem &other) diff --git a/src/dbus/NhekoDBusBackend.cpp b/src/dbus/NhekoDBusBackend.cpp index f0ed9df1..e752f15f 100644 --- a/src/dbus/NhekoDBusBackend.cpp +++ b/src/dbus/NhekoDBusBackend.cpp @@ -16,7 +16,8 @@ NhekoDBusBackend::NhekoDBusBackend(RoomlistModel *parent) : QObject{parent} , m_parent{parent} -{} +{ +} QVector NhekoDBusBackend::rooms(const QDBusMessage &message) diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index 25ae8725..db782a86 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -631,7 +631,7 @@ DeviceVerificationFlow::startVerificationRequest() req.hashes = {"sha256"}; req.message_authentication_codes = {"hkdf-hmac-sha256"}; req.short_authentication_string = {mtx::events::msg::SASMethods::Decimal, - mtx::events::msg::SASMethods::Emoji}; + mtx::events::msg::SASMethods::Emoji}; if (this->type == DeviceVerificationFlow::Type::ToDevice) { mtx::requests::ToDeviceMessages body; diff --git a/src/encryption/VerificationManager.cpp b/src/encryption/VerificationManager.cpp index 8c775948..826f5194 100644 --- a/src/encryption/VerificationManager.cpp +++ b/src/encryption/VerificationManager.cpp @@ -15,7 +15,8 @@ VerificationManager::VerificationManager(TimelineViewManager *o) : QObject(o) , rooms_(o->rooms()) -{} +{ +} static bool isValidTime(std::optional t) diff --git a/src/main.cpp b/src/main.cpp index 47ebba27..aabc0da1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,7 +102,8 @@ registerSignalHandlers() // No implementation for systems with no stacktrace support. void registerSignalHandlers() -{} +{ +} #endif diff --git a/src/notifications/ManagerWin.cpp b/src/notifications/ManagerWin.cpp index 91483492..3e6a0c77 100644 --- a/src/notifications/ManagerWin.cpp +++ b/src/notifications/ManagerWin.cpp @@ -44,7 +44,8 @@ init() NotificationsManager::NotificationsManager(QObject *parent) : QObject(parent) -{} +{ +} void NotificationsManager::postNotification(const mtx::responses::Notification ¬ification, diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp index 4f650f49..14909479 100644 --- a/src/timeline/CommunitiesModel.cpp +++ b/src/timeline/CommunitiesModel.cpp @@ -14,7 +14,8 @@ CommunitiesModel::CommunitiesModel(QObject *parent) : QAbstractListModel(parent) -{} +{ +} QHash CommunitiesModel::roleNames() const diff --git a/src/timeline/DelegateChooser.h b/src/timeline/DelegateChooser.h index 1772c0c2..8dff66ad 100644 --- a/src/timeline/DelegateChooser.h +++ b/src/timeline/DelegateChooser.h @@ -74,7 +74,8 @@ private: DelegateIncubator(DelegateChooser &parent) : QQmlIncubator(QQmlIncubator::AsynchronousIfNested) , chooser(parent) - {} + { + } void statusChanged(QQmlIncubator::Status status) override; DelegateChooser &chooser; diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 28a4bcf6..683a2ed9 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -39,7 +39,8 @@ class InputVideoSurface : public QAbstractVideoSurface public: InputVideoSurface(QObject *parent) : QAbstractVideoSurface(parent) - {} + { + } bool present(const QVideoFrame &frame) override; diff --git a/src/timeline/PresenceEmitter.h b/src/timeline/PresenceEmitter.h index 6cbfa96a..7028c501 100644 --- a/src/timeline/PresenceEmitter.h +++ b/src/timeline/PresenceEmitter.h @@ -19,7 +19,8 @@ class PresenceEmitter : public QObject public: PresenceEmitter(QObject *p = nullptr) : QObject(p) - {} + { + } void sync(const std::vector> &presences); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 142ca793..1e0893b4 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1366,7 +1366,8 @@ struct SendMessageVisitor { explicit SendMessageVisitor(TimelineModel *model) : model_(model) - {} + { + } template void sendRoomEvent(mtx::events::RoomEvent msg) @@ -1390,7 +1391,8 @@ struct SendMessageVisitor // Do-nothing operator for all unhandled events template void operator()(const mtx::events::Event &) - {} + { + } // Operator for m.room.message events that contain a msgtype in their content template &&fn) : fn_(std::move(fn)) - {} + { + } ~StateKeeper() { fn_(); } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 58426178..384cb3ff 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -242,13 +242,17 @@ TimelineViewManager::escapeEmoji(QString str) const } void -TimelineViewManager::openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId) +TimelineViewManager::openImageOverlay(TimelineModel *room, + QString mxcUrl, + QString eventId, + double originalWidth, + double proportionalHeight) { if (mxcUrl.isEmpty()) { return; } - emit showImageOverlay(room, eventId, mxcUrl); + emit showImageOverlay(room, eventId, mxcUrl, originalWidth, proportionalHeight); } void diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 020bdac5..6b9d9e94 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -54,7 +54,11 @@ public: Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } bool isConnected() const { return isConnected_; } - Q_INVOKABLE void openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId); + Q_INVOKABLE void openImageOverlay(TimelineModel *room, + QString mxcUrl, + QString eventId, + double originalWidth, + double proportionalHeight); Q_INVOKABLE void openImagePackSettings(QString roomid); Q_INVOKABLE void saveMedia(QString mxcUrl); Q_INVOKABLE QColor userColor(QString id, QColor background); @@ -87,7 +91,11 @@ signals: void openProfile(UserProfile *profile); void showImagePackSettings(TimelineModel *room, ImagePackListModel *packlist); void openLeaveRoomDialog(QString roomid, QString reason = ""); - void showImageOverlay(TimelineModel *room, QString eventId, QString url); + void showImageOverlay(TimelineModel *room, + QString eventId, + QString url, + double originalWidth, + double proportionalHeight); public slots: void updateReadReceipts(const QString &room_id, const std::vector &event_ids); diff --git a/src/ui/HiddenEvents.h b/src/ui/HiddenEvents.h index 928b14ba..52f62bbd 100644 --- a/src/ui/HiddenEvents.h +++ b/src/ui/HiddenEvents.h @@ -18,7 +18,8 @@ class HiddenEvents : public QObject public: explicit HiddenEvents(QObject *p = nullptr) : QObject(p) - {} + { + } Q_INVOKABLE void toggle(int type); Q_INVOKABLE void save(); diff --git a/src/ui/MxcAnimatedImage.cpp b/src/ui/MxcAnimatedImage.cpp index 4af527b4..d4f54a69 100644 --- a/src/ui/MxcAnimatedImage.cpp +++ b/src/ui/MxcAnimatedImage.cpp @@ -193,7 +193,8 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD } QSizeF r = img.size(); - r.scale(size(), Qt::KeepAspectRatio); + if (height() != 0 || width() != 0) + r.scale(size(), Qt::KeepAspectRatio); n->setRect((width() - r.width()) / 2, (height() - r.height()) / 2, r.width(), r.height()); n->setFiltering(QSGTexture::Linear); diff --git a/src/ui/NhekoCursorShape.cpp b/src/ui/NhekoCursorShape.cpp index 10a6ddab..1c5918b4 100644 --- a/src/ui/NhekoCursorShape.cpp +++ b/src/ui/NhekoCursorShape.cpp @@ -10,7 +10,8 @@ NhekoCursorShape::NhekoCursorShape(QQuickItem *parent) : QQuickItem(parent) , currentShape_(Qt::CursorShape::ArrowCursor) -{} +{ +} Qt::CursorShape NhekoCursorShape::cursorShape() const diff --git a/src/ui/UIA.h b/src/ui/UIA.h index 150b595d..9d673dea 100644 --- a/src/ui/UIA.h +++ b/src/ui/UIA.h @@ -20,7 +20,8 @@ public: UIA(QObject *parent = nullptr) : QObject(parent) - {} + { + } mtx::http::UIAHandler genericHandler(QString context); diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h index 4652a72e..0f993928 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h @@ -45,7 +45,8 @@ public: , verification_status(verification_status_) , lastIp(lastIp_) , lastTs(lastTs_) - {} + { + } DeviceInfo(const QString deviceID, const QString displayName, verification::Status verification_status_) @@ -53,10 +54,12 @@ public: , display_name(displayName) , verification_status(verification_status_) , lastTs(0) - {} + { + } DeviceInfo() : verification_status(verification::UNVERIFIED) - {} + { + } QString device_id; QString display_name; diff --git a/src/voip/CallDevices.cpp b/src/voip/CallDevices.cpp index b0c90d84..61c6c0a1 100644 --- a/src/voip/CallDevices.cpp +++ b/src/voip/CallDevices.cpp @@ -20,7 +20,8 @@ extern "C" CallDevices::CallDevices() : QObject() -{} +{ +} #ifdef GSTREAMER_AVAILABLE namespace { diff --git a/src/voip/CallDevices.h b/src/voip/CallDevices.h index cecb6357..4b2c1e48 100644 --- a/src/voip/CallDevices.h +++ b/src/voip/CallDevices.h @@ -43,6 +43,6 @@ private: GstDevice *videoDevice(std::pair &resolution, std::pair &frameRate) const; public: - CallDevices(CallDevices const &) = delete; + CallDevices(CallDevices const &) = delete; void operator=(CallDevices const &) = delete; }; diff --git a/src/voip/WebRTCSession.cpp b/src/voip/WebRTCSession.cpp index 31174500..89a6d268 100644 --- a/src/voip/WebRTCSession.cpp +++ b/src/voip/WebRTCSession.cpp @@ -1152,7 +1152,8 @@ WebRTCSession::acceptAnswer(const std::string &) void WebRTCSession::acceptICECandidates(const std::vector &) -{} +{ +} bool WebRTCSession::isMicMuted() const @@ -1168,10 +1169,12 @@ WebRTCSession::toggleMicMute() void WebRTCSession::toggleLocalPiP() -{} +{ +} void WebRTCSession::end() -{} +{ +} #endif diff --git a/src/voip/WebRTCSession.h b/src/voip/WebRTCSession.h index 04383679..15e904ca 100644 --- a/src/voip/WebRTCSession.h +++ b/src/voip/WebRTCSession.h @@ -113,6 +113,6 @@ private: void clear(); public: - WebRTCSession(WebRTCSession const &) = delete; + WebRTCSession(WebRTCSession const &) = delete; void operator=(WebRTCSession const &) = delete; };