From bde99b02738213322491a927f079363f6e5b0d01 Mon Sep 17 00:00:00 2001
From: TURX <turx2003@gmail.com>
Date: Mon, 20 Jan 2020 01:32:19 +0800
Subject: fix Haiku support


diff --git a/src/main.cpp b/src/main.cpp
index 267bae8..8a91bbe 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -51,6 +51,10 @@ static const char* kDefaultScaleRoundPolicy = "RoundPreferFloor";
 static const char* kDefaultScaleRoundPolicy = "Round";
 #endif
 
+#ifdef Q_OS_HAIKU
+#include <FindDirectory.h>
+#endif
+
 static void mlt_log_handler(void *service, int mlt_level, const char *format, va_list args)
 {
     if (mlt_level > mlt_log_get_level())
@@ -196,7 +200,14 @@ public:
             resourceArg = parser.positionalArguments();
 
         // Startup logging.
+#if !defined(Q_OS_HAIKU)
         dir.setPath(Settings.appDataLocation());
+#else
+        char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
+        find_directory(B_USER_LOG_DIRECTORY, -1, false, buffer, sizeof(buffer));
+        QString path = QString::fromUtf8(buffer);
+        dir.setPath(path);
+#endif
         if (!dir.exists()) dir.mkpath(dir.path());
         const QString logFileName = dir.filePath("shotcut-log.txt");
         QFile::remove(logFileName);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a478128..00e383a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -96,6 +96,10 @@
 #include <QVersionNumber>
 #include <clocale>
 
+#ifdef Q_OS_HAIKU
+#include <FindDirectory.h>
+#endif
+
 static bool eventDebugCallback(void **data)
 {
     QEvent *event = reinterpret_cast<QEvent*>(data[1]);
@@ -3861,7 +3865,15 @@ void MainWindow::onDrawingMethodTriggered(QAction *action)
 void MainWindow::on_actionApplicationLog_triggered()
 {
     TextViewerDialog dialog(this);
-    QDir dir = Settings.appDataLocation();
+    QDir dir;
+#if !defined(Q_OS_HAIKU)
+    dir = Settings.appDataLocation();
+#else
+    char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
+    find_directory(B_USER_LOG_DIRECTORY, -1, false, buffer, sizeof(buffer));
+    QString path = QString::fromUtf8(buffer);
+    dir = path;
+#endif
     QFile logFile(dir.filePath("shotcut-log.txt"));
     logFile.open(QIODevice::ReadOnly | QIODevice::Text);
     dialog.setText(logFile.readAll());
diff --git a/src/src.pro b/src/src.pro
index 48a6fbf..504bff9 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -401,11 +401,13 @@ win32 {
     SOURCES += \
     windowstools.cpp
 }
-unix:!mac {
+unix:!mac:!haiku {
     QT += x11extras
+    LIBS += -lX11
+}
+unix:!mac {
     CONFIG += link_pkgconfig
     PKGCONFIG += mlt++
-    LIBS += -lX11
 }
 
 unix:!mac:isEmpty(PREFIX) {
-- 
2.30.0

