From ae6e135d9b91d12dc385e7980e5f516dc1676e15 Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Tue, 8 Aug 2017 11:27:18 +0300
Subject: Haiku patch


diff --git a/goldendict.pro b/goldendict.pro
index 9ba9e69..2f427a5 100644
--- a/goldendict.pro
+++ b/goldendict.pro
@@ -138,7 +138,19 @@ win32 {
     }
 }
 
-unix:!mac {
+haiku {
+    LIBS += -liconv \
+			-lavutil \
+			-lavformat \
+			-lavcodec \
+			-lao \
+			-lhunspell-1.7 \
+			-lvorbisfile \
+			-lexecinfo
+
+}
+
+unix:!mac:!haiku {
   DEFINES += HAVE_X11
   # This is to keep symbols for backtraces
   QMAKE_CXXFLAGS += -rdynamic
diff --git a/hotkeywrapper.cc b/hotkeywrapper.cc
index 267e0be..a0438c4 100644
--- a/hotkeywrapper.cc
+++ b/hotkeywrapper.cc
@@ -463,6 +463,23 @@ bool QHotkeyApplication::winEventFilter ( MSG * message, long * result )
 
 //////////////////////////////////////////////////////////////////////////
 
+#elif defined(Q_OS_HAIKU)
+
+void HotkeyWrapper::init()
+{
+
+}
+
+bool HotkeyWrapper::setGlobalKey( int key, int key2,
+                                  Qt::KeyboardModifiers modifier, int handle )
+{
+	return true;
+}
+
+void HotkeyWrapper::unregister()
+{
+
+}
 #else
 
 //////////////////////////////////////////////////////////////////////////
diff --git a/hotkeywrapper.hh b/hotkeywrapper.hh
index a27873e..e2bdf22 100644
--- a/hotkeywrapper.hh
+++ b/hotkeywrapper.hh
@@ -107,7 +107,7 @@ private:
   EventHandlerRef handlerRef;
 
 #else
-
+#ifndef Q_OS_HAIKU
   static void recordEventCallback( XPointer, XRecordInterceptData * );
 
   /// Called by recordEventCallback()
@@ -118,9 +118,9 @@ private:
   // We do one-time init of those, translating keysyms to keycodes
   KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode,
           cCode, insertCode, kpInsertCode, lMetaCode, rMetaCode;
-
+#endif
   quint32 currentModifiers;
-
+#ifndef Q_OS_HAIKU
   Display * dataDisplay;
   XRecordRange * recordRange;
   XRecordContext recordContext;
@@ -145,7 +145,7 @@ private:
   /// Ungrabs the given key. erasing it from grabbedKeys. The key's provided
   /// as an interator inside the grabbedKeys set.
   void ungrabKey( GrabbedKeys::iterator );
-
+#endif
 signals:
 
   /// Emitted from the thread
diff --git a/keyboardstate.cc b/keyboardstate.cc
index 29c986f..f3787d7 100644
--- a/keyboardstate.cc
+++ b/keyboardstate.cc
@@ -40,6 +40,7 @@ bool KeyboardState::checkModifiersPressed( int mask )
     ( mask & Shift && !( keys & ( 1 << shiftKeyBit ) ) ) ||
     ( mask & Win && !( keys & ( 1 << controlKeyBit ) ) ) );
   #else
+  #ifndef Q_OS_HAIKU
   XkbStateRec state;
 
   XkbGetState( QX11Info::display(), XkbUseCoreKbd, &state );
@@ -50,5 +51,14 @@ bool KeyboardState::checkModifiersPressed( int mask )
     ( mask & Shift && !( state.base_mods & ShiftMask ) ) ||
     ( mask & Win && !( state.base_mods & Mod4Mask ) ) );
   #endif
+//  
+/*  uint32 mask = modifiers();
+return !(
+( mask & B_COMMAND_KEY && !( state.base_mods & Mod1Mask ) ) ||
+( mask & B_CONTROL_KEY && !( state.base_mods & ControlMask ) ) ||
+( mask & B_SHIFT_KEY && !( state.base_mods & ShiftMask ) ) ||
+( mask & B_OPTION_KEY && !( state.base_mods & Mod4Mask ) ) );*/
+
+  #endif
 }
 
