Skip to content

Commit

Permalink
Merge branch 'release/v0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseGuoX committed May 5, 2023
2 parents 6934c2e + a2f7ec4 commit 3753eb2
Show file tree
Hide file tree
Showing 25 changed files with 2,144 additions and 48 deletions.
31 changes: 26 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@ set(HEADERS
src/controller.h
src/stdafx.h
src/updater.h
src/hotkey.h
)
set(SOURCES
"src/main.cpp"
"src/controller.cpp"
"src/updater.cpp"
src/main.cpp
src/controller.cpp
src/updater.cpp
src/hotkey.cpp
)

set(RESOURCES
GPT_Translator.qrc
)

add_subdirectory(lib/)


IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE(STATUS "current platform: Linux ")
find_package(X11 REQUIRED)

qt_add_executable(GPT_Translator
${SOURCES} ${HEADERS} ${RESOURCES}
Expand All @@ -66,7 +70,7 @@ ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
MESSAGE(STATUS "current platform: Darwin")

find_library( APP_SERVICES_LIBRARY ApplicationServices )

set(MACOSX_BUNDLE_ICON_FILE logo.icns)
# And the following tells CMake where to find and install the file itself.
Expand Down Expand Up @@ -99,19 +103,36 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
user32
)
else()
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
user32
)
endif()
ELSE()
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_include_directories(GPT_Translator PRIVATE ${X11_INCLUDE_DIR})

target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
${X11_LIBRARIES}
)

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
${APP_SERVICES_LIBRARY}
)
ENDIF()

Expand Down
2 changes: 2 additions & 0 deletions GPT_Translator.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
<file>res/speak1.png</file>
<file>res/speak2.png</file>
<file>res/tray.png</file>
<file>qml/GPopWindow.qml</file>
<file>res/icon.png</file>
</qresource>
</RCC>
Binary file modified doc/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.16)


add_subdirectory(QHotkey-1.5.0)
34 changes: 34 additions & 0 deletions lib/QHotkey-1.5.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# C++ objects and libs

*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib

# Qt-es

/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*build-*

# QtCreator

*.autosave

#QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
96 changes: 96 additions & 0 deletions lib/QHotkey-1.5.0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.1)

project(qhotkey VERSION 1.5.0 LANGUAGES CXX)

option(QHOTKEY_EXAMPLES "Build examples" OFF)
option(QHOTKEY_INSTALL "Enable install rule" ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)

if(NOT QT_DEFAULT_MAJOR_VERSION)
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
endif()

if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} 6.2.0 COMPONENTS Core Gui REQUIRED)
else()
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Core Gui REQUIRED)
endif()

add_library(qhotkey QHotkey/qhotkey.cpp)
add_library(QHotkey::QHotkey ALIAS qhotkey)
target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)

if(BUILD_SHARED_LIBS)
target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY)
target_compile_definitions(qhotkey PUBLIC QHOTKEY_SHARED)
endif()

if(APPLE)
find_library(CARBON_LIBRARY Carbon)
mark_as_advanced(CARBON_LIBRARY)

target_sources(qhotkey PRIVATE QHotkey/qhotkey_mac.cpp)
target_link_libraries(qhotkey PRIVATE ${CARBON_LIBRARY})
elseif(WIN32)
target_sources(qhotkey PRIVATE QHotkey/qhotkey_win.cpp)
else()
find_package(X11 REQUIRED)
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES})
else()
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS X11Extras REQUIRED)
target_link_libraries(qhotkey
PRIVATE
${X11_LIBRARIES}
Qt${QT_DEFAULT_MAJOR_VERSION}::X11Extras)
endif()

include_directories(${X11_INCLUDE_DIR})
target_sources(qhotkey PRIVATE QHotkey/qhotkey_x11.cpp)
endif()

include(GNUInstallDirs)

target_include_directories(qhotkey
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/QHotkey>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

include(CMakePackageConfigHelpers)

set_target_properties(qhotkey PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
INTERFACE_QHotkey_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
COMPATIBLE_INTERFACE_STRING QHotkey_MAJOR_VERSION)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion)

if(QHOTKEY_EXAMPLES)
add_subdirectory(HotkeyTest)
endif()

if(QHOTKEY_INSTALL)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)

install(
TARGETS qhotkey EXPORT QHotkeyConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/QHotkeyConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR})
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})

export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
endif()
1 change: 1 addition & 0 deletions lib/QHotkey-1.5.0/QHotkey/QHotkey
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "qhotkey.h"
16 changes: 16 additions & 0 deletions lib/QHotkey-1.5.0/QHotkey/QHotkey.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TEMPLATE = lib
win32: CONFIG += dll

TARGET = QHotkey
VERSION = 1.5.0

include(../qhotkey.pri)

DEFINES += QHOTKEY_SHARED QHOTKEY_LIBRARY

# use INSTALL_ROOT to modify the install location
headers.files = $$PUBLIC_HEADERS
headers.path = $$[QT_INSTALL_HEADERS]
target.path = $$[QT_INSTALL_LIBS]
INSTALLS += target headers

Loading

0 comments on commit 3753eb2

Please sign in to comment.