mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
clean up QHotkey
This commit is contained in:
parent
447b9bdf42
commit
bf8de2e9e9
@ -47,6 +47,7 @@ message("[CMAKE_FIND_ROOT_PATH] ${CMAKE_FIND_ROOT_PATH}")
|
||||
|
||||
include("cmake/print.cmake")
|
||||
include("cmake/nkr.cmake")
|
||||
include("cmake/QHotkey.cmake")
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
@ -66,9 +67,7 @@ list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing)
|
||||
find_package(cpr REQUIRED)
|
||||
list(APPEND NKR_EXTERNAL_TARGETS cpr::cpr)
|
||||
|
||||
set(QHOTKEY_INSTALL OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(3rdparty/QHotkey)
|
||||
list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
|
||||
|
||||
# Sources
|
||||
|
||||
58
cmake/QHotkey.cmake
Normal file
58
cmake/QHotkey.cmake
Normal file
@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(qhotkey
|
||||
VERSION 1.5.0
|
||||
DESCRIPTION "Global hotkey library for Qt software"
|
||||
HOMEPAGE_URL "https://skycoder42.github.io/QHotkey/"
|
||||
LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(Qt6 6.8.0 COMPONENTS Core Gui REQUIRED)
|
||||
|
||||
# General settings
|
||||
set(CPACK_PACKAGE_VENDOR "Skycoder42")
|
||||
set(CPACK_PACKAGE_CONTACT "Shatur")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
||||
# CPACK: DEB Specific Settings
|
||||
set(CPACK_DEBIAN_PACKAGE_NAME "libqhotkey")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries")
|
||||
# Set dependencies
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6x11extras6 (>= 6.2.0)")
|
||||
include(CPack)
|
||||
|
||||
add_library(qhotkey 3rdparty/QHotkey/qhotkey.cpp)
|
||||
add_library(QHotkey::QHotkey ALIAS qhotkey)
|
||||
target_link_libraries(qhotkey PUBLIC Qt6::Core Qt6::Gui)
|
||||
|
||||
if(APPLE)
|
||||
find_library(CARBON_LIBRARY Carbon)
|
||||
mark_as_advanced(CARBON_LIBRARY)
|
||||
|
||||
target_sources(qhotkey PRIVATE 3rdparty/QHotkey/qhotkey_mac.cpp)
|
||||
target_link_libraries(qhotkey PRIVATE ${CARBON_LIBRARY})
|
||||
elseif(WIN32)
|
||||
target_sources(qhotkey PRIVATE 3rdparty/QHotkey/qhotkey_win.cpp)
|
||||
else()
|
||||
find_package(X11 REQUIRED)
|
||||
target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES})
|
||||
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
target_sources(qhotkey PRIVATE 3rdparty/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)
|
||||
@ -43,6 +43,7 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QStyleHints>
|
||||
#include <3rdparty/QHotkey/qhotkey.h>
|
||||
#include <include/global/HTTPRequestHelper.hpp>
|
||||
|
||||
#include "include/sys/macos/MacOS.h"
|
||||
@ -1738,10 +1739,6 @@ inline QJsonArray last_arr; // format is nekoray_connections_json
|
||||
|
||||
// Hotkey
|
||||
|
||||
#ifndef NKR_NO_QHOTKEY
|
||||
|
||||
#include <QHotkey>
|
||||
|
||||
inline QList<std::shared_ptr<QHotkey>> RegisteredHotkey;
|
||||
|
||||
void MainWindow::RegisterHotkey(bool unregister) {
|
||||
@ -1801,13 +1798,6 @@ void MainWindow::HotkeyEvent(const QString &key) {
|
||||
});
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void MainWindow::RegisterHotkey(bool unregister) {}
|
||||
|
||||
void MainWindow::HotkeyEvent(const QString &key) {}
|
||||
|
||||
#endif
|
||||
bool MainWindow::StopVPNProcess() {
|
||||
vpn_pid = core_process->processId();
|
||||
if (vpn_pid != 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user