From 65583a54ae5cb931ea4a8e58de515ba85447eb43 Mon Sep 17 00:00:00 2001 From: DreamNik Date: Wed, 26 Oct 2022 20:27:21 +0300 Subject: [PATCH] fix cross-compilation errors for Android --- CMakeLists.txt | 57 ++++++--- cmake/modules/CPM.cmake | 2 +- cmake/modules/CodeCoverage.cmake | 2 +- cmake/stellarium.iss.cmake | 55 ++++---- cmake/stellarium.rc.cmake | 2 +- data/CMakeLists.txt | 22 +++- ...cations.bin.gz => base_locations.bin.gzip} | Bin data/ssystem_major.ini | 4 +- doc/CMakeLists.txt | 16 +-- models/CMakeLists.txt | 2 +- models/{m1phobos.obj.gz => m1phobos.obj.gzip} | Bin models/{m2deimos.obj.gz => m2deimos.obj.gzip} | Bin plugins/Satellites/src/gsatellite/gTime.cpp | 6 +- .../src/ASCOM/ASCOMDevice.cpp | 9 +- .../CMakeLists.txt | 2 +- po/stellarium-remotecontrol/CMakeLists.txt | 2 +- po/stellarium-scripts/CMakeLists.txt | 2 +- po/stellarium-skycultures/CMakeLists.txt | 2 +- po/stellarium/CMakeLists.txt | 4 +- scenery3d/Sterngarten/CMakeLists.txt | 2 +- scenery3d/Testscene/CMakeLists.txt | 2 +- src/CMakeLists.txt | 20 ++- src/StelLogger.cpp | 8 +- src/StelMainView.cpp | 40 +++--- src/StelMainView.hpp | 10 +- src/StelSplashScreen.cpp | 37 +++++- src/core/Dithering.cpp | 13 +- src/core/StelApp.hpp | 2 +- src/core/StelFileMgr.cpp | 119 +++++++----------- src/core/StelLocationMgr.cpp | 4 +- src/core/StelModuleMgr.cpp | 22 +++- src/core/StelOBJ.cpp | 2 +- src/core/modules/AtmosphereShowMySky.cpp | 2 +- src/core/modules/StarMgr.cpp | 11 +- src/core/planetsephems/jpleph.cpp | 2 + src/external/CMakeLists.txt | 24 ++-- src/gui/StelGui.cpp | 2 + src/main.cpp | 33 ++++- src/scripting/StelScriptMgr.cpp | 3 + 39 files changed, 334 insertions(+), 213 deletions(-) rename data/{base_locations.bin.gz => base_locations.bin.gzip} (100%) rename models/{m1phobos.obj.gz => m1phobos.obj.gzip} (100%) rename models/{m2deimos.obj.gz => m2deimos.obj.gzip} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e92cbf2616d77..c34b702976d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ SET(CMAKE_WARN_DEPRECATED 1) SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) +SET( QT_ANDROID_APPLICATION_BINARY stellarium ) +SET( ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android ) + ########### Project name ########### PROJECT(Stellarium C CXX) @@ -124,7 +127,7 @@ ELSE() ENDIF() # Use customized cmake macros -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) INCLUDE(CPM) # Show platform info @@ -381,6 +384,9 @@ IF(ENABLE_LTO) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_FLAGS}") ENDIF() +ELSEIF(UNIX) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") ENDIF() ########### Others ########### @@ -425,9 +431,9 @@ ENDIF() IF(ENABLE_SPOUT) ADD_DEFINITIONS(-DENABLE_SPOUT) IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") # 32bit build? - SET(SPOUT_PATH_HINT ${CMAKE_SOURCE_DIR}/util/spout2/Win32/) + SET(SPOUT_PATH_HINT ${PROJECT_SOURCE_DIR}/util/spout2/Win32/) ELSEIF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") # 64bit build? - SET(SPOUT_PATH_HINT ${CMAKE_SOURCE_DIR}/util/spout2/x64/) + SET(SPOUT_PATH_HINT ${PROJECT_SOURCE_DIR}/util/spout2/x64/) ENDIF() # make sure the .lib file is used, otherwise MinGW will try the .dll directly and fails to link @@ -441,7 +447,7 @@ IF(ENABLE_SPOUT) # try to find the .dll for automatic copy GET_FILENAME_COMPONENT(SPOUT_LIBRARY_DIR ${SPOUT_LIBRARY} DIRECTORY) SET(SPOUT_LIBRARY_DLL ${SPOUT_LIBRARY_DIR}/SpoutLibrary.dll CACHE FILEPATH "The path to the Spout .dll file") - SET(SPOUT_LIBRARY_LICENCE ${CMAKE_SOURCE_DIR}/util/spout2/licence.txt CACHE FILEPATH "The path to the Spout licence file") + SET(SPOUT_LIBRARY_LICENCE ${PROJECT_SOURCE_DIR}/util/spout2/licence.txt CACHE FILEPATH "The path to the Spout licence file") IF(NOT EXISTS ${SPOUT_LIBRARY_DLL}) UNSET(SPOUT_LIBRARY_DLL) @@ -483,14 +489,14 @@ SET(GENERATE_PACKAGE_TARGET 1 CACHE BOOL "Set to 1 or true if you want to have m # On WIN32 we need to split the main binary into a small binary and a dll # This is for allowing to link dynamic plug-ins afterward # It does not seem to work with MSVC, so I disable it for the moment. -IF(WIN32 AND NOT MSVC) +IF( (WIN32 AND (NOT MSVC)) OR UNIX OR ANDROID ) SET(GENERATE_STELMAINLIB 1) ELSE() SET(GENERATE_STELMAINLIB 0) ENDIF() ########### User Guide ############### -IF(EXISTS "${CMAKE_SOURCE_DIR}/guide/guide.pdf") +IF(EXISTS "${PROJECT_SOURCE_DIR}/guide/guide.pdf") MESSAGE(STATUS "Found Stellarium User Guide") INSTALL(FILES guide/guide.pdf DESTINATION ${SDATALOC}/guide) SET(ISS_GUIDE "Name: \"{group}\\{cm:UserGuide}\"; Filename: \"{app}\\guide\\guide.pdf\"") @@ -609,6 +615,19 @@ IF(WIN32) ENDIF() ENDIF() +IF(ANDROID) +# FIND_PACKAGE( Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS AndroidExtras ) + + FIND_FILE(OPENSSL_SSL_LIBRARY_DLL libssl_1_1.so) + FIND_FILE(OPENSSL_CRYPTO_LIBRARY_DLL libcrypto_1_1.so) + + IF( (EXISTS ${OPENSSL_SSL_LIBRARY_DLL}) AND (EXISTS ${OPENSSL_CRYPTO_LIBRARY_DLL}) ) + SET( ANDROID_EXTRA_LIBS ${OPENSSL_SSL_LIBRARY_DLL} ${OPENSSL_CRYPTO_LIBRARY_DLL} CACHE INTERNAL "" ) + ELSE() + message( "OpenSSL libraries not found" ) + ENDIF() +ENDIF() + IF(APPLE) IF(${QT_VERSION_MAJOR} EQUAL 6) FIND_PACKAGE(Qt${QT_VERSION_MAJOR} COMPONENTS DBus REQUIRED) @@ -781,7 +800,7 @@ ENDIF() IF(NOT USE_SYSTEM_ZLIB) #use our own zlib - MESSAGE(STATUS "Using bundled zlib version at ${CMAKE_SOURCE_DIR}/src/external/zlib") + MESSAGE(STATUS "Using bundled zlib version at ${PROJECT_SOURCE_DIR}/src/external/zlib") SET(ZLIB_LIBRARIES zlib_stel) ELSE() MESSAGE(STATUS "Using system-provided zlib at ${ZLIB_LIBRARIES}") @@ -821,10 +840,10 @@ ELSE() ADD_DEFINITIONS(-DINSTALL_DATADIR=".") ADD_DEFINITIONS(-DINSTALL_LOCALEDIR="./locale") ENDIF() -# For not installed debug builds with build directory path that not match sources directory path ${PROJECT_BINARY_DIR} != ${CMAKE_SOURCE_DIR} +# For not installed debug builds with build directory path that not match sources directory path ${PROJECT_BINARY_DIR} != ${PROJECT_SOURCE_DIR} IF(CMAKE_BUILD_TYPE STREQUAL "Debug") - ADD_DEFINITIONS(-DINSTALL_DATADIR_FOR_DEBUG="${CMAKE_SOURCE_DIR}") - ADD_DEFINITIONS(-DINSTALL_LOCALEDIR_FOR_DEBUG="${CMAKE_SOURCE_DIR}") + ADD_DEFINITIONS(-DINSTALL_DATADIR_FOR_DEBUG="${PROJECT_SOURCE_DIR}") + ADD_DEFINITIONS(-DINSTALL_LOCALEDIR_FOR_DEBUG="${PROJECT_SOURCE_DIR}") ENDIF() IF(WIN32) @@ -845,7 +864,7 @@ IF(WIN32) SET(WINDOWS_PACKAGE_VERSION "${VERSION}.0") SET(PACKAGE_VERSION_RC "${WINDOWS_PACKAGE_VERSION}") STRING(REGEX REPLACE "([.]+)" "," PACKAGE_VERSION_RC ${PACKAGE_VERSION_RC}) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/stellarium.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/stellarium.rc @ONLY) + CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/stellarium.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/stellarium.rc @ONLY) ####################################################### ### [Optional] Embed icon in the Windows executable @@ -906,7 +925,7 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebI ADD_DEFINITIONS(-DNDEBUG) ENDIF() -CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/default_cfg.ini.cmake ${CMAKE_SOURCE_DIR}/data/default_cfg.ini @ONLY) +CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/default_cfg.ini.cmake ${PROJECT_SOURCE_DIR}/data/default_cfg.ini @ONLY) ########### uninstall files ############### CONFIGURE_FILE( @@ -961,7 +980,7 @@ IF(APPLE) SET(PACKAGE_OSX_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET}) ADD_DEFINITIONS(-DPACKAGE_OSX_TARGET) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Info.plist.cmake ${CMAKE_SOURCE_DIR}/data/Info.plist @ONLY) + CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/Info.plist.cmake ${PROJECT_SOURCE_DIR}/data/Info.plist @ONLY) GET_FILENAME_COMPONENT(_qt_bin_dir "${QMAKE_LOCATION}" DIRECTORY) FIND_PROGRAM(MACDEPLOYQT_COMMAND macdeployqt HINTS "${_qt_bin_dir}") @@ -1015,12 +1034,12 @@ ENDIF() # This will be used for all compilations in sub-directories INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/core - ${CMAKE_SOURCE_DIR}/src/core/modules - ${CMAKE_SOURCE_DIR}/src/core/planetsephems - ${CMAKE_SOURCE_DIR}/src/gui - ${CMAKE_SOURCE_DIR}/src/scripting + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src/core/modules + ${PROJECT_SOURCE_DIR}/src/core/planetsephems + ${PROJECT_SOURCE_DIR}/src/gui + ${PROJECT_SOURCE_DIR}/src/scripting ${INTL_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/src ) diff --git a/cmake/modules/CPM.cmake b/cmake/modules/CPM.cmake index 70aebf10a6d45..45f98f602019c 100644 --- a/cmake/modules/CPM.cmake +++ b/cmake/modules/CPM.cmake @@ -1113,7 +1113,7 @@ function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT) string(APPEND PRETTY_OUT_VAR "#") endif() if(${oneArgName} STREQUAL "SOURCE_DIR") - string(REPLACE ${CMAKE_SOURCE_DIR} "\${CMAKE_SOURCE_DIR}" CPM_ARGS_${oneArgName} + string(REPLACE ${PROJECT_SOURCE_DIR} "\${PROJECT_SOURCE_DIR}" CPM_ARGS_${oneArgName} ${CPM_ARGS_${oneArgName}} ) endif() diff --git a/cmake/modules/CodeCoverage.cmake b/cmake/modules/CodeCoverage.cmake index f74b9f150770f..f7683c71faa4b 100644 --- a/cmake/modules/CodeCoverage.cmake +++ b/cmake/modules/CodeCoverage.cmake @@ -74,7 +74,7 @@ include(CMakeParseArguments) find_program( GCOV_PATH gcov ) find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl) find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat ) -find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test) +find_program( GCOVR_PATH gcovr PATHS ${PROJECT_SOURCE_DIR}/scripts/test) find_program( SIMPLE_PYTHON_EXECUTABLE python ) if(NOT GCOV_PATH) diff --git a/cmake/stellarium.iss.cmake b/cmake/stellarium.iss.cmake index df2d47e9ed1e9..7eb5acf3b6c06 100644 --- a/cmake/stellarium.iss.cmake +++ b/cmake/stellarium.iss.cmake @@ -3,12 +3,12 @@ ; @ISS_AUTOGENERATED_WARNING@ [Setup] -@ISS_ARCHITECTURE_SPECIFIC@ +@ISS_ARCHITECTURE_SPECIFIC@ DisableStartupPrompt=yes DisableDirPage=no DisableProgramGroupPage=no -WizardSmallImageFile=@CMAKE_SOURCE_DIR@\data\icon.bmp -WizardImageFile=@CMAKE_SOURCE_DIR@\data\splash.bmp +WizardSmallImageFile=@PROJECT_SOURCE_DIR@\data\icon.bmp +WizardImageFile=@PROJECT_SOURCE_DIR@\data\splash.bmp WizardImageStretch=no WizardImageBackColor=clBlack AppName=Stellarium @@ -21,13 +21,13 @@ AppSupportURL=@STELLARIUM_URL@ AppUpdatesURL=@STELLARIUM_URL@ VersionInfoVersion=@WINDOWS_PACKAGE_VERSION@ MinVersion=0,@ISS_MIN_WIN_VERSION@ -SetupIconFile=@CMAKE_SOURCE_DIR@\data\@PACKAGE_ICON@.ico +SetupIconFile=@PROJECT_SOURCE_DIR@\data\@PACKAGE_ICON@.ico OutputBaseFilename=stellarium-@ISS_PACKAGE_VERSION@-@ISS_PACKAGE_PLATFORM@ -OutputDir=@CMAKE_SOURCE_DIR@\installers +OutputDir=@PROJECT_SOURCE_DIR@\installers DefaultDirName={pf}\Stellarium DefaultGroupName=Stellarium UninstallDisplayIcon={app}\data\stellarium.ico -LicenseFile=@CMAKE_SOURCE_DIR@\COPYING +LicenseFile=@PROJECT_SOURCE_DIR@\COPYING ChangesAssociations=yes ; LZMA2/ultra required 356 MB RAM for compression and 32 MB RAM for decompression Compression=lzma2/ultra @@ -35,12 +35,12 @@ Compression=lzma2/ultra [Files] Source: "@CMAKE_INSTALL_PREFIX@\bin\stellarium.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "@CMAKE_INSTALL_PREFIX@\bin\*.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "@CMAKE_SOURCE_DIR@\data\stellarium.url"; DestDir: "{app}"; Flags: ignoreversion -Source: "@CMAKE_SOURCE_DIR@\data\stellarium-devdocs.url"; DestDir: "{app}"; Flags: ignoreversion -Source: "@CMAKE_SOURCE_DIR@\data\qt.conf"; DestDir: "{app}"; Flags: ignoreversion -Source: "@CMAKE_SOURCE_DIR@\*.md"; DestDir: "{app}"; Flags: ignoreversion -Source: "@CMAKE_SOURCE_DIR@\COPYING"; DestDir: "{app}"; Flags: ignoreversion; DestName: "GPL.txt" -Source: "@CMAKE_SOURCE_DIR@\ChangeLog"; DestDir: "{app}"; Flags: ignoreversion; DestName: "ChangeLog.txt" +Source: "@PROJECT_SOURCE_DIR@\data\stellarium.url"; DestDir: "{app}"; Flags: ignoreversion +Source: "@PROJECT_SOURCE_DIR@\data\stellarium-devdocs.url"; DestDir: "{app}"; Flags: ignoreversion +Source: "@PROJECT_SOURCE_DIR@\data\qt.conf"; DestDir: "{app}"; Flags: ignoreversion +Source: "@PROJECT_SOURCE_DIR@\*.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "@PROJECT_SOURCE_DIR@\COPYING"; DestDir: "{app}"; Flags: ignoreversion; DestName: "GPL.txt" +Source: "@PROJECT_SOURCE_DIR@\ChangeLog"; DestDir: "{app}"; Flags: ignoreversion; DestName: "ChangeLog.txt" ; Qt stuff Source: "@CMAKE_INSTALL_PREFIX@\qtstuff\*"; DestDir: "{app}\"; Flags: recursesubdirs ignoreversion ; Stellarium's stuff @@ -77,7 +77,7 @@ Name: "{group}\Stellarium"; Filename: "{app}\stellarium.exe"; WorkingDir: "{app} #if "Qt5_@Qt5_FOUND@" == "Qt5_1" Name: "{group}\Stellarium {cm:AngleMode}"; Filename: "{app}\stellarium.exe"; Parameters: "--angle-d3d9"; WorkingDir: "{app}"; IconFilename: "{app}\data\stellarium.ico" Name: "{group}\Stellarium {cm:AngleD3D11Mode}"; Filename: "{app}\stellarium.exe"; Parameters: "--angle-d3d11"; WorkingDir: "{app}"; IconFilename: "{app}\data\stellarium.ico" -#else +#else Name: "{group}\Stellarium {cm:SingleBuffer}"; Filename: "{app}\stellarium.exe"; Parameters: "--single-buffer"; WorkingDir: "{app}"; IconFilename: "{app}\data\stellarium.ico" #endif Name: "{group}\Stellarium {cm:MesaMode}"; Filename: "{app}\stellarium.exe"; Parameters: "--mesa-mode"; WorkingDir: "{app}"; IconFilename: "{app}\data\stellarium.ico" @@ -121,35 +121,32 @@ Root: HKCR; Subkey: "Stellarium.Script\shell\open\command"; ValueType: string; V ; Recommended use Inno Setup 5.5.3+ [Languages] ; Official translations of GUI of Inno Setup + translation Stellarium specific lines -Name: "en"; MessagesFile: "compiler:Default.isl,@CMAKE_SOURCE_DIR@\util\ISL\EnglishCM.isl" -Name: "ca"; MessagesFile: "compiler:Languages\Catalan.isl,@CMAKE_SOURCE_DIR@\util\ISL\CatalanCM.isl" +Name: "en"; MessagesFile: "compiler:Default.isl,@PROJECT_SOURCE_DIR@\util\ISL\EnglishCM.isl" +Name: "ca"; MessagesFile: "compiler:Languages\Catalan.isl,@PROJECT_SOURCE_DIR@\util\ISL\CatalanCM.isl" Name: "co"; MessagesFile: "compiler:Languages\Corsican.isl" Name: "cs"; MessagesFile: "compiler:Languages\Czech.isl" Name: "da"; MessagesFile: "compiler:Languages\Danish.isl" Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl" Name: "fi"; MessagesFile: "compiler:Languages\Finnish.isl" -Name: "fr"; MessagesFile: "compiler:Languages\French.isl,@CMAKE_SOURCE_DIR@\util\ISL\FrenchCM.isl" -Name: "de"; MessagesFile: "compiler:Languages\German.isl,@CMAKE_SOURCE_DIR@\util\ISL\GermanCM.isl" +Name: "fr"; MessagesFile: "compiler:Languages\French.isl,@PROJECT_SOURCE_DIR@\util\ISL\FrenchCM.isl" +Name: "de"; MessagesFile: "compiler:Languages\German.isl,@PROJECT_SOURCE_DIR@\util\ISL\GermanCM.isl" Name: "he"; MessagesFile: "compiler:Languages\Hebrew.isl" Name: "it"; MessagesFile: "compiler:Languages\Italian.isl" Name: "ja"; MessagesFile: "compiler:Languages\Japanese.isl" -Name: "no"; MessagesFile: "compiler:Languages\Norwegian.isl,@CMAKE_SOURCE_DIR@\util\ISL\NorwegianCM.isl" +Name: "no"; MessagesFile: "compiler:Languages\Norwegian.isl,@PROJECT_SOURCE_DIR@\util\ISL\NorwegianCM.isl" Name: "pl"; MessagesFile: "compiler:Languages\Polish.isl" -Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl,@CMAKE_SOURCE_DIR@\util\ISL\BrazilianPortugueseCM.isl" +Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl,@PROJECT_SOURCE_DIR@\util\ISL\BrazilianPortugueseCM.isl" Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl" -Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl,@CMAKE_SOURCE_DIR@\util\ISL\RussianCM.isl" +Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl,@PROJECT_SOURCE_DIR@\util\ISL\RussianCM.isl" Name: "sl"; MessagesFile: "compiler:Languages\Slovenian.isl" Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl" -Name: "uk"; MessagesFile: "compiler:Languages\Ukrainian.isl,@CMAKE_SOURCE_DIR@\util\ISL\UkrainianCM.isl" +Name: "uk"; MessagesFile: "compiler:Languages\Ukrainian.isl,@PROJECT_SOURCE_DIR@\util\ISL\UkrainianCM.isl" ; Unofficial translations of GUI of Inno Setup -Name: "el"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\Greek.isl" -Name: "hu"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\Hungarian.isl" -Name: "sr"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\SerbianCyrillic.isl" -Name: "bg"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\Bulgarian.isl,@CMAKE_SOURCE_DIR@\util\ISL\BulgarianCM.isl" -Name: "bs"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\Bosnian.isl,@CMAKE_SOURCE_DIR@\util\ISL\BosnianCM.isl" -Name: "ko"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\Korean.isl,@CMAKE_SOURCE_DIR@\util\ISL\KoreanCM.isl" -Name: "zh_CN"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\ChineseSimplified.isl,@CMAKE_SOURCE_DIR@\util\ISL\ChineseSimplifiedCM.isl" -Name: "zh_TW"; MessagesFile: "@CMAKE_SOURCE_DIR@\util\ISL\ChineseTraditional.isl,@CMAKE_SOURCE_DIR@\util\ISL\ChineseTraditionalCM.isl" +Name: "el"; MessagesFile: "@PROJECT_SOURCE_DIR@\util\ISL\Greek.isl" +Name: "hu"; MessagesFile: "@PROJECT_SOURCE_DIR@\util\ISL\Hungarian.isl" +Name: "sr"; MessagesFile: "@PROJECT_SOURCE_DIR@\util\ISL\SerbianCyrillic.isl" +Name: "zh_CN"; MessagesFile: "@PROJECT_SOURCE_DIR@\util\ISL\ChineseSimplified.isl,@PROJECT_SOURCE_DIR@\util\ISL\ChineseSimplifiedCM.isl" +Name: "zh_TW"; MessagesFile: "@PROJECT_SOURCE_DIR@\util\ISL\ChineseTraditional.isl,@PROJECT_SOURCE_DIR@\util\ISL\ChineseTraditionalCM.isl" [Code] procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep); diff --git a/cmake/stellarium.rc.cmake b/cmake/stellarium.rc.cmake index 9a5c78c0d91c2..0119804cf7770 100644 --- a/cmake/stellarium.rc.cmake +++ b/cmake/stellarium.rc.cmake @@ -1,4 +1,4 @@ -stellarium-icon ICON "@CMAKE_SOURCE_DIR@/data/@PACKAGE_ICON@.ico" +stellarium-icon ICON "@PROJECT_SOURCE_DIR@/data/@PACKAGE_ICON@.ico" 1 VERSIONINFO FILEVERSION @PACKAGE_VERSION_RC@ PRODUCTVERSION @PACKAGE_VERSION_RC@ diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index b41071092115d..57c37a744e2bd 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,7 +1,7 @@ ########### install files ############### INSTALL(FILES ssystem_major.ini ssystem_minor.ini ssystem_1000comets.ini - base_locations.bin.gz default_cfg.ini languages.tab iso3166.tab + base_locations.bin.gzip default_cfg.ini languages.tab iso3166.tab regions-geoscheme.tab constellation_boundaries.dat constellations_spans.dat nomenclature.dat DESTINATION ${SDATALOC}/data) # install fonts @@ -12,7 +12,6 @@ INSTALL(DIRECTORY shaders/ DESTINATION ${SDATALOC}/data/shaders FILES_MATCHING PATTERN "planet*") ########### splash target ############## -ADD_CUSTOM_TARGET(splash ALL) SET(_splashFile splash.png) SET(_splashDstFile ${CMAKE_CURRENT_BINARY_DIR}/${_splashFile}) @@ -22,14 +21,21 @@ ELSE() GET_FILENAME_COMPONENT(_splashSrcFile splash.png ABSOLUTE) ENDIF() + +ADD_CUSTOM_TARGET(splash ALL + DEPENDS ${_splashDstFile} +) + ADD_CUSTOM_COMMAND( - TARGET splash + OUTPUT ${_splashDstFile} + DEPENDS ${_splashSrcFile} COMMAND ${CMAKE_COMMAND} -E copy ${_splashSrcFile} ${_splashDstFile} ) + + SET_TARGET_PROPERTIES(splash PROPERTIES FOLDER "data") ########### icon target ############### -ADD_CUSTOM_TARGET(icon ALL) IF(APPLE) SET(_iconFile stellarium.icns) IF(NOT STELLARIUM_RELEASE_BUILD) @@ -47,8 +53,14 @@ ELSE() ENDIF() SET(_iconDstFile ${CMAKE_CURRENT_BINARY_DIR}/${_iconFile}) + +ADD_CUSTOM_TARGET(icon ALL + DEPENDS ${_iconDstFile} +) + ADD_CUSTOM_COMMAND( - TARGET icon + OUTPUT ${_iconDstFile} + DEPENDS ${_iconSrcFile} COMMAND ${CMAKE_COMMAND} -E copy ${_iconSrcFile} ${_iconDstFile} ) SET_TARGET_PROPERTIES(icon PROPERTIES FOLDER "data") diff --git a/data/base_locations.bin.gz b/data/base_locations.bin.gzip similarity index 100% rename from data/base_locations.bin.gz rename to data/base_locations.bin.gzip diff --git a/data/ssystem_major.ini b/data/ssystem_major.ini index c259b78add399..e6cc83e327bff 100644 --- a/data/ssystem_major.ini +++ b/data/ssystem_major.ini @@ -351,7 +351,7 @@ absolute_magnitude=12.89 albedo=0.08 color=1., 0.93, 0.832 coord_func=deimos_special -model=m2deimos.obj.gz +model=m2deimos.obj.gzip name=Deimos orbit_Period=1.263 parent=Mars @@ -1456,7 +1456,7 @@ absolute_magnitude=11.8 albedo=0.07 color=1., 0.919, 0.806 coord_func=phobos_special -model=m1phobos.obj.gz +model=m1phobos.obj.gzip name=Phobos orbit_Period=0.319 parent=Mars diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index c7771d7b3a1d2..3ed631e171fb4 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -2,8 +2,10 @@ # to generate manual page: # pod2man --section=1 -r ${VERSION} --center=" " stellarium.pod stellarium.1 -IF(UNIX AND NOT WIN32 AND NOT APPLE) - ADD_CUSTOM_TARGET(ManPages ALL) +IF(UNIX AND NOT WIN32 AND NOT APPLE AND NOT ANDROID) + ADD_CUSTOM_TARGET(ManPages ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 + ) CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/cmake/stellarium.pod.cmake @@ -11,15 +13,9 @@ IF(UNIX AND NOT WIN32 AND NOT APPLE) ) ADD_CUSTOM_COMMAND( - TARGET ManPages + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 COMMAND pod2man ARGS -s 1 -r ${VERSION} -center=" " ${CMAKE_CURRENT_BINARY_DIR}/stellarium.pod ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 - OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 - ) - - ADD_CUSTOM_COMMAND( - TARGET ManPages - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 ) IF(${CMAKE_SYSTEM_NAME} MATCHES "(DragonFly|FreeBSD|NetBSD|OpenBSD)" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD") @@ -27,6 +23,6 @@ IF(UNIX AND NOT WIN32 AND NOT APPLE) ELSE(${CMAKE_SYSTEM_NAME} MATCHES "(DragonFly|FreeBSD|NetBSD|OpenBSD)" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD") INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/stellarium.1 DESTINATION share/man/man1) ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "(DragonFly|FreeBSD|NetBSD|OpenBSD)" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD") -ENDIF(UNIX AND NOT WIN32 AND NOT APPLE) +ENDIF(UNIX AND NOT WIN32 AND NOT APPLE AND NOT ANDROID) diff --git a/models/CMakeLists.txt b/models/CMakeLists.txt index 440b47fb0b5d7..f5211d198b21f 100644 --- a/models/CMakeLists.txt +++ b/models/CMakeLists.txt @@ -7,7 +7,7 @@ INSTALL(DIRECTORY ./ DESTINATION ${SDATALOC}/models PATTERN "*.mtl" PATTERN "*.png" PATTERN "*.obj" - PATTERN "*.gz" + PATTERN "*.gzip" PATTERN "CMakeFiles" EXCLUDE ) INSTALL(DIRECTORY blender/ DESTINATION ${SDATALOC}/models/blender diff --git a/models/m1phobos.obj.gz b/models/m1phobos.obj.gzip similarity index 100% rename from models/m1phobos.obj.gz rename to models/m1phobos.obj.gzip diff --git a/models/m2deimos.obj.gz b/models/m2deimos.obj.gzip similarity index 100% rename from models/m2deimos.obj.gz rename to models/m2deimos.obj.gzip diff --git a/plugins/Satellites/src/gsatellite/gTime.cpp b/plugins/Satellites/src/gsatellite/gTime.cpp index 0bafa6fbcaa3a..8bb2725056242 100644 --- a/plugins/Satellites/src/gsatellite/gTime.cpp +++ b/plugins/Satellites/src/gsatellite/gTime.cpp @@ -69,7 +69,7 @@ gTime gTime::getCurrentTime() struct tm timeinfo; time(&rawtime); - #ifdef _MSC_VER + #ifdef WIN32 gmtime_s(&timeinfo, &rawtime); #else gmtime_r(&rawtime, &timeinfo); @@ -128,7 +128,7 @@ gTimeSpan gTime::getTimeToUTC() time_t when = time(nullptr); struct tm utc; struct tm lcl; - #ifdef _MSC_VER + #ifdef WIN32 gmtime_s(&utc, &when); localtime_s(&lcl, &when); #else @@ -154,7 +154,7 @@ const gTime& gTime::operator=(time_t t) { struct tm ptm; - #ifdef _MSC_VER + #ifdef WIN32 gmtime_s(&ptm, &t); #else gmtime_r(&t, &ptm); diff --git a/plugins/TelescopeControl/src/ASCOM/ASCOMDevice.cpp b/plugins/TelescopeControl/src/ASCOM/ASCOMDevice.cpp index e0ec22aff38d0..5da60455fd4d7 100644 --- a/plugins/TelescopeControl/src/ASCOM/ASCOMDevice.cpp +++ b/plugins/TelescopeControl/src/ASCOM/ASCOMDevice.cpp @@ -17,9 +17,16 @@ */ #include "ASCOMDevice.hpp" -#include #include +#ifdef _MSC_VER +#include +#endif // _MSC_VER + +#ifdef _MSC_VER +#include +#endif // _MSC_VER + ASCOMDevice::ASCOMDevice(QObject* parent, QString ascomDeviceId) : QObject(parent), mAscomDeviceId(ascomDeviceId) {} diff --git a/po/stellarium-planetary-features/CMakeLists.txt b/po/stellarium-planetary-features/CMakeLists.txt index df8b94790a427..4b161692dc932 100644 --- a/po/stellarium-planetary-features/CMakeLists.txt +++ b/po/stellarium-planetary-features/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB poscfiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium-planetary-features/" "*.po") +FILE(GLOB poscfiles RELATIVE "${PROJECT_SOURCE_DIR}/po/stellarium-planetary-features/" "*.po") LIST(SORT poscfiles) STRING(REGEX REPLACE ".po" "" outposcfiles "${poscfiles}") diff --git a/po/stellarium-remotecontrol/CMakeLists.txt b/po/stellarium-remotecontrol/CMakeLists.txt index 4a891579f2fc6..4cfc62118affa 100644 --- a/po/stellarium-remotecontrol/CMakeLists.txt +++ b/po/stellarium-remotecontrol/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB porcfiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium-remotecontrol/" "*.po") +FILE(GLOB porcfiles RELATIVE "${PROJECT_SOURCE_DIR}/po/stellarium-remotecontrol/" "*.po") LIST(SORT porcfiles) STRING(REGEX REPLACE ".po" "" outporcfiles "${porcfiles}") diff --git a/po/stellarium-scripts/CMakeLists.txt b/po/stellarium-scripts/CMakeLists.txt index 8bc533d9fd18e..53e3ba5b816f3 100644 --- a/po/stellarium-scripts/CMakeLists.txt +++ b/po/stellarium-scripts/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB poscrfiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium-scripts/" "*.po") +FILE(GLOB poscrfiles RELATIVE "${PROJECT_SOURCE_DIR}/po/stellarium-scripts/" "*.po") LIST(SORT poscrfiles) STRING(REGEX REPLACE ".po" "" outposcrfiles "${poscrfiles}") diff --git a/po/stellarium-skycultures/CMakeLists.txt b/po/stellarium-skycultures/CMakeLists.txt index f074c715eea10..a356631181abc 100644 --- a/po/stellarium-skycultures/CMakeLists.txt +++ b/po/stellarium-skycultures/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB poscfiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium-skycultures/" "*.po") +FILE(GLOB poscfiles RELATIVE "${PROJECT_SOURCE_DIR}/po/stellarium-skycultures/" "*.po") LIST(SORT poscfiles) STRING(REGEX REPLACE ".po" "" outposcfiles "${poscfiles}") diff --git a/po/stellarium/CMakeLists.txt b/po/stellarium/CMakeLists.txt index aea67a28b0c10..7f6c2f1645f83 100644 --- a/po/stellarium/CMakeLists.txt +++ b/po/stellarium/CMakeLists.txt @@ -1,6 +1,6 @@ SET(stellarium_POT stellarium.pot) -FILE(GLOB pofiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium/" "*.po") +FILE(GLOB pofiles RELATIVE "${PROJECT_SOURCE_DIR}/po/stellarium/" "*.po") LIST(SORT pofiles) STRING(REGEX REPLACE ".po" "" outpofiles "${pofiles}") @@ -22,7 +22,7 @@ IF(${XGETTEXT_FOUND}) --keyword=translate:2,3c --add-comments=TRANSLATORS: --directory=${CMAKE_BINARY_DIR} - --directory=${CMAKE_SOURCE_DIR} + --directory=${PROJECT_SOURCE_DIR} --output-dir=${CMAKE_BINARY_DIR} --files-from=${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in --copyright-holder=Stellarium's\ team diff --git a/scenery3d/Sterngarten/CMakeLists.txt b/scenery3d/Sterngarten/CMakeLists.txt index a010a37f2f6b3..d2fd880a6d96e 100644 --- a/scenery3d/Sterngarten/CMakeLists.txt +++ b/scenery3d/Sterngarten/CMakeLists.txt @@ -7,7 +7,7 @@ INSTALL(DIRECTORY ./ DESTINATION ${SDATALOC}/scenery3d/Sterngarten PATTERN "*.ini" PATTERN "*.mtl" PATTERN "*.obj" - PATTERN "*.obj.gz" + PATTERN "*.obj.gzip" PATTERN "description.*.utf8" PATTERN "*.png" PATTERN "CMakeFiles" EXCLUDE ) diff --git a/scenery3d/Testscene/CMakeLists.txt b/scenery3d/Testscene/CMakeLists.txt index 42fb3c838ffb4..a5932f8f50733 100644 --- a/scenery3d/Testscene/CMakeLists.txt +++ b/scenery3d/Testscene/CMakeLists.txt @@ -5,7 +5,7 @@ INSTALL(DIRECTORY ./ DESTINATION ${SDATALOC}/scenery3d/Testscene PATTERN "*.ini" PATTERN "*.mtl" PATTERN "*.obj" - PATTERN "*.obj.gz" + PATTERN "*.obj.gzip" PATTERN "description.*.utf8" PATTERN "*.png" PATTERN "CMakeFiles" EXCLUDE ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 731e1822ef813..e530521d943c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -290,7 +290,7 @@ ENDIF() SET(stellarium_exe_SRCS main.cpp) ################# compiles resources files ############ -SET(stellarium_RES ${CMAKE_SOURCE_DIR}/data/mainRes.qrc) +SET(stellarium_RES ${PROJECT_SOURCE_DIR}/data/mainRes.qrc) IF(${QT_VERSION_MAJOR} EQUAL "5") QT5_ADD_RESOURCES(stellarium_RES_CXX ${stellarium_RES}) ELSE() @@ -419,7 +419,7 @@ IF(STELLARIUM_GUI_MODE STREQUAL "Standard") ENDIF() # compiles resources files - SET(stellarium_gui_RES ${CMAKE_SOURCE_DIR}/data/gui/guiRes.qrc) + SET(stellarium_gui_RES ${PROJECT_SOURCE_DIR}/data/gui/guiRes.qrc) IF(${QT_VERSION_MAJOR} EQUAL "5") QT5_ADD_RESOURCES(stellarium_gui_RES_CXX ${stellarium_gui_RES}) ELSE() @@ -468,7 +468,7 @@ IF(WIN32) # This library is required for some native methods used in a fix in main.cpp SET(winMMLib winmm) # This part is required to apply qt.conf for stellarium.exe when it's starting via QtCreator - SET(QT_CONF ${CMAKE_SOURCE_DIR}/data/qt.conf CACHE FILEPATH "The path to the qt.conf file") + SET(QT_CONF ${PROJECT_SOURCE_DIR}/data/qt.conf CACHE FILEPATH "The path to the qt.conf file") CONFIGURE_FILE(${QT_CONF} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) ENDIF() @@ -527,9 +527,13 @@ IF(GENERATE_STELMAINLIB) TARGET_LINK_LIBRARIES(stelMain ${STELMAIN_DEPS}) INSTALL(TARGETS stelMain DESTINATION lib) # WIN32 creates a windows app without console, no effect on non-win platforms - ADD_EXECUTABLE(stellarium WIN32 ${stellarium_exe_SRCS}) + IF( ANDROID ) + qt_add_executable(stellarium ${stellarium_exe_SRCS}) + ELSE() + ADD_EXECUTABLE(stellarium WIN32 ${stellarium_exe_SRCS}) + ENDIF() #stelMain should be after the plug-ins, otherwise the build crashes - TARGET_LINK_LIBRARIES(stellarium stelMain ${winMMLib}) + TARGET_LINK_LIBRARIES(stellarium PUBLIC stelMain ${winMMLib}) ELSE() ADD_LIBRARY(stelMain STATIC ${stellarium_lib_SRCS} ${stellarium_RES_CXX}) TARGET_LINK_LIBRARIES(stelMain ${STELMAIN_DEPS}) @@ -602,7 +606,11 @@ IF(APPLE) " ) ELSE() - INSTALL(TARGETS stellarium DESTINATION bin) + IF( ANDROID ) + INSTALL(TARGETS stellarium DESTINATION lib) + ELSE() + INSTALL(TARGETS stellarium DESTINATION bin) + ENDIF() ENDIF() IF(WIN32) IF((${QT_VERSION_MAJOR} EQUAL "5") AND (Qt5Core_VERSION VERSION_LESS "5.15")) diff --git a/src/StelLogger.cpp b/src/StelLogger.cpp index 58a7f3b42ce08..899bbfad6edae 100644 --- a/src/StelLogger.cpp +++ b/src/StelLogger.cpp @@ -33,10 +33,12 @@ QMutex StelLogger::fileMutex; void StelLogger::init(const QString& logFilePath) { +#if !defined(Q_OS_ANDROID) logFile.setFileName(logFilePath); if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text | QIODevice::Unbuffered)) qInstallMessageHandler(StelLogger::debugLogHandler); +#endif // write timestamp writeLog(QString("%1").arg(QDateTime::currentDateTime().toString(Qt::ISODate))); @@ -61,7 +63,7 @@ void StelLogger::init(const QString& logFilePath) // write memory and CPU info #ifdef Q_OS_LINUX -#ifndef BUILD_FOR_MAEMO +#if !defined(BUILD_FOR_MAEMO) && !defined(Q_OS_ANDROID) QFile infoFile("/proc/meminfo"); if(!infoFile.open(QIODevice::ReadOnly | QIODevice::Text)) writeLog("Could not get memory info."); @@ -282,9 +284,13 @@ void StelLogger::writeLog(QString msg) if (!msg.endsWith('\n')) msg.append(QLatin1Char('\n')); +#if defined(Q_OS_ANDROID) + qDebug() << msg; +#else fileMutex.lock(); const auto utf8 = msg.toUtf8(); logFile.write(utf8.constData(), utf8.size()); log += msg; fileMutex.unlock(); +#endif } diff --git a/src/StelMainView.cpp b/src/StelMainView.cpp index 5caf067d9b682..384ed480c8509 100644 --- a/src/StelMainView.cpp +++ b/src/StelMainView.cpp @@ -60,7 +60,7 @@ #include #include #include -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) #include #endif #include @@ -367,10 +367,11 @@ class StelRootItem : public QGraphicsObject setAcceptHoverEvents(true); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) setAcceptTouchEvents(true); grabGesture(Qt::PinchGesture); #endif + setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton); previousPaintTime = StelApp::getTotalRunTime(); } @@ -483,8 +484,8 @@ class StelRootItem : public QGraphicsObject mainView->thereWasAnEvent(); } - //*** Gesture and touch support, currently only for Windows -#ifdef Q_OS_WIN + //*** Gesture and touch support, currently only for Windows and Android +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) bool event(QEvent * e) Q_DECL_OVERRIDE { bool r = false; @@ -499,8 +500,12 @@ class StelRootItem : public QGraphicsObject if (touchPoints.count() == 1) setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton); +#if defined(Q_OS_WIN) r = true; break; +#else + return QGraphicsObject::event(e); +#endif } case QEvent::Gesture: setAcceptedMouseButtons(Qt::NoButton); @@ -907,7 +912,7 @@ void StelMainView::init() auto addr = glInfo.mainContext->getProcAddress("glMinSampleShading"); if(!addr) addr = glInfo.mainContext->getProcAddress("glMinSampleShadingARB"); - glInfo.glMinSampleShading = reinterpret_cast(addr); + glInfo.glMinSampleShading = reinterpret_cast(addr); } gl.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glInfo.maxTextureSize); qDebug() << "Maximum 2D texture size:" << glInfo.maxTextureSize; @@ -944,11 +949,12 @@ void StelMainView::init() scene()->addItem(rootItem); //set the default focus to the sky focusSky(); - nightModeEffect = new NightModeGraphicsEffect(this); - updateNightModeProperty(StelApp::getInstance().getVisionModeNight()); //install the effect on the whole view - rootItem->setGraphicsEffect(nightModeEffect); + rootItem->setGraphicsEffect(new NightModeGraphicsEffect(this)); + updateNightModeProperty(StelApp::getInstance().getVisionModeNight()); +#if !defined(Q_OS_ANDROID) +#endif flagInvertScreenShotColors = configuration->value("main/invert_screenshots_colors", false).toBool(); setScreenshotFormat(configuration->value("main/screenshot_format", "png").toString()); // includes check for supported formats. flagScreenshotDateFileName=configuration->value("main/screenshot_datetime_filename", false).toBool(); @@ -1042,7 +1048,7 @@ void StelMainView::updateNightModeProperty(bool b) { // So that the bottom bar tooltips get properly rendered in night mode. setProperty("nightMode", b); - nightModeEffect->setEnabled(b); + rootItem->graphicsEffect()->setEnabled(b); } void StelMainView::reloadShaders() @@ -1638,8 +1644,8 @@ void StelMainView::doScreenshot(void) const auto pixelRatio = QOpenGLContext::currentContext()->screen()->devicePixelRatio(); int physImgWidth = std::lround(stelScene->width() * pixelRatio); int physImgHeight = std::lround(stelScene->height() * pixelRatio); - bool nightModeWasEnabled=nightModeEffect->isEnabled(); - nightModeEffect->setEnabled(false); + bool effectWasEnabled=rootItem->graphicsEffect()->isEnabled(); + rootItem->graphicsEffect()->setEnabled(false); if (flagUseCustomScreenshotSize) { // Borrowed from Scenery3d renderer: determine maximum framebuffer size as minimum of texture, viewport and renderbuffer size @@ -1744,7 +1750,7 @@ void StelMainView::doScreenshot(void) // reset viewport and GUI core->setCurrentStelProjectorParams(pParams); customScreenshotMagnification=1.0f; - nightModeEffect->setEnabled(nightModeWasEnabled); + rootItem->graphicsEffect()->setEnabled(effectWasEnabled); stelScene->setSceneRect(0, 0, pParams.viewportXywh[2], pParams.viewportXywh[3]); rootItem->setSize(QSize(pParams.viewportXywh[2], pParams.viewportXywh[3])); StelGui* stelGui = dynamic_cast(gui); @@ -1754,16 +1760,6 @@ void StelMainView::doScreenshot(void) stelGui->forceRefreshGui(); } - if (nightModeWasEnabled) - { - for (int row=0; rowshow(); + +#if !defined(Q_OS_ANDROID) instance->ensureFirstPaint(); +#endif +} +#include +#include + +namespace +{ + class OpenGLContextPresever + { + public: + QOpenGLContext * prevContext; + QSurface * prevSurface; + + OpenGLContextPresever() + { + prevContext = QOpenGLContext::currentContext(); + if (prevContext) { + prevSurface = prevContext->surface(); + } + } + + ~OpenGLContextPresever() + { + if (QOpenGLContext::currentContext() != prevContext) { + prevContext->makeCurrent(prevSurface); + } + } + }; } void SplashScreen::showMessage(QString const& message) { + OpenGLContextPresever contextPreserver; Q_ASSERT(instance); instance->showMessage(message, Qt::AlignLeft|Qt::AlignBottom, Qt::white); } void SplashScreen::finish(QWidget* mainWindow) { - Q_ASSERT(instance); + OpenGLContextPresever contextPreserver; + Q_ASSERT(instance); instance->finish(mainWindow); delete instance; instance=nullptr; @@ -54,6 +86,7 @@ void SplashScreen::finish(QWidget* mainWindow) void SplashScreen::clearMessage() { + OpenGLContextPresever contextPreserver; Q_ASSERT(instance); instance->clearMessage(); } @@ -76,6 +109,8 @@ SplashScreen::SplashScreenWidget::SplashScreenWidget(QPixmap const& pixmap) void SplashScreen::SplashScreenWidget::paintEvent(QPaintEvent* event) { + OpenGLContextPresever contextPreserver; + QSplashScreen::paintEvent(event); // Add version text diff --git a/src/core/Dithering.cpp b/src/core/Dithering.cpp index 8084eca3237b5..0e6b3ac687bc5 100644 --- a/src/core/Dithering.cpp +++ b/src/core/Dithering.cpp @@ -35,13 +35,22 @@ GLuint makeDitherPatternTexture(QOpenGLFunctions& gl) // OpenGL ES has different defined formats. However, the shader will use the red channel, so this should work: if(QOpenGLContext::currentContext()->isOpenGLES()) { - gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, std::size(blueNoiseTriangleRemapped), std::size(blueNoiseTriangleRemapped[0]), - 0, GL_LUMINANCE, GL_FLOAT, blueNoiseTriangleRemapped); + std::vector tmpBuf(3 * sizeof(blueNoiseTriangleRemapped) / sizeof(blueNoiseTriangleRemapped[0][0])); + for (size_t i = 0; i < tmpBuf.size(); i++) { + tmpBuf[i * 3 + 0] = (((float *)blueNoiseTriangleRemapped)[i] + 1) / 2; + tmpBuf[i * 3 + 1] = 0; + tmpBuf[i * 3 + 2] = 0; + } + + gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, std::size(blueNoiseTriangleRemapped), std::size(blueNoiseTriangleRemapped[0]), + 0, GL_RGB, GL_UNSIGNED_BYTE, tmpBuf.data()); } else { +#if !defined(QT_OPENGL_ES_2) gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, std::size(blueNoiseTriangleRemapped), std::size(blueNoiseTriangleRemapped[0]), 0, GL_RED, GL_FLOAT, blueNoiseTriangleRemapped); +#endif } return tex; } diff --git a/src/core/StelApp.hpp b/src/core/StelApp.hpp index c8d46f7d0e85f..b076a404c7002 100644 --- a/src/core/StelApp.hpp +++ b/src/core/StelApp.hpp @@ -389,7 +389,7 @@ public slots: void highGraphicsModeDraw(); QString getVersion() const; - +public: // The StelApp singleton static StelApp* singleton; diff --git a/src/core/StelFileMgr.cpp b/src/core/StelFileMgr.cpp index 3d1c47755d840..6116035576d7e 100644 --- a/src/core/StelFileMgr.cpp +++ b/src/core/StelFileMgr.cpp @@ -93,17 +93,20 @@ void StelFileMgr::init() // OK, now we have the userDir set, add it to the search path fileLocations.append(userDir); - // Determine install data directory location - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - QString envRoot = env.value("STELLARIUM_DATA_ROOT", "."); - if (QFileInfo::exists(envRoot + QDir::separator() + QString(CHECK_FILE))) - { - installDir = envRoot; - } - else - { - #if defined(Q_OS_MACOS) + // Determine install data directory location + QStringList searchPaths; + + searchPaths += QProcessEnvironment::systemEnvironment().value("STELLARIUM_DATA_ROOT", "."); + + #if defined(Q_OS_ANDROID) + searchPaths += "assets:"; + for( QFileInfo info : QDir("/storage").entryInfoList(QDir::Dirs|QDir::NoDotDot) ){ + searchPaths += info.absoluteFilePath() + "/stellarium"; + searchPaths += info.absoluteFilePath() + "/0/stellarium"; + } + searchPaths += "/sdcard/stellarium"; + #elif defined(Q_OS_MACOS) QString relativePath = "/../Resources"; if (QCoreApplication::applicationDirPath().contains("src")) { relativePath = "/../.."; @@ -118,76 +121,42 @@ void StelFileMgr::init() if (!QCoreApplication::applicationDirPath().contains("src")) { ResourcesDir.cd(QString("Resources")); } - QFileInfo installLocation(ResourcesDir.absolutePath()); - QFileInfo checkFile(installLocation.filePath() + QDir::separator() + QString(CHECK_FILE)); + searchPaths += ResourcesDir.absolutePath(); #elif defined(Q_OS_WIN) - QFileInfo installLocation(QCoreApplication::applicationDirPath()); - QFileInfo checkFile(installLocation.filePath() + QDir::separator() + QString(CHECK_FILE)); + searchPaths += QCoreApplication::applicationDirPath(); #else // Linux, BSD, Solaris etc. // We use the value from the config.h filesystem - QFileInfo installLocation(QFile::decodeName(INSTALL_DATADIR)); - QFileInfo checkFile(QFile::decodeName(INSTALL_DATADIR "/" CHECK_FILE)); - #endif - - #ifdef DEBUG - if (!checkFile.exists()) - { // for DEBUG use sources location - QString debugDataPath = INSTALL_DATADIR_FOR_DEBUG; - checkFile = QFileInfo(debugDataPath + QDir::separator() + CHECK_FILE); - installLocation = QFileInfo(debugDataPath); - } - #endif + searchPaths += QFile::decodeName(INSTALL_DATADIR); +#endif - if (checkFile.exists()) - { - installDir = installLocation.filePath(); - } - else - { - qWarning() << "WARNING StelFileMgr::StelFileMgr: could not find install location:" - << QDir::toNativeSeparators(installLocation.filePath()) - << " (we checked for " - << QDir::toNativeSeparators(checkFile.filePath()) << ")."; - - qWarning() << "Maybe this is AppImage or something similar? Let's check relative path..."; - // This hook has been added after reverse-engineering an AppImage application - QString relativePath = QCoreApplication::applicationDirPath() + QString("/../share/stellarium"); - checkFile = QFileInfo(relativePath + QDir::separator() + CHECK_FILE); - if (checkFile.exists()) - { - installDir = relativePath; - } - else - { - qWarning() << "WARNING StelFileMgr::StelFileMgr: could not find install location:" - << QDir::toNativeSeparators(relativePath) - << " (we checked for " - << QDir::toNativeSeparators(checkFile.filePath()) << ")."; - - qWarning() << "Maybe this is development environment? Let's check source directory path..."; - - QString sourceDirPath = STELLARIUM_SOURCE_DIR; // The variable is defined in CMakeLists.txt file - checkFile = QFileInfo(sourceDirPath + QDir::separator() + CHECK_FILE); - if (checkFile.exists()) - { - installDir = sourceDirPath; - } - else - { - qWarning() << "WARNING StelFileMgr::StelFileMgr: could not find install location:" - << QDir::toNativeSeparators(sourceDirPath) - << " (we checked for " - << QDir::toNativeSeparators(checkFile.filePath()) << ")."; - - #ifndef UNIT_TEST - // NOTE: Hook for buildbots (using within testEphemeris) - qFatal("Couldn't find install directory location."); - #endif - } - } - } - } + searchPaths += QCoreApplication::applicationDirPath() + QString("/../share/stellarium"); + +#ifdef DEBUG + searchPaths += NSTALL_DATADIR_FOR_DEBUG; +#endif + + searchPaths += STELLARIUM_SOURCE_DIR; + + for (auto & path : searchPaths) { + QFileInfo checkFile(path + QDir::separator() + CHECK_FILE); + if (checkFile.exists()) { + qInfo() << "StelFileMgr found install location" << path; + installDir = path; + break; + } + } + + if (installDir.isEmpty()) { +#ifndef UNIT_TEST + for (auto & path : searchPaths) { + qWarning() << "WARNING StelFileMgr::StelFileMgr: could not find install location:" + << QDir::toNativeSeparators(path) << " (we checked for " << CHECK_FILE << ")."; + } + // NOTE: Hook for buildbots (using within testEphemeris) + qFatal("Couldn't find install directory location."); +#endif + } // Then add the installation directory to the search path fileLocations.append(installDir); diff --git a/src/core/StelLocationMgr.cpp b/src/core/StelLocationMgr.cpp index 7ac1261b6b51f..0456fe8ccafa2 100644 --- a/src/core/StelLocationMgr.cpp +++ b/src/core/StelLocationMgr.cpp @@ -487,7 +487,7 @@ StelLocationMgr::StelLocationMgr() if (conf->value("devel/convert_locations_list", false).toBool()) generateBinaryLocationFile("data/base_locations.txt", false, "data/base_locations.bin"); - locations = loadCitiesBin("data/base_locations.bin.gz"); + locations = loadCitiesBin("data/base_locations.bin.gzip"); #if QT_VERSION >= QT_VERSION_CHECK(5,15,0) locations.insert(loadCities("data/user_locations.txt", true)); #else @@ -566,7 +566,7 @@ LocationMap StelLocationMgr::loadCitiesBin(const QString& fileName) return res; } - if (fileName.endsWith(".gz")) + if (fileName.endsWith(".gzip")) { QDataStream in(StelUtils::uncompress(sourcefile.readAll())); in.setVersion(QDataStream::Qt_5_2); diff --git a/src/core/StelModuleMgr.cpp b/src/core/StelModuleMgr.cpp index 3569825fb25d3..e9d4c618df822 100644 --- a/src/core/StelModuleMgr.cpp +++ b/src/core/StelModuleMgr.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "StelModuleMgr.hpp" @@ -244,6 +245,8 @@ QList StelModuleMgr::getPluginsList() } } + QStringList modules; + // Then list dynamic libraries from the modules/ directory const QSet moduleDirs = StelFileMgr::listContents("modules",StelFileMgr::Directory); @@ -257,6 +260,21 @@ QList StelModuleMgr::getPluginsList() #else moduleFullPath += ".so"; #endif + + modules += moduleFullPath; + } + + +#if defined(Q_OS_ANDROID) + for( QFileInfo& info : QDir(QCoreApplication::applicationDirPath()).entryInfoList( QStringList() << "libmodule_*.so" , QDir::Files ) ) + { + modules += info.absoluteFilePath(); + } +#endif + + + foreach (QString moduleFullPath, modules) + { moduleFullPath = StelFileMgr::findFile(moduleFullPath, StelFileMgr::File); if (moduleFullPath.isEmpty()) continue; @@ -265,7 +283,7 @@ QList StelModuleMgr::getPluginsList() if (!loader.load()) { qWarning() << "Couldn't load the dynamic library:" << QDir::toNativeSeparators(moduleFullPath) << ": " << loader.errorString(); - qWarning() << "Plugin" << dir << "will not be loaded."; + qWarning() << "Plugin" << moduleFullPath << "will not be loaded."; continue; } @@ -273,7 +291,7 @@ QList StelModuleMgr::getPluginsList() if (!obj) { qWarning() << "Couldn't open the dynamic library:" << QDir::toNativeSeparators(moduleFullPath) << ": " << loader.errorString(); - qWarning() << "Plugin" << dir << "will not be open."; + qWarning() << "Plugin" << moduleFullPath << "will not be open."; continue; } diff --git a/src/core/StelOBJ.cpp b/src/core/StelOBJ.cpp index 47691421cd22a..d8975b2db8aae 100644 --- a/src/core/StelOBJ.cpp +++ b/src/core/StelOBJ.cpp @@ -69,7 +69,7 @@ bool StelOBJ::load(const QString& filename, const VertexOrder vertexOrder, const qCDebug(stelOBJ)<<"Opened file in"< #include #include -#include +#include // ShowMySky library API is documented online at https://10110111.github.io/CalcMySky/showmysky-api.html // Or you can build the documentation from the CalcMySky sources, using CMake doc target: `cmake --build . --target doc` diff --git a/src/core/modules/StarMgr.cpp b/src/core/modules/StarMgr.cpp index 50c1c1acdd5cf..2a6f691377692 100644 --- a/src/core/modules/StarMgr.cpp +++ b/src/core/modules/StarMgr.cpp @@ -556,7 +556,16 @@ bool StarMgr::checkAndLoadCatalog(const QVariantMap& catDesc) } } - ZoneArray* z = ZoneArray::create(catalogFilePath, true); + bool useMmap; + + #if defined(Q_OS_ANDROID) + useMmap = false; + #else + useMmap = true; + #endif + + + ZoneArray* z = ZoneArray::create(catalogFilePath, useMmap); if (z) { if (z->levelvalue("gui/flag_enable_kinetic_scrolling", false).toBool()); + setFlagUseButtonsBackground(conf->value("gui/flag_show_buttons_background", true).toBool()); // Add everything QPixmap pxmapDefault, pxmapOn, pxmapOff; diff --git a/src/main.cpp b/src/main.cpp index fb67562751ac4..e5e4a1167089d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,6 +82,19 @@ } #endif //Q_OS_WIN +#if defined(Q_OS_ANDROID) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +namespace QtAndroidPrivate +{ + enum PermissionResult + { + Undetermined, + Authorized, + Denied + }; + Q_CORE_EXPORT QFuture requestPermission(const QString & permission); +} +#endif + //! @class CustomQTranslator //! Provides custom i18n support. class CustomQTranslator : public QTranslator @@ -163,7 +176,9 @@ int main(int argc, char **argv) QCoreApplication::setOrganizationName("stellarium"); QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents); - // Support high DPI pixmaps and fonts +#ifdef Q_OS_ANDROID + QCoreApplication::setAttribute(Qt::AA_Use96Dpi, true); +#endif #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); @@ -176,7 +191,7 @@ int main(int argc, char **argv) QDir appDir(appInfo.absolutePath()); appDir.cdUp(); QCoreApplication::addLibraryPath(appDir.absoluteFilePath("PlugIns")); - #elif defined(Q_OS_WIN) + #elif defined(Q_OS_WIN) || defined(Q_OS_ANDROID) QFileInfo appInfo(QString::fromUtf8(argv[0])); QCoreApplication::addLibraryPath(appInfo.absolutePath()); #endif @@ -209,8 +224,22 @@ int main(int argc, char **argv) // otherwise configuration/INI file parsing will be erroneous. setlocale(LC_NUMERIC, "C"); +#ifdef Q_OS_ANDROID + QFont newFont = QApplication::font(); + newFont.setPixelSize(14); + QApplication::setFont(newFont); +#endif + + // Solution for bug: https://bugs.launchpad.net/stellarium/+bug/1498616 qputenv("QT_HARFBUZZ", "old"); + //#if defined(Q_OS_ANDROID) + // // QCoreApplication::requestPermission(); + // // QtAndroid::requestPermissionsSync( QStringList("android.permission.WRITE_EXTERNAL_STORAGE") ); + // // QtAndroid::requestPermissionsSync( QStringList("android.permission.READ_EXTERNAL_STORAGE") ); + // QtAndroidPrivate::requestPermission("android.permission.WRITE_EXTERNAL_STORAGE").waitForFinished(); + // QtAndroidPrivate::requestPermission("android.permission.READ_EXTERNAL_STORAGE").waitForFinished(); + //#endif // Init the file manager StelFileMgr::init(); diff --git a/src/scripting/StelScriptMgr.cpp b/src/scripting/StelScriptMgr.cpp index 9aca274a7b9f6..53513b580503c 100644 --- a/src/scripting/StelScriptMgr.cpp +++ b/src/scripting/StelScriptMgr.cpp @@ -785,7 +785,10 @@ bool StelScriptMgr::runPreprocessedScript(const QString &preprocessedScript, con #else // run that script in a new context QScriptContext *context = engine->pushContext(); + //disable for android, for now, until crash fix is found + #if !defined(Q_OS_ANDROID) engine->evaluate(preprocessedScript); + #endif engine->popContext(); scriptEnded(); Q_UNUSED(context)