File haruna-qt512_1.patch of Package haruna

From de947654fc13a7ea80d3b010a31ad862d1bce34f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?George=20Florea=20B=C4=83nu=C8=99?= <georgefb899@gmail.com>
Date: Thu, 15 Oct 2020 21:37:18 +0300
Subject: [PATCH] Change qmlRegisterSingletonType function and settings classes
 so it compiles on qt 5.12 Move settings types registration to application
 class

---
 src/Settings/audiosettings.h     |  2 +-
 src/Settings/generalsettings.h   |  2 +-
 src/Settings/mousesettings.h     |  2 +-
 src/Settings/playbacksettings.h  |  2 +-
 src/Settings/playlistsettings.h  |  2 +-
 src/Settings/subtitlessettings.h |  2 +-
 src/Settings/videosettings.h     |  2 +-
 src/application.cpp              | 18 ++++++++++++++++++
 src/application.h                |  2 ++
 src/main.cpp                     | 19 ++++---------------
 10 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/Settings/audiosettings.h b/src/Settings/audiosettings.h
index 0d1696f..a0740c6 100644
--- a/src/Settings/audiosettings.h
+++ b/src/Settings/audiosettings.h
@@ -31,7 +31,7 @@ class AudioSettings : public Settings
     int preferredTrack();
     void setPreferredTrack(int track);
 
-    static AudioSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/generalsettings.h b/src/Settings/generalsettings.h
index 46f952b..6153b8d 100644
--- a/src/Settings/generalsettings.h
+++ b/src/Settings/generalsettings.h
@@ -105,7 +105,7 @@ class GeneralSettings : public Settings
     QString colorScheme();
     void setColorScheme(const QString &scheme);
 
-    static GeneralSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/mousesettings.h b/src/Settings/mousesettings.h
index 8347b40..ab17450 100644
--- a/src/Settings/mousesettings.h
+++ b/src/Settings/mousesettings.h
@@ -79,7 +79,7 @@ class MouseSettings : public Settings
     QString scrollDownAction();
     void setScrollDownAction(const QString &action);
 
-    static MouseSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/playbacksettings.h b/src/Settings/playbacksettings.h
index 4f86f21..f797dc9 100644
--- a/src/Settings/playbacksettings.h
+++ b/src/Settings/playbacksettings.h
@@ -47,7 +47,7 @@ class PlaybackSettings : public Settings
     QString ytdlFormat();
     void setYtdlFormat(const QString &format);
 
-    static PlaybackSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/playlistsettings.h b/src/Settings/playlistsettings.h
index eaa04ba..db931cc 100644
--- a/src/Settings/playlistsettings.h
+++ b/src/Settings/playlistsettings.h
@@ -55,7 +55,7 @@ class PlaylistSettings : public Settings
     bool bigFontFullscreen();
     void setBigFontFullscreen(bool bigFont);
 
-    static PlaylistSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/subtitlessettings.h b/src/Settings/subtitlessettings.h
index ead6f8e..3a516d0 100644
--- a/src/Settings/subtitlessettings.h
+++ b/src/Settings/subtitlessettings.h
@@ -39,7 +39,7 @@ class SubtitlesSettings : public Settings
     int preferredTrack();
     void setPreferredTrack(int track);
 
-    static SubtitlesSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/Settings/videosettings.h b/src/Settings/videosettings.h
index 732a786..e0c4d72 100644
--- a/src/Settings/videosettings.h
+++ b/src/Settings/videosettings.h
@@ -32,7 +32,7 @@ class VideoSettings : public Settings
     void setScreenshotFormat(QString format);
 
 
-    static VideoSettings *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+    static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine)
     {
         Q_UNUSED(engine)
         Q_UNUSED(scriptEngine)
diff --git a/src/application.cpp b/src/application.cpp
index f4bfa13..c59505f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -7,6 +7,13 @@
 #include "_debug.h"
 #include "application.h"
 #include "haction.h"
+#include "Settings/audiosettings.h"
+#include "Settings/generalsettings.h"
+#include "Settings/mousesettings.h"
+#include "Settings/playbacksettings.h"
+#include "Settings/playlistsettings.h"
+#include "Settings/subtitlessettings.h"
+#include "Settings/videosettings.h"
 
 #include <QApplication>
 #include <QCoreApplication>
@@ -31,6 +38,17 @@ Application::Application(QObject *parent)
     m_schemes = new KColorSchemeManager(this);
 }
 
