mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 19:38:48 +03:00
Fix char out of range and media player signals
This commit is contained in:
parent
c775a93f77
commit
159bec3654
6 changed files with 91 additions and 103 deletions
|
@ -4040,9 +4040,8 @@ Cache::displayName(const QString &room_id, const QString &user_id)
|
|||
static bool
|
||||
isDisplaynameSafe(const std::string &s)
|
||||
{
|
||||
for (uint32_t cc : QString::fromStdString(s).toStdU32String()) {
|
||||
auto c = QChar(cc);
|
||||
if (c.isPrint() && !c.isSpace())
|
||||
for (char32_t c : QString::fromStdString(s).toUcs4()) {
|
||||
if (QChar::isPrint(c) && !QChar::isSpace(c))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,8 +292,10 @@ main(int argc, char *argv[])
|
|||
app.installTranslator(&qtTranslator);
|
||||
|
||||
QTranslator appTranslator;
|
||||
if(appTranslator.load(
|
||||
QLocale(), QStringLiteral("nheko"), QStringLiteral("_"), QStringLiteral(":/translations")))
|
||||
if (appTranslator.load(QLocale(),
|
||||
QStringLiteral("nheko"),
|
||||
QStringLiteral("_"),
|
||||
QStringLiteral(":/translations")))
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
MainWindow w;
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
#include "InputBar.h"
|
||||
|
||||
#include <QVideoSink>
|
||||
#include <QBuffer>
|
||||
#include <QClipboard>
|
||||
#include <QDropEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QGuiApplication>
|
||||
#include <QInputMethod>
|
||||
#include <QVideoFrame>
|
||||
#include <QMediaMetaData>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextBoundaryFinder>
|
||||
#include <QVideoFrame>
|
||||
#include <QVideoSink>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <mtx/responses/common.hpp>
|
||||
|
@ -758,8 +758,10 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
|||
|
||||
if (mimeClass_ == u"video") {
|
||||
auto newSurface = new QVideoSink(this);
|
||||
connect(
|
||||
newSurface, &QVideoSink::videoFrameChanged, this, [this, mediaPlayer](const QVideoFrame& frame) {
|
||||
connect(newSurface,
|
||||
&QVideoSink::videoFrameChanged,
|
||||
this,
|
||||
[this, mediaPlayer](const QVideoFrame &frame) {
|
||||
QImage img = frame.toImage();
|
||||
|
||||
if (img.size().isEmpty())
|
||||
|
@ -767,10 +769,11 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
|||
|
||||
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) {
|
||||
img =
|
||||
img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation);
|
||||
img = img.transformed(QTransform().rotate(orientation),
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
nhlog::ui()->debug("Got image {}x{}", img.width(), img.height());
|
||||
|
@ -797,10 +800,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
|||
mediaPlayer->setVideoOutput(newSurface);
|
||||
}
|
||||
|
||||
connect(mediaPlayer,
|
||||
&QMediaPlayer::error,
|
||||
this,
|
||||
[mediaPlayer]() {
|
||||
connect(mediaPlayer, &QMediaPlayer::errorChanged, this, [mediaPlayer]() {
|
||||
nhlog::ui()->debug("Media player error {} and errorStr {}",
|
||||
mediaPlayer->error(),
|
||||
mediaPlayer->errorString().toStdString());
|
||||
|
@ -811,9 +811,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
|||
nhlog::ui()->debug(
|
||||
"Media player status {} and error {}", status, mediaPlayer->error());
|
||||
});
|
||||
connect(mediaPlayer,
|
||||
&QMediaPlayer::metaDataChanged,
|
||||
[this, mediaPlayer]() {
|
||||
connect(mediaPlayer, &QMediaPlayer::metaDataChanged, [this, mediaPlayer]() {
|
||||
nhlog::ui()->debug("Got metadata");
|
||||
|
||||
if (mediaPlayer->duration() > 0)
|
||||
|
|
|
@ -24,21 +24,14 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
|
|||
{
|
||||
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this,
|
||||
&MxcMediaProxy::error,
|
||||
[this]() {
|
||||
nhlog::ui()->info("Media player error {} and errorStr {}",
|
||||
error(),
|
||||
this->errorString().toStdString());
|
||||
connect(this, &MxcMediaProxy::error, [this]() {
|
||||
nhlog::ui()->info(
|
||||
"Media player error {} and errorStr {}", error(), this->errorString().toStdString());
|
||||
});
|
||||
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
||||
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
||||
});
|
||||
connect(this,
|
||||
&MxcMediaProxy::metaDataChanged,
|
||||
[this]() {
|
||||
emit orientationChanged();
|
||||
});
|
||||
connect(this, &MxcMediaProxy::metaDataChanged, [this]() { emit orientationChanged(); });
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QVideoSink>
|
||||
#include <QBuffer>
|
||||
#include <QMediaPlayer>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QVideoSink>
|
||||
|
||||
#include "timeline/TimelineModel.h"
|
||||
#include "Logging.h"
|
||||
#include "timeline/TimelineModel.h"
|
||||
|
||||
class TimelineModel;
|
||||
|
||||
|
|
|
@ -142,10 +142,7 @@ CallManager::CallManager(QObject *parent)
|
|||
player_.play();
|
||||
});
|
||||
|
||||
connect(&player_,
|
||||
&QMediaPlayer::error,
|
||||
this,
|
||||
[this]() {
|
||||
connect(&player_, &QMediaPlayer::errorChanged, this, [this]() {
|
||||
stopRingtone();
|
||||
switch (player_.error()) {
|
||||
case QMediaPlayer::FormatError:
|
||||
|
@ -496,8 +493,7 @@ CallManager::retrieveTurnServer()
|
|||
void
|
||||
CallManager::playRingtone(const QUrl &ringtone, bool repeat)
|
||||
{
|
||||
player_.setLoops(repeat ? QMediaPlayer::Infinite :
|
||||
1);
|
||||
player_.setLoops(repeat ? QMediaPlayer::Infinite : 1);
|
||||
player_.setSource(ringtone);
|
||||
// player_.audioOutput()->setVolume(100);
|
||||
player_.play();
|
||||
|
|
Loading…
Reference in a new issue