From a64c2561240cef51dea4c15a52b3f8a663ee0dce Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 2 Sep 2017 20:33:12 +1000
Subject: Fix build for Haiku


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0749577..c8299d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.6)
 
 #INCLUDE(CPack)
 
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 if( ${CMAKE_SYSTEM} MATCHES "Darwin" )
   message("MAC OSX build")
   SET(MAC 1)
diff --git a/cr3qt/CMakeLists.txt b/cr3qt/CMakeLists.txt
index 4eda8f3..1a63cbd 100644
--- a/cr3qt/CMakeLists.txt
+++ b/cr3qt/CMakeLists.txt
@@ -48,6 +48,10 @@ if(MAC)
           -DUSE_FONTCONFIG=0
     ${CARBON_CFLAGS}
     )
+ELSEIF (HAIKU)
+    ADD_DEFINITIONS(-DCR3_DATA_DIR="${CMAKE_INSTALL_PREFIX}/data/"
+          -DUSE_FONTCONFIG=1
+    )
 ELSEIF (UNIX)
     ADD_DEFINITIONS(-DCR3_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/cr3/" 
           -DUSE_FONTCONFIG=1 
@@ -171,7 +175,9 @@ IF(MAC)
 #    SET(FRAMEWORKS "-framework ApplicationServices -framework Carbon -framework AppKit")
 #/Developer/Qt/lib/libQtCore.a /Developer/Qt/lib/libQtGui.a ${FRAMEWORKS} 
     SET (EXTRA_LIBS ${QT_LIBRARIES} ${STD_LIBS} )
-#${QT_LIBRARIES} 
+#${QT_LIBRARIES}
+ELSEIF (HAIKU)
+    SET (EXTRA_LIBS ${QT_LIBRARIES} ${STD_LIBS} ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} fontconfig intl)
 ELSEIF (UNIX)
     SET (EXTRA_LIBS ${QT_LIBRARIES} fontconfig ${STD_LIBS} )
 ELSE()
@@ -200,6 +206,20 @@ INSTALL( FILES src/desktop/PkgInfo DESTINATION Contents )
 #INSTALL( FILES src/desktop/cr3.png DESTINATION share/pixmaps )
 #INSTALL( FILES src/desktop/cr3.xpm DESTINATION share/pixmaps )
 
+ELSEIF (HAIKU)
+
+INSTALL( TARGETS cr3 RUNTIME DESTINATION . )
+INSTALL( DIRECTORY data/ DESTINATION data
+   FILES_MATCHING PATTERN "*.css" PATTERN "skins" EXCLUDE PATTERN "docs" EXCLUDE)
+INSTALL( DIRECTORY data/hyph DESTINATION data
+   FILES_MATCHING PATTERN "*.pdb" )
+INSTALL( DIRECTORY data/hyph DESTINATION data
+   FILES_MATCHING PATTERN "*.pattern" )
+INSTALL( DIRECTORY data/textures DESTINATION data )
+INSTALL( DIRECTORY data/backgrounds DESTINATION data )
+INSTALL( FILES ${CR3_CHANGELOG} DESTINATION data )
+INSTALL( FILES ${QM_FILES} DESTINATION i18n )
+
 ELSEIF (UNIX)
 
 
-- 
2.13.1


From e21d817cebdd528ceca0dfb077f80da0036df91d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 2 Sep 2017 20:49:13 +1000
Subject: =?UTF-8?q?Fix=20settings=20for=20Haiku=0A*=20fix=20paths=0A*=20fi?=
 =?UTF-8?q?x=20default=20params=0A*=20add=20Noto=20Sans=20support?=


diff --git a/cr3qt/src/cr3widget.cpp b/cr3qt/src/cr3widget.cpp
index 2e1c784..a328172 100644
--- a/cr3qt/src/cr3widget.cpp
+++ b/cr3qt/src/cr3widget.cpp
@@ -347,7 +347,7 @@ void CR3View::updateDefProps()
     _data->_props->setStringDef( PROP_WINDOW_SHOW_MENU, "1" );
     _data->_props->setStringDef( PROP_WINDOW_SHOW_SCROLLBAR, "1" );
     _data->_props->setStringDef( PROP_WINDOW_TOOLBAR_SIZE, "1" );
-    _data->_props->setStringDef( PROP_WINDOW_SHOW_STATUSBAR, "0" );
+    _data->_props->setStringDef( PROP_WINDOW_SHOW_STATUSBAR, "1" );
     _data->_props->setStringDef( PROP_APP_START_ACTION, "0" );
 
 
diff --git a/cr3qt/src/main.cpp b/cr3qt/src/main.cpp
index ed56449..008db81 100644
--- a/cr3qt/src/main.cpp
+++ b/cr3qt/src/main.cpp
@@ -123,7 +123,11 @@ int main(int argc, char *argv[])
         lString16 home = Utf8ToUnicode(lString8(( getenv("HOME") ) ));
         lString16 homecr3 = home;
         LVAppendPathDelimiter(homecr3);
+#ifdef __HAIKU__
+		homecr3 << "config/settings/cr3";
+#else
         homecr3 << ".cr3";
+#endif
         LVAppendPathDelimiter(homecr3);
         //~/.cr3/
         lString16 homefonts = homecr3;
@@ -166,7 +170,7 @@ int main(int argc, char *argv[])
             QString exeDir = QDir::toNativeSeparators(qApp->applicationDirPath() + "/Contents/Resources/"); //QDir::separator();
             QString translations = exeDir + "i18n";
 #else
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__HAIKU__)
             QString exeDir = QDir::toNativeSeparators(qApp->applicationDirPath() + "/"); //QDir::separator();
             QString translations = exeDir + "i18n";
 #else
