Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Qt6: Support Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
QxQ authored and QxQ committed Dec 13, 2020
1 parent 46988ed commit 0e2f15b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down Expand Up @@ -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)
27 changes: 17 additions & 10 deletions core/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

#include <QProcess>

#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)
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0e2f15b

Please sign in to comment.