From 039f0c5a09a7a0e74f4d865bf9530376fe15f377 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 30 Mar 2021 19:43:06 +1000
Subject: Fix build for Haiku


diff --git a/core/app/DigikamTarget.cmake b/core/app/DigikamTarget.cmake
index c3dd4ef..87aa3d6 100644
--- a/core/app/DigikamTarget.cmake
+++ b/core/app/DigikamTarget.cmake
@@ -50,6 +50,10 @@ target_link_libraries(digikam
                       digikamgui
 )
 
+if(HAIKU)
+    target_link_libraries(digikamcore PUBLIC network iconv intl)
+endif()
+
 if(ENABLE_DBUS)
 
     target_link_libraries(digikam
diff --git a/core/app/main/digikamapp_setup.cpp b/core/app/main/digikamapp_setup.cpp
index 94b436d..1660e08 100644
--- a/core/app/main/digikamapp_setup.cpp
+++ b/core/app/main/digikamapp_setup.cpp
@@ -1,3 +1,4 @@
+
 /* ============================================================
  *
  * This file is a part of digiKam project
@@ -792,9 +793,9 @@ void DigikamApp::setupActions()
     loadCameras();
 
     // Load Themes
-
+#ifndef Q_OS_HAIKU
     populateThemes();
-
+#endif
     createGUI(xmlFile());
 
     registerPluginsActions();
diff --git a/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/Core/NptConfig.h b/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/Core/NptConfig.h
index 81d79d5..0df98a0 100644
--- a/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/Core/NptConfig.h
+++ b/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/Core/NptConfig.h
@@ -136,6 +136,11 @@
 #define NPT_CONFIG_HAVE_GETADDRINFO
 #endif
 
+/* Haiku */
+#if defined(__HAIKU__)
+#define NPT_CONFIG_HAVE_GETADDRINFO
+#endif
+
 /* linux */
 #if defined(__linux__)
 #define NPT_CONFIG_HAVE_GETADDRINFO
diff --git a/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/System/Bsd/NptBsdNetwork.cpp b/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/System/Bsd/NptBsdNetwork.cpp
index 6208185..1f5e213 100644
--- a/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/System/Bsd/NptBsdNetwork.cpp
+++ b/core/dplugins/generic/tools/mediaserver/upnpsdk/Neptune/Source/System/Bsd/NptBsdNetwork.cpp
@@ -13,6 +13,9 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/select.h>
+#ifdef __HAIKU__
+#include <sys/sockio.h>
+#endif
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include <netinet/in.h>
diff --git a/core/libs/dimg/filters/curves/curveswidget.cpp b/core/libs/dimg/filters/curves/curveswidget.cpp
index ee6ccd5..9cce4b7 100644
--- a/core/libs/dimg/filters/curves/curveswidget.cpp
+++ b/core/libs/dimg/filters/curves/curveswidget.cpp
@@ -32,6 +32,7 @@
 
 #include <QPixmap>
 #include <QPainter>
+#include <QPainterPath>
 #include <QPoint>
 #include <QPen>
 #include <QEvent>
diff --git a/core/libs/dngwriter/extra/dng_sdk/dng_types.h b/core/libs/dngwriter/extra/dng_sdk/dng_types.h
index c8915d9..11d3996 100644
--- a/core/libs/dngwriter/extra/dng_sdk/dng_types.h
+++ b/core/libs/dngwriter/extra/dng_sdk/dng_types.h
@@ -33,7 +33,9 @@
 /*****************************************************************************/
 
 #ifdef qDNGUseStdInt
-
+#ifdef __HAIKU__
+#include <SupportDefs.h>
+#else
 typedef int8_t  int8;
 typedef int16_t int16;
 typedef int32_t int32;
@@ -43,7 +45,7 @@ typedef uint8_t  uint8;
 typedef uint16_t uint16;
 typedef uint32_t uint32;
 typedef uint64_t uint64;
-
+#endif
 #else
 
 typedef signed char		 int8;
diff --git a/core/libs/pgfutils/libpgf/PGFplatform.h b/core/libs/pgfutils/libpgf/PGFplatform.h
index 791343a..76a8dba 100644
--- a/core/libs/pgfutils/libpgf/PGFplatform.h
+++ b/core/libs/pgfutils/libpgf/PGFplatform.h
@@ -320,7 +320,7 @@ inline OSError SetFPos(HANDLE hFile, int posMode, INT64 posOff) {
 //-------------------------------------------------------------------------------
 // LINUX
 //-------------------------------------------------------------------------------
-#if defined(__linux__) || defined(__GLIBC__)
+#if defined(__linux__) || defined(__GLIBC__) || defined(__HAIKU__)
 #define __POSIX__
 #endif // __linux__ or __GLIBC__
 
@@ -336,7 +336,7 @@ inline OSError SetFPos(HANDLE hFile, int posMode, INT64 posOff) {
 //-------------------------------------------------------------------------------
 // *BSD
 //-------------------------------------------------------------------------------
-#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__)
 #ifndef __POSIX__ 
 #define __POSIX__ 
 #endif 
diff --git a/core/libs/settings/applicationsettings_miscs.cpp b/core/libs/settings/applicationsettings_miscs.cpp
index 8b56470..9198ea3 100644
--- a/core/libs/settings/applicationsettings_miscs.cpp
+++ b/core/libs/settings/applicationsettings_miscs.cpp
@@ -484,7 +484,11 @@ void ApplicationSettings::setApplicationFont(const QFont& font)
 
 QFont ApplicationSettings::getApplicationFont() const
 {
+#ifdef Q_OS_HAIKU
+	return QFontDatabase::systemFont(QFontDatabase::GeneralFont);
+#else
     return d->applicationFont;
+#endif
 }
 
 bool ApplicationSettings::getHelpBoxNotificationSeen() {
diff --git a/core/libs/threadimageio/thumb/thumbnailcreator_basic.cpp b/core/libs/threadimageio/thumb/thumbnailcreator_basic.cpp
index 3b69700..56174cc 100644
--- a/core/libs/threadimageio/thumb/thumbnailcreator_basic.cpp
+++ b/core/libs/threadimageio/thumb/thumbnailcreator_basic.cpp
@@ -47,7 +47,7 @@ extern "C"
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#ifndef Q_OS_WIN32
+#if !defined(Q_OS_WIN32) && !defined(Q_OS_HAIKU)
 #   include <sys/ipc.h>
 #   include <sys/shm.h>
 #endif
diff --git a/core/libs/widgets/mainview/thememanager.cpp b/core/libs/widgets/mainview/thememanager.cpp
index 8283afd..fb6d7ff 100644
--- a/core/libs/widgets/mainview/thememanager.cpp
+++ b/core/libs/widgets/mainview/thememanager.cpp
@@ -116,6 +116,7 @@ void ThemeManager::setCurrentTheme(const QString& name)
 
 void ThemeManager::slotChangePalette()
 {
+#ifndef Q_OS_HAIKU
     updateCurrentDesktopDefaultThemePreview();
 
     QString theme(currentThemeName());
@@ -139,6 +140,7 @@ void ThemeManager::slotChangePalette()
     qCDebug(DIGIKAM_WIDGETS_LOG) << theme << " :: " << filePath;
 
     emit signalThemeChanged();
+#endif
 }
 
 void ThemeManager::setThemeMenuAction(QMenu* const action)
@@ -165,6 +167,7 @@ void ThemeManager::registerThemeActions(DXmlGuiWindow* const win)
 
 void ThemeManager::populateThemeMenu()
 {
+#ifndef Q_OS_HAIKU
     if (!d->themeMenuAction)
     {
         return;
@@ -227,6 +230,7 @@ void ThemeManager::populateThemeMenu()
 
     updateCurrentDesktopDefaultThemePreview();
     setCurrentTheme(theme);
+#endif
 }
 
 void ThemeManager::updateCurrentDesktopDefaultThemePreview()
diff --git a/core/showfoto/main/showfoto_setup.cpp b/core/showfoto/main/showfoto_setup.cpp
index 4fd6b85..4d42c64 100644
--- a/core/showfoto/main/showfoto_setup.cpp
+++ b/core/showfoto/main/showfoto_setup.cpp
@@ -28,7 +28,9 @@ namespace ShowFoto
 
 void ShowFoto::setupActions()
 {
+#ifndef Q_OS_HAIKU
     Digikam::ThemeManager::instance()->setThemeMenuAction(new QMenu(i18n("&Themes"), this));
+#endif
     setupStandardActions();
 
     // Extra 'File' menu actions ---------------------------------------------
diff --git a/core/showfoto/main/showfotosettings.cpp b/core/showfoto/main/showfotosettings.cpp
index af093f4..45b8de3 100644
--- a/core/showfoto/main/showfotosettings.cpp
+++ b/core/showfoto/main/showfotosettings.cpp
@@ -397,7 +397,11 @@ QString ShowfotoSettings::getIconTheme() const
 
 QFont ShowfotoSettings::getApplicationFont() const
 {
+#ifdef Q_OS_HAIKU
+	return QFontDatabase::systemFont(QFontDatabase::GeneralFont);
+#else
     return d->applicationFont;
+#endif
 }
 
 bool ShowfotoSettings::getShowSplash() const
diff --git a/core/showfoto/setup/showfotosetup.cpp b/core/showfoto/setup/showfotosetup.cpp
index b4cfca3..216be24 100644
--- a/core/showfoto/setup/showfotosetup.cpp
+++ b/core/showfoto/setup/showfotosetup.cpp
@@ -196,7 +196,9 @@ Setup::Setup(QWidget* const parent, Setup::Page page)
 
     winId();
     Digikam::DXmlGuiWindow::restoreWindowSize(windowHandle(), group);
+#ifndef Q_OS_HAIKU
     resize(windowHandle()->size());
+#endif
 }
 
 Setup::~Setup()
diff --git a/core/showfoto/setup/showfotosetupmisc.cpp b/core/showfoto/setup/showfotosetupmisc.cpp
index 957995b..c91c772 100644
--- a/core/showfoto/setup/showfotosetupmisc.cpp
+++ b/core/showfoto/setup/showfotosetupmisc.cpp
@@ -83,7 +83,9 @@ public:
         sortOrderComboBox       (nullptr),
         applicationStyle        (nullptr),
         applicationIcon         (nullptr),
+#ifndef Q_OS_HAIKU
         applicationFont         (nullptr),
+#endif
         systemSettingsWidget    (nullptr),
         settings                (ShowfotoSettings::instance())
     {
@@ -110,7 +112,9 @@ public:
     QComboBox*            sortOrderComboBox;
     QComboBox*            applicationStyle;
     QComboBox*            applicationIcon;
+#ifndef Q_OS_HAIKU
     DFontSelect*          applicationFont;
+#endif
 
     SystemSettingsWidget* systemSettingsWidget;
 
@@ -300,10 +304,10 @@ SetupMisc::SetupMisc(QWidget* const parent)
     {
         d->applicationIcon->addItem(it.key(), it.value());
     }
-
+#ifndef Q_OS_HAIKU
     d->applicationFont = new DFontSelect(i18n("Application font:"), appearancePanel);
     d->applicationFont->setToolTip(i18n("Select here the font used to display text in whole application."));
-
+#endif
     // --------------------------------------------------------
 
     layout2->setContentsMargins(spacing, spacing, spacing, spacing);
@@ -313,7 +317,9 @@ SetupMisc::SetupMisc(QWidget* const parent)
     layout2->addWidget(tabStyleHbox);
     layout2->addWidget(appStyleHbox);
     layout2->addWidget(iconThemeHbox);
+#ifndef Q_OS_HAIKU
     layout2->addWidget(d->applicationFont);
+#endif
     layout2->addStretch();
 
     d->tab->insertTab(Appearance, appearancePanel, i18nc("@title:tab", "Appearance"));
@@ -383,7 +389,9 @@ void SetupMisc::readSettings()
 #endif
 
     d->applicationIcon->setCurrentIndex(d->applicationIcon->findData(d->settings->getIconTheme()));
+#ifndef Q_OS_HAIKU
     d->applicationFont->setFont(d->settings->getApplicationFont());
+#endif
 }
 
 void SetupMisc::applySettings()
@@ -408,7 +416,9 @@ void SetupMisc::applySettings()
 #endif
 
     d->settings->setIconTheme(d->applicationIcon->currentData().toString());
+#ifndef Q_OS_HAIKU
     d->settings->setApplicationFont(d->applicationFont->font());
+#endif
     d->settings->syncConfig();
 }
 
diff --git a/core/utilities/import/backend/gpcamera.cpp b/core/utilities/import/backend/gpcamera.cpp
index 368dd07..4dacb1b 100644
--- a/core/utilities/import/backend/gpcamera.cpp
+++ b/core/utilities/import/backend/gpcamera.cpp
@@ -67,6 +67,10 @@ extern "C"
 
 //#define GPHOTO2_DEBUG 1
 
+#ifdef Q_OS_HAIKU
+#define HAVE_GPHOTO25 1
+#endif
+
 #ifdef HAVE_GPHOTO2
 
 // LibGphoto2 includes
diff --git a/core/utilities/setup/setupmisc.cpp b/core/utilities/setup/setupmisc.cpp
index 83cddca..600955f 100644
--- a/core/utilities/setup/setupmisc.cpp
+++ b/core/utilities/setup/setupmisc.cpp
@@ -92,7 +92,9 @@ public:
         stringComparisonType                    (nullptr),
         applicationStyle                        (nullptr),
         applicationIcon                         (nullptr),
+#ifndef Q_OS_HAIKU
         applicationFont                         (nullptr),
+#endif
         minimumSimilarityBound                  (nullptr),
         systemSettingsWidget                    (nullptr),
         groupingButtons                         (QHash<int, QButtonGroup*>())
@@ -127,8 +129,9 @@ public:
     QComboBox*                stringComparisonType;
     QComboBox*                applicationStyle;
     QComboBox*                applicationIcon;
+#ifndef Q_OS_HAIKU
     DFontSelect*              applicationFont;
-
+#endif
     QSpinBox*                 minimumSimilarityBound;
 
     SystemSettingsWidget*     systemSettingsWidget;
@@ -352,9 +355,10 @@ SetupMisc::SetupMisc(QWidget* const parent)
         d->applicationIcon->addItem(it.key(), it.value());
     }
 
+#ifndef Q_OS_HAIKU
     d->applicationFont = new DFontSelect(i18n("Application font:"), appearancePanel);
     d->applicationFont->setToolTip(i18n("Select here the font used to display text in whole application."));
-
+#endif
     // --------------------------------------------------------
 
     layout2->setContentsMargins(spacing, spacing, spacing, spacing);
@@ -365,7 +369,9 @@ SetupMisc::SetupMisc(QWidget* const parent)
     layout2->addWidget(tabStyleHbox);
     layout2->addWidget(appStyleHbox);
     layout2->addWidget(iconThemeHbox);
+#ifndef Q_OS_HAIKU
     layout2->addWidget(d->applicationFont);
+#endif
     layout2->addStretch();
 
     d->tab->insertTab(Appearance, appearancePanel, i18nc("@title:tab", "Appearance"));
@@ -518,7 +524,9 @@ void SetupMisc::applySettings()
 #endif
 
     settings->setIconTheme(d->applicationIcon->currentData().toString());
+#ifndef Q_OS_HAIKU
     settings->setApplicationFont(d->applicationFont->font());
+#endif
     settings->saveSettings();
 }
 
@@ -558,7 +566,9 @@ void SetupMisc::readSettings()
 #endif
 
     d->applicationIcon->setCurrentIndex(d->applicationIcon->findData(settings->getIconTheme()));
+#ifndef Q_OS_HAIKU
     d->applicationFont->setFont(settings->getApplicationFont());
+#endif
 }
 
 } // namespace Digikam
-- 
2.30.2

