From c7884a88f74e89d27572ffaa1ee69b57273d94d3 Mon Sep 17 00:00:00 2001
From: Mazbrili <mazbrili@yahoo.com>
Date: Sat, 8 Feb 2020 10:44:28 +0700
Subject: patch for haiku path requirement..


diff --git a/database.cpp b/database.cpp
index a8f50da..ddca0ed 100644
--- a/database.cpp
+++ b/database.cpp
@@ -54,6 +54,8 @@ Database::Database()
 
     appDir.cdUp();
     appPath=  appDir.absolutePath()+"/share/elforkane";
+#elif defined(Q_OS_HAIKU)
+    appPath=  appDir.absolutePath()+"/lib";
 #elif defined(Q_OS_MAC)
     if (appDir.dirName() == "MacOS") {
         appDir.cdUp();
diff --git a/fs-wallpapers/fullscreen.cpp b/fs-wallpapers/fullscreen.cpp
index f135ed4..fbb1731 100644
--- a/fs-wallpapers/fullscreen.cpp
+++ b/fs-wallpapers/fullscreen.cpp
@@ -20,6 +20,8 @@ SceenFull::SceenFull(int w, int h):m_Width(w),m_Height(h)
     //  if (appDir.dirName().toLower() == "debug" || appDir.dirName().toLower() == "release")
     appDir.cdUp();
     appPath=  appDir.absolutePath()+"/share/elforkane";
+ #elif defined(Q_OS_HAIKU)
+    appPath=  appDir.absolutePath()+"/lib" ;
 #elif defined(Q_OS_MAC)
     if (appDir.dirName() == "MacOS") {
         appDir.cdUp();
diff --git a/main.cpp b/main.cpp
index f30f038..fb68394 100644
--- a/main.cpp
+++ b/main.cpp
@@ -70,6 +70,8 @@ int main(int argc, char *argv[])
 #if defined(Q_OS_WIN)
     appDir.cdUp();
        appPath=  appDir.absolutePath()+"/share/elforkane";
+ #elif defined(Q_OS_HAIKU)
+    appPath=  appDir.absolutePath()+"/lib"  ;    
 #elif defined(Q_OS_MAC)
     if (appDir.dirName() == "MacOS") {
         appDir.cdUp();
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 9d93cfa..313724c 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -57,6 +57,8 @@ MainWindow::MainWindow(QWidget *parent) :
 #if defined(Q_OS_WIN)
     appDir.cdUp();
     m_appPath=  appDir.absolutePath()+"/share/elforkane";
+#elif defined(Q_OS_HAIKU)
+    m_appPath=  appDir.absolutePath()+"/lib";
 #elif defined(Q_OS_MAC)
     if (appDir.dirName() == "MacOS") {
         appDir.cdUp();
-- 
2.24.0


From 41d2621d171287c247e9fff82e189ee105b09777 Mon Sep 17 00:00:00 2001
From: Mazbrili <mazbrili@yahoo.com>
Date: Tue, 10 Mar 2020 10:52:55 +0700
Subject: patch for close application


diff --git a/mainwindow.cpp b/mainwindow.cpp
index 313724c..90a0259 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -2381,6 +2381,7 @@ void MainWindow::on_actionQuit_triggered()
         trayIcon->hide();
 
     this->close();
+    qApp->quit();
 }
 
 void MainWindow::on_actionStopMedia_triggered()
-- 
2.24.0


From 4df736a75a4c3d8563c56e1041887bb8d177c10d Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Sat, 2 May 2020 11:28:55 +0700
Subject: Revert "patch for close application"

This reverts commit 105fa61987862795f54f4aab30bf4c35362b30a2.

diff --git a/mainwindow.cpp b/mainwindow.cpp
index 90a0259..313724c 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -2381,7 +2381,6 @@ void MainWindow::on_actionQuit_triggered()
         trayIcon->hide();
 
     this->close();
-    qApp->quit();
 }
 
 void MainWindow::on_actionStopMedia_triggered()
-- 
2.24.0


From e2e4ac052520b283bf00a644f6b8a6c72db64d50 Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Sat, 2 May 2020 11:30:02 +0700
Subject: ugly fix for closing app


diff --git a/main.cpp b/main.cpp
index fb68394..a137d86 100644
--- a/main.cpp
+++ b/main.cpp
@@ -32,7 +32,11 @@
 #include <QSettings>
 #include <QTranslator>
 #include <QLibraryInfo>
-
+#ifdef __HAIKU__
+#include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
+#endif
 
 static void associateFileTypes()
 {
@@ -212,6 +216,11 @@ int main(int argc, char *argv[])
 
     MainWindow w;
     w.show();
-
+ #ifdef __HAIKU__
+	a.exec();
+	kill(::getpid(),SIGKILL);
+	return 0;
+#elif
     return a.exec();
+#endif
 }
-- 
2.24.0


From de9a83795c2b18d40ead05059f4a330183802dd0 Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Mon, 4 May 2020 10:51:36 +0700
Subject: fix for mediakit not closed


diff --git a/mainwindow.cpp b/mainwindow.cpp
index 313724c..d1b170a 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -41,6 +41,7 @@
 #include <QTextCodec>
 #include <QDirIterator>
 #include <math.h>       /* fmod */
+#include <QStandardPaths>
 
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
@@ -207,7 +208,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
     //
     qDebug()<<"closing quit";
     delete ui;
-    // delete mPlayer;
+    delete mPlayer;
     //  qApp->quit();
 
     e->accept();
@@ -215,8 +216,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
 
 MainWindow::~MainWindow()
 {
-
-}
+    QTimer::singleShot(0,qApp,&QCoreApplication::quit);}
 
 void MainWindow::setupToolbarIcons()
 {
diff --git a/playermultimedia.cpp b/playermultimedia.cpp
index d2f6c59..74733f3 100644
--- a/playermultimedia.cpp
+++ b/playermultimedia.cpp
@@ -101,7 +101,13 @@ controlLayout->setSpacing(2);
 
 PlayerMultimedia::~PlayerMultimedia()
 {
+	qDebug() << "Begin destroy mediaplayer";
+	if (mediaPlayer) {
+		mediaPlayer->stop();
+		delete mediaPlayer;
+	}
     deleteLater();
+	qDebug() << "end destroy mediaplayer";
 }
 
 void PlayerMultimedia::play(QMediaContent url,bool besmala)
-- 
2.24.0


From eb5f6cfbeea1a829d90d570b2de5da7135cd1fa1 Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Mon, 4 May 2020 13:54:24 +0700
Subject: adjust path as haiku requirement


diff --git a/mainwindow.cpp b/mainwindow.cpp
index d1b170a..49178c4 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -180,7 +180,11 @@ void MainWindow::closeEvent(QCloseEvent *e)
     close();
     qDebug()<<"closing";
     mPlayer->stop();
-    QFile fileReciter(QDir::homePath()+"/.elforkane/reciterInfo");
+	#ifdef __HAIKU__
+    QFile fileReciter(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/reciterInfo");
+	#elif
+	QFile fileReciter(QDir::homePath()+"/.elforkane/reciterInfo");
+	#endif
     if (!fileReciter.open(QFile::WriteOnly)){
         // return ;
     }
@@ -577,7 +581,12 @@ void MainWindow::chargeDataTools()
     }
     file.close();
     //تحميل بيانات المقرئين------------------------------------------------------------
-    file.setFileName(QDir::homePath()+"/.elforkane/reciterInfo");
+	#ifdef __HAIKU__
+		qDebug() << "base lokasi"+ QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
+		file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/reciterInfo");
+	#elif
+	    file.setFileName(QDir::homePath()+"/.elforkane/reciterInfo");
+	#endif
     if(!file.exists())
         file.setFileName(m_appPath+"/.elforkane/reciterInfo");
 
@@ -781,8 +790,11 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
 //begen---------------save and load settings--------------------
 void MainWindow::loadSetting()
 {
-    QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
-
+    #ifdef __HAIKU__
+    QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/setting.ini",QSettings::IniFormat);
+	#elif
+	QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
+	#endif
     settings.beginGroup("Main");
     m_id=settings.value("id",1).toInt();
     m_fitInView=  settings.value("fitInView", false).toBool();
@@ -845,8 +857,11 @@ void MainWindow::loadSetting()
 
 void MainWindow::saveSetting()
 {
-    QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
-
+	#ifdef __HAIKU__
+    QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/setting.ini",QSettings::IniFormat);
+	#elif
+	QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
+	#endif
     settings.beginGroup("Main");
     settings.setValue("id", m_id);
     settings.setValue("fitInView", m_fitInView);
@@ -2145,11 +2160,20 @@ mPlayer->clearList();
     if(QFile::exists(m_soundPath)){
         destFile=m_soundPath+"/";
     }else{
-        destFile=QDir::homePath()+"/.elforkane/"+m_soundPath+"/";
-        if(!QFile::exists(destFile)){
+	#ifdef __HAIKU__
+    destFile=(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/"+m_soundPath+"/");
+			if(!QFile::exists(destFile)){
+            QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
+            dir.mkpath(destFile);
+        }
+	#elif
+	    destFile=QDir::homePath()+"/.elforkane/"+m_soundPath+"/";
+		    if(!QFile::exists(destFile)){
             QDir dir(QDir::homePath()+"/.elforkane/");
             dir.mkpath(destFile);
         }
+	#endif
+
     }
 
     QString fileurl(destFile+m_soundName+".mp3");
-- 
2.24.0


From d97c09a505b0f8ad5dbde58e646502ce9b3c2140 Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Tue, 5 May 2020 14:18:00 +0700
Subject: update path location


diff --git a/mainwindow.cpp b/mainwindow.cpp
index 49178c4..9d99cc7 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -583,12 +583,16 @@ void MainWindow::chargeDataTools()
     //تحميل بيانات المقرئين------------------------------------------------------------
 	#ifdef __HAIKU__
 		qDebug() << "base lokasi"+ QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
+		qDebug() << "lokas m_appPath "+ m_appPath;
 		file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/reciterInfo");
+		if(!file.exists())
+        file.setFileName(m_appPath+"/reciterInfo");
 	#elif
 	    file.setFileName(QDir::homePath()+"/.elforkane/reciterInfo");
-	#endif
-    if(!file.exists())
+		if(!file.exists())
         file.setFileName(m_appPath+"/.elforkane/reciterInfo");
+	#endif
+    
 
     if(file.open( QFile::ReadOnly)){
 
-- 
2.24.0


From 71c17ebbf1f0aadfae3c17b0c067932751e8e3e6 Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Wed, 6 May 2020 08:39:09 +0700
Subject: update patch location for setting.ini


diff --git a/main.cpp b/main.cpp
index a137d86..7c31bdf 100644
--- a/main.cpp
+++ b/main.cpp
@@ -37,7 +37,7 @@
 #include <sys/types.h>
 #include <signal.h>
 #endif
-
+#include <QStandardPaths>
 static void associateFileTypes()
 {
     #if defined(Q_OS_WIN)
@@ -92,16 +92,26 @@ int main(int argc, char *argv[])
     //-----------------------
     QDir dir;
     //   QString h=dir.homePath();
-
-    if (!dir.exists(QDir::homePath()+"/.elforkane")) //
+    QFile file;
+	
+	#ifdef __HAIKU__
+	
+	 if (!file.exists(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/reciterInfo")){
+        file.copy(appPath+"/reciterInfo",QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/reciterInfo");
+    }
+	QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/setting.ini",QSettings::IniFormat);
+	
+	#elif
+	if (!dir.exists(QDir::homePath()+"/.elforkane")) //
     {
         dir.mkdir( QDir::homePath()+"/.elforkane");
     }
-    QFile file;
     if (!file.exists(QDir::homePath()+"/.elforkane/reciterInfo")){
         file.copy(appPath+"/reciterInfo",QDir::homePath()+"/.elforkane/reciterInfo");
     }
-    QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
+	QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
+	#endif
+    
     settings.beginGroup("Main");
     QString lng=settings.value("lng","sys").toString();
     int m_locale= settings.value("locale",0).toInt();
-- 
2.24.0

