From 33780eaddae9905a36ac96882c1ff1416a508082 Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 13:58:44 +0200
Subject: [PATCH 1/8] Make deprecated QMutex::Recursives QRecursiveMutexes.

Reading https://doc.qt.io/qt-5/qrecursivemutex.html this should be
a pretty straightforward change.
---
 src/EngineController.cpp                                | 1 -
 src/EngineController.h                                  | 4 ++--
 src/core-impl/collections/db/sql/SqlMeta.cpp            | 1 -
 src/core-impl/collections/db/sql/SqlMeta.h              | 4 ++--
 src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp | 1 -
 src/core-impl/storage/sql/mysql-shared/MySqlStorage.h   | 4 ++--
 src/core/playlists/Playlist.cpp                         | 4 +---
 src/core/playlists/Playlist.h                           | 6 +++---
 src/core/support/Debug.cpp                              | 4 ++--
 src/core/support/Debug.h                                | 4 ++--
 src/dynamic/biases/EchoNestBias.cpp                     | 1 -
 src/dynamic/biases/EchoNestBias.h                       | 4 ++--
 src/importers/ImporterSqlConnection.cpp                 | 3 ---
 src/importers/ImporterSqlConnection.h                   | 4 ++--
 src/services/lastfm/biases/LastFmBias.cpp               | 1 -
 src/services/lastfm/biases/LastFmBias.h                 | 4 ++--
 src/statusbar/CompoundProgressBar.cpp                   | 1 -
 src/statusbar/CompoundProgressBar.h                     | 4 ++--
 tests/TestExpression.cpp                                | 2 +-
 tests/TestQStringx.cpp                                  | 2 +-
 20 files changed, 24 insertions(+), 35 deletions(-)

diff --git a/src/EngineController.cpp b/src/EngineController.cpp
index 8eea4c5921..5dd8db9190 100644
--- a/src/EngineController.cpp
+++ b/src/EngineController.cpp
@@ -84,7 +84,6 @@ EngineController::EngineController()
     , m_tickInterval( 0 )
     , m_lastTickPosition( -1 )
     , m_lastTickCount( 0 )
