summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-02 01:37:53 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-08 22:32:08 +0200
commitde8522a185f9d62eaefb37d0f1a5e2e77c73c175 (patch)
treef97226408199f2f66c1815c71f7ef0e571d3fafc /src/timeline
parentGet rid of scrollhelper (diff)
downloadnheko-de8522a185f9d62eaefb37d0f1a5e2e77c73c175.tar.xz
lint
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/CommunitiesModel.cpp1
-rw-r--r--src/timeline/EventStore.cpp4
-rw-r--r--src/timeline/EventStore.h6
-rw-r--r--src/timeline/InputBar.cpp105
-rw-r--r--src/timeline/RoomlistModel.cpp1
-rw-r--r--src/timeline/TimelineModel.cpp1
6 files changed, 56 insertions, 62 deletions
diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp

index dc09a95e..b04fd7a9 100644 --- a/src/timeline/CommunitiesModel.cpp +++ b/src/timeline/CommunitiesModel.cpp
@@ -17,7 +17,6 @@ #include "Utils.h" #include "timeline/TimelineModel.h" - CommunitiesModel::CommunitiesModel(QObject *parent) : QAbstractListModel(parent) , hiddenTagIds_{UserSettings::instance()->hiddenTags()} diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp
index d373cf55..63b67474 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp
@@ -18,7 +18,6 @@ #include "UserSettingsPage.h" #include "Utils.h" - QCache<EventStore::IdIndex, olm::DecryptionResult> EventStore::decryptedEvents_{1000}; QCache<EventStore::IdIndex, mtx::events::collections::TimelineEvents> EventStore::events_by_id_{ 1000}; @@ -27,7 +26,6 @@ QCache<EventStore::Index, mtx::events::collections::TimelineEvents> EventStore:: EventStore::EventStore(std::string room_id, QObject *) : room_id_(std::move(room_id)) { - auto range = cache::client()->getTimelineRange(room_id_); if (range) { @@ -289,7 +287,7 @@ EventStore::EventStore(std::string room_id, QObject *) } void -EventStore::addPending(const mtx::events::collections::TimelineEvents& event) +EventStore::addPending(const mtx::events::collections::TimelineEvents &event) { if (this->thread() != QThread::currentThread()) nhlog::db()->warn("{} called from a different thread!", __func__); diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h
index f2f9e2d7..ee92a795 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h
@@ -11,10 +11,10 @@ #include <QObject> #include <QVariant> +#include <mtx/common.hpp> #include <mtx/events/collections.hpp> #include <mtx/responses/messages.hpp> #include <mtx/responses/sync.hpp> -#include <mtx/common.hpp> #include "Reaction.h" #include "encryption/Olm.h" @@ -107,7 +107,7 @@ signals: void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void eventFetched(std::string id, std::string relatedTo, - const mtx::events::collections::TimelineEvents& timeline); + const mtx::events::collections::TimelineEvents &timeline); void oldMessagesRetrieved(const mtx::responses::Messages &); void fetchedMore(); @@ -119,7 +119,7 @@ signals: void updateFlowEventId(std::string event_id); 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 clearTimeline(); void enableKeyRequests(bool suppressKeyRequests_); diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index af974592..6980c364 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -989,56 +989,58 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_, blurhash_ = QString::fromStdString(blurhash::encode(data_.data(), img.width(), img.height(), 4, 3)); } else if (mimeClass_ == u"video" || mimeClass_ == u"audio") { - auto mediaPlayer = new QMediaPlayer( this); + auto mediaPlayer = new QMediaPlayer(this); mediaPlayer->setAudioOutput(nullptr); if (mimeClass_ == u"video") { auto newSurface = new QVideoSink(this); - connect( - newSurface, &QVideoSink::videoFrameChanged, this, [this, mediaPlayer](const QVideoFrame& frame) { - QImage img = frame.toImage(); - if (img.size().isEmpty()) - return; + connect(newSurface, + &QVideoSink::videoFrameChanged, + this, + [this, mediaPlayer](const QVideoFrame &frame) { + QImage img = frame.toImage(); + if (img.size().isEmpty()) + return; - mediaPlayer->stop(); + mediaPlayer->stop(); - auto orientation = mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt(); - if (orientation == 90 || orientation == 270 || orientation == 180) { - img = - img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation); - } + auto orientation = + mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt(); + if (orientation == 90 || orientation == 270 || orientation == 180) { + img = img.transformed(QTransform().rotate(orientation), + Qt::SmoothTransformation); + } - nhlog::ui()->debug("Got image {}x{}", img.width(), img.height()); + nhlog::ui()->debug("Got image {}x{}", img.width(), img.height()); - this->setThumbnail(img); + this->setThumbnail(img); - if (!dimensions_.isValid()) - this->dimensions_ = img.size(); + if (!dimensions_.isValid()) + this->dimensions_ = img.size(); - if (img.height() > 200 && img.width() > 360) - img = img.scaled(360, 200, Qt::KeepAspectRatioByExpanding); - std::vector<unsigned char> data_; - for (int y = 0; y < img.height(); y++) { - for (int x = 0; x < img.width(); x++) { - auto p = img.pixel(x, y); - data_.push_back(static_cast<unsigned char>(qRed(p))); - data_.push_back(static_cast<unsigned char>(qGreen(p))); - data_.push_back(static_cast<unsigned char>(qBlue(p))); - } - } - blurhash_ = QString::fromStdString( - blurhash::encode(data_.data(), img.width(), img.height(), 4, 3)); - }); + if (img.height() > 200 && img.width() > 360) + img = img.scaled(360, 200, Qt::KeepAspectRatioByExpanding); + std::vector<unsigned char> data_; + for (int y = 0; y < img.height(); y++) { + for (int x = 0; x < img.width(); x++) { + auto p = img.pixel(x, y); + data_.push_back(static_cast<unsigned char>(qRed(p))); + data_.push_back(static_cast<unsigned char>(qGreen(p))); + data_.push_back(static_cast<unsigned char>(qBlue(p))); + } + } + blurhash_ = QString::fromStdString( + blurhash::encode(data_.data(), img.width(), img.height(), 4, 3)); + }); mediaPlayer->setVideoOutput(newSurface); } connect(mediaPlayer, -&QMediaPlayer::errorOccurred, + &QMediaPlayer::errorOccurred, this, [](QMediaPlayer::Error error, QString errorString) { - nhlog::ui()->debug("Media player error {} and errorStr {}", - error, - errorString.toStdString()); + nhlog::ui()->debug( + "Media player error {} and errorStr {}", error, errorString.toStdString()); }); connect(mediaPlayer, &QMediaPlayer::mediaStatusChanged, @@ -1046,25 +1048,22 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_, nhlog::ui()->debug( "Media player status {} and error {}", status, mediaPlayer->error()); }); - connect(mediaPlayer, -&QMediaPlayer::metaDataChanged, - this, - [this, mediaPlayer]() { - nhlog::ui()->debug("Got metadata {}"); + connect(mediaPlayer, &QMediaPlayer::metaDataChanged, this, [this, mediaPlayer]() { + nhlog::ui()->debug("Got metadata {}"); - if (mediaPlayer->duration() > 0) - this->duration_ = mediaPlayer->duration(); + if (mediaPlayer->duration() > 0) + this->duration_ = mediaPlayer->duration(); - auto dimensions = mediaPlayer->metaData().value(QMediaMetaData::Resolution).toSize(); - if (!dimensions.isEmpty()) { - dimensions_ = dimensions; - auto orientation = - mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt(); - if (orientation == 90 || orientation == 270) { - dimensions_.transpose(); - } - } - }); + auto dimensions = mediaPlayer->metaData().value(QMediaMetaData::Resolution).toSize(); + if (!dimensions.isEmpty()) { + dimensions_ = dimensions; + auto orientation = + mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt(); + if (orientation == 90 || orientation == 270) { + dimensions_.transpose(); + } + } + }); connect( mediaPlayer, &QMediaPlayer::durationChanged, this, [this, mediaPlayer](qint64 duration) { if (duration > 0) { @@ -1077,8 +1076,8 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_, auto originalFile = qobject_cast<QFile *>(source.get()); - mediaPlayer->setSourceDevice(source.get(), - QUrl(originalFile ? originalFile->fileName() : originalFilename_)); + mediaPlayer->setSourceDevice( + source.get(), QUrl(originalFile ? originalFile->fileName() : originalFilename_)); mediaPlayer->play(); } diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index b55cbabd..35507cbd 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -28,7 +28,6 @@ RoomlistModel::RoomlistModel(TimelineViewManager *parent) : QAbstractListModel(parent) , manager(parent) { - connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() { auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar(); QHash<QString, QSharedPointer<TimelineModel>>::iterator i; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index a4659f33..0e99e7e1 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -31,7 +31,6 @@ #include "Utils.h" #include "encryption/Olm.h" - namespace std { inline uint // clazy:exclude=qhash-namespace qHash(const std::string &key, uint seed = 0)