diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e5390e..58805f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,14 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED) +option(QVPLUGIN_USE_QT6 "Use Qt6") +if(QVPLUGIN_USE_QT6) + set(QV_QT_LIBNAME Qt6) +else() + set(QV_QT_LIBNAME Qt5) +endif() +find_package(${QV_QT_LIBNAME} COMPONENTS Core Widgets Gui Network REQUIRED) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(QVPLUGIN_INTERFACE_INCLUDE_DIR "interface/") @@ -42,8 +49,8 @@ if(APPLE) endif() target_link_libraries(${PROJECT_NAME} - Qt5::Core - Qt5::Gui - Qt5::Widgets) + ${QV_QT_LIBNAME}::Core + ${QV_QT_LIBNAME}::Gui + ${QV_QT_LIBNAME}::Widgets) install(TARGETS ${PROJECT_NAME} DESTINATION share/qv2ray/plugins) diff --git a/core/EventHandler.cpp b/core/EventHandler.cpp index 8220d1c..541e4f7 100644 --- a/core/EventHandler.cpp +++ b/core/EventHandler.cpp @@ -4,6 +4,13 @@ #include +#if QT_VERSION_MAJOR >= 6 +using QRegExp = QRegularExpression; + #define SkipEmpty Qt::SkipEmptyParts +#else + #define SkipEmpty QString::SkipEmptyParts +#endif + using namespace Qv2rayPlugin; SimpleEventHandler::SimpleEventHandler() : Qv2rayPlugin::PluginEventHandler(){}; QvPlugin_EventHandler(SimpleEventHandler, Connectivity) @@ -21,22 +28,22 @@ QvPlugin_EventHandler(SimpleEventHandler, Connectivity) { case Events::Connectivity::Connected: { - actions << settings.afterConnection.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.afterConnection.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::Connectivity::Connecting: { - actions << settings.beforeConnection.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.beforeConnection.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::Connectivity::Disconnected: { - actions << settings.afterDisConnection.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.afterDisConnection.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::Connectivity::Disconnecting: { - actions << settings.beforeDisConnection.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.beforeDisConnection.split(QRegExp("[\r\n]"), SkipEmpty); break; } } @@ -77,12 +84,12 @@ QvPlugin_EventHandler(SimpleEventHandler, SystemProxy) { case Events::SystemProxy::SetProxy: { - actions << settings.setSystemProxy.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.setSystemProxy.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::SystemProxy::ClearProxy: { - actions << settings.clearSystemProxy.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.clearSystemProxy.split(QRegExp("[\r\n]"), SkipEmpty); break; } } @@ -120,23 +127,23 @@ QvPlugin_EventHandler(SimpleEventHandler, ConnectionEntry) { case Events::ConnectionEntry::Created: { - actions << settings.connectionCreated.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.connectionCreated.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::ConnectionEntry::FullyRemoved: case Events::ConnectionEntry::RemovedFromGroup: { - actions << settings.connectionDeleted.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.connectionDeleted.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::ConnectionEntry::Renamed: { - actions << settings.connectionRenamed.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.connectionRenamed.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::ConnectionEntry::Edited: { - actions << settings.connectionUpdated.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + actions << settings.connectionUpdated.split(QRegExp("[\r\n]"), SkipEmpty); break; } case Events::ConnectionEntry::LinkedWithGroup: