diff --git a/src/ui/MxcAnimatedImage.cpp b/src/ui/MxcAnimatedImage.cpp
index 7544537d..14f5dbd8 100644
--- a/src/ui/MxcAnimatedImage.cpp
+++ b/src/ui/MxcAnimatedImage.cpp
@@ -152,9 +152,9 @@ MxcAnimatedImage::startDownload()
}
void
-MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+MxcAnimatedImage::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ QQuickItem::geometryChange(newGeometry, oldGeometry);
if (newGeometry.size() != oldGeometry.size()) {
if (height() != 0 && width() != 0) {
diff --git a/src/ui/MxcAnimatedImage.h b/src/ui/MxcAnimatedImage.h
index a32de6ee..bc53e711 100644
--- a/src/ui/MxcAnimatedImage.h
+++ b/src/ui/MxcAnimatedImage.h
@@ -59,7 +59,7 @@ public:
}
}
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
QSGNode *updatePaintNode(QSGNode *oldNode,
QQuickItem::UpdatePaintNodeData *updatePaintNodeData) override;
diff --git a/src/ui/MxcMediaProxy.cpp b/src/ui/MxcMediaProxy.cpp
index 9a439c30..e10cb846 100644
--- a/src/ui/MxcMediaProxy.cpp
+++ b/src/ui/MxcMediaProxy.cpp
@@ -8,17 +8,11 @@
#include <QFile>
#include <QFileInfo>
#include <QMediaMetaData>
-#include <QMediaObject>
#include <QMediaPlayer>
#include <QMimeDatabase>
#include <QStandardPaths>
#include <QUrl>
-#if defined(Q_OS_MACOS)
-// TODO (red_sky): Remove for Qt6. See other ifdef below
-#include <QTemporaryFile>
-#endif
-
#include "ChatPage.h"
#include "EventAccessors.h"
#include "Logging.h"
@@ -32,19 +26,18 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
connect(this,
- qOverload<QMediaPlayer::Error>(&MxcMediaProxy::error),
- [this](QMediaPlayer::Error error) {
+ &MxcMediaProxy::error,
+ [this]() {
nhlog::ui()->info("Media player error {} and errorStr {}",
- error,
+ 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,
- qOverload<const QString &, const QVariant &>(&MxcMediaProxy::metaDataChanged),
- [this](const QString &t, const QVariant &) {
- if (t == QMediaMetaData::Orientation)
+ &MxcMediaProxy::metaDataChanged,
+ [this]() {
emit orientationChanged();
});
@@ -53,28 +46,12 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
this,
&MxcMediaProxy::pause);
}
-void
-MxcMediaProxy::setVideoSurface(QAbstractVideoSurface *surface)
-{
- if (surface != m_surface) {
- qDebug() << "Changing surface";
- m_surface = surface;
- setVideoOutput(m_surface);
- emit videoSurfaceChanged();
- }
-}
-
-QAbstractVideoSurface *
-MxcMediaProxy::getVideoSurface()
-{
- return m_surface;
-}
int
MxcMediaProxy::orientation() const
{
- nhlog::ui()->debug("metadata: {}", availableMetaData().join(QStringLiteral(",")).toStdString());
- auto orientation = metaData(QMediaMetaData::Orientation).toInt();
+ //nhlog::ui()->debug("metadata: {}", availableMetaData().join(QStringLiteral(",")).toStdString());
+ auto orientation = metaData().value(QMediaMetaData::Orientation).toInt();
nhlog::ui()->debug("Video orientation: {}", orientation);
return orientation;
}
@@ -135,34 +112,10 @@ MxcMediaProxy::startDownload()
buffer.open(QIODevice::ReadOnly);
buffer.reset();
- QTimer::singleShot(0, this, [this, filename, suffix, encryptionInfo] {
-#if defined(Q_OS_MACOS)
- if (encryptionInfo) {
- // macOS has issues reading from a buffer in setMedia for whatever reason.
- // Instead, write the buffer to a temporary file and read from that.
- // This should be fixed in Qt6, so update this when we do that!
- // TODO: REMOVE IN QT6
- QTemporaryFile tempFile;
- tempFile.setFileTemplate(tempFile.fileTemplate() + QLatin1Char('.') + suffix);
- tempFile.open();
- tempFile.write(buffer.data());
- tempFile.close();
- nhlog::ui()->debug("Playing media from temp buffer file: {}. Remove in QT6!",
- filename.filePath().toStdString());
- this->setMedia(QUrl::fromLocalFile(tempFile.fileName()));
- } else {
- nhlog::ui()->info(
- "Playing buffer with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
- this->setMedia(QUrl::fromLocalFile(filename.filePath()));
- }
-#else
- Q_UNUSED(suffix)
- Q_UNUSED(encryptionInfo)
-
+ QTimer::singleShot(0, this, [this, filename] {
nhlog::ui()->info(
"Playing buffer with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
- this->setMedia(QMediaContent(filename.fileName()), &buffer);
-#endif
+ this->setSourceDevice(&buffer, QUrl(filename.fileName()));
emit loadedChanged();
});
};
diff --git a/src/ui/MxcMediaProxy.h b/src/ui/MxcMediaProxy.h
index 48de5a4f..7b7947e9 100644
--- a/src/ui/MxcMediaProxy.h
+++ b/src/ui/MxcMediaProxy.h
@@ -4,9 +4,9 @@
#pragma once
-#include <QAbstractVideoSurface>
+#include <QVideoSink>
#include <QBuffer>
-#include <QMediaContent>
+#include <QUrl>
#include <QMediaPlayer>
#include <QObject>
#include <QPointer>
@@ -23,8 +23,6 @@ class MxcMediaProxy : public QMediaPlayer
Q_OBJECT
Q_PROPERTY(TimelineModel *roomm READ room WRITE setRoom NOTIFY roomChanged REQUIRED)
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
- Q_PROPERTY(QAbstractVideoSurface *videoSurface READ getVideoSurface WRITE setVideoSurface NOTIFY
- videoSurfaceChanged)
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
@@ -44,16 +42,13 @@ public:
room_ = room;
emit roomChanged();
}
- void setVideoSurface(QAbstractVideoSurface *surface);
- QAbstractVideoSurface *getVideoSurface();
-
int orientation() const;
signals:
void roomChanged();
void eventIdChanged();
void loadedChanged();
- void newBuffer(QMediaContent, QIODevice *buf);
+ void newBuffer(QUrl, QIODevice *buf);
void orientationChanged();
void videoSurfaceChanged();
@@ -66,5 +61,5 @@ private:
QString eventId_;
QString filename_;
QBuffer buffer;
- QAbstractVideoSurface *m_surface = nullptr;
+ QObject *m_surface = nullptr;
};
diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp
index a6f9abe7..8f410dae 100644
--- a/src/ui/NhekoGlobalObject.cpp
+++ b/src/ui/NhekoGlobalObject.cpp
@@ -5,16 +5,12 @@
#include "NhekoGlobalObject.h"
#include <QApplication>
+#include <QGuiApplication>
#include <QDesktopServices>
#include <QStyle>
#include <QUrl>
#include <QWindow>
-// for some reason that is not installed in our macOS env...
-#ifndef Q_OS_MAC
-#include <QtPlatformHeaders/QXcbWindowFunctions>
-#endif
-
#include "Cache_p.h"
#include "ChatPage.h"
#include "Logging.h"
@@ -22,6 +18,8 @@
#include "Utils.h"
#include "voip/WebRTCSession.h"
+#include <xcb/xproto.h>
+
Nheko::Nheko()
{
connect(
@@ -186,7 +184,21 @@ Nheko::createRoom(bool space,
void
Nheko::setWindowRole([[maybe_unused]] QWindow *win, [[maybe_unused]] QString newRole) const
{
-#ifndef Q_OS_MAC
- QXcbWindowFunctions::setWmWindowRole(win, newRole.toUtf8());
-#endif
+ const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
+
+ if (!x11Interface) return;
+
+ auto connection = x11Interface->connection();
+
+ auto role = newRole.toStdString();
+
+ char WM_WINDOW_ROLE[] = "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);
+ auto atom = reply ->atom;
+ free(reply);
+
+ xcb_change_property(connection, XCB_PROP_MODE_REPLACE, win->winId(),
+ atom, XCB_ATOM_STRING, 8,
+ role.size(), role.data());
}
diff --git a/src/ui/Theme.cpp b/src/ui/Theme.cpp
index 48cb8bce..8cf38548 100644
--- a/src/ui/Theme.cpp
+++ b/src/ui/Theme.cpp
@@ -4,12 +4,10 @@
#include "Theme.h"
-Q_DECLARE_METATYPE(Theme)
QPalette
Theme::paletteFromTheme(QStringView theme)
{
- [[maybe_unused]] static auto meta = qRegisterMetaType<Theme>("Theme");
static QPalette original;
if (theme == u"light") {
static QPalette lightActive = [] {
|