-    , m_mutex( QMutex::Recursive )
 {
     DEBUG_BLOCK
     // ensure this object is created in a main thread
diff --git a/src/EngineController.h b/src/EngineController.h
index ca4ebfe132..0653868947 100644
--- a/src/EngineController.h
+++ b/src/EngineController.h
@@ -27,7 +27,7 @@
 #include "playback/EqualizerController.h"
 #include "core/meta/Meta.h"
 
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QObject>
 #include <QPointer>
 #include <QSemaphore>
@@ -579,7 +579,7 @@ private:
     qint64 m_lastTickPosition;
     qint64 m_lastTickCount;
 
-    QMutex m_mutex;
+    QRecursiveMutex m_mutex;
 
     // FIXME: this variable should be updated when
     // Phonon::BackendCapabilities::notifier()'s capabilitiesChanged signal is emitted
diff --git a/src/core-impl/collections/db/sql/SqlMeta.cpp b/src/core-impl/collections/db/sql/SqlMeta.cpp
index 5fd0b11abf..45e7513f3d 100644
--- a/src/core-impl/collections/db/sql/SqlMeta.cpp
+++ b/src/core-impl/collections/db/sql/SqlMeta.cpp
@@ -1471,7 +1471,6 @@ SqlAlbum::SqlAlbum( Collections::SqlCollection *collection, int id, const QStrin
     , m_unsetImageId( -1 )
     , m_tracksLoaded( NotLoaded )
     , m_suppressAutoFetch( false )
-    , m_mutex( QMutex::Recursive )
 {
     Q_ASSERT( m_collection );
     Q_ASSERT( m_id > 0 );
diff --git a/src/core-impl/collections/db/sql/SqlMeta.h b/src/core-impl/collections/db/sql/SqlMeta.h
index cf0204ff9e..dd385b1c50 100644
--- a/src/core-impl/collections/db/sql/SqlMeta.h
+++ b/src/core-impl/collections/db/sql/SqlMeta.h
@@ -28,7 +28,7 @@
 
 #include <QAtomicInt>
 #include <QByteArray>
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QReadWriteLock>
 #include <QString>
 #include <QStringList>
@@ -450,7 +450,7 @@ class AMAROK_SQLCOLLECTION_EXPORT SqlAlbum : public Meta::Album
         bool m_suppressAutoFetch;
         Meta::ArtistPtr m_artist;
         Meta::TrackList m_tracks;
-        mutable QMutex m_mutex;
+        mutable QRecursiveMutex m_mutex;
 
         //TODO: add album artist
 
diff --git a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp
index e13a32951d..4b8cf3ca65 100644
--- a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp
+++ b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.cpp
@@ -90,7 +90,6 @@ QThreadStorage< ThreadInitializer* > ThreadInitializer::storage;
 MySqlStorage::MySqlStorage()
     : SqlStorage()
     , m_db( nullptr )
-    , m_mutex( QMutex::Recursive )
     , m_debugIdent( "MySQL-none" )
 {
     //Relevant code must be implemented in subclasses
diff --git a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h
index 2ff4fa1bec..7027072738 100644
--- a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h
+++ b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h
@@ -22,7 +22,7 @@
 #include <mysql.h>
 
 
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QString>
 
 #ifdef Q_WS_WIN
@@ -87,7 +87,7 @@ class MySqlStorage: public SqlStorage
         MYSQL* m_db;
 
         /** Mutex protecting the m_lastErrors list */
-        mutable QMutex m_mutex;
+        mutable QRecursiveMutex m_mutex;
 
         QString m_debugIdent;
         QStringList m_lastErrors;
diff --git a/src/core/playlists/Playlist.cpp b/src/core/playlists/Playlist.cpp
index 06dee458a5..a77c726cd8 100644
--- a/src/core/playlists/Playlist.cpp
+++ b/src/core/playlists/Playlist.cpp
@@ -21,7 +21,6 @@
 using namespace Playlists;
 
 PlaylistObserver::PlaylistObserver()
-    : m_playlistSubscriptionsMutex( QMutex::Recursive )  // prevent deadlocks
 {
 }
 
@@ -73,8 +72,7 @@ void PlaylistObserver::tracksLoaded( PlaylistPtr )
 }
 
 Playlist::Playlist()
-    : m_observersMutex( QMutex::Recursive ) // prevent deadlocks
-    , m_async( true )
+    : m_async( true )
 {
 }
 
diff --git a/src/core/playlists/Playlist.h b/src/core/playlists/Playlist.h
index 1ff92df5a1..6a0b25965a 100644
--- a/src/core/playlists/Playlist.h
+++ b/src/core/playlists/Playlist.h
@@ -22,7 +22,7 @@
 
 #include <QList>
 #include <QMetaType>
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QPixmap>
 #include <QSet>
 #include <QSharedData>
@@ -128,7 +128,7 @@ namespace Playlists
 
         private:
             QSet<PlaylistPtr> m_playlistSubscriptions;
-            QMutex m_playlistSubscriptionsMutex; // guards access to m_playlistSubscriptions
+            QRecursiveMutex m_playlistSubscriptionsMutex; // guards access to m_playlistSubscriptions
     };
 
     class AMAROKCORE_EXPORT Playlist : public virtual QSharedData
@@ -292,7 +292,7 @@ namespace Playlists
              * write, even if it is recursive. This can cause deadlocks, so it would be
              * never safe to lock it just for read.
              */
-            QMutex m_observersMutex;
+            QRecursiveMutex m_observersMutex;
             bool m_async;
     };
 }
diff --git a/src/core/support/Debug.cpp b/src/core/support/Debug.cpp
index 138c080b9a..50c6e5e830 100644
--- a/src/core/support/Debug.cpp
+++ b/src/core/support/Debug.cpp
@@ -24,7 +24,7 @@
 #include <KConfigCore/KConfigGroup>
 
 #include <QApplication>
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QObject>
 
 #include <iostream>
@@ -37,7 +37,7 @@
 
 #define DEBUG_INDENT_OBJECTNAME QLatin1String("Debug_Indent_object")
 
-AMAROKCORE_EXPORT QMutex Debug::mutex( QMutex::Recursive );
+AMAROKCORE_EXPORT QRecursiveMutex Debug::mutex;
 
 using namespace Debug;
 
diff --git a/src/core/support/Debug.h b/src/core/support/Debug.h
index b0872f1b80..1504a8ea2b 100644
--- a/src/core/support/Debug.h
+++ b/src/core/support/Debug.h
@@ -26,7 +26,7 @@
 
 #include "core/amarokcore_export.h"
 #include <QDebug>
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QVariant>
 
 // BEGIN: DEBUG_ASSERT