+void Application::setupQmlSettingsTypes()
+{
+    qmlRegisterSingletonType<AudioSettings>("AudioSettings", 1, 0, "AudioSettings", &AudioSettings::provider);
+    qmlRegisterSingletonType<GeneralSettings>("GeneralSettings", 1, 0, "GeneralSettings", &GeneralSettings::provider);
+    qmlRegisterSingletonType<MouseSettings>("MouseSettings", 1, 0, "MouseSettings", &MouseSettings::provider);
+    qmlRegisterSingletonType<PlaybackSettings>("PlaybackSettings", 1, 0, "PlaybackSettings", &PlaybackSettings::provider);
+    qmlRegisterSingletonType<PlaylistSettings>("PlaylistSettings", 1, 0, "PlaylistSettings", &PlaylistSettings::provider);
+    qmlRegisterSingletonType<SubtitlesSettings>("SubtitlesSettings", 1, 0, "SubtitlesSettings", &SubtitlesSettings::provider);
+    qmlRegisterSingletonType<VideoSettings>("VideoSettings", 1, 0, "VideoSettings", &VideoSettings::provider);
+}
+
 QString Application::formatTime(const double time)
 {
     QTime t(0, 0, 0);
diff --git a/src/application.h b/src/application.h
index e02a989..0aa2398 100644
--- a/src/application.h
+++ b/src/application.h
@@ -28,6 +28,8 @@ class Application : public QObject
     explicit Application(QObject *parent = nullptr);
     ~Application() = default;
 
+    void setupQmlSettingsTypes();
+
 public slots:
     static QString formatTime(const double time);
     static QUrl getPathFromArg(const QString &arg);
diff --git a/src/main.cpp b/src/main.cpp
index b0813c2..63325f8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,13 +12,6 @@
 #include "subtitlesfoldersmodel.h"
 #include "playlist/playlistitem.h"
 #include "playlist/playlistmodel.h"
-#include "Settings/audiosettings.h"
-#include "Settings/generalsettings.h"
-#include "Settings/mousesettings.h"
-#include "Settings/playbacksettings.h"
-#include "Settings/playlistsettings.h"
-#include "Settings/subtitlessettings.h"
-#include "Settings/videosettings.h"
 #include "worker.h"
 
 #include <QApplication>
@@ -109,7 +102,7 @@ int main(int argc, char *argv[])
     qmlRegisterUncreatableType<PlayListModel>("PlayListModel", 1, 0, "PlayListModel",
                                                QStringLiteral("PlayListModel should not be created in QML"));
 
-    engine.rootContext()->setContextProperty(QStringLiteral("app"), myApp.release());
+    engine.rootContext()->setContextProperty(QStringLiteral("app"), myApp.get());
     qmlRegisterUncreatableType<Application>("Application", 1, 0, "Application",
                                             QStringLiteral("Application should not be created in QML"));
 
@@ -118,13 +111,9 @@ int main(int argc, char *argv[])
                                             QStringLiteral("LockManager should not be created in QML"));
 
     engine.rootContext()->setContextProperty(QStringLiteral("subsFoldersModel"), subsFoldersModel.release());
-    qmlRegisterSingletonType<VideoSettings>("VideoSettings", 1, 0, "VideoSettings", VideoSettings::provider);
-    qmlRegisterSingletonType<MouseSettings>("MouseSettings", 1, 0, "MouseSettings", MouseSettings::provider);
-    qmlRegisterSingletonType<PlaylistSettings>("PlaylistSettings", 1, 0, "PlaylistSettings", PlaylistSettings::provider);
-    qmlRegisterSingletonType<PlaybackSettings>("PlaybackSettings", 1, 0, "PlaybackSettings", PlaybackSettings::provider);
-    qmlRegisterSingletonType<GeneralSettings>("GeneralSettings", 1, 0, "GeneralSettings", GeneralSettings::provider);
-    qmlRegisterSingletonType<AudioSettings>("AudioSettings", 1, 0, "AudioSettings", AudioSettings::provider);
-    qmlRegisterSingletonType<SubtitlesSettings>("SubtitlesSettings", 1, 0, "SubtitlesSettings", SubtitlesSettings::provider);
+
+    myApp.get()->setupQmlSettingsTypes();
+
     engine.load(url);
     return QApplication::exec();
 }