Skip to content

Commit

Permalink
Merge pull request #350 from openstudiocoalition/349_resources_locales
Browse files Browse the repository at this point in the history
Fix #349 - Remove Annoying messages in console about QWebEngine not finding its resources/translations by correctly setting them up
  • Loading branch information
jmarrec authored May 28, 2021
2 parents f10b850 + e642183 commit 34efc64
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
45 changes: 33 additions & 12 deletions src/openstudio_app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,18 @@ elseif( UNIX )

add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $<TARGET_FILE_DIR:${target_name}>/ )
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/qt.conf $<TARGET_FILE_DIR:${target_name}>
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $<TARGET_FILE_DIR:${target_name}>/resources/
#COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/translations $<TARGET_FILE_DIR:${target_name}>/translations/
# Copying just one locale is enough to shut the annoying console warning...
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/translations/
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/translations/qtwebengine_locales
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_INSTALL_DIR}/translations/qtwebengine_locales/en-US.pak $<TARGET_FILE_DIR:${target_name}>/translations/qtwebengine_locales/
)

# TODO: not sure if chrpath is needed
add_custom_command(TARGET ${target_name}
Expand Down Expand Up @@ -258,10 +266,18 @@ elseif( WIN32 )

add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $<TARGET_FILE_DIR:${target_name}>/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $<TARGET_FILE_DIR:${target_name}>/ )
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/qt.conf $<TARGET_FILE_DIR:${target_name}>
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $<TARGET_FILE_DIR:${target_name}>/resources/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $<TARGET_FILE_DIR:${target_name}>/resources/
#COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/translations $<TARGET_FILE_DIR:${target_name}>/translations/
# Copying just one locale is enough to shut the annoying console warning...
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/translations/
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target_name}>/translations/qtwebengine_locales
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_INSTALL_DIR}/translations/qtwebengine_locales/en-US.pak $<TARGET_FILE_DIR:${target_name}>/translations/qtwebengine_locales/
)

add_custom_command(TARGET ${target_name}
POST_BUILD
Expand Down Expand Up @@ -334,10 +350,15 @@ endif()

# since on apple the whole app bundle is installed (including these webkit components) we can exclude apple
if( NOT APPLE )
install(FILES ${icudtl} DESTINATION bin COMPONENT OpenStudioApp )
install(FILES ${qweb_resources} DESTINATION bin COMPONENT OpenStudioApp )
install(FILES ${qweb_resources_100} DESTINATION bin COMPONENT OpenStudioApp )
install(FILES ${qweb_resources_200} DESTINATION bin COMPONENT OpenStudioApp )

install(FILES $<TARGET_FILE_DIR:${target_name}>/qt.conf DESTINATION bin COMPONENT OpenStudioApp)
# install(DIRECTORY ${QT_INSTALL_DIR}/translations DESTINATION bin COMPONENT OpenStudioApp)
install(DIRECTORY $<TARGET_FILE_DIR:${target_name}>/translations/ DESTINATION bin/translations/ COMPONENT OpenStudioApp)
install(DIRECTORY $<TARGET_FILE_DIR:${target_name}>/resources/ DESTINATION bin/resources/ COMPONENT OpenStudioApp)
# install(FILES ${icudtl} DESTINATION bin/resources COMPONENT OpenStudioApp )/translatio
# install(FILES ${qweb_resources} DESTINATION bin/resources COMPONENT OpenStudioApp )
# install(FILES ${qweb_resources_100} DESTINATION bin/resources COMPONENT OpenStudioApp )
# install(FILES ${qweb_resources_200} DESTINATION bin/resources COMPONENT OpenStudioApp )
if(WIN32)
install(TARGETS OpenStudioApp DESTINATION bin COMPONENT OpenStudioApp )

Expand Down
6 changes: 6 additions & 0 deletions src/openstudio_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <QDir>
#include <QTcpServer>
#include <QtGlobal>
#include <QLibraryInfo>

#ifdef _WIN32
# include <Windows.h>
Expand Down Expand Up @@ -223,6 +224,11 @@ int main(int argc, char* argv[]) {
// Make the run path the default plugin search location
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());

LOG_FREE(Info, "OpenStudioApp.main", "LibraryExecutablesPath: "
<< openstudio::toString(QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath)));
LOG_FREE(Info, "OpenStudioApp.main", "DataPath: " << openstudio::toString(QLibraryInfo::location(QLibraryInfo::DataPath)));
LOG_FREE(Info, "OpenStudioApp.main", "TranslationsPath: " << openstudio::toString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)));

#ifdef Q_OS_DARWIN
// Gross but perhaps the simplest way to find the webengine process
// Improvements are welcome.
Expand Down
4 changes: 4 additions & 0 deletions src/openstudio_app/qt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Paths]
Resources = resources
Translations = translations
LibraryExecutables = .

0 comments on commit 34efc64

Please sign in to comment.