@@ -116,7 +116,7 @@
  */
 namespace Debug
 {
-    extern AMAROKCORE_EXPORT QMutex mutex;
+    extern AMAROKCORE_EXPORT QRecursiveMutex mutex;
 
     // from kdebug.h
     enum DebugLevel {
diff --git a/src/dynamic/biases/EchoNestBias.cpp b/src/dynamic/biases/EchoNestBias.cpp
index 5831fcd259..c14264326a 100644
--- a/src/dynamic/biases/EchoNestBias.cpp
+++ b/src/dynamic/biases/EchoNestBias.cpp
@@ -64,7 +64,6 @@ Dynamic::EchoNestBias::EchoNestBias()
     : SimpleMatchBias()
     , m_artistSuggestedQuery( nullptr )
     , m_match( PreviousTrack )
-    , m_mutex( QMutex::Recursive )
 {
     loadDataFromFile();
 }
diff --git a/src/dynamic/biases/EchoNestBias.h b/src/dynamic/biases/EchoNestBias.h
index 413cdb33d0..54eee360f5 100644
--- a/src/dynamic/biases/EchoNestBias.h
+++ b/src/dynamic/biases/EchoNestBias.h
@@ -20,7 +20,7 @@
 
 #include "dynamic/biases/TagMatchBias.h"
 
-#include <QMutex>
+#include <QRecursiveMutex>
 
 namespace KIO {
     class StoredTransferJob;
@@ -104,7 +104,7 @@ namespace Dynamic
 
             MatchType m_match;
 
-            mutable QMutex m_mutex; // mutex protecting all of the below structures
+            mutable QRecursiveMutex m_mutex; // mutex protecting all of the below structures
             mutable QMap< QString, QStringList> m_similarArtistMap;
             mutable QMap< QString, TrackSet> m_tracksMap;
 
diff --git a/src/importers/ImporterSqlConnection.cpp b/src/importers/ImporterSqlConnection.cpp
index 8176baca85..0853279ebb 100644
--- a/src/importers/ImporterSqlConnection.cpp
+++ b/src/importers/ImporterSqlConnection.cpp
@@ -35,7 +35,6 @@ ImporterSqlConnection::ImporterSqlConnection( const QString &driver,
                                               const QString &user,
                                               const QString &password )
     : m_connectionName( QUuid::createUuid().toString() )
-    , m_apiMutex( QMutex::Recursive )
     , m_openTransaction( false )
 {
     QSqlDatabase db = QSqlDatabase::addDatabase( driver, m_connectionName );
@@ -48,7 +47,6 @@ ImporterSqlConnection::ImporterSqlConnection( const QString &driver,
 
 ImporterSqlConnection::ImporterSqlConnection( const QString &dbPath )
     : m_connectionName( QUuid::createUuid().toString() )
-    , m_apiMutex( QMutex::Recursive )
     , m_openTransaction( false )
 {
     QSqlDatabase db = QSqlDatabase::addDatabase( QStringLiteral("QSQLITE"), m_connectionName );
@@ -57,7 +55,6 @@ ImporterSqlConnection::ImporterSqlConnection( const QString &dbPath )
 
 ImporterSqlConnection::ImporterSqlConnection()
     : m_connectionName( QUuid::createUuid().toString() )
-    , m_apiMutex( QMutex::Recursive )
     , m_openTransaction( false )
 {
 }
diff --git a/src/importers/ImporterSqlConnection.h b/src/importers/ImporterSqlConnection.h
index b0b7c844e9..70896ef223 100644
--- a/src/importers/ImporterSqlConnection.h
+++ b/src/importers/ImporterSqlConnection.h
@@ -22,7 +22,7 @@
 #include "amarok_export.h"
 
 #include <QList>
-#include <QMutex>
+#include <QRecursiveMutex>
 #include <QPointer>
 #include <QSharedPointer>
 #include <QSqlDatabase>
@@ -130,7 +130,7 @@ private:
 
     Qt::ConnectionType blockingConnectionType() const;
 
-    QMutex m_apiMutex;
+    QRecursiveMutex m_apiMutex;
     bool m_openTransaction;
     QList<QVariantList> m_result;
 
diff --git a/src/services/lastfm/biases/LastFmBias.cpp b/src/services/lastfm/biases/LastFmBias.cpp
index af4ae2a987..468ca714aa 100644
--- a/src/services/lastfm/biases/LastFmBias.cpp
+++ b/src/services/lastfm/biases/LastFmBias.cpp
@@ -64,7 +64,6 @@ Dynamic::LastFmBiasFactory::createBias()
 Dynamic::LastFmBias::LastFmBias()
     : SimpleMatchBias()
     , m_match( SimilarArtist )
-    , m_mutex( QMutex::Recursive )
 {
     loadDataFromFile();
 }
diff --git a/src/services/lastfm/biases/LastFmBias.h b/src/services/lastfm/biases/LastFmBias.h
index 2848b38d9a..77509dc9f1 100644
--- a/src/services/lastfm/biases/LastFmBias.h
+++ b/src/services/lastfm/biases/LastFmBias.h
@@ -20,7 +20,7 @@
 
 #include "dynamic/biases/TagMatchBias.h"
 
-#include <QMutex>
+#include <QRecursiveMutex>
 
 namespace Dynamic
 {
@@ -95,7 +95,7 @@ namespace Dynamic
 
             MatchType m_match;
 
-            mutable QMutex m_mutex; // mutex protecting all of the below structures
+            mutable QRecursiveMutex m_mutex; // mutex protecting all of the below structures
             mutable QMap< QString, QStringList> m_similarArtistMap;
             mutable QMap< TitleArtistPair, QList<TitleArtistPair> > m_similarTrackMap;
             mutable QMap< QString, TrackSet> m_tracksMap; // for artist AND album
diff --git a/src/statusbar/CompoundProgressBar.cpp b/src/statusbar/CompoundProgressBar.cpp
index 3741ff5b34..3f437ff432 100644
--- a/src/statusbar/CompoundProgressBar.cpp
+++ b/src/statusbar/CompoundProgressBar.cpp
@@ -26,7 +26,6 @@
 
 CompoundProgressBar::CompoundProgressBar( QWidget *parent )
         : ProgressBar( parent )
-        , m_mutex( QMutex::Recursive )
 {
     m_progressDetailsWidget = new PopupWidget();
     m_progressDetailsWidget->hide();
diff --git a/src/statusbar/CompoundProgressBar.h b/src/statusbar/CompoundProgressBar.h
index cfd5070c41..ed9e72012a 100644
--- a/src/statusbar/CompoundProgressBar.h
+++ b/src/statusbar/CompoundProgressBar.h
@@ -23,7 +23,7 @@
 #include <QList>
 #include <QMap>
 #include <QMouseEvent>
-#include <QMutex>
+#include <QRecursiveMutex>
 
 /**
  * A progress bar that wraps a number of simple progress bars and displays their 
@@ -75,7 +75,7 @@ private:
 
     QMap< const QObject *, ProgressBar *> m_progressMap;
     PopupWidget *m_progressDetailsWidget;
-    QMutex m_mutex; // protecting m_progressMap consistency
+    QRecursiveMutex m_mutex; // protecting m_progressMap consistency
 };
 
 #endif
diff --git a/tests/TestExpression.cpp b/tests/TestExpression.cpp
index a84ee6f7f8..ea298c10c5 100644
--- a/tests/TestExpression.cpp
+++ b/tests/TestExpression.cpp
@@ -27,7 +27,7 @@
 QTEST_GUILESS_MAIN( TestExpression )
 
 //required for Debug.h
-QMutex Debug::mutex;
+QRecursiveMutex Debug::mutex;
 
 TestExpression::TestExpression()
 {
diff --git a/tests/TestQStringx.cpp b/tests/TestQStringx.cpp
index 7b96d83ae9..010db2252e 100644
--- a/tests/TestQStringx.cpp
+++ b/tests/TestQStringx.cpp
@@ -28,7 +28,7 @@
 QTEST_GUILESS_MAIN( TestQStringx )
 
 //required for Debug.h
-QMutex Debug::mutex;
+QRecursiveMutex Debug::mutex;
 
 TestQStringx::TestQStringx()
 {
-- 
GitLab


From 413efb028f41808e9a59166805f4a8ec73737237 Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 17:33:54 +0200
Subject: [PATCH 2/8] Use more-recently-deprecated codepaths.

KDeclarative::setupBindings() is deprecated since 5.45 and current
KF5_MIN_VERSION is 5.57, so this is probably a feasible thing to do.
---
 src/context/ContextView.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/context/ContextView.cpp b/src/context/ContextView.cpp
index 9e3ba064d2..1aa3fc70af 100644
--- a/src/context/ContextView.cpp
+++ b/src/context/ContextView.cpp
@@ -60,7 +60,8 @@ ContextView::ContextView( QWidget *parent )
 
     KDeclarative::KDeclarative decl;
     decl.setDeclarativeEngine( engine() );
-    decl.setupBindings();
+    engine()->rootContext()->setContextObject( new KLocalizedContext( this ) );
+    decl.setupEngine( engine() );
 
     connect( this, &QQuickWidget::statusChanged, this, &ContextView::slotStatusChanged );
     connect( The::paletteHandler(), &PaletteHandler::newPalette, this, &ContextView::updatePalette );
-- 
GitLab


From f212bcb2466a2faee48ff43c631a67335c42b2f0 Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 17:39:18 +0200
Subject: [PATCH 3/8] Port away from deprecated QDesktopWidget::numScreens.

Replace with QGuiApplication::screens() based approaches as instructed on
https://doc.qt.io/qt-5/qdesktopwidget-obsolete.html#numScreens
---
 src/configdialog/dialogs/NotificationsConfig.cpp | 2 +-
 src/widgets/Osd.cpp                              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/configdialog/dialogs/NotificationsConfig.cpp b/src/configdialog/dialogs/NotificationsConfig.cpp
index 0c16fdcb17..00a15f6bef 100644
--- a/src/configdialog/dialogs/NotificationsConfig.cpp
+++ b/src/configdialog/dialogs/NotificationsConfig.cpp
@@ -55,7 +55,7 @@ NotificationsConfig::NotificationsConfig( Amarok2ConfigDialog* parent )
 
     connect( m_osdPreview, &OSDPreviewWidget::positionChanged, this, &NotificationsConfig::slotPositionChanged );
 
-    const int numScreens = QApplication::desktop()->numScreens();
+    const int numScreens = QApplication::screens().size();
     for( int i = 0; i < numScreens; i++ )
         kcfg_OsdScreen->addItem( QString::number( i ) );
 
diff --git a/src/widgets/Osd.cpp b/src/widgets/Osd.cpp
index dc1cf722e3..4de9749a76 100644
--- a/src/widgets/Osd.cpp
+++ b/src/widgets/Osd.cpp
@@ -463,7 +463,7 @@ OSDWidget::setTextColor(const QColor& color)
 void
 OSDWidget::setScreen( int screen )
 {
-    const int n = QApplication::desktop()->numScreens();
+    const int n = QApplication::screens().size();
     m_screen = ( screen >= n ) ? n - 1 : screen;
 }
 
-- 
GitLab


From d9cf76b03ea64bc7fa4c40a65f4de2fdc6d57fdc Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 18:34:21 +0200
Subject: [PATCH 4/8] Avoid some warnings from a TODO function.

---
 src/scripting/scriptengine/AmarokLyricsScript.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/scripting/scriptengine/AmarokLyricsScript.cpp b/src/scripting/scriptengine/AmarokLyricsScript.cpp
index d4b5eedd5a..fae437130d 100644
--- a/src/scripting/scriptengine/AmarokLyricsScript.cpp
+++ b/src/scripting/scriptengine/AmarokLyricsScript.cpp
@@ -97,6 +97,8 @@ AmarokLyricsScript::escape( const QString &str )
 void
 AmarokLyricsScript::setLyricsForTrack( const QString &trackUrl, const QString &lyrics ) const
 {
+    Q_UNUSED( trackUrl );
+    Q_UNUSED( lyrics );
     /* TODO - convert method invocation below
     LyricsManager::instance()->setLyricsForTrack( trackUrl, lyrics );
     */
-- 
GitLab


From 3dd0add1d17d52132db13ef74f74034d14c4ffb6 Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 18:39:01 +0200
Subject: [PATCH 5/8] Use non-deprecated signals.

Introduced in Qt 5.15 ( https://doc.qt.io/qt-5/qsignalmapper.html#mappedObject
https://doc.qt.io/qt-5/qsignalmapper.html#mappedString ), which is currently
the minimum version for us.
---
 src/network/NetworkAccessViewer.cpp        | 2 +-
 src/playlistgenerator/PresetEditDialog.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/network/NetworkAccessViewer.cpp b/src/network/NetworkAccessViewer.cpp
index 38f50ed038..5454ab8819 100644
--- a/src/network/NetworkAccessViewer.cpp
+++ b/src/network/NetworkAccessViewer.cpp
@@ -33,7 +33,7 @@ NetworkAccessViewer::NetworkAccessViewer( QWidget *parent )
     networkRequestsDialog->setupUi(dialog);
 
     mapper = new QSignalMapper(this);
-    connect( mapper, QOverload<QObject*>::of(&QSignalMapper::mapped),
+    connect( mapper, QOverload<QObject*>::of(&QSignalMapper::mappedObject),
              this, &NetworkAccessViewer::requestFinished );
 
     connect( networkRequestsDialog->requestList, &QTreeWidget::currentItemChanged, this, &NetworkAccessViewer::showItemDetails );
diff --git a/src/playlistgenerator/PresetEditDialog.cpp b/src/playlistgenerator/PresetEditDialog.cpp
index 7ef060ce22..fcf0f8e2d0 100644
--- a/src/playlistgenerator/PresetEditDialog.cpp
+++ b/src/playlistgenerator/PresetEditDialog.cpp
@@ -52,7 +52,7 @@ APG::PresetEditDialog::PresetEditDialog( const PresetPtr &p )
     ui.constraintTreeView->expandAll();
 
     QSignalMapper* adderMapper = new QSignalMapper( this );
-    connect( adderMapper, QOverload<const QString&>::of(&QSignalMapper::mapped),
+    connect( adderMapper, QOverload<const QString&>::of(&QSignalMapper::mappedString),
              this, &PresetEditDialog::addNode );
 
     QMenuBar* menuBar_Actions = new QMenuBar( this );
-- 
GitLab


From 5f27e8531b603b82aa7d3371868e2425a1095b77 Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 18:51:44 +0200
Subject: [PATCH 6/8] Port away from deprecated TagLib::String::Null.

As instructed on https://taglib.org/api/classTagLib_1_1String.html#ae5f42b9ceca1b59814cffc2eddff3d09
and https://taglib.org/api/classTagLib_1_1String.html#a8c35a7ec22fdfcf8afaf3edee01a01e0
---
 shared/tag_helpers/APETagHelper.cpp           | 2 +-
 shared/tag_helpers/ASFTagHelper.cpp           | 2 +-
 shared/tag_helpers/ID3v2TagHelper.cpp         | 2 +-
 shared/tag_helpers/MP4TagHelper.cpp           | 2 +-
 shared/tag_helpers/StringHelper.cpp           | 2 +-
 shared/tag_helpers/VorbisCommentTagHelper.cpp | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/shared/tag_helpers/APETagHelper.cpp b/shared/tag_helpers/APETagHelper.cpp
index eee34e05a3..66e8510a53 100644
--- a/shared/tag_helpers/APETagHelper.cpp
+++ b/shared/tag_helpers/APETagHelper.cpp
@@ -84,7 +84,7 @@ APETagHelper::setTags( const Meta::FieldHash &changes )
         QVariant value = changes.value( key );
         TagLib::String field = fieldName( key );
 
-        if( !field.isNull() && !field.isEmpty() )
+        if( !field.isEmpty() )
         {
             if( key == Meta::valRating )
                 m_tag->addValue( field, Qt4QStringToTString( QString::number( value.toFloat() / 10.0 ) ) );
diff --git a/shared/tag_helpers/ASFTagHelper.cpp b/shared/tag_helpers/ASFTagHelper.cpp
index 241e93d714..772728b58f 100644
--- a/shared/tag_helpers/ASFTagHelper.cpp
+++ b/shared/tag_helpers/ASFTagHelper.cpp
@@ -107,7 +107,7 @@ ASFTagHelper::setTags( const Meta::FieldHash &changes )
         QVariant value = changes.value( key );
         TagLib::String field = fieldName( key );
 
-        if( !field.isNull() && !field.isEmpty() )
+        if( !field.isEmpty() )
         {
             if( key == Meta::valHasCover )
                 continue;
diff --git a/shared/tag_helpers/ID3v2TagHelper.cpp b/shared/tag_helpers/ID3v2TagHelper.cpp
index ea9281dc30..7dd98062bc 100644
--- a/shared/tag_helpers/ID3v2TagHelper.cpp
+++ b/shared/tag_helpers/ID3v2TagHelper.cpp
@@ -187,7 +187,7 @@ ID3v2TagHelper::setTags( const Meta::FieldHash &changes )
         QVariant value = changes.value( key );
         TagLib::ByteVector field( fieldName( key ).toCString() );
 
-        if( !field.isNull() && !field.isEmpty() )
+        if( !field.isEmpty() )
         {
             if( key == Meta::valHasCover )
                 continue;
diff --git a/shared/tag_helpers/MP4TagHelper.cpp b/shared/tag_helpers/MP4TagHelper.cpp
index 7a28b4473c..54d192ffae 100644
--- a/shared/tag_helpers/MP4TagHelper.cpp
+++ b/shared/tag_helpers/MP4TagHelper.cpp
@@ -106,7 +106,7 @@ MP4TagHelper::setTags( const Meta::FieldHash &changes )
         QVariant value = changes.value( key );
         TagLib::String field = fieldName( key );
 
-        if( !field.isNull() && !field.isEmpty() )
+        if( !field.isEmpty() )
         {
             // http://gitorious.org/~jefferai/xdg-specs/jefferais-xdg-specs/blobs/mediaspecs/specifications/FMPSpecs/specification.txt sais that mp4 tags should be saved as strings
             if( key == Meta::valHasCover )
diff --git a/shared/tag_helpers/StringHelper.cpp b/shared/tag_helpers/StringHelper.cpp
index fd7e49b432..a8d2aa3e97 100644
--- a/shared/tag_helpers/StringHelper.cpp
+++ b/shared/tag_helpers/StringHelper.cpp
@@ -36,7 +36,7 @@ Meta::Tag::Qt4QStringToTString( const QString &str )
 {
     // Declare new var to prevent double call of trimmed func
     QString val = str.trimmed();
-    return val.isEmpty() ? TagLib::String::null : TagLib::String( val.toUtf8().data(), TagLib::String::UTF8 );
+    return val.isEmpty() ? TagLib::String() : TagLib::String( val.toUtf8().data(), TagLib::String::UTF8 );
 }
 
 QString
diff --git a/shared/tag_helpers/VorbisCommentTagHelper.cpp b/shared/tag_helpers/VorbisCommentTagHelper.cpp
index f3ff542db6..95dc041d8a 100644
--- a/shared/tag_helpers/VorbisCommentTagHelper.cpp
+++ b/shared/tag_helpers/VorbisCommentTagHelper.cpp
@@ -151,7 +151,7 @@ VorbisCommentTagHelper::setTags( const Meta::FieldHash &changes )
         QVariant value = changes.value( key );
         TagLib::String field = fieldName( key );
 
-        if( !field.isNull() && !field.isEmpty() )
+        if( !field.isEmpty() )
         {
             if( key == Meta::valHasCover )
                 continue;
-- 
GitLab


From 45fbce7eff1d4e38751db49f6ee0c4ede884e44e Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Thu, 9 Mar 2023 19:22:02 +0200
Subject: [PATCH 7/8] Port away from KDiskFreeSpaceInfo.

Deprecated in KF 5.88. QStorageInfo is available since Qt 5.4, and actually
provides better functionality with bytesAvailable() instead of just bytesFree().
---
 .../db/sql/SqlCollectionLocation.cpp          | 24 +++++++------------
 .../ipodcollection/IpodCollection.cpp         |  8 +++----
 .../MediaDeviceCollection.cpp                 |  2 --
 .../umscollection/UmsCollection.cpp           |  6 ++---
 4 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp
index 7f761432ef..2f6835c073 100644
--- a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp
+++ b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp
@@ -38,8 +38,8 @@
 #include <QDir>
 #include <QFile>
 #include <QFileInfo>
+#include <QStorageInfo>
 
-#include <KDiskFreeSpaceInfo>
 #include <KFileItem>
 #include <KJob>
 #include <KIO/DeleteJob>
@@ -90,13 +90,7 @@ SqlCollectionLocation::isWritable() const
     QStringList folders = actualLocation();
     foreach( const QString &path, folders )
     {
-        float used = KDiskFreeSpaceInfo::freeSpaceInfo( path ).used();
-        float total = KDiskFreeSpaceInfo::freeSpaceInfo( path ).size();
-
-        if( total <= 0 ) // protect against div by zero
-            continue; //How did this happen?
-
-        float free_space = total - used;
+        float free_space = QStorageInfo( path ).bytesAvailable();
         if( free_space >= 500*1000*1000 ) // ~500 megabytes
             path_exists_with_space = true;
 
@@ -298,18 +292,18 @@ SqlCollectionLocation::showDestinationDialog( const Meta::TrackList &tracks,
         if( path.isEmpty() )
             continue;
         debug() << "Path" << path;
-        KDiskFreeSpaceInfo spaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo( path );
+        QStorageInfo spaceInfo(path);
         if( !spaceInfo.isValid() )
             continue;
 
-        KIO::filesize_t totalCapacity = spaceInfo.size();
-        KIO::filesize_t used = spaceInfo.used();
+        KIO::filesize_t totalCapacity = spaceInfo.bytesTotal();
+        KIO::filesize_t used = totalCapacity - spaceInfo.bytesFree();
 
-        KIO::filesize_t freeSpace = totalCapacity - used;
+        KIO::filesize_t availableSpace = spaceInfo.bytesAvailable();
 
         debug() << "used:" << used;
         debug() << "total:" << totalCapacity;
-        debug() << "Free space" << freeSpace;
+        debug() << "Available space" << availableSpace;
         debug() << "transfersize" << transferSize;
 
         if( totalCapacity <= 0 ) // protect against div by zero
@@ -320,8 +314,8 @@ SqlCollectionLocation::showDestinationDialog( const Meta::TrackList &tracks,
         // since bad things happen when drives become totally full
 	// we make sure there is at least ~500MB left
         // finally, ensure the path is writable
-        debug() << ( freeSpace - transferSize );
-        if( ( freeSpace - transferSize ) > 1024*1024*500 && info.isWritable() )
+        debug() << ( availableSpace - transferSize );
+        if( ( availableSpace - transferSize ) > 1024*1024*500 && info.isWritable() )
             available_folders << path;
     }
 
diff --git a/src/core-impl/collections/ipodcollection/IpodCollection.cpp b/src/core-impl/collections/ipodcollection/IpodCollection.cpp
index cd555ca47f..1aab224054 100644
--- a/src/core-impl/collections/ipodcollection/IpodCollection.cpp
+++ b/src/core-impl/collections/ipodcollection/IpodCollection.cpp
@@ -34,7 +34,6 @@
 #include "core-impl/collections/support/MemoryQueryMaker.h"
 #include "playlistmanager/PlaylistManager.h"
 
-#include <KDiskFreeSpaceInfo>
 #include <solid/device.h>
 #include <solid/predicate.h>
 #include <solid/storageaccess.h>
@@ -47,6 +46,7 @@
 #include <KConfigGroup>
 #include <QDialogButtonBox>
 #include <QPushButton>
+#include <QStorageInfo>
 #include <QVBoxLayout>
 
 
@@ -261,19 +261,19 @@ IpodCollection::icon() const
 bool
 IpodCollection::hasCapacity() const
 {
-    return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).isValid();
+    return QStorageInfo( m_mountPoint ).isValid();
 }
 
 float
 IpodCollection::usedCapacity() const
 {
-    return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).used();
+    return QStorageInfo( m_mountPoint ).bytesTotal() - QStorageInfo( m_mountPoint ).bytesFree();
 }
 
 float
 IpodCollection::totalCapacity() const
 {
-    return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).size();
+    return QStorageInfo( m_mountPoint ).bytesTotal();
 }
 
 Collections::CollectionLocation*
diff --git a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp
index 0eec859ffd..f6795e733a 100644
--- a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp
+++ b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.cpp
@@ -24,8 +24,6 @@
 #include "core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h"
 #include "core-impl/collections/support/MemoryQueryMaker.h"
 
-#include <KDiskFreeSpaceInfo>
-
 using namespace Collections;
 
 MediaDeviceCollectionFactoryBase::MediaDeviceCollectionFactoryBase( ConnectionAssistant* assistant )
diff --git a/src/core-impl/collections/umscollection/UmsCollection.cpp b/src/core-impl/collections/umscollection/UmsCollection.cpp
index 32873350e9..0ac4b438fb 100644
--- a/src/core-impl/collections/umscollection/UmsCollection.cpp
+++ b/src/core-impl/collections/umscollection/UmsCollection.cpp
@@ -44,12 +44,12 @@
 #include <Solid/StorageDrive>
 #include <Solid/StorageVolume>
 
+#include <QStorageInfo>
 #include <QThread>
 #include <QTimer>
 #include <QUrl>
 
 #include <KConfigGroup>
-#include <KDiskFreeSpaceInfo>
 
 
 UmsCollectionFactory::UmsCollectionFactory()
@@ -407,13 +407,13 @@ UmsCollection::hasCapacity() const
 float
 UmsCollection::usedCapacity() const
 {
-    return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).used();
+    return QStorageInfo( m_mountPoint ).bytesTotal()-QStorageInfo( m_mountPoint ).bytesFree();
 }
 
 float
 UmsCollection::totalCapacity() const
 {
-    return KDiskFreeSpaceInfo::freeSpaceInfo( m_mountPoint ).size();
+    return QStorageInfo( m_mountPoint ).bytesTotal();
 }
 
 CollectionLocation *
-- 
GitLab


From 7b1af767ba420e175a0f2f3c0486a3e49730c33e Mon Sep 17 00:00:00 2001
From: Tuomas Nurmi <tuomas@norsumanageri.org>
Date: Fri, 10 Mar 2023 19:41:19 +0200
Subject: [PATCH 8/8] Update KF5 and Qt5 requirements in README.

---
 README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README b/README
index f2639a2a7c..346094923f 100644
--- a/README
+++ b/README
@@ -39,14 +39,14 @@ not be entirely up to date. You can always look at CMakeLists.txt to discover
 the most recent dependencies.
 
 Required
-    * KDE Frameworks 5.41 (or newer, for an exact list look at CMakeLists.txt)
+    * KDE Frameworks 5.57 (or newer, for an exact list look at CMakeLists.txt)
       https://www.kde.org
 
     * Phonon 4.6.60 (or newer with support for Qt5) and one of the following backends:
       * phonon-gstreamer 4.6.3 (or newer)
       * phonon-vlc 0.6.1 (or newer; as of 0.6.1 doesn't yet play Audio CDs, bug 313046)
 
-    * Qt 5.10 (or newer)
+    * Qt 5.15
       https://qt.io/
 
     * TagLib 1.7 (or newer)
-- 
GitLab