diff --git a/cr3qt/src/mainwindow.cpp b/cr3qt/src/mainwindow.cpp
index 7899171..f7a7c85 100644
--- a/cr3qt/src/mainwindow.cpp
+++ b/cr3qt/src/mainwindow.cpp
@@ -74,6 +74,10 @@ MainWindow::MainWindow(QWidget *parent)
     addAction(ui->actionNextSentence);
     addAction(ui->actionPrevSentence);
 
+#ifdef __HAIKU__
+	QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/config/settings/cr3/");
+	QString exeDir = QString(CR3_DATA_DIR);
+#else
 #ifdef _LINUX
     QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/.cr3/");
 #else
@@ -84,6 +88,8 @@ MainWindow::MainWindow(QWidget *parent)
 #else
     QString exeDir = QDir::toNativeSeparators(qApp->applicationDirPath() + "/"); //QDir::separator();
 #endif
+#endif
+#ifndef __HAIKU__
     QString cacheDir = homeDir + "cache";
     QString bookmarksDir = homeDir + "bookmarks";
     QString histFile = exeDir + "cr3hist.bmk";
@@ -92,6 +98,16 @@ MainWindow::MainWindow(QWidget *parent)
     QString iniFile = homeDir + "cr3.ini";
     QString cssFile = homeDir + "fb2.css";
     QString cssFile2 = exeDir + "fb2.css";
+#else
+    QString cacheDir = homeDir + "cache";
+    QString bookmarksDir = homeDir + "bookmarks";
+    QString histFile = homeDir + "cr3hist.bmk";
+    QString histFile2 = histFile;
+    QString iniFile = homeDir + "cr3.ini";
+    QString iniFile2 = iniFile;
+    QString cssFile = exeDir + "fb2.css";
+    QString cssFile2 = homeDir + "fb2.css";
+#endif
     //QString translations = exeDir + "i18n";
     //CRLog::info("Translations directory: %s", LCSTR(qt2cr(translations)) );
     QString hyphDir = exeDir + "hyph" + QDir::separator();
diff --git a/cr3qt/src/settings.cpp b/cr3qt/src/settings.cpp
index 11b53bc..e2ecf48 100644
--- a/cr3qt/src/settings.cpp
+++ b/cr3qt/src/settings.cpp
@@ -84,6 +84,10 @@ SettingsDlg::SettingsDlg(QWidget *parent, CR3View * docView ) :
 
     m_oldHyph = cr2qt(HyphMan::getSelectedDictionary()->getId());
 
+#ifdef __HAIKU__
+	QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/config/settings/cr3/");
+	QString exeDir = QString(CR3_DATA_DIR);
+#else
 #ifdef _LINUX
     QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/.cr3/");
 #else
@@ -96,6 +100,7 @@ SettingsDlg::SettingsDlg(QWidget *parent, CR3View * docView ) :
 #else
     QString exeDir = QDir::toNativeSeparators(qApp->applicationDirPath() + "/"); //QDir::separator();
 #endif
+#endif
 
     lString16Collection baseDirs;
     baseDirs.add(qt2cr(homeDir));
@@ -176,7 +181,7 @@ SettingsDlg::SettingsDlg(QWidget *parent, CR3View * docView ) :
     m_ui->cbBookmarkHighlightMode->setCurrentIndex(highlight);
 
 
-    int n = m_props->getIntDef( PROP_PAGE_MARGIN_LEFT, 8 );
+    int n = m_props->getIntDef( PROP_PAGE_MARGIN_LEFT, 30 );
     int mi = 0;
     for (int i=0; i <  (int)MAX_MARGIN_INDEX; i++) {
         if (n <= def_margins[i]) {
@@ -212,6 +217,9 @@ SettingsDlg::SettingsDlg(QWidget *parent, CR3View * docView ) :
     
     const char * defFontFace = "DejaVu Sans";
     static const char * goodFonts[] = {
+#ifdef __HAIKU__
+		"Noto Sans",
+#endif
         "DejaVu Sans",
         "FreeSans",
         "Liberation Sans",
diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp
index c84883a..c480b2c 100644
--- a/crengine/src/lvdocview.cpp
+++ b/crengine/src/lvdocview.cpp
@@ -87,9 +87,9 @@ const char
 					"body[name=\"notes\"]  section[id] empty-line { display: inline }\n"
 					"code, pre { display: block; white-space: pre; font-family: \"Courier New\", monospace }\n";
 
-static const char * DEFAULT_FONT_NAME = "Arial, DejaVu Sans"; //Times New Roman";
+static const char * DEFAULT_FONT_NAME = "Arial, Noto Sans, DejaVu Sans"; //Times New Roman";
 static const char * DEFAULT_STATUS_FONT_NAME =
-		"Arial Narrow, Arial, DejaVu Sans"; //Times New Roman";
+		"Arial Narrow, Arial, Noto Sans, DejaVu Sans"; //Times New Roman";
 static css_font_family_t DEFAULT_FONT_FAMILY = css_ff_sans_serif;
 //    css_ff_serif,
 //    css_ff_sans_serif,
@@ -5625,7 +5625,7 @@ void LVDocView::propsUpdateDefaults(CRPropRef props) {
 	props->setIntDef(PROP_DISPLAY_TURBO_UPDATE_MODE, 0);
 
 	lString8 defFontFace;
-	static const char * goodFonts[] = { "DejaVu Sans", "FreeSans",
+	static const char * goodFonts[] = { "Noto Sans", "DejaVu Sans", "FreeSans",
 			"Liberation Sans", "Arial", "Verdana", NULL };
 	for (int i = 0; goodFonts[i]; i++) {
 		if (list.contains(lString16(goodFonts[i]))) {
-- 
2.13.1

