From ccbb524bd22970d19e726d09225282134eb1ed2a Mon Sep 17 00:00:00 2001
From: mazbrili <mazbrili@yahoo.com>
Date: Sat, 20 Oct 2018 18:56:36 +0700
Subject: apply path difference

change path with builtin QStandardPaths from Qt

modify pro files to use pkgconfig

diff --git a/bookinfo.cpp b/bookinfo.cpp
index f75bcaa..30204eb 100644
--- a/bookinfo.cpp
+++ b/bookinfo.cpp
@@ -19,17 +19,13 @@
  * Boston, MA 02110-1301, USA.
  */
 #include "bookinfo.h"
-#if QT_VERSION >= 0x050000
-#include <poppler-qt5.h>
-#else
-#include <poppler-qt4.h>
-#endif
 
 #include<QApplication>
 #include<QInputDialog>
 #include<QDir>
 #include<QFileInfo>
 #include<QSettings>
+#include<QStandardPaths>
 //#define thumbnails QDir::homePath()+"/."+QApplication::applicationName()+"/thumbnails"
 
 BookInfo::BookInfo()
@@ -37,8 +33,14 @@ BookInfo::BookInfo()
 
 QSettings settings;
 
+#ifndef Q_OS_HAIKU
 QString appdir=(settings.value("BooksPath",
                                              QDir::homePath()+"/."+QApplication::applicationName()).toString());
+#else
+QString appdir=(settings.value("BooksPath",
+                                             QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).toString());
+#endif
+
 mThumbnails=appdir+"/thumbnails/";
 
 }
diff --git a/booksorganizer.pro b/booksorganizer.pro
index 2162d85..c057736 100644
--- a/booksorganizer.pro
+++ b/booksorganizer.pro
@@ -27,6 +27,11 @@ win32{
     LIBS         += -L poppler-win\bin -lpoppler-qt5
     RC_FILE = myapp.rc
 #    QT +=winextras
+}
+haiku{
+	TARGET = BooksOrg
+	CONFIG += link_pkgconfig
+	PKGCONFIG += poppler-qt5
 }else{
 
         equals(QT_MAJOR_VERSION, 5) {
diff --git a/configuredialog.cpp b/configuredialog.cpp
index 4058fa3..17fff99 100644
--- a/configuredialog.cpp
+++ b/configuredialog.cpp
@@ -4,6 +4,7 @@
 #include <QSettings>
 #include <QMessageBox>
 #include <QFileDialog>
+#include <QStandardPaths>
 ConfigureDialog::ConfigureDialog(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::ConfigureDialog)
@@ -11,8 +12,14 @@ ConfigureDialog::ConfigureDialog(QWidget *parent) :
     ui->setupUi(this);
     QSettings settings;
 
+#ifndef Q_OS_HAIKU
     ui->lineEditPath->setText(settings.value("BooksPath",
                                              QDir::homePath()+"/."+QApplication::applicationName()).toString());
+#else
+    ui->lineEditPath->setText(settings.value("BooksPath",
+                                             QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).toString());
+#endif
+
     ui->checkBoxCopy->setChecked(settings.value("CopyBooks",false).toBool());
 
 }
diff --git a/main.cpp b/main.cpp
index e45955e..eeda882 100644
--- a/main.cpp
+++ b/main.cpp
@@ -57,7 +57,12 @@ int main(int argc, char *argv[])
     qRegisterMetaType< QList< QRectF > >("QList<QRectF>");
 
     QApplication a(argc, argv);
+
+#ifndef Q_OS_HAIKU
     a.setApplicationName("booksorg");
+#else
+    a.setApplicationName("BooksOrg");
+#endif
     a.setOrganizationName("elokab");
      a.setApplicationVersion("0.3");
     a.setWindowIcon(QIcon(":/icons/booksorg"));
@@ -98,7 +103,12 @@ int main(int argc, char *argv[])
 #endif
 
     QDir dir;
+#ifndef Q_OS_HAIKU
     dir.mkpath(QDir::homePath()+"/."+a.applicationName()+"/thumbnails");
+#else
+    dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+
+               QDir::separator()+"thumbnails");
+#endif
 
     MainWindow w;
     w.show();
diff --git a/mainwindow.cpp b/mainwindow.cpp
index d1f46a0..9fd1741 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -68,8 +68,13 @@ QSettings settings;
 
 
 
+#ifdef Q_OS_HAIKU
+   Path::setWorkingDir(settings.value("BooksPath",
+                             QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).toString());
+#else
    Path::setWorkingDir(settings.value("BooksPath",
                              QDir::homePath()+"/."+QApplication::applicationName()).toString());
+#endif
 
    Path::setCopyBooks(settings.value("CopyBooks",false).toBool());
 
diff --git a/path.cpp b/path.cpp
index 069e2be..9eb1db6 100644
--- a/path.cpp
+++ b/path.cpp
@@ -1,3 +1,8 @@
 #include "path.h"
+#include <QStandardPaths>
+#ifdef Q_OS_HAIKU
+QString Path::mWorkingDir= QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
+#else
 QString Path::mWorkingDir= QDir::homePath()+"/."+QApplication::applicationName();
+#endif
 bool Path::mCopy=false;
diff --git a/searchtools.cpp b/searchtools.cpp
index 3bf60ca..c64a4a4 100644
--- a/searchtools.cpp
+++ b/searchtools.cpp
@@ -24,6 +24,7 @@
 #include "eicon.h"
 #include <QtGui>
 #include <QSettings>
+#include <QAction>
 
 SearchTools::SearchTools(bool isPdf, QWidget *parent) :
     QWidget(parent),
-- 
2.19.1

