From fc5607a9172da9a508279fe7a35543315b10748c Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 10 Feb 2021 21:54:35 +1000
Subject: Fixes for Haiku


diff --git a/SimulIDE.pro b/SimulIDE.pro
index a4b382f..ead046c 100644
--- a/SimulIDE.pro
+++ b/SimulIDE.pro
@@ -25,6 +25,10 @@ TEMPLATE = app
 
 TARGET = simulide
 
+haiku {
+	TARGET = SimulIDE
+}
+
 QT += svg
 QT += xml
 QT += script
@@ -189,6 +193,11 @@ linux {
     QMAKE_LIBS += -lelf
     QMAKE_LFLAGS += -no-pie
 }
+haiku {
+    OS = Haiku
+    QMAKE_LIBS += -lelf -lnetwork -lbsd
+    QMAKE_LFLAGS += -no-pie
+}
 macx {
     OS = MacOs
     INCLUDEPATH += \
@@ -231,6 +240,17 @@ win32 | linux {
         $(COPY_DIR) ../resources/icons             $$TARGET_PREFIX/share ; \
         $(MOVE)     ../resources/translations/*.qm $$TARGET_PREFIX/share/simulide/translations ;
 }
+haiku {
+    DESTDIR = $$TARGET_PREFIX 
+    mkpath( $$TARGET_PREFIX )
+    copy2dest.commands = \
+        $(MKDIR)    $$TARGET_PREFIX/data ; \
+        $(MKDIR)    $$TARGET_PREFIX/examples ; \
+        $(MKDIR)    $$TARGET_PREFIX/translations ; \
+        $(COPY_DIR) ../resources/data              $$TARGET_PREFIX ; \
+        $(COPY_DIR) ../resources/examples          $$TARGET_PREFIX ; \
+        $(MOVE)     ../resources/translations/*.qm $$TARGET_PREFIX/translations ;
+}
 macx {
     QMAKE_CC = gcc-10
     QMAKE_CXX = g++-10
diff --git a/src/gui/componentselector/componentselector.cpp b/src/gui/componentselector/componentselector.cpp
index f2dd1d9..64f6066 100644
--- a/src/gui/componentselector/componentselector.cpp
+++ b/src/gui/componentselector/componentselector.cpp
@@ -141,7 +141,11 @@ void ComponentSelector::loadXml( const QString &setFile )
                 if( element.hasAttribute("icon") )
                 {
                     QDir compSetDir( qApp->applicationDirPath() );
+#ifdef Q_OS_HAIKU
+                    compSetDir.cd( "./data/images" );
+#else
                     compSetDir.cd( "../share/simulide/data/images" );
+#endif
                     icon = compSetDir.absoluteFilePath( element.attribute("icon") );
                 }
                 QString name = element.attribute( "name" );
diff --git a/src/gui/editorwidget/codeeditor.cpp b/src/gui/editorwidget/codeeditor.cpp
index 828cc33..b32c7ff 100644
--- a/src/gui/editorwidget/codeeditor.cpp
+++ b/src/gui/editorwidget/codeeditor.cpp
@@ -80,8 +80,11 @@ CodeEditor::CodeEditor( QWidget* parent, OutPanelText* outPane )
     m_properties = false;
 
     m_help = "";
-    
+#ifdef Q_OS_HAIKU
+	m_font.setFamily("Noto Sans Mono");
+#else
     m_font.setFamily("Monospace");
+#endif
     m_font.setFixedPitch( true );
     m_font.setPixelSize( m_fontSize );
     setFont( m_font );
diff --git a/src/gui/editorwidget/inodebugger.cpp b/src/gui/editorwidget/inodebugger.cpp
index 46700d7..1752749 100644
--- a/src/gui/editorwidget/inodebugger.cpp
+++ b/src/gui/editorwidget/inodebugger.cpp
@@ -34,8 +34,12 @@ InoDebugger::InoDebugger( QObject* parent, OutPanelText* outPane, QString filePa
     Q_UNUSED( InoDebugger_properties );
     
     setObjectName( "Arduino Compiler/Debugger" );
-    
-    m_compilerPath = "";
+
+#ifdef Q_OS_HAIKU    
+    m_compilerPath = "/system/apps/Arduino/";
+#else
+	m_compilerPath = "";
+#endif
     m_compSetting = "arduino_Path";
     
     readSettings();
@@ -150,7 +154,11 @@ int InoDebugger::compile()
     /// , then debugger will hang!
     QString cBuildPath = buildPath;
     QString preferencesPath = SIMUAPI_AppPath::self()->availableDataFilePath("codeeditor/preferences.txt");
+#ifdef Q_OS_HAIKU
+	QString command  = m_compilerPath +"arduino.sh";
+#else
     QString command  = m_compilerPath +"arduino";
+#endif
     
     #ifndef Q_OS_UNIX
     command    += "_debug";
@@ -167,7 +175,11 @@ int InoDebugger::compile()
     command += " -v --board arduino:avr:"+boardName+" --pref build.path=" + cBuildPath;
     if( !preferencesPath.isEmpty() )
         command += " --preferences-file " + preferencesPath;
+#ifdef Q_OS_HAIKU
+	command += " --pref preproc.save_build_files=true --verify " + ProcInoFile;
+#else
     command += " --preserve-temp-files --verify " + ProcInoFile;
+#endif
     m_firmware = "";
     
     m_outPane->appendText( command );
@@ -204,6 +216,10 @@ int InoDebugger::compile()
     else
     {
         m_firmware = buildPath + "/"+ m_fileName + ".ino.hex";
+#ifdef Q_OS_HAIKU
+    	QString cmd = "cp " + cBuildPath + "/*.hex " + m_firmware;
+    	system(cmd.toUtf8().data());
+#endif
         error = 0;
     }
     QApplication::restoreOverrideCursor();
diff --git a/src/main.cpp b/src/main.cpp
index 523e084..fe4df10 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,7 +25,11 @@
 
 QString langFile( QString locale )
 {
+#ifdef Q_OS_HAIKU
+ 	QString langF = "./translations/simulide_"+locale+".qm";
+#else
     QString langF = "../share/simulide/translations/simulide_"+locale+".qm";
+#endif
 
     QFile file( langF );
     if( !file.exists() ) langF = "";
@@ -59,7 +63,11 @@ int main(int argc, char *argv[])
     //QApplication::setGraphicsSystem( "raster" );//native, raster, opengl
     QApplication app( argc, argv );
 
+#ifdef Q_OS_HAIKU
+	QSettings settings( QStandardPaths::standardLocations( QStandardPaths::AppConfigLocation).first()+"/simulide.ini",  QSettings::IniFormat, 0l );
+#else
     QSettings settings( QStandardPaths::standardLocations( QStandardPaths::DataLocation).first()+"/simulide.ini",  QSettings::IniFormat, 0l );
+#endif
 
     QString locale = QLocale::system().name();
     if( settings.contains( "language" ) ) locale = settings.value( "language" ).toString();
@@ -70,7 +78,11 @@ int main(int argc, char *argv[])
         locale = QLocale::system().name().split("_").first();
         langF = langFile( locale );
     }
+#ifdef Q_OS_HAIKU
+	if( langF == "" ) langF = "./translations/simulide_en.qm";
+#else
     if( langF == "" ) langF = "../share/simulide/translations/simulide_en.qm";
+#endif
     
     QTranslator translator;
     translator.load( langF );
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 911fba1..3d98626 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -33,7 +33,11 @@ MainWindow* MainWindow::m_pSelf = 0l;
 
 MainWindow::MainWindow()
           : QMainWindow()
+#ifdef Q_OS_HAIKU
+          , m_settings( QStandardPaths::standardLocations( QStandardPaths::AppConfigLocation).first()+"/simulide.ini",  QSettings::IniFormat, this )
+#else
           , m_settings( QStandardPaths::standardLocations( QStandardPaths::DataLocation).first()+"/simulide.ini", QSettings::IniFormat, this )
+#endif
 {
     setWindowIcon( QIcon(":/simulide.png") );
     m_pSelf   = this;
diff --git a/src/simuapi_apppath.cpp b/src/simuapi_apppath.cpp
index 8fcd2fe..c0315a8 100644
--- a/src/simuapi_apppath.cpp
+++ b/src/simuapi_apppath.cpp
@@ -31,6 +31,17 @@ SIMUAPI_AppPath *SIMUAPI_AppPath::self()
     return m_pSelf;
 }
 
+#ifdef Q_OS_HAIKU
+SIMUAPI_AppPath::SIMUAPI_AppPath()
+               : m_ROExamFolder( qApp->applicationDirPath() )
+               , m_RODataFolder( qApp->applicationDirPath() )
+               , m_RWDataFolder( QStandardPaths::writableLocation( QStandardPaths::AppConfigLocation ))
+{
+    m_ROExamFolder.cd( "./examples" );
+    m_RODataFolder.cd( "./data" );
+    m_RWDataFolder.cd( "data" );
+}
+#else
 SIMUAPI_AppPath::SIMUAPI_AppPath()
                : m_ROExamFolder( qApp->applicationDirPath() )
                , m_RODataFolder( qApp->applicationDirPath() )
@@ -40,6 +51,7 @@ SIMUAPI_AppPath::SIMUAPI_AppPath()
     m_RODataFolder.cd( "../share/simulide/data" );
     m_RWDataFolder.cd( "data" );
 }
+#endif
 
 QDir SIMUAPI_AppPath::RWDataFolder() const
 {
-- 
2.30.0


From 410e9e21f148093174d749b46bc3009d01952f58 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 10 Feb 2021 21:54:53 +1000
Subject: Add haiku svg icons


diff --git a/src/application.qrc b/src/application.qrc
index 87a60ce..9b20c62 100644
--- a/src/application.qrc
+++ b/src/application.qrc
@@ -4,64 +4,64 @@
         
         <file alias="simulide.png">../src/icons/simulide.png</file>
         <file alias="null-0.png">../src/icons/components/null-0.png</file>
-        <file alias="newcirc.png">../src/icons/mainwindow/new.png</file>
-        <file alias="opencirc.png">../src/icons/mainwindow/open.png</file>
-        <file alias="savecirc.png">../src/icons/mainwindow/save.png</file>
-        <file alias="savecircas.png">../src/icons/mainwindow/saveas.png</file>
-        <file alias="help.png">../src/icons/mainwindow/help.png</file>
-        <file alias="about.png">../src/icons/mainwindow/about.png</file>
-        
-        <file alias="new.png">../src/icons/mainwindow/new.png</file>
-        <file alias="open.png">../src/icons/mainwindow/open.png</file>
-        <file alias="save.png">../src/icons/mainwindow/save.png</file>
-        <file alias="saveas.png">../src/icons/mainwindow/saveas.png</file>
-        
-        <file alias="cut.png">../src/icons/mainwindow/cut.png</file>
-        <file alias="copy.png">../src/icons/mainwindow/copy.png</file>
-        <file alias="paste.png">../src/icons/mainwindow/paste.png</file>
-        
-        <file alias="cdup.png">../src/icons/mainwindow/cdup.png</file>
-        <file alias="undo.png">../src/icons/mainwindow/rotateCCW.png</file>
-        <file alias="redo.png">../src/icons/mainwindow/rotateCW.png</file>
-        <file alias="find.png">../src/icons/mainwindow/find.png</file>
-        
-        <file alias="compile.png">../src/icons/mainwindow/verify.png</file>
-        <file alias="setroot.png">../src/icons/mainwindow/verify.png</file>
-        
-        <file alias="finish.png">../src/icons/mainwindow/finish.png</file>
-        <file alias="step.png">../src/icons/mainwindow/step.png</file>
-        <file alias="stepover.png">../src/icons/mainwindow/stepover.png</file>
-        <file alias="play.png">../src/icons/mainwindow/play.png</file>
-        <file alias="runtobk.png">../src/icons/mainwindow/runtobk.png</file>
-        <file alias="pause.png">../src/icons/mainwindow/pause.png</file>
-        <file alias="reset.png">../src/icons/mainwindow/reset.png</file>
-        <file alias="stop.png">../src/icons/mainwindow/stop.png</file>
-        
-        <file alias="poweroff.png">../src/icons/mainwindow/poweroff.png</file>
-        <file alias="poweron.png">../src/icons/mainwindow/poweron.png</file>
-        <file alias="powerdeb.png">../src/icons/mainwindow/powerdeb.png</file>
-        <file alias="pausesim.png">../src/icons/mainwindow/pausesim.png</file>
-        
-        <file alias="remove.png">../src/icons/mainwindow/remove.png</file>
-        <file alias="properties.png">../src/icons/mainwindow/properties.png</file>
-        <file alias="rotateCW.png">../src/icons/mainwindow/rotateCW.png</file>
-        <file alias="rotateCCW.png">../src/icons/mainwindow/rotateCCW.png</file>
-        <file alias="rotate180.png">../src/icons/mainwindow/rotate180.png</file>
-        <file alias="hflip.png">../src/icons/mainwindow/hflip.png</file>
-        <file alias="vflip.png">../src/icons/mainwindow/vflip.png</file>
-        <file alias="load.png">../src/icons/mainwindow/load.png</file>
-        <file alias="lastfiles.png">../src/icons/mainwindow/lastfiles.png</file>
-        <file alias="reload.png">../src/icons/mainwindow/reload.png</file>
-        <file alias="terminal.png">../src/icons/mainwindow/terminal.png</file>
-        <file alias="closeterminal.png">../src/icons/mainwindow/closeterminal.png</file>
-        <file alias="saveimage.png">../src/icons/mainwindow/saveimage.png</file>
-        
-        <file alias="rename.png">../src/icons/mainwindow/rename.png</file>
+        <file alias="newcirc.png">../src/icons/mainwindow/new.svg</file>
+        <file alias="opencirc.png">../src/icons/mainwindow/open.svg</file>
+        <file alias="savecirc.png">../src/icons/mainwindow/save.svg</file>
+        <file alias="savecircas.png">../src/icons/mainwindow/saveas.svg</file>
+        <file alias="help.png">../src/icons/mainwindow/help.svg</file>
+        <file alias="about.png">../src/icons/mainwindow/about.svg</file>
+        
+        <file alias="new.png">../src/icons/mainwindow/new.svg</file>
+        <file alias="open.png">../src/icons/mainwindow/open.svg</file>
+        <file alias="save.png">../src/icons/mainwindow/save.svg</file>
+        <file alias="saveas.png">../src/icons/mainwindow/saveas.svg</file>
+        
+        <file alias="cut.png">../src/icons/mainwindow/cut.svg</file>
+        <file alias="copy.png">../src/icons/mainwindow/copy.svg</file>
+        <file alias="paste.png">../src/icons/mainwindow/paste.svg</file>
+        
+        <file alias="cdup.png">../src/icons/mainwindow/cdup.svg</file>
+        <file alias="undo.png">../src/icons/mainwindow/undo.svg</file>
+        <file alias="redo.png">../src/icons/mainwindow/redo.svg</file>
+        <file alias="find.png">../src/icons/mainwindow/find.svg</file>
+        
+        <file alias="compile.png">../src/icons/mainwindow/verify.svg</file>
+        <file alias="setroot.png">../src/icons/mainwindow/verify.svg</file>
+        
+        <file alias="finish.png">../src/icons/mainwindow/finish.svg</file>
+        <file alias="step.png">../src/icons/mainwindow/step.svg</file>
+        <file alias="stepover.png">../src/icons/mainwindow/stepover.svg</file>
+        <file alias="play.png">../src/icons/mainwindow/play.svg</file>
+        <file alias="runtobk.png">../src/icons/mainwindow/runtobk.svg</file>
+        <file alias="pause.png">../src/icons/mainwindow/pause.svg</file>
+        <file alias="reset.png">../src/icons/mainwindow/reset.svg</file>
+        <file alias="stop.png">../src/icons/mainwindow/stop.svg</file>
+        
+        <file alias="poweroff.png">../src/icons/mainwindow/poweroff.svg</file>
+        <file alias="poweron.png">../src/icons/mainwindow/poweron.svg</file>
+        <file alias="powerdeb.png">../src/icons/mainwindow/powerdeb.svg</file>
+        <file alias="pausesim.png">../src/icons/mainwindow/pausesim.svg</file>
+        
+        <file alias="remove.png">../src/icons/mainwindow/remove.svg</file>
+        <file alias="properties.png">../src/icons/mainwindow/properties.svg</file>
+        <file alias="rotateCW.png">../src/icons/mainwindow/rotateCW.svg</file>
+        <file alias="rotateCCW.png">../src/icons/mainwindow/rotateCCW.svg</file>
+        <file alias="rotate180.png">../src/icons/mainwindow/rotate180.svg</file>
+        <file alias="hflip.png">../src/icons/mainwindow/hflip.svg</file>
+        <file alias="vflip.png">../src/icons/mainwindow/vflip.svg</file>
+        <file alias="load.png">../src/icons/mainwindow/load.svg</file>
+        <file alias="lastfiles.png">../src/icons/mainwindow/lastfiles.svg</file>
+        <file alias="reload.png">../src/icons/mainwindow/reload.svg</file>
+        <file alias="terminal.png">../src/icons/mainwindow/terminal.svg</file>
+        <file alias="closeterminal.png">../src/icons/mainwindow/closeterminal.svg</file>
+        <file alias="saveimage.png">../src/icons/mainwindow/saveimage.svg</file>
+        
+        <file alias="rename.png">../src/icons/mainwindow/rename.svg</file>
         <file alias="invert.png">../src/icons/mainwindow/invert.png</file>
         <file alias="unuse.png">../src/icons/mainwindow/unuse.png</file>
         
-        <file alias="breakpoint.png">../src/icons/mainwindow/breakpoint.png</file>
-        <file alias="nobreakpoint.png">../src/icons/mainwindow/nobreakpoint.png</file>
+        <file alias="breakpoint.png">../src/icons/mainwindow/breakpoint.svg</file>
+        <file alias="nobreakpoint.png">../src/icons/mainwindow/nobreakpoint.svg</file>
     
         <file alias="led.png">../src/icons/components/led.png</file>
         <file alias="diode.png">../src/icons/components/diode.png</file>
-- 
2.30.0

