Make forward messages a bit more readable

This commit is contained in:
Nicolas Werner 2021-04-27 11:33:46 +02:00
parent 65d85768d0
commit 2b253ead9e
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 55 additions and 51 deletions

View File

@ -25,7 +25,10 @@ Popup {
height: implicitHeight + completerPopup.height + padding * 2 height: implicitHeight + completerPopup.height + padding * 2
leftPadding: 10 leftPadding: 10
rightPadding: 10 rightPadding: 10
background: null background: Rectangle {
color: colors.window
}
onOpened: { onOpened: {
completerPopup.open(); completerPopup.open();
roomTextInput.forceActiveFocus(); roomTextInput.forceActiveFocus();
@ -108,7 +111,7 @@ Popup {
} }
Overlay.modal: Rectangle { Overlay.modal: Rectangle {
color: Qt.rgba(colors.window.r, colors.window.g, colors.window.b, 0.75) color: Qt.rgba(colors.window.r, colors.window.g, colors.window.b, 0.7)
} }
} }

View File

@ -18,6 +18,7 @@
#include "CompletionProxyModel.h" #include "CompletionProxyModel.h"
#include "DelegateChooser.h" #include "DelegateChooser.h"
#include "DeviceVerificationFlow.h" #include "DeviceVerificationFlow.h"
#include "EventAccessors.h"
#include "Logging.h" #include "Logging.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MatrixClient.h" #include "MatrixClient.h"
@ -36,6 +37,54 @@ Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
namespace msgs = mtx::events::msg; namespace msgs = mtx::events::msg;
namespace {
template<template<class...> class Op, class... Args>
using is_detected = typename nheko::detail::detector<nheko::nonesuch, void, Op, Args...>::value_t;
template<class Content>
using file_t = decltype(Content::file);
template<class Content>
using url_t = decltype(Content::url);
template<class Content>
using body_t = decltype(Content::body);
template<class Content>
using formatted_body_t = decltype(Content::formatted_body);
template<typename T>
static constexpr bool
messageWithFileAndUrl(const mtx::events::Event<T> &)
{
return is_detected<file_t, T>::value && is_detected<url_t, T>::value;
}
template<typename T>
static constexpr void
removeReplyFallback(mtx::events::Event<T> &e)
{
if constexpr (is_detected<body_t, T>::value) {
if constexpr (std::is_same_v<std::optional<std::string>,
std::remove_cv_t<decltype(e.content.body)>>) {
if (e.content.body) {
e.content.body = utils::stripReplyFromBody(e.content.body);
}
} else if constexpr (std::is_same_v<std::string,
std::remove_cv_t<decltype(e.content.body)>>) {
e.content.body = utils::stripReplyFromBody(e.content.body);
}
}
if constexpr (is_detected<formatted_body_t, T>::value) {
if (e.content.format == "org.matrix.custom.html") {
e.content.formatted_body =
utils::stripReplyFromFormattedBody(e.content.formatted_body);
}
}
}
}
void void
TimelineViewManager::updateEncryptedDescriptions() TimelineViewManager::updateEncryptedDescriptions()
{ {
@ -694,4 +743,4 @@ TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEven
} }
}, },
*e); *e);
} }

View File

@ -16,7 +16,6 @@
#include "Cache.h" #include "Cache.h"
#include "CallManager.h" #include "CallManager.h"
#include "EventAccessors.h"
#include "Logging.h" #include "Logging.h"
#include "TimelineModel.h" #include "TimelineModel.h"
#include "Utils.h" #include "Utils.h"
@ -152,53 +151,6 @@ public slots:
private slots: private slots:
void openImageOverlayInternal(QString eventId, QImage img); void openImageOverlayInternal(QString eventId, QImage img);
private:
template<template<class...> class Op, class... Args>
using is_detected =
typename nheko::detail::detector<nheko::nonesuch, void, Op, Args...>::value_t;
template<class Content>
using file_t = decltype(Content::file);
template<class Content>
using url_t = decltype(Content::url);
template<class Content>
using body_t = decltype(Content::body);
template<class Content>
using formatted_body_t = decltype(Content::formatted_body);
template<typename T>
static constexpr bool messageWithFileAndUrl(const mtx::events::Event<T> &)
{
return is_detected<file_t, T>::value && is_detected<url_t, T>::value;
}
template<typename T>
static constexpr void removeReplyFallback(mtx::events::Event<T> &e)
{
if constexpr (is_detected<body_t, T>::value) {
if constexpr (std::is_same_v<std::optional<std::string>,
std::remove_cv_t<decltype(e.content.body)>>) {
if (e.content.body) {
e.content.body = utils::stripReplyFromBody(e.content.body);
}
} else if constexpr (std::is_same_v<
std::string,
std::remove_cv_t<decltype(e.content.body)>>) {
e.content.body = utils::stripReplyFromBody(e.content.body);
}
}
if constexpr (is_detected<formatted_body_t, T>::value) {
if (e.content.format == "org.matrix.custom.html") {
e.content.formatted_body =
utils::stripReplyFromFormattedBody(e.content.formatted_body);
}
}
}
private: private:
#ifdef USE_QUICK_VIEW #ifdef USE_QUICK_VIEW
QQuickView *view; QQuickView *view;