This commit is contained in:
Nicolas Werner 2023-06-02 01:37:53 +02:00
parent c25d0c6b2f
commit de8522a185
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
20 changed files with 95 additions and 116 deletions

View file

@ -13,7 +13,6 @@
#include "Cache_p.h" #include "Cache_p.h"
#include "emoji/Provider.h" #include "emoji/Provider.h"
QString QString
emoji::categoryToName(emoji::Emoji::Category cat) emoji::categoryToName(emoji::Emoji::Category cat)
{ {
@ -69,7 +68,6 @@ GridImagePackModel::GridImagePackModel(const std::string &roomId, bool stickers,
, room_id(roomId) , room_id(roomId)
, columns(stickers ? 3 : 7) , columns(stickers ? 3 : 7)
{ {
if (!stickers) { if (!stickers) {
for (const auto &category : { for (const auto &category : {
emoji::Emoji::Category::People, emoji::Emoji::Category::People,

View file

@ -52,9 +52,7 @@ public:
QImage m_pixmap; QImage m_pixmap;
}; };
class JdenticonProvider class JdenticonProvider : public QQuickAsyncImageProvider
:
public QQuickAsyncImageProvider
{ {
Q_OBJECT Q_OBJECT

View file

@ -5,9 +5,9 @@
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <mtx/events/collections.hpp>
#include <mtx/requests.hpp> #include <mtx/requests.hpp>
#include <mtx/responses/login.hpp> #include <mtx/responses/login.hpp>
#include <mtx/events/collections.hpp>
#include "AliasEditModel.h" #include "AliasEditModel.h"
#include "BlurhashProvider.h" #include "BlurhashProvider.h"
@ -132,8 +132,6 @@ MainWindow::MainWindow(QWindow *parent)
void void
MainWindow::registerQmlTypes() MainWindow::registerQmlTypes()
{ {
qmlRegisterUncreatableMetaObject(qml_mtx_events::staticMetaObject, qmlRegisterUncreatableMetaObject(qml_mtx_events::staticMetaObject,
"im.nheko", "im.nheko",
1, 1,
@ -253,7 +251,6 @@ MainWindow::registerQmlTypes()
qmlRegisterSingletonInstance("im.nheko", 1, 0, "Settings", userSettings_.data()); qmlRegisterSingletonInstance("im.nheko", 1, 0, "Settings", userSettings_.data());
qmlRegisterUncreatableType<FilteredCommunitiesModel>( qmlRegisterUncreatableType<FilteredCommunitiesModel>(
"im.nheko", "im.nheko",
1, 1,

View file

@ -15,8 +15,6 @@
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include <mtx/responses.hpp> #include <mtx/responses.hpp>
namespace http { namespace http {
mtx::http::Client * mtx::http::Client *

View file

@ -70,9 +70,7 @@ public:
QImage m_image; QImage m_image;
}; };
class MxcImageProvider class MxcImageProvider : public QQuickAsyncImageProvider
:
public QQuickAsyncImageProvider
{ {
Q_OBJECT Q_OBJECT

View file

@ -20,7 +20,6 @@
#include "timeline/Permissions.h" #include "timeline/Permissions.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent) SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, roomid_(std::move(pack_.source_room)) , roomid_(std::move(pack_.source_room))
@ -29,7 +28,6 @@ SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
, pack(std::move(pack_.pack)) , pack(std::move(pack_.pack))
, fromSpace_(pack_.from_space) , fromSpace_(pack_.from_space)
{ {
if (!pack.pack) if (!pack.pack)
pack.pack = mtx::events::msc2545::ImagePack::PackDescription{}; pack.pack = mtx::events::msc2545::ImagePack::PackDescription{};

View file

@ -330,15 +330,17 @@ main(int argc, char *argv[])
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
QTranslator qtTranslator; QTranslator qtTranslator;
if(qtTranslator.load(QLocale(), if (qtTranslator.load(QLocale(),
QStringLiteral("qt"), QStringLiteral("qt"),
QStringLiteral("_"), QStringLiteral("_"),
QLibraryInfo::path(QLibraryInfo::TranslationsPath))) QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTranslator appTranslator; QTranslator appTranslator;
if(appTranslator.load( if (appTranslator.load(QLocale(),
QLocale(), QStringLiteral("nheko"), QStringLiteral("_"), QStringLiteral(":/translations"))) QStringLiteral("nheko"),
QStringLiteral("_"),
QStringLiteral(":/translations")))
app.installTranslator(&appTranslator); app.installTranslator(&appTranslator);
MainWindow w; MainWindow w;

View file

@ -17,7 +17,6 @@
#include "Utils.h" #include "Utils.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
CommunitiesModel::CommunitiesModel(QObject *parent) CommunitiesModel::CommunitiesModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, hiddenTagIds_{UserSettings::instance()->hiddenTags()} , hiddenTagIds_{UserSettings::instance()->hiddenTags()}

View file

@ -18,7 +18,6 @@
#include "UserSettingsPage.h" #include "UserSettingsPage.h"
#include "Utils.h" #include "Utils.h"
QCache<EventStore::IdIndex, olm::DecryptionResult> EventStore::decryptedEvents_{1000}; QCache<EventStore::IdIndex, olm::DecryptionResult> EventStore::decryptedEvents_{1000};
QCache<EventStore::IdIndex, mtx::events::collections::TimelineEvents> EventStore::events_by_id_{ QCache<EventStore::IdIndex, mtx::events::collections::TimelineEvents> EventStore::events_by_id_{
1000}; 1000};
@ -27,7 +26,6 @@ QCache<EventStore::Index, mtx::events::collections::TimelineEvents> EventStore::
EventStore::EventStore(std::string room_id, QObject *) EventStore::EventStore(std::string room_id, QObject *)
: room_id_(std::move(room_id)) : room_id_(std::move(room_id))
{ {
auto range = cache::client()->getTimelineRange(room_id_); auto range = cache::client()->getTimelineRange(room_id_);
if (range) { if (range) {
@ -289,7 +287,7 @@ EventStore::EventStore(std::string room_id, QObject *)
} }
void void
EventStore::addPending(const mtx::events::collections::TimelineEvents& event) EventStore::addPending(const mtx::events::collections::TimelineEvents &event)
{ {
if (this->thread() != QThread::currentThread()) if (this->thread() != QThread::currentThread())
nhlog::db()->warn("{} called from a different thread!", __func__); nhlog::db()->warn("{} called from a different thread!", __func__);

View file

@ -11,10 +11,10 @@
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
#include <mtx/common.hpp>
#include <mtx/events/collections.hpp> #include <mtx/events/collections.hpp>
#include <mtx/responses/messages.hpp> #include <mtx/responses/messages.hpp>
#include <mtx/responses/sync.hpp> #include <mtx/responses/sync.hpp>
#include <mtx/common.hpp>
#include "Reaction.h" #include "Reaction.h"
#include "encryption/Olm.h" #include "encryption/Olm.h"
@ -107,7 +107,7 @@ signals:
void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo);
void eventFetched(std::string id, void eventFetched(std::string id,
std::string relatedTo, std::string relatedTo,
const mtx::events::collections::TimelineEvents& timeline); const mtx::events::collections::TimelineEvents &timeline);
void oldMessagesRetrieved(const mtx::responses::Messages &); void oldMessagesRetrieved(const mtx::responses::Messages &);
void fetchedMore(); void fetchedMore();
@ -119,7 +119,7 @@ signals:
void updateFlowEventId(std::string event_id); void updateFlowEventId(std::string event_id);
public slots: public slots:
void addPending(const mtx::events::collections::TimelineEvents& event); void addPending(const mtx::events::collections::TimelineEvents &event);
void receivedSessionKey(const std::string &session_id); void receivedSessionKey(const std::string &session_id);
void clearTimeline(); void clearTimeline();
void enableKeyRequests(bool suppressKeyRequests_); void enableKeyRequests(bool suppressKeyRequests_);

View file

@ -989,23 +989,26 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
blurhash_ = blurhash_ =
QString::fromStdString(blurhash::encode(data_.data(), img.width(), img.height(), 4, 3)); QString::fromStdString(blurhash::encode(data_.data(), img.width(), img.height(), 4, 3));
} else if (mimeClass_ == u"video" || mimeClass_ == u"audio") { } else if (mimeClass_ == u"video" || mimeClass_ == u"audio") {
auto mediaPlayer = new QMediaPlayer( this); auto mediaPlayer = new QMediaPlayer(this);
mediaPlayer->setAudioOutput(nullptr); mediaPlayer->setAudioOutput(nullptr);
if (mimeClass_ == u"video") { if (mimeClass_ == u"video") {
auto newSurface = new QVideoSink(this); auto newSurface = new QVideoSink(this);
connect( connect(newSurface,
newSurface, &QVideoSink::videoFrameChanged, this, [this, mediaPlayer](const QVideoFrame& frame) { &QVideoSink::videoFrameChanged,
this,
[this, mediaPlayer](const QVideoFrame &frame) {
QImage img = frame.toImage(); QImage img = frame.toImage();
if (img.size().isEmpty()) if (img.size().isEmpty())
return; return;
mediaPlayer->stop(); mediaPlayer->stop();
auto orientation = mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt(); auto orientation =
mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt();
if (orientation == 90 || orientation == 270 || orientation == 180) { if (orientation == 90 || orientation == 270 || orientation == 180) {
img = img = img.transformed(QTransform().rotate(orientation),
img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation); Qt::SmoothTransformation);
} }
nhlog::ui()->debug("Got image {}x{}", img.width(), img.height()); nhlog::ui()->debug("Got image {}x{}", img.width(), img.height());
@ -1033,12 +1036,11 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
} }
connect(mediaPlayer, connect(mediaPlayer,
&QMediaPlayer::errorOccurred, &QMediaPlayer::errorOccurred,
this, this,
[](QMediaPlayer::Error error, QString errorString) { [](QMediaPlayer::Error error, QString errorString) {
nhlog::ui()->debug("Media player error {} and errorStr {}", nhlog::ui()->debug(
error, "Media player error {} and errorStr {}", error, errorString.toStdString());
errorString.toStdString());
}); });
connect(mediaPlayer, connect(mediaPlayer,
&QMediaPlayer::mediaStatusChanged, &QMediaPlayer::mediaStatusChanged,
@ -1046,10 +1048,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
nhlog::ui()->debug( nhlog::ui()->debug(
"Media player status {} and error {}", status, mediaPlayer->error()); "Media player status {} and error {}", status, mediaPlayer->error());
}); });
connect(mediaPlayer, connect(mediaPlayer, &QMediaPlayer::metaDataChanged, this, [this, mediaPlayer]() {
&QMediaPlayer::metaDataChanged,
this,
[this, mediaPlayer]() {
nhlog::ui()->debug("Got metadata {}"); nhlog::ui()->debug("Got metadata {}");
if (mediaPlayer->duration() > 0) if (mediaPlayer->duration() > 0)
@ -1077,8 +1076,8 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
auto originalFile = qobject_cast<QFile *>(source.get()); auto originalFile = qobject_cast<QFile *>(source.get());
mediaPlayer->setSourceDevice(source.get(), mediaPlayer->setSourceDevice(
QUrl(originalFile ? originalFile->fileName() : originalFilename_)); source.get(), QUrl(originalFile ? originalFile->fileName() : originalFilename_));
mediaPlayer->play(); mediaPlayer->play();
} }

View file

@ -28,7 +28,6 @@ RoomlistModel::RoomlistModel(TimelineViewManager *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, manager(parent) , manager(parent)
{ {
connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() { connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() {
auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar(); auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar();
QHash<QString, QSharedPointer<TimelineModel>>::iterator i; QHash<QString, QSharedPointer<TimelineModel>>::iterator i;

View file

@ -31,7 +31,6 @@
#include "Utils.h" #include "Utils.h"
#include "encryption/Olm.h" #include "encryption/Olm.h"
namespace std { namespace std {
inline uint // clazy:exclude=qhash-namespace inline uint // clazy:exclude=qhash-namespace
qHash(const std::string &key, uint seed = 0) qHash(const std::string &key, uint seed = 0)

View file

@ -25,22 +25,15 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
{ {
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload); connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload); connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
connect(this, connect(
&QMediaPlayer::errorOccurred, this, &QMediaPlayer::errorOccurred, this, [](QMediaPlayer::Error error, QString errorString) {
this, nhlog::ui()->debug(
[](QMediaPlayer::Error error, QString errorString) { "Media player error {} and errorStr {}", error, errorString.toStdString());
nhlog::ui()->debug("Media player error {} and errorStr {}",
error,
errorString.toStdString());
}); });
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) { connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
nhlog::ui()->info("Media player status {} and error {}", status, this->error()); nhlog::ui()->info("Media player status {} and error {}", status, this->error());
}); });
connect(this, connect(this, &MxcMediaProxy::metaDataChanged, [this]() { emit orientationChanged(); });
&MxcMediaProxy::metaDataChanged,
[this]() {
emit orientationChanged();
});
connect(ChatPage::instance()->timelineManager()->rooms(), connect(ChatPage::instance()->timelineManager()->rooms(),
&RoomlistModel::currentRoomChanged, &RoomlistModel::currentRoomChanged,
@ -51,7 +44,8 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
int int
MxcMediaProxy::orientation() const MxcMediaProxy::orientation() const
{ {
//nhlog::ui()->debug("metadata: {}", availableMetaData().join(QStringLiteral(",")).toStdString()); // nhlog::ui()->debug("metadata: {}",
// availableMetaData().join(QStringLiteral(",")).toStdString());
auto orientation = metaData().value(QMediaMetaData::Orientation).toInt(); auto orientation = metaData().value(QMediaMetaData::Orientation).toInt();
nhlog::ui()->debug("Video orientation: {}", orientation); nhlog::ui()->debug("Video orientation: {}", orientation);
return orientation; return orientation;

View file

@ -4,13 +4,13 @@
#pragma once #pragma once
#include <QVideoSink>
#include <QBuffer> #include <QBuffer>
#include <QUrl>
#include <QMediaPlayer> #include <QMediaPlayer>
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
#include <QString> #include <QString>
#include <QUrl>
#include <QVideoSink>
#include "Logging.h" #include "Logging.h"

View file

@ -5,8 +5,8 @@
#include "NhekoGlobalObject.h" #include "NhekoGlobalObject.h"
#include <QApplication> #include <QApplication>
#include <QGuiApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QGuiApplication>
#include <QStyle> #include <QStyle>
#include <QUrl> #include <QUrl>
#include <QWindow> #include <QWindow>
@ -184,9 +184,11 @@ Nheko::createRoom(bool space,
void void
Nheko::setWindowRole([[maybe_unused]] QWindow *win, [[maybe_unused]] QString newRole) const Nheko::setWindowRole([[maybe_unused]] QWindow *win, [[maybe_unused]] QString newRole) const
{ {
const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>(); const QNativeInterface::QX11Application *x11Interface =
qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
if (!x11Interface) return; if (!x11Interface)
return;
auto connection = x11Interface->connection(); auto connection = x11Interface->connection();
@ -195,10 +197,15 @@ Nheko::setWindowRole([[maybe_unused]] QWindow *win, [[maybe_unused]] QString new
char WM_WINDOW_ROLE[] = "WM_WINDOW_ROLE"; char WM_WINDOW_ROLE[] = "WM_WINDOW_ROLE";
auto cookie = xcb_intern_atom(connection, false, std::size(WM_WINDOW_ROLE) - 1, WM_WINDOW_ROLE); auto cookie = xcb_intern_atom(connection, false, std::size(WM_WINDOW_ROLE) - 1, WM_WINDOW_ROLE);
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookie, nullptr); xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookie, nullptr);
auto atom = reply ->atom; auto atom = reply->atom;
free(reply); free(reply);
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, win->winId(), xcb_change_property(connection,
atom, XCB_ATOM_STRING, 8, XCB_PROP_MODE_REPLACE,
role.size(), role.data()); win->winId(),
atom,
XCB_ATOM_STRING,
8,
role.size(),
role.data());
} }

View file

@ -4,7 +4,6 @@
#include "Theme.h" #include "Theme.h"
QPalette QPalette
Theme::paletteFromTheme(QStringView theme) Theme::paletteFromTheme(QStringView theme)
{ {

View file

@ -41,7 +41,6 @@ extern "C"
} }
#endif #endif
using namespace mtx::events; using namespace mtx::events;
using namespace mtx::events::voip; using namespace mtx::events::voip;
@ -60,7 +59,6 @@ CallManager::CallManager(QObject *parent)
, session_(WebRTCSession::instance()) , session_(WebRTCSession::instance())
, turnServerTimer_(this) , turnServerTimer_(this)
{ {
#ifdef GSTREAMER_AVAILABLE #ifdef GSTREAMER_AVAILABLE
std::string errorMessage; std::string errorMessage;
if (session_.havePlugins(true, true, ScreenShareType::XDP, &errorMessage)) { if (session_.havePlugins(true, true, ScreenShareType::XDP, &errorMessage)) {
@ -186,7 +184,8 @@ CallManager::CallManager(QObject *parent)
nhlog::ui()->error("WebRTC: access to ringtone file denied"); nhlog::ui()->error("WebRTC: access to ringtone file denied");
break; break;
default: default:
nhlog::ui()->error("WebRTC: unable to play ringtone, {}", errorString.toStdString()); nhlog::ui()->error("WebRTC: unable to play ringtone, {}",
errorString.toStdString());
break; break;
} }
}); });
@ -820,10 +819,9 @@ CallManager::retrieveTurnServer()
void void
CallManager::playRingtone(const QUrl &ringtone, bool repeat) CallManager::playRingtone(const QUrl &ringtone, bool repeat)
{ {
player_.setLoops(repeat ? QMediaPlayer::Infinite : player_.setLoops(repeat ? QMediaPlayer::Infinite : 1);
1);
player_.setSource(ringtone); player_.setSource(ringtone);
//player_.audioOutput()->setVolume(100); // player_.audioOutput()->setVolume(100);
player_.play(); player_.play();
} }

View file

@ -438,7 +438,6 @@ struct PipeWireStream
QVariantMap map; QVariantMap map;
}; };
const QDBusArgument & const QDBusArgument &
operator>>(const QDBusArgument &argument, PipeWireStream &stream) operator>>(const QDBusArgument &argument, PipeWireStream &stream)
{ {

View file

@ -41,7 +41,6 @@ extern "C"
// https://github.com/vector-im/riot-web/issues/10173 // https://github.com/vector-im/riot-web/issues/10173
#define STUN_SERVER "stun://turn.matrix.org:3478" #define STUN_SERVER "stun://turn.matrix.org:3478"
using webrtc::CallType; using webrtc::CallType;
using webrtc::ScreenShareType; using webrtc::ScreenShareType;
using webrtc::State; using webrtc::State;