Skip to content

Commit

Permalink
compile qm on the fly at the time of the build.
Browse files Browse the repository at this point in the history
trying to fix builds before 4.0 release.

add qttools5-dev to ubuntu package list
add qt5-linguist to snapcraft file
add missing file
  • Loading branch information
whoozle committed Nov 15, 2020
1 parent 67b15a8 commit 9d71220
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ matrix:
install:
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
sudo apt-get -y install qt5-default libfuse-dev libmagic-dev libtag1-dev libssl-dev
sudo apt-get -y install qt5-default qttools5-dev qttools5-dev-tools libfuse-dev libmagic-dev libtag1-dev libssl-dev
elif [ "${TRAVIS_OS_NAME}" = "freebsd" ]; then
sudo pkg install -y ninja qt5-qmake qt5-buildtools qt5-widgets fusefs-libs pybind11 taglib
sudo pkg install -y ninja qt5-qmake qt5-buildtools qt5-widgets qt5-linguist fusefs-libs pybind11 taglib
elif [ "${TRAVIS_OS_NAME}" = "osx" ]; then
brew tap homebrew/cask && brew install qt5 homebrew/cask/osxfuse pybind11 taglib [email protected]
fi
Expand Down
31 changes: 29 additions & 2 deletions qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ if(DESIRED_QT_VERSION)
else()
find_package(Qt5Widgets QUIET)
find_package(Qt5Network QUIET)
find_package(Qt5LinguistTools QUIET)
endif()
else()
find_package(Qt5Widgets QUIET)
find_package(Qt5Network QUIET)
find_package(Qt5LinguistTools QUIET)
find_package(Qt4 QUIET)
endif()

Expand Down Expand Up @@ -40,18 +42,43 @@ set(FORMS mainwindow.ui
renamedialog.ui
)

set(TS_FILES
translations/android-file-transfer-linux_cs.ts
translations/android-file-transfer-linux_it.ts
translations/android-file-transfer-linux_nl.ts
translations/android-file-transfer-linux_ru.ts
)

if (Qt5Widgets_FOUND)
message(STATUS "Using Qt5")
qt5_wrap_cpp(HEADERS_MOC ${HEADERS})
qt5_wrap_ui(FORMS_HEADERS ${FORMS})
qt5_add_resources(RESOURCES android-file-transfer.qrc)

qt5_add_translation(QM_FILES ${TS_FILES})
set(QM_FILES_XML "")
foreach(_QM ${QM_FILES})
get_filename_component(_QM ${_QM} NAME)
set(QM_FILES_XML "${QM_FILES_XML}<file>${_QM}</file>")
endforeach()
configure_file(translations/translations.qrc.in translations.qrc)

qt5_add_resources(RESOURCES android-file-transfer.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
set(EXTRA_QT_LINK ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES})
elseif(Qt4_FOUND OR QT_FOUND OR QT4_FOUND)
message(STATUS "Using Qt4")
qt4_wrap_cpp(HEADERS_MOC ${HEADERS})
qt4_wrap_ui(FORMS_HEADERS ${FORMS})
qt4_add_resources(RESOURCES android-file-transfer.qrc)

qt4_add_translation(QM_FILES ${TS_FILES})
set(QM_FILES_XML "")
foreach(_QM ${QM_FILES})
get_filename_component(_QM ${_QM} NAME)
set(QM_FILES_XML "${QM_FILES_XML}<file>${_QM}</file>")
endforeach()
configure_file(translations/translations.qrc.in translations.qrc)

qt4_add_resources(RESOURCES android-file-transfer.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
include(${QT_USE_FILE})
set(EXTRA_QT_LINK Qt4::QtNetwork ${QT_LIBRARIES})
else()
Expand Down
2 changes: 0 additions & 2 deletions qt/android-file-transfer.qrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<RCC>
<qresource prefix="/">
<file>android-file-transfer.png</file>
<file>translations/android-file-transfer-linux_ru.qm</file>
<file>translations/android-file-transfer-linux_cs.qm</file>
<file>icons/dark/folder-new.svg</file>
<file>icons/dark/go-next.svg</file>
<file>icons/dark/go-previous.svg</file>
Expand Down
2 changes: 1 addition & 1 deletion qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char *argv[])
app.installTranslator(&qtTranslator);

QTranslator aTranslator;
aTranslator.load(":/translations/android-file-transfer-linux_" + QLocale::system().name());
aTranslator.load(":/android-file-transfer-linux_" + QLocale::system().name());
app.installTranslator(&aTranslator);

MainWindow w;
Expand Down
Binary file removed qt/translations/android-file-transfer-linux_cs.qm
Binary file not shown.
Binary file removed qt/translations/android-file-transfer-linux_ru.qm
Binary file not shown.
5 changes: 5 additions & 0 deletions qt/translations/translations.qrc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
${QM_FILES_XML}
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@

build-packages:
- qt5-default
- qttools5-dev
- qttools5-dev-tools
- libfuse-dev
- libmagic-dev
- libtag1-dev
Expand Down

0 comments on commit 9d71220

Please sign in to comment.