diff --git a/examples/qmake/.gitignore b/examples/qmake/.gitignore new file mode 100644 index 0000000..7cef1a4 --- /dev/null +++ b/examples/qmake/.gitignore @@ -0,0 +1 @@ +build-demo* \ No newline at end of file diff --git a/examples/qmake/README.md b/examples/qmake/README.md new file mode 100644 index 0000000..f4b751c --- /dev/null +++ b/examples/qmake/README.md @@ -0,0 +1,17 @@ +# 通用步骤与功能介绍 + +快速开始前请先阅读以下文档 + +[Finclip桌面版Demo集成指引与功能介绍](https://github.com/finogeeks/finclip-desktop-demo/tree/master/examples/README.md) + + +# 快速开始 + +1. 使用qt creator打开 demo文件夹 +2. 点击运行, 即可打开 + + +# 注意事项 + +1. 下载路径请不要有中文, 否则会有奇怪的问题 +2. 集成时将finclip存放至独立的位置, 避免dll冲突 \ No newline at end of file diff --git a/examples/qt/demo/.gitignore b/examples/qmake/demo/.gitignore similarity index 100% rename from examples/qt/demo/.gitignore rename to examples/qmake/demo/.gitignore diff --git a/examples/qt/demo/demo.pro b/examples/qmake/demo/demo.pro similarity index 100% rename from examples/qt/demo/demo.pro rename to examples/qmake/demo/demo.pro diff --git a/examples/qt/demo/finclip-qt-demo.cpp b/examples/qmake/demo/finclip-qt-demo.cpp similarity index 100% rename from examples/qt/demo/finclip-qt-demo.cpp rename to examples/qmake/demo/finclip-qt-demo.cpp diff --git a/examples/qt/demo/finclip-qt-demo.h b/examples/qmake/demo/finclip-qt-demo.h similarity index 100% rename from examples/qt/demo/finclip-qt-demo.h rename to examples/qmake/demo/finclip-qt-demo.h diff --git a/examples/qt/demo/main.cpp b/examples/qmake/demo/main.cpp similarity index 100% rename from examples/qt/demo/main.cpp rename to examples/qmake/demo/main.cpp diff --git a/examples/qt/.gitignore b/examples/qt/.gitignore index 7cef1a4..d163863 100644 --- a/examples/qt/.gitignore +++ b/examples/qt/.gitignore @@ -1 +1 @@ -build-demo* \ No newline at end of file +build/ \ No newline at end of file diff --git a/examples/qt/CMakeLists.txt b/examples/qt/CMakeLists.txt new file mode 100644 index 0000000..95829a0 --- /dev/null +++ b/examples/qt/CMakeLists.txt @@ -0,0 +1,92 @@ +cmake_minimum_required(VERSION 3.21) +project(FinClipQtDemo) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(FINCLIP_QTDEMO_TARGET "FinClipQtDemo") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + # 在arm下编译x86的包需要特殊处理 + if(PROJECT_ARCH STREQUAL "x86_64") + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE) + endif() +endif() + +set(FINCLIP_QTDEMO_SRCS src/main.cc) + +add_executable(${FINCLIP_QTDEMO_TARGET} ${FINCLIP_QTDEMO_SRCS}) + +if(NOT DEFINED PROJECT_ARCH) + set(PROJECT_ARCH ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +add_library( finclip_wrapper SHARED IMPORTED ) + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + if(PROJECT_ARCH STREQUAL "x86_64") + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/win/x86_64") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_IMPLIB "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.lib") + set(Qt5_DIR "C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5") + elseif(PROJECT_ARCH STREQUAL "x86") + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/win/x86") + set(Qt5_DIR "C:/Qt/5.15.2/msvc2019/lib/cmake/Qt5") + else() + + endif() + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_IMPLIB "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.lib") + add_custom_command(TARGET ${FINCLIP_QTDEMO_TARGET} POST_BUILD # Adds a post-build event to MyTest + COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." + "${FINCLIP_SDK_PATH}/FinClipSDKWrapper.dll" # <--this is in-file + $) # <--this is out-file path +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if(PROJECT_ARCH STREQUAL "x86_64") + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/linux/x86_64") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") + else() + # arm64 + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/linux/arm64") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") + endif() +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + if(PROJECT_ARCH STREQUAL "x86_64") + # intel + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/mac/intel") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") + else() + # arm64 + set(FINCLIP_SDK_PATH "${PROJECT_SOURCE_DIR}/../../vendor/mac/arm64") + set_target_properties(finclip_wrapper PROPERTIES IMPORTED_LOCATION "${FINCLIP_SDK_PATH}/libFinClipSDKWrapper.so") + endif() +else() + message("Operating System: Unknown") +endif() +find_package( + Qt5 + COMPONENTS Widgets Gui + REQUIRED) +target_include_directories(${FINCLIP_QTDEMO_TARGET} PRIVATE "${FINCLIP_SDK_PATH}") + +message(STATUS "cmake configuration is ${CMAKE_SYSTEM_NAME} ${PROJECT_ARCH} ${FINCLIP_SDK_PATH} ${Qt5_DIR}") + +# +# include_directories(../vendor/json) + +target_link_libraries( + ${FINCLIP_QTDEMO_TARGET} + finclip_wrapper + Qt5::Widgets + Qt5::Gui +) + + + + + + diff --git a/examples/qt/README.md b/examples/qt/README.md index f4b751c..e69de29 100644 --- a/examples/qt/README.md +++ b/examples/qt/README.md @@ -1,17 +0,0 @@ -# 通用步骤与功能介绍 - -快速开始前请先阅读以下文档 - -[Finclip桌面版Demo集成指引与功能介绍](https://github.com/finogeeks/finclip-desktop-demo/tree/master/examples/README.md) - - -# 快速开始 - -1. 使用qt creator打开 demo文件夹 -2. 点击运行, 即可打开 - - -# 注意事项 - -1. 下载路径请不要有中文, 否则会有奇怪的问题 -2. 集成时将finclip存放至独立的位置, 避免dll冲突 \ No newline at end of file diff --git a/examples/qt/src/main.cc b/examples/qt/src/main.cc new file mode 100644 index 0000000..5d52beb --- /dev/null +++ b/examples/qt/src/main.cc @@ -0,0 +1,79 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include "finclip_api.h" +#include "finclip_api_const.h" + +using namespace std; +#define CHECK_RESULT(func) \ + do { \ + int result = func; \ + if (result == 0) { \ + std::cout << "Result is 0" << std::endl; \ + } else { \ + std::cout << "Result is not 0" << std::endl; \ + } \ + } while (0) +#define ASSERT_RESULT(result) \ + do { \ + if (result != 0) std::cout << "Result is " << result << std::endl; \ + assert(result == 0); \ + } while (0) +void fc_lifecycle_close(enum LifecycleType type, const char* appid, + void* input) { + _Exit(0); +} +void fc_lifecycle_crash(enum LifecycleType type, const char* appid, + void* input) { + _Exit(0); +} + +void example_api(const char* event, const char* param, void* input, + int callbackid, const char* appid) { + auto* params = finclip_create_params(); + // YOUR CODE HERE + finclip_callback_success(callbackid, params); + finclip_destory_params(params); +} + +int main(int argc, char* argv[]) { + const QApplication app(argc, argv); + const string appkey = ""; + const string secret = ""; + const string domain = ""; + const string appid = ""; + const string exe_path = ""; + const string app_store = "1"; + + FinclipParams* config = finclip_create_params(); + ASSERT_RESULT( + finclip_params_set(config, FINCLIP_CONFIG_APPSTORE, app_store.c_str())); + ASSERT_RESULT( + finclip_params_set(config, FINCLIP_CONFIG_APPKEY, appkey.c_str())); + ASSERT_RESULT( + finclip_params_set(config, FINCLIP_CONFIG_SECRET, secret.c_str())); + ASSERT_RESULT( + finclip_params_set(config, FINCLIP_CONFIG_DOMAIN, domain.c_str())); + ASSERT_RESULT( + finclip_params_set(config, FINCLIP_CONFIG_EXE_PATH, exe_path.c_str())); + ASSERT_RESULT(finclip_register_lifecycle(appid.c_str(), kLifecycleClosed, + fc_lifecycle_close, nullptr)); + ASSERT_RESULT(finclip_register_lifecycle(appid.c_str(), kLifecycleCrashed, + fc_lifecycle_crash, nullptr)); + finclip_register_api_v2(kApplet, "example_api", example_api, nullptr); + finclip_register_api_v2(kWebView, "example_api1", example_api, nullptr); + auto* params = finclip_create_params(); + ASSERT_RESULT(finclip_init_with_config(app_store.c_str(), config)); + + ASSERT_RESULT( + finclip_start_applet_params(app_store.c_str(), appid.data(), params)); + + app.exec(); + return 0; +} diff --git a/examples/tauri/README.md b/examples/tauri/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/linux/.gitignore b/vendor/linux/.gitignore new file mode 100644 index 0000000..0a00d70 --- /dev/null +++ b/vendor/linux/.gitignore @@ -0,0 +1 @@ +*/ \ No newline at end of file diff --git a/vendor/mac/.gitignore b/vendor/mac/.gitignore index 051c921..0a00d70 100644 --- a/vendor/mac/.gitignore +++ b/vendor/mac/.gitignore @@ -1,2 +1 @@ -arm/ -x64/ \ No newline at end of file +*/ \ No newline at end of file diff --git a/vendor/mac/README.md b/vendor/mac/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/win/.gitignore b/vendor/win/.gitignore index 3291639..0a00d70 100644 --- a/vendor/win/.gitignore +++ b/vendor/win/.gitignore @@ -1,2 +1 @@ -x86/ -x64/ \ No newline at end of file +*/ \ No newline at end of file diff --git a/vendor/win/README.md b/vendor/win/README.md deleted file mode 100644 index e69de29..0000000