diff --git a/CMakeLists.txt b/CMakeLists.txt index 69eea6af..2244acfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(ENABLE_PQXX "Build with Postgres supoort" ON) option(ENABLE_FROTZ "Build Frotz plugin" ON) option(ENABLE_IRC "Build IRC plugin" ON) +option(ENABLE_QT6 "Build IRC plugin with QT6 libraries" OFF) option(ENABLE_PURPLE "Build Libpurple plugin" ON) option(ENABLE_SMSTOOLS3 "Build SMSTools3 plugin" ON) option(ENABLE_XMPP "Build XMPP plugin" ON) @@ -190,7 +191,11 @@ endif() if(ENABLE_IRC) find_package(Communi) - find_package(Qt5 COMPONENTS Core Network) + if(ENABLE_QT6) + find_package(Qt6 COMPONENTS Core Network) + else() + find_package(Qt5 COMPONENTS Core Network) + endif() endif() find_package(event) diff --git a/backends/libcommuni/CMakeLists.txt b/backends/libcommuni/CMakeLists.txt index 7e3152fc..d88d8ae6 100644 --- a/backends/libcommuni/CMakeLists.txt +++ b/backends/libcommuni/CMakeLists.txt @@ -3,6 +3,9 @@ file(GLOB HEADERS *.h) if(ENABLE_QT4) QT4_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) +elseif(ENABLE_QT6) + QT6_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) + include_directories(${Qt6Core_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS}) else() QT5_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) @@ -15,12 +18,16 @@ target_compile_features(spectrum2_libcommuni_backend PUBLIC cxx_std_11) if(NOT WIN32) if(ENABLE_QT4) target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport-plugin) + elseif(ENABLE_QT6) + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt6::Network Qt6::Core transport-plugin) else() target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport-plugin) endif() else() if(ENABLE_QT4) target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport-plugin) + elseif(ENABLE_QT6) + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt6::Network Qt6::Core transport-plugin) else() target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport-plugin) endif() diff --git a/backends/libcommuni/backports.h b/backends/libcommuni/backports.h deleted file mode 100644 index 525e4e69..00000000 --- a/backends/libcommuni/backports.h +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include -#include - -namespace CommuniBackport { - -bool parseColors(const QString& message, int pos, int* len, int* fg = 0, int* bg = 0) -{ - // fg(,bg) - *len = 0; - if (fg) - *fg = -1; - if (bg) - *bg = -1; - QRegExp rx(QLatin1String("(\\d{1,2})(?:,(\\d{1,2}))?")); - int idx = rx.indexIn(message, pos); - if (idx == pos) { - *len = rx.matchedLength(); - if (fg) - *fg = rx.cap(1).toInt(); - if (bg) { - bool ok = false; - int tmp = rx.cap(2).toInt(&ok); - if (ok) - *bg = tmp; - } - } - return *len > 0; -} - -/*! -Converts \a text to plain text. This function parses the text and -strips away IRC-style formatting like colors, bold and underline. - -\sa toHtml() -*/ -void toPlainText(QString& processed) -{ - - int pos = 0; - int len = 0; - while (pos < processed.size()) { - switch (processed.at(pos).unicode()) { - case '\x02': // bold - case '\x0f': // none - case '\x13': // strike-through - case '\x15': // underline - case '\x16': // inverse - case '\x1d': // italic - case '\x1f': // underline - processed.remove(pos, 1); - break; - - case '\x03': // color - if (parseColors(processed, pos + 1, &len)) - processed.remove(pos, len + 1); - else - processed.remove(pos, 1); - break; - - default: - ++pos; - break; - } - } - -} - -} diff --git a/backends/libcommuni/session.cpp b/backends/libcommuni/session.cpp index fbbf3e1b..7826532e 100644 --- a/backends/libcommuni/session.cpp +++ b/backends/libcommuni/session.cpp @@ -25,7 +25,6 @@ #include #include #include -#include "backports.h" #include "ircnetworkplugin.h" @@ -409,7 +408,7 @@ void MyIrcSession::sendMessageToFrontend(const std::string &channel, const std:: void MyIrcSession::on_messageReceived(IrcMessage *message) { IrcPrivateMessage *m = (IrcPrivateMessage *) message; if (m->isRequest()) { - QString request = m->content().split(" ", QString::SkipEmptyParts).value(0).toUpper(); + QString request = m->content().split(" ", Qt::SkipEmptyParts).value(0).toUpper(); if (request == "PING" || request == "TIME" || request == "VERSION") { LOG4CXX_INFO(connectionLogger, m_user << ": " << TO_UTF8(request) << " received and has been answered"); return; diff --git a/cmake_modules/FindCommuni.cmake b/cmake_modules/FindCommuni.cmake index c6508975..1ee3ba92 100644 --- a/cmake_modules/FindCommuni.cmake +++ b/cmake_modules/FindCommuni.cmake @@ -1,6 +1,8 @@ if( ENABLE_QT4 ) find_package(Qt4) include( ${QT_USE_FILE} ) +elseif(ENABLE_QT6) + find_package(Qt6Network) else() find_package(Qt5Network) endif() @@ -8,6 +10,8 @@ endif() FIND_LIBRARY(IRC_LIBRARY NAMES IrcCore PATHS ${QT_LIBRARY_DIR}) if( ENABLE_QT4 ) FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES Communi) +elseif(ENABLE_QT6) + FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${Qt6Core_INCLUDE_DIRS} ${Qt6Core_INCLUDE_DIRS}"/.." PATH_SUFFIXES Communi) else() FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${Qt5Core_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS}"/.." PATH_SUFFIXES Communi) endif()