mirror of
https://github.com/KDE/kasts.git
synced 2025-01-19 03:50:57 +01:00
Port c++ to qt6
This commit is contained in:
parent
4b9843ce58
commit
9ead23ff59
@ -9,3 +9,7 @@ include:
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/windows.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/flatpak.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
|
||||
# - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml
|
||||
# - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android-qt6.yml
|
||||
# - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/windows-qt6.yml
|
||||
|
@ -52,7 +52,10 @@ set_package_properties(Qt${QT_MAJOR_VERSION}Keychain PROPERTIES
|
||||
find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS NetworkManagerQt)
|
||||
|
||||
if (ANDROID)
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Svg AndroidExtras)
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Svg)
|
||||
if (QT_MAJOR_VERSION EQUAL "5")
|
||||
find_package(Qt5 REQUIRED COMPONENTS AndroidExtras)
|
||||
endif()
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(SQLite3)
|
||||
find_package(ZLIB)
|
||||
|
@ -9,11 +9,17 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QAudio>
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QAudioOutput>
|
||||
#endif
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QImage>
|
||||
#include <QMediaPlayer>
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QMediaMetaData>
|
||||
#endif
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTimer>
|
||||
@ -24,13 +30,24 @@ private:
|
||||
friend class QtMediaBackend;
|
||||
|
||||
KMediaSession *m_KMediaSession = nullptr;
|
||||
|
||||
QMediaPlayer m_player;
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
QAudioOutput m_output;
|
||||
#else
|
||||
#define m_output m_player
|
||||
#define QAudioOutput QMediaPlayer
|
||||
#endif
|
||||
|
||||
std::unique_ptr<QTemporaryDir> imageCacheDir = nullptr;
|
||||
|
||||
KMediaSession::Error translateErrorEnum(QMediaPlayer::Error errorEnum);
|
||||
KMediaSession::MediaStatus translateMediaStatusEnum(QMediaPlayer::MediaStatus mediaEnum);
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
KMediaSession::PlaybackState translatePlaybackStateEnum(QMediaPlayer::PlaybackState playbackStateEnum);
|
||||
#else
|
||||
KMediaSession::PlaybackState translatePlaybackStateEnum(QMediaPlayer::State playbackStateEnum);
|
||||
#endif
|
||||
void parseMetaData();
|
||||
};
|
||||
|
||||
@ -42,76 +59,30 @@ QtMediaBackend::QtMediaBackend(QObject *parent)
|
||||
|
||||
d->m_KMediaSession = static_cast<KMediaSession *>(parent);
|
||||
|
||||
// Parsing of metadata
|
||||
connect(&d->m_player, QOverload<>::of(&QMediaObject::metaDataChanged), this, [this]() {
|
||||
d->parseMetaData();
|
||||
});
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
d->m_player.setAudioOutput(&d->m_output);
|
||||
#endif
|
||||
|
||||
// connect to QMediaPlayer signals and dispatch to AbstractMediaBackend
|
||||
// signals and add debug output
|
||||
connect(&d->m_player, &QMediaPlayer::mutedChanged, this, [this](bool muted) {
|
||||
QTimer::singleShot(0, this, [this, muted]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::mutedChanged(" << muted << ")";
|
||||
Q_EMIT mutedChanged(muted);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::volumeChanged, this, [this](int volume) {
|
||||
qreal realVolume = static_cast<qreal>(volume) / 100.0;
|
||||
qreal userVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale)) * 100.0;
|
||||
QTimer::singleShot(0, this, [this, userVolume]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::volumeChanged(" << userVolume << ")";
|
||||
Q_EMIT volumeChanged(userVolume);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::mediaChanged, this, [this](const QMediaContent &media) {
|
||||
QUrl source = media.request().url();
|
||||
QTimer::singleShot(0, this, [this, source]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::sourceChanged(" << source << ")";
|
||||
Q_EMIT sourceChanged(source);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::mediaStatusChanged, this, [this](const QMediaPlayer::MediaStatus &qtMediaStatus) {
|
||||
const KMediaSession::MediaStatus mediaStatus = d->translateMediaStatusEnum(qtMediaStatus);
|
||||
QTimer::singleShot(0, this, [this, mediaStatus]() {
|
||||
Q_EMIT mediaStatusChanged(mediaStatus);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::stateChanged, this, [this](const QMediaPlayer::State &qtPlaybackState) {
|
||||
const KMediaSession::PlaybackState playbackState = d->translatePlaybackStateEnum(qtPlaybackState);
|
||||
QTimer::singleShot(0, this, [this, playbackState]() {
|
||||
Q_EMIT playbackStateChanged(playbackState);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::playbackRateChanged, this, [this](const qreal &playbackRate) {
|
||||
QTimer::singleShot(0, this, [this, playbackRate]() {
|
||||
Q_EMIT playbackRateChanged(playbackRate);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), this, [this](const QMediaPlayer::Error &error) {
|
||||
QTimer::singleShot(0, this, [this, error]() {
|
||||
Q_EMIT errorChanged(d->translateErrorEnum(error));
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::durationChanged, this, [this](qint64 duration) {
|
||||
QTimer::singleShot(0, this, [this, duration]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::durationChanged(" << duration << ")";
|
||||
Q_EMIT durationChanged(duration);
|
||||
});
|
||||
});
|
||||
|
||||
connect(&d->m_player, &QMediaPlayer::positionChanged, this, [this](qint64 position) {
|
||||
QTimer::singleShot(0, this, [this, position]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::positionChanged(" << position << ")";
|
||||
Q_EMIT positionChanged(position);
|
||||
});
|
||||
});
|
||||
connect(&d->m_output, &QAudioOutput::mutedChanged, this, &QtMediaBackend::playerMutedSignalChanges);
|
||||
connect(&d->m_output, &QAudioOutput::volumeChanged, this, &QtMediaBackend::playerVolumeSignalChanges);
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
connect(&d->m_player, &QMediaPlayer::sourceChanged, this, &QtMediaBackend::playerSourceSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::playbackStateChanged, this, &QtMediaBackend::playerStateSignalChanges);
|
||||
connect(&d->m_player, QOverload<QMediaPlayer::Error, const QString &>::of(&QMediaPlayer::errorOccurred), this, &QtMediaBackend::playerErrorSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::metaDataChanged, this, &QtMediaBackend::playerMetaDataSignalChanges);
|
||||
#else
|
||||
connect(&d->m_player, &QMediaPlayer::mediaChanged, this, &QtMediaBackend::playerSourceSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::stateChanged, this, &QtMediaBackend::playerStateSignalChanges);
|
||||
connect(&d->m_player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), this, &QtMediaBackend::playerErrorSignalChanges);
|
||||
connect(&d->m_player, QOverload<>::of(&QMediaObject::metaDataChanged), this, &QtMediaBackend::playerMetaDataSignalChanges);
|
||||
#endif
|
||||
connect(&d->m_player, &QMediaPlayer::mediaStatusChanged, this, &QtMediaBackend::mediaStatusSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::playbackRateChanged, this, &QtMediaBackend::playerPlaybackRateSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::durationChanged, this, &QtMediaBackend::playerDurationSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::positionChanged, this, &QtMediaBackend::playerPositionSignalChanges);
|
||||
connect(&d->m_player, &QMediaPlayer::seekableChanged, this, &QtMediaBackend::playerSeekableSignalChanges);
|
||||
}
|
||||
|
||||
QtMediaBackend::~QtMediaBackend()
|
||||
@ -129,13 +100,17 @@ KMediaSession::MediaBackends QtMediaBackend::backend() const
|
||||
bool QtMediaBackend::muted() const
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::muted()";
|
||||
return d->m_player.isMuted();
|
||||
return d->m_output.isMuted();
|
||||
}
|
||||
|
||||
qreal QtMediaBackend::volume() const
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::volume()";
|
||||
qreal realVolume = static_cast<qreal>(d->m_player.volume() / 100.0);
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
qreal realVolume = static_cast<qreal>(d->m_output.volume());
|
||||
#else
|
||||
qreal realVolume = static_cast<qreal>(d->m_output.volume() / 100.0);
|
||||
#endif
|
||||
qreal userVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale));
|
||||
|
||||
return userVolume * 100.0;
|
||||
@ -144,7 +119,11 @@ qreal QtMediaBackend::volume() const
|
||||
QUrl QtMediaBackend::source() const
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::source()";
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
return d->m_player.source();
|
||||
#else
|
||||
return d->m_player.media().request().url();
|
||||
#endif
|
||||
}
|
||||
|
||||
KMediaSession::MediaStatus QtMediaBackend::mediaStatus() const
|
||||
@ -156,7 +135,11 @@ KMediaSession::MediaStatus QtMediaBackend::mediaStatus() const
|
||||
KMediaSession::PlaybackState QtMediaBackend::playbackState() const
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::playbackState()";
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
return d->translatePlaybackStateEnum(d->m_player.playbackState());
|
||||
#else
|
||||
return d->translatePlaybackStateEnum(d->m_player.state());
|
||||
#endif
|
||||
}
|
||||
|
||||
qreal QtMediaBackend::playbackRate() const
|
||||
@ -192,7 +175,7 @@ bool QtMediaBackend::seekable() const
|
||||
void QtMediaBackend::setMuted(bool muted)
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::setMuted(" << muted << ")";
|
||||
d->m_player.setMuted(muted);
|
||||
d->m_output.setMuted(muted);
|
||||
}
|
||||
|
||||
void QtMediaBackend::setVolume(qreal volume)
|
||||
@ -200,13 +183,21 @@ void QtMediaBackend::setVolume(qreal volume)
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::setVolume(" << volume << ")";
|
||||
|
||||
qreal realVolume = static_cast<qreal>(QAudio::convertVolume(volume / 100.0, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale));
|
||||
d->m_player.setVolume(qRound(realVolume * 100.0));
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
d->m_output.setVolume(realVolume);
|
||||
#else
|
||||
d->m_output.setVolume(qRound(realVolume * 100.0));
|
||||
#endif
|
||||
}
|
||||
|
||||
void QtMediaBackend::setSource(const QUrl &source)
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::setSource(" << source << ")";
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
d->m_player.setSource(source);
|
||||
#else
|
||||
d->m_player.setMedia(source);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QtMediaBackend::setPosition(qint64 position)
|
||||
@ -239,6 +230,108 @@ void QtMediaBackend::stop()
|
||||
d->m_player.stop();
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerMutedSignalChanges(bool muted)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, muted]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::mutedChanged(" << muted << ")";
|
||||
Q_EMIT mutedChanged(muted);
|
||||
});
|
||||
}
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
void QtMediaBackend::playerVolumeSignalChanges(float volume)
|
||||
{
|
||||
qreal realVolume = static_cast<qreal>(volume);
|
||||
#else
|
||||
void QtMediaBackend::playerVolumeSignalChanges(qint64 volume)
|
||||
{
|
||||
qreal realVolume = static_cast<qreal>(volume) / 100.0;
|
||||
#endif
|
||||
qreal userVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale)) * 100.0;
|
||||
QTimer::singleShot(0, this, [this, userVolume]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::volumeChanged(" << userVolume << ")";
|
||||
Q_EMIT volumeChanged(userVolume);
|
||||
});
|
||||
}
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
void QtMediaBackend::playerSourceSignalChanges(const QUrl &media)
|
||||
{
|
||||
QUrl source = media;
|
||||
|
||||
#else
|
||||
void QtMediaBackend::playerSourceSignalChanges(const QMediaContent &media)
|
||||
{
|
||||
QUrl source = media.request().url();
|
||||
#endif
|
||||
QTimer::singleShot(0, this, [this, source]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::sourceChanged(" << source << ")";
|
||||
Q_EMIT sourceChanged(source);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::mediaStatusSignalChanges(const QMediaPlayer::MediaStatus &qtMediaStatus)
|
||||
{
|
||||
const KMediaSession::MediaStatus mediaStatus = d->translateMediaStatusEnum(qtMediaStatus);
|
||||
QTimer::singleShot(0, this, [this, mediaStatus]() {
|
||||
Q_EMIT mediaStatusChanged(mediaStatus);
|
||||
});
|
||||
}
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
void QtMediaBackend::playerStateSignalChanges(const QMediaPlayer::PlaybackState &qtPlaybackState)
|
||||
#else
|
||||
void QtMediaBackend::playerStateSignalChanges(const QMediaPlayer::State &qtPlaybackState)
|
||||
#endif
|
||||
{
|
||||
const KMediaSession::PlaybackState playbackState = d->translatePlaybackStateEnum(qtPlaybackState);
|
||||
QTimer::singleShot(0, this, [this, playbackState]() {
|
||||
Q_EMIT playbackStateChanged(playbackState);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerPlaybackRateSignalChanges(const qreal &playbackRate)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, playbackRate]() {
|
||||
Q_EMIT playbackRateChanged(playbackRate);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerErrorSignalChanges(const QMediaPlayer::Error &error)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, error]() {
|
||||
Q_EMIT errorChanged(d->translateErrorEnum(error));
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerDurationSignalChanges(qint64 newDuration)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, newDuration]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::durationChanged(" << newDuration << ")";
|
||||
Q_EMIT durationChanged(newDuration);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerPositionSignalChanges(qint64 newPosition)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, newPosition]() {
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackend::positionChanged(" << newPosition << ")";
|
||||
Q_EMIT positionChanged(newPosition);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerSeekableSignalChanges(bool seekable)
|
||||
{
|
||||
QTimer::singleShot(0, this, [this, seekable]() {
|
||||
Q_EMIT seekableChanged(seekable);
|
||||
});
|
||||
}
|
||||
|
||||
void QtMediaBackend::playerMetaDataSignalChanges()
|
||||
{
|
||||
d->parseMetaData();
|
||||
}
|
||||
|
||||
KMediaSession::Error QtMediaBackendPrivate::translateErrorEnum(QMediaPlayer::Error errorEnum)
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translateErrorEnum(" << errorEnum << ")";
|
||||
@ -253,8 +346,10 @@ KMediaSession::Error QtMediaBackendPrivate::translateErrorEnum(QMediaPlayer::Err
|
||||
return KMediaSession::Error::NetworkError;
|
||||
case QMediaPlayer::Error::AccessDeniedError:
|
||||
return KMediaSession::Error::AccessDeniedError;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
case QMediaPlayer::Error::ServiceMissingError:
|
||||
return KMediaSession::Error::ServiceMissingError;
|
||||
#endif
|
||||
default:
|
||||
return KMediaSession::Error::NoError;
|
||||
}
|
||||
@ -264,8 +359,6 @@ KMediaSession::MediaStatus QtMediaBackendPrivate::translateMediaStatusEnum(QMedi
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translateMediaStatusEnum(" << mediaEnum << ")";
|
||||
switch (mediaEnum) {
|
||||
case QMediaPlayer::MediaStatus::UnknownMediaStatus:
|
||||
return KMediaSession::MediaStatus::UnknownMediaStatus;
|
||||
case QMediaPlayer::MediaStatus::NoMedia:
|
||||
return KMediaSession::MediaStatus::NoMedia;
|
||||
case QMediaPlayer::MediaStatus::LoadingMedia:
|
||||
@ -282,11 +375,34 @@ KMediaSession::MediaStatus QtMediaBackendPrivate::translateMediaStatusEnum(QMedi
|
||||
return KMediaSession::MediaStatus::EndOfMedia;
|
||||
case QMediaPlayer::MediaStatus::InvalidMedia:
|
||||
return KMediaSession::MediaStatus::InvalidMedia;
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
default:
|
||||
return KMediaSession::MediaStatus::NoMedia;
|
||||
#else
|
||||
case QMediaPlayer::MediaStatus::UnknownMediaStatus:
|
||||
default:
|
||||
return KMediaSession::MediaStatus::UnknownMediaStatus;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
KMediaSession::PlaybackState QtMediaBackendPrivate::translatePlaybackStateEnum(QMediaPlayer::PlaybackState playbackStateEnum)
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translateMediaStatusEnum(" << playbackStateEnum << ")";
|
||||
|
||||
switch (playbackStateEnum) {
|
||||
case QMediaPlayer::PlaybackState::StoppedState:
|
||||
return KMediaSession::PlaybackState::StoppedState;
|
||||
case QMediaPlayer::PlaybackState::PlayingState:
|
||||
return KMediaSession::PlaybackState::PlayingState;
|
||||
case QMediaPlayer::PlaybackState::PausedState:
|
||||
return KMediaSession::PlaybackState::PausedState;
|
||||
default:
|
||||
return KMediaSession::PlaybackState::StoppedState;
|
||||
}
|
||||
}
|
||||
#else
|
||||
KMediaSession::PlaybackState QtMediaBackendPrivate::translatePlaybackStateEnum(QMediaPlayer::State playbackStateEnum)
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translateMediaStatusEnum(" << playbackStateEnum << ")";
|
||||
@ -302,26 +418,50 @@ KMediaSession::PlaybackState QtMediaBackendPrivate::translatePlaybackStateEnum(Q
|
||||
return KMediaSession::PlaybackState::StoppedState;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void QtMediaBackendPrivate::parseMetaData()
|
||||
{
|
||||
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::parseMetaData()";
|
||||
|
||||
if (m_KMediaSession->metaData()->title().isEmpty()) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
m_KMediaSession->metaData()->setTitle(m_player.metaData().stringValue(QMediaMetaData::Title));
|
||||
#else
|
||||
m_KMediaSession->metaData()->setTitle(m_player.metaData(QStringLiteral("Title")).toString());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_KMediaSession->metaData()->artist().isEmpty()) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
m_KMediaSession->metaData()->setArtist(m_player.metaData().stringValue(QMediaMetaData::ContributingArtist));
|
||||
#else
|
||||
m_KMediaSession->metaData()->setArtist(m_player.metaData(QStringLiteral("ContributingArtist")).toString());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_KMediaSession->metaData()->album().isEmpty()) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
m_KMediaSession->metaData()->setAlbum(m_player.metaData().stringValue(QMediaMetaData::AlbumTitle));
|
||||
#else
|
||||
m_KMediaSession->metaData()->setAlbum(m_player.metaData(QStringLiteral("AlbumTitle")).toString());
|
||||
#endif
|
||||
}
|
||||
if (m_KMediaSession->metaData()->artworkUrl().isEmpty()) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
if (m_player.metaData().value(QMediaMetaData::CoverArtImage).isValid()) {
|
||||
#else
|
||||
if (m_player.metaData(QStringLiteral("CoverArtImage")).isValid()) {
|
||||
#endif
|
||||
imageCacheDir = std::make_unique<QTemporaryDir>();
|
||||
if (imageCacheDir->isValid()) {
|
||||
QString filePath = imageCacheDir->path() + QStringLiteral("/coverimage");
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
bool success = m_player.metaData().value(QMediaMetaData::CoverArtImage).value<QImage>().save(filePath, "PNG");
|
||||
#else
|
||||
bool success = m_player.metaData(QStringLiteral("CoverArtImage")).value<QImage>().save(filePath, "PNG");
|
||||
#endif
|
||||
|
||||
if (success) {
|
||||
QString localFilePath = QStringLiteral("file://") + filePath;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QMediaPlayer>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
@ -52,4 +53,22 @@ public Q_SLOTS:
|
||||
private:
|
||||
friend class QtMediaBackendPrivate;
|
||||
std::unique_ptr<QtMediaBackendPrivate> d;
|
||||
|
||||
void playerMutedSignalChanges(bool muted);
|
||||
void mediaStatusSignalChanges(const QMediaPlayer::MediaStatus &qtMediaStatus);
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
void playerVolumeSignalChanges(float volume);
|
||||
void playerSourceSignalChanges(const QUrl &media);
|
||||
void playerStateSignalChanges(const QMediaPlayer::PlaybackState &qtPlaybackState);
|
||||
#else
|
||||
void playerVolumeSignalChanges(qint64 volume);
|
||||
void playerSourceSignalChanges(const QMediaContent &media);
|
||||
void playerStateSignalChanges(const QMediaPlayer::State &qtPlaybackState);
|
||||
#endif
|
||||
void playerPlaybackRateSignalChanges(const qreal &playbackRate);
|
||||
void playerErrorSignalChanges(const QMediaPlayer::Error &error);
|
||||
void playerDurationSignalChanges(qint64 newDuration);
|
||||
void playerPositionSignalChanges(qint64 newPosition);
|
||||
void playerSeekableSignalChanges(bool isSeekable);
|
||||
void playerMetaDataSignalChanges();
|
||||
};
|
||||
|
@ -288,7 +288,7 @@ void MediaPlayer2Player::Seek(qlonglong Offset)
|
||||
|
||||
void MediaPlayer2Player::SetPosition(const QDBusObjectPath &trackId, qlonglong pos)
|
||||
{
|
||||
qCDebug(Mpris2Log) << "MediaPlayer2Player::SetPosition(" << trackId << pos << ")";
|
||||
qCDebug(Mpris2Log) << "MediaPlayer2Player::SetPosition(" << pos << ")";
|
||||
if (m_audioPlayer) {
|
||||
if (!m_audioPlayer->source().isEmpty()) {
|
||||
if (trackId.path() == m_currentTrackId) {
|
||||
|
@ -53,6 +53,10 @@
|
||||
#include "sync/sync.h"
|
||||
#include "sync/syncutils.h"
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_DECL_EXPORT
|
||||
#endif
|
||||
@ -63,8 +67,10 @@ int main(int argc, char *argv[])
|
||||
qputenv("QT_ENABLE_GLYPH_CACHE_WORKAROUND", "1");
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
QGuiApplication app(argc, argv);
|
||||
|
@ -31,7 +31,9 @@ target_include_directories(KastsSolidExtras PUBLIC "$<BUILD_INTERFACE:${CMAKE_CU
|
||||
target_link_libraries(KastsSolidExtras PUBLIC Qt::Core)
|
||||
|
||||
if (ANDROID)
|
||||
target_link_libraries(KastsSolidExtras PRIVATE Qt::AndroidExtras)
|
||||
if (QT_MAJOR_VERSION EQUAL "5")
|
||||
target_link_libraries(KastsSolidExtras PRIVATE Qt::AndroidExtras)
|
||||
endif()
|
||||
else ()
|
||||
target_link_libraries(KastsSolidExtras PRIVATE Qt::DBus)
|
||||
if (TARGET KF5::NetworkManagerQt)
|
||||
|
@ -28,7 +28,7 @@ StorageManager::StorageManager()
|
||||
|
||||
QString StorageManager::storagePath() const
|
||||
{
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
|
||||
if (!SettingsManager::self()->storagePath().isEmpty()) {
|
||||
path = SettingsManager::self()->storagePath().toLocalFile();
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QVector>
|
||||
@ -22,7 +21,7 @@ UploadEpisodeActionRequest::UploadEpisodeActionRequest(SyncUtils::Provider provi
|
||||
{
|
||||
}
|
||||
|
||||
QVector<QPair<QString, QString>> UploadEpisodeActionRequest::updateUrls() const
|
||||
QVector<std::pair<QString, QString>> UploadEpisodeActionRequest::updateUrls() const
|
||||
{
|
||||
return m_updateUrls;
|
||||
}
|
||||
@ -47,7 +46,7 @@ void UploadEpisodeActionRequest::processResults()
|
||||
m_errorString = error->errorString();
|
||||
} else {
|
||||
for (auto jsonFeed : data.object().value(QStringLiteral("update_urls")).toArray()) {
|
||||
m_updateUrls += QPair(jsonFeed.toArray().at(0).toString(), jsonFeed.toArray().at(1).toString());
|
||||
m_updateUrls += std::pair<QString, QString>(jsonFeed.toArray().at(0).toString(), jsonFeed.toArray().at(1).toString());
|
||||
}
|
||||
m_timestamp = data.object().value(QStringLiteral("timestamp")).toInt();
|
||||
}
|
||||
|
@ -6,9 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
@ -22,12 +23,12 @@ class UploadEpisodeActionRequest : public GenericRequest
|
||||
public:
|
||||
UploadEpisodeActionRequest(SyncUtils::Provider provider, QNetworkReply *reply, QObject *parent);
|
||||
|
||||
QVector<QPair<QString, QString>> updateUrls() const;
|
||||
QVector<std::pair<QString, QString>> updateUrls() const;
|
||||
qulonglong timestamp() const;
|
||||
|
||||
private:
|
||||
void processResults() override;
|
||||
|
||||
QVector<QPair<QString, QString>> m_updateUrls;
|
||||
QVector<std::pair<QString, QString>> m_updateUrls;
|
||||
qulonglong m_timestamp = 0;
|
||||
};
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QVector>
|
||||
@ -22,7 +21,7 @@ UploadSubscriptionRequest::UploadSubscriptionRequest(SyncUtils::Provider provide
|
||||
{
|
||||
}
|
||||
|
||||
QVector<QPair<QString, QString>> UploadSubscriptionRequest::updateUrls() const
|
||||
QVector<std::pair<QString, QString>> UploadSubscriptionRequest::updateUrls() const
|
||||
{
|
||||
return m_updateUrls;
|
||||
}
|
||||
@ -47,7 +46,7 @@ void UploadSubscriptionRequest::processResults()
|
||||
m_errorString = error->errorString();
|
||||
} else {
|
||||
for (auto jsonFeed : data.object().value(QStringLiteral("update_urls")).toArray()) {
|
||||
m_updateUrls += QPair(jsonFeed.toArray().at(0).toString(), jsonFeed.toArray().at(1).toString());
|
||||
m_updateUrls += std::pair<QString, QString>(jsonFeed.toArray().at(0).toString(), jsonFeed.toArray().at(1).toString());
|
||||
}
|
||||
m_timestamp = data.object().value(QStringLiteral("timestamp")).toInt();
|
||||
}
|
||||
|
@ -6,9 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
@ -22,12 +23,12 @@ class UploadSubscriptionRequest : public GenericRequest
|
||||
public:
|
||||
UploadSubscriptionRequest(SyncUtils::Provider provider, QNetworkReply *reply, QObject *parent);
|
||||
|
||||
QVector<QPair<QString, QString>> updateUrls() const;
|
||||
QVector<std::pair<QString, QString>> updateUrls() const;
|
||||
qulonglong timestamp() const;
|
||||
|
||||
private:
|
||||
void processResults() override;
|
||||
|
||||
QVector<QPair<QString, QString>> m_updateUrls;
|
||||
QVector<std::pair<QString, QString>> m_updateUrls;
|
||||
qulonglong m_timestamp = 0;
|
||||
};
|
||||
|
@ -19,7 +19,12 @@
|
||||
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <qt6keychain/keychain.h>
|
||||
#else
|
||||
#include <qt5keychain/keychain.h>
|
||||
#endif
|
||||
|
||||
#include "audiomanager.h"
|
||||
#include "database.h"
|
||||
@ -666,9 +671,9 @@ void Sync::linkUpAllDevices()
|
||||
|
||||
QSet<QString> syncDevices;
|
||||
for (const QStringList &group : syncRequest->syncedDevices()) {
|
||||
syncDevices += group.toSet();
|
||||
syncDevices += QSet(group.begin(), group.end());
|
||||
}
|
||||
syncDevices += syncRequest->unsyncedDevices().toSet();
|
||||
syncDevices += QSet(syncRequest->unsyncedDevices().begin(), syncRequest->unsyncedDevices().end());
|
||||
|
||||
QVector<QStringList> syncDeviceGroups;
|
||||
syncDeviceGroups += QStringList(syncDevices.values());
|
||||
|
@ -136,7 +136,7 @@ void SyncJob::doQuickSync()
|
||||
Q_EMIT infoMessage(this, getProgressMessage(Started));
|
||||
|
||||
// Quick sync of local subscription changes
|
||||
QPair<QStringList, QStringList> localChanges = getLocalSubscriptionChanges();
|
||||
std::pair<QStringList, QStringList> localChanges = getLocalSubscriptionChanges();
|
||||
// store the local changes in a member variable such that the exact changes can be deleted from DB when processed
|
||||
m_localSubscriptionChanges = localChanges;
|
||||
|
||||
@ -189,7 +189,7 @@ void SyncJob::syncSubscriptions()
|
||||
localAddFeedList << query.value(QStringLiteral("url")).toString();
|
||||
}
|
||||
} else {
|
||||
QPair<QStringList, QStringList> localChanges = getLocalSubscriptionChanges();
|
||||
std::pair<QStringList, QStringList> localChanges = getLocalSubscriptionChanges();
|
||||
// immediately store the local changes such that the exact changes can be deleted from DB when processed
|
||||
m_localSubscriptionChanges = localChanges;
|
||||
|
||||
@ -363,7 +363,7 @@ void SyncJob::uploadSubscriptions(const QStringList &localAddFeedUrlList, const
|
||||
removeAppliedSubscriptionChangesFromDB();
|
||||
|
||||
// TODO: deal with updateUrlsList -> needs on-the-fly feed URL renaming
|
||||
QVector<QPair<QString, QString>> updateUrlsList = upSubRequest->updateUrls();
|
||||
QVector<std::pair<QString, QString>> updateUrlsList = upSubRequest->updateUrls();
|
||||
qCDebug(kastsSync) << "updateUrlsList:" << updateUrlsList;
|
||||
|
||||
// if this is a quick upload only sync, then stop here, otherwise continue with
|
||||
@ -594,8 +594,9 @@ void SyncJob::uploadEpisodeActionsPartial(const QVector<EpisodeAction> &episodeA
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(kastsSync) << "Uploading episode actions" << startIndex << "to" << std::min(startIndex + maxAmountEpisodeUploads, episodeActionList.count()) << "of"
|
||||
<< episodeActionList.count() << "total episode actions";
|
||||
qCDebug(kastsSync) << "Uploading episode actions" << startIndex << "to"
|
||||
<< std::min(startIndex + maxAmountEpisodeUploads, static_cast<int>(episodeActionList.count())) << "of" << episodeActionList.count()
|
||||
<< "total episode actions";
|
||||
|
||||
if (!m_gpodder) {
|
||||
setError(SyncJobError::InternalDataError);
|
||||
@ -741,9 +742,9 @@ QVector<EpisodeAction> SyncJob::createListFromHash(const QHash<QString, QHash<QS
|
||||
return episodeActionList;
|
||||
}
|
||||
|
||||
QPair<QStringList, QStringList> SyncJob::getLocalSubscriptionChanges() const
|
||||
std::pair<QStringList, QStringList> SyncJob::getLocalSubscriptionChanges() const
|
||||
{
|
||||
QPair<QStringList, QStringList> localChanges;
|
||||
std::pair<QStringList, QStringList> localChanges;
|
||||
QSqlQuery query;
|
||||
query.prepare(QStringLiteral("SELECT * FROM FeedActions;"));
|
||||
Database::instance().execute(query);
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
@ -73,7 +75,7 @@ private:
|
||||
void removeAppliedSubscriptionChangesFromDB();
|
||||
void removeAppliedEpisodeActionsFromDB();
|
||||
|
||||
QPair<QStringList, QStringList> getLocalSubscriptionChanges() const; // First list are additions, second are removals
|
||||
std::pair<QStringList, QStringList> getLocalSubscriptionChanges() const; // First list are additions, second are removals
|
||||
QVector<SyncUtils::EpisodeAction> getLocalEpisodeActions() const;
|
||||
|
||||
void removeSubscriptionChangeConflicts(QStringList &addList, QStringList &removeList);
|
||||
@ -95,7 +97,7 @@ private:
|
||||
QStringList m_feedsToBeUpdatedEps;
|
||||
int m_feedUpdateProgress = 0;
|
||||
int m_feedUpdateTotal = 0;
|
||||
QPair<QStringList, QStringList> m_localSubscriptionChanges;
|
||||
std::pair<QStringList, QStringList> m_localSubscriptionChanges;
|
||||
QVector<SyncUtils::EpisodeAction> m_localEpisodeActions;
|
||||
QHash<QString, QHash<QString, SyncUtils::EpisodeAction>> m_remoteEpisodeActionHash;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user