diff --git a/loaddictionaries.cc b/loaddictionaries.cc
index cf31e63..91f799e 100644
--- a/loaddictionaries.cc
+++ b/loaddictionaries.cc
@@ -80,12 +80,12 @@ void LoadDictionaries::run()
 
     // Make soundDirs
     {
-      vector< sptr< Dictionary::Class > > soundDirDictionaries =
+/*     vector< sptr< Dictionary::Class > > soundDirDictionaries =
         SoundDir::makeDictionaries( soundDirs, FsEncoding::encode( Config::getIndexDir() ), *this );
 
       dictionaries.insert( dictionaries.end(), soundDirDictionaries.begin(),
                            soundDirDictionaries.end() );
-    }
+*/    }
 
     // Make hunspells
     {
-- 
2.21.0


From 72200cd030b200514f4904dc8d7bc08e501581e2 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 4 Jul 2018 23:37:22 +1000
Subject: Fix build for gcc7


diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
index 04c35d8..7e803d1 100644
--- a/ffmpegaudio.cc
+++ b/ffmpegaudio.cc
@@ -143,7 +143,7 @@ bool DecoderContext::openCodec( QString & errorString )
     return false;
   }
 
-  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
   if ( !avioBuffer )
   {
     errorString = QObject::tr( "av_malloc() failed." );
@@ -380,7 +380,7 @@ bool DecoderContext::play( QString & errorString )
   }
 
   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
-       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
   {
     av_init_packet( &packet );
     int gotFrame = 0;
diff --git a/fulltextsearch.hh b/fulltextsearch.hh
index cedeed6..36e5ce4 100644
--- a/fulltextsearch.hh
+++ b/fulltextsearch.hh
@@ -6,6 +6,7 @@
 #include <QRegExp>
 #include <QAbstractListModel>
 #include <QList>
+#include <QAction>
 
 #include "dictionary.hh"
 #include "ui_fulltextsearch.h"
diff --git a/groups_widgets.hh b/groups_widgets.hh
index ce442fa..ce21c32 100644
--- a/groups_widgets.hh
+++ b/groups_widgets.hh
@@ -10,6 +10,7 @@
 
 #include <QListWidget>
 #include <QSortFilterProxyModel>
+#include <QAction>
 
 #include "config.hh"
 #include "dictionary.hh"
diff --git a/initializing.cc b/initializing.cc
index 0db6909..f467925 100644
--- a/initializing.cc
+++ b/initializing.cc
@@ -3,6 +3,7 @@
 
 #include "initializing.hh"
 #include <QCloseEvent>
+#include <QIcon>
 
 #if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) ) && defined( Q_OS_WIN32 )
 #include <QtWidgets/QStyleFactory>
-- 
2.21.0


From 44f27246ddb4947bca977c248037742ba9f4bbff Mon Sep 17 00:00:00 2001
From: Nikolay Korotkiy <sikmir@gmail.com>
Date: Mon, 29 Oct 2018 22:41:18 +0000
Subject: Fix config path


diff --git a/config.cc b/config.cc
index 9b27b31..318ac9c 100644
--- a/config.cc
+++ b/config.cc
@@ -37,6 +37,8 @@ namespace
         return result;
       char const * pathInHome = "GoldenDict";
       result = QDir::fromNativeSeparators( QString::fromWCharArray( _wgetenv( L"APPDATA" ) ) );
+    #elif defined(Q_OS_HAIKU)
+      char const * pathInHome = "config/settings/Goldendict";
     #else
       char const * pathInHome = ".goldendict";
     #endif
-- 
2.21.0


From ce0ce7bb4e3617a6a53d92f064acb84e3d52c4a4 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Thu, 15 Aug 2019 10:20:22 +0200
Subject: Fix path to the myspell dictionaries


diff --git a/config.cc b/config.cc
index 318ac9c..a9d047c 100644
--- a/config.cc
+++ b/config.cc
@@ -346,6 +346,11 @@ Class load() throw( exError )
     if ( QDir( "/usr/share/myspell/dicts" ).exists() )
       c.hunspell.dictionariesPath = "/usr/share/myspell/dicts";
 
+	#elif defined(Q_OS_HAIKU)
+
+    if ( QDir( "/system/data/hunspell" ).exists() )
+      c.hunspell.dictionariesPath = "/system/data/hunspell";
+
     #endif
 
     #ifdef Q_OS_WIN32
-- 
2.21.0

