From 822fced70522a4691fbae2e1af7a8910117e040b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 1 Oct 2021 20:50:15 +1000
Subject: Fix build for Haiku


diff --git a/gmic-qt/CMakeLists.txt b/gmic-qt/CMakeLists.txt
index 93119fa..149a61b 100644
--- a/gmic-qt/CMakeLists.txt
+++ b/gmic-qt/CMakeLists.txt
@@ -240,7 +240,7 @@ add_definitions(-Dgmic_gui)
 add_definitions(-Dcimg_use_abort)
 add_definitions(-Dcimg_appname=\"gmic\")
 
-if (UNIX AND NOT APPLE)
+if (UNIX AND NOT APPLE AND NOT HAIKU)
     add_definitions(-Dcimg_display=1)
     add_definitions(-D_IS_LINUX_)
     add_definitions(-Dcimg_use_vt100)
@@ -261,6 +261,10 @@ if (APPLE)
     add_definitions(-mmacosx-version-min=10.9 -Wno-macro-redefined -Wno-deprecated-register)
 endif()
 
+if (HAIKU)
+    add_definitions(-Dcimg_display=0)
+endif()
+
 if (WIN32)
     add_definitions(-Dcimg_display=2)
     add_definitions(-DPSAPI_VERSION=1)
diff --git a/src/gmic.h b/src/gmic.h
index 6698bc0..1546281 100644
--- a/src/gmic.h
+++ b/src/gmic.h
@@ -51,6 +51,11 @@
  #
 */
 
+#ifdef __HAIKU__
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
 #ifndef gmic_version
 #define gmic_version 299
 
-- 
2.30.2


From 8429831bfedfcf5a715fa44ed80dd865a5adf5dc Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 3 Oct 2021 00:00:52 +1000
Subject: Add Haiku to detected OS


diff --git a/src/CImg.h b/src/CImg.h
index efdbaf4..da43a30 100644
--- a/src/CImg.h
+++ b/src/CImg.h
@@ -7124,6 +7124,8 @@ namespace cimg_library_suffixed {
       static const char *const str = "Irix";
 #elif defined(__MACOSX__) || defined(__APPLE__)
       static const char *const str = "Mac OS";
+#elif defined(__HAIKU__)
+      static const char *const str = "Haiku";
 #elif defined(unix) || defined(__unix) || defined(__unix__)
       static const char *const str = "Generic Unix";
 #elif defined(_MSC_VER) || defined(WIN32)  || defined(_WIN32) || defined(__WIN32__) || \
-- 
2.30.2


From 43034ff8912068f280b22bddd66cbdcc2103a3d2 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 9 Oct 2021 21:23:21 +1000
Subject: Fix save file with default quality


diff --git a/gmic-qt/src/Host/None/ImageDialog.cpp b/gmic-qt/src/Host/None/ImageDialog.cpp
index 973c0ae..73eb636 100644
--- a/gmic-qt/src/Host/None/ImageDialog.cpp
+++ b/gmic-qt/src/Host/None/ImageDialog.cpp
@@ -56,9 +56,6 @@ bool ImageView::save(const QString & filename, int quality)
   if ((ext == "jpg" || ext == "jpeg") && (quality == -1)) {
     quality = JpegQualityDialog::ask(dynamic_cast<QWidget *>(parent()), -1);
   }
-  if (quality == -1) {
-    return false;
-  }
   if (!_image.save(filename, nullptr, quality)) {
     QMessageBox::critical(this, tr("Error"), tr("Could not write image file %1").arg(filename));
     return false;
-- 
2.30.2

