Skip to content

Commit

Permalink
fix android build
Browse files Browse the repository at this point in the history
  • Loading branch information
maz-1 committed Jul 5, 2021
1 parent 6d8150a commit 5303c15
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "modules/SingleApplication"]
path = modules/SingleApplication
url = https://github.com/itay-grudev/SingleApplication.git
[submodule "modules/qt-android-cmake"]
path = modules/qt-android-cmake
url = https://github.com/maz-1/qt-android-cmake
21 changes: 17 additions & 4 deletions CMakeLists.txt
Expand Up @@ -123,10 +123,20 @@ if(USE_SINGLE_APP)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/modules/SingleApplication)
endif()

add_executable(${PROJECT_NAME}
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_RESOURCES})
if(ANDROID)
add_library(${PROJECT_NAME} SHARED
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_RESOURCES})
include(modules/qt-android-cmake/AddQtAndroidApk.cmake)
add_qt_android_apk(${PROJECT_NAME}_apk ${PROJECT_NAME})
else()
add_executable(${PROJECT_NAME}
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_RESOURCES})
endif()


if(USE_SINGLE_APP)
add_dependencies(${PROJECT_NAME} SingleApplication)
Expand All @@ -144,6 +154,9 @@ find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")

if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE True
)
target_link_libraries(${PROJECT_NAME} Ws2_32 ole32 user32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Visual Studio C++
Expand Down
19 changes: 11 additions & 8 deletions main.cpp
Expand Up @@ -26,10 +26,10 @@
#include "duktowindow.h"

#ifdef SINGLE_APP
#include <singleapplication.h>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#include <singleapplication.h>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#endif

int main(int argc, char *argv[])
Expand All @@ -41,6 +41,8 @@ int main(int argc, char *argv[])
qputenv("QSG_RHI_BACKEND", "gl");
#endif

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

#ifndef SINGLE_APP
QApplication app(argc, argv);
#else
Expand All @@ -54,7 +56,7 @@ int main(int argc, char *argv[])
return 0;
}
#endif

QCommandLineParser parser;
parser.setApplicationDescription("Dukto is a simple, fast and multi-platform file transfer tool for LAN users.");
parser.addHelpOption();
Expand All @@ -66,11 +68,12 @@ int main(int argc, char *argv[])

GuiBehind gb(&settings);
app.installEventFilter(&gb);

DuktoWindow viewer(&gb, &settings);
#ifdef SINGLE_APP
QObject::connect(&app, &SingleApplication::receivedMessage, [&viewer]()->void {
if (viewer.isMinimized()) {
if (viewer.isMinimized())
{
viewer.showNormal();
}
viewer.activateWindow();
Expand All @@ -82,6 +85,6 @@ int main(int argc, char *argv[])

gb.setViewer(&viewer, &tray);
viewer.setVisible(!parser.isSet(hideOption));

return app.exec();
}
1 change: 1 addition & 0 deletions modules/qt-android-cmake
Submodule qt-android-cmake added at 7ac4a3

0 comments on commit 5303c15

Please sign in to comment.