From 632cd4c4ba8e865b796a30a85d471be8fe52d64a Mon Sep 17 00:00:00 2001 From: Tiernan Hubble Date: Mon, 10 Apr 2023 08:49:53 -0600 Subject: [PATCH] Initial support for building with Qt6/KF6. --- CMakeLists.txt | 98 ++++++++++++------- autotests/qml/qmluserscriptapitest.cpp | 2 +- src/lib/3rdparty/fancytabwidget.cpp | 7 +- src/lib/3rdparty/fancytabwidget.h | 6 +- .../qtsingleapplication/qtlocalpeer.cpp | 8 ++ src/lib/3rdparty/stylehelper.cpp | 8 ++ src/lib/CMakeLists.txt | 45 ++++++--- src/lib/adblock/adblockmanager.cpp | 4 + src/lib/adblock/adblockrule.cpp | 33 ++++++- src/lib/adblock/adblocksubscription.cpp | 14 ++- src/lib/app/browserwindow.cpp | 9 +- src/lib/app/mainapplication.cpp | 12 +++ src/lib/app/mainapplication.h | 8 ++ src/lib/app/qzcommon.h | 2 +- src/lib/autofill/autofill.cpp | 6 +- .../bookmarksexport/htmlexporter.cpp | 6 +- .../bookmarksimport/operaimporter.cpp | 6 +- src/lib/bookmarks/bookmarksmanager.h | 3 +- src/lib/bookmarks/bookmarksmodel.cpp | 1 + src/lib/bookmarks/bookmarkstoolbar.cpp | 5 +- src/lib/bookmarks/bookmarkstoolbarbutton.cpp | 4 + src/lib/bookmarks/bookmarkstoolbarbutton.h | 6 +- src/lib/downloads/downloaditem.cpp | 29 ++++-- src/lib/downloads/downloaditem.h | 15 ++- src/lib/downloads/downloadmanager.cpp | 37 +++++-- src/lib/downloads/downloadmanager.h | 12 +++ src/lib/downloads/downloadoptionsdialog.cpp | 6 +- src/lib/downloads/downloadoptionsdialog.h | 9 +- src/lib/history/historymenu.cpp | 4 +- .../completer/locationcompleterdelegate.cpp | 6 +- .../completer/locationcompleterrefreshjob.cpp | 4 + src/lib/navigation/locationbar.cpp | 2 +- src/lib/navigation/navigationbar.cpp | 10 +- src/lib/navigation/websearchbar.cpp | 4 + src/lib/network/networkmanager.cpp | 34 ++++++- src/lib/network/networkmanager.h | 9 ++ src/lib/opensearch/editsearchengine.cpp | 4 + src/lib/opensearch/searchenginesdialog.cpp | 4 + src/lib/other/statusbar.cpp | 2 +- src/lib/plugins/ocssupport.cpp | 4 + src/lib/plugins/plugins.cpp | 2 +- src/lib/plugins/plugins.h | 1 + .../qml/api/bookmarks/qmlbookmarktreenode.h | 2 + .../plugins/qml/api/events/qmlwheelevent.cpp | 2 +- .../qml/api/userscript/qmluserscript.cpp | 13 +++ .../qml/api/userscript/qmluserscript.h | 11 +++ .../qml/api/userscript/qmluserscripts.cpp | 17 +++- src/lib/plugins/speeddial.h | 2 +- src/lib/preferences/autofillmanager.cpp | 11 ++- src/lib/preferences/pluginlistdelegate.cpp | 4 +- src/lib/preferences/preferences.cpp | 16 ++- src/lib/session/sessionmanager.cpp | 1 + src/lib/session/sessionmanagerdialog.cpp | 2 +- src/lib/sidebar/sidebar.cpp | 1 + src/lib/tabwidget/combotabbar.cpp | 57 ++++++----- src/lib/tabwidget/combotabbar.h | 6 +- src/lib/tabwidget/tabicon.cpp | 1 + src/lib/tools/buttonwithmenu.cpp | 4 + src/lib/tools/buttonwithmenu.h | 2 +- src/lib/tools/desktopfile.cpp | 3 + .../html5permissionsnotification.cpp | 5 + src/lib/tools/progressbar.cpp | 2 +- src/lib/tools/qztools.cpp | 10 +- src/lib/webengine/webhittestresult.cpp | 19 +++- src/lib/webengine/webhittestresult.h | 8 +- src/lib/webengine/webpage.cpp | 28 ++++++ src/lib/webengine/webpage.h | 8 ++ src/lib/webengine/webscrollbar.cpp | 1 + src/lib/webengine/webscrollbarmanager.cpp | 7 ++ src/lib/webengine/webview.cpp | 23 ++++- src/lib/webtab/searchtoolbar.cpp | 5 + src/lib/webtab/searchtoolbar.h | 1 + src/main/CMakeLists.txt | 5 +- src/plugins/AutoScroll/autoscroller.cpp | 1 + src/plugins/CMakeLists.txt | 4 +- src/plugins/FlashCookieManager/fcm_plugin.h | 2 +- src/plugins/GreaseMonkey/gm_manager.cpp | 18 ++++ .../settings/gm_settingslistdelegate.cpp | 4 +- src/plugins/PyFalkon/CMakeLists.txt | 28 +++--- src/plugins/PyFalkon/autotests/CMakeLists.txt | 2 +- .../StatusBarIcons/sbi_networkicon.cpp | 16 +++ src/plugins/StatusBarIcons/sbi_networkicon.h | 7 ++ src/plugins/TabManager/tabmanagerwidget.cpp | 13 ++- src/plugins/TabManager/tabmanagerwidget.h | 4 + .../TabManager/tabmanagerwidgetcontroller.cpp | 7 ++ src/plugins/VerticalTabs/tabtreedelegate.cpp | 2 +- 86 files changed, 711 insertions(+), 165 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a847838be..a2ab8bde2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,15 @@ include(ECMSetupVersion) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) include(ECMPoQmTools) +if (QT_MAJOR_VERSION STREQUAL "6") + set(QT_MIN_VERSION "6.4.0") + set(KF_MIN_VERSION "5.240.0") + set(KF_MAJOR_VERSION "6") +else() + set(QT_MIN_VERSION "5.15.0") + set(KF_MIN_VERSION "5.78.0") + set(KF_MAJOR_VERSION "5") +endif() # Output dirs (like ECM 5.38 does) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") @@ -49,26 +58,30 @@ endif() # Defines that are always set add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_TO_ASCII) -# Mandatory: Qt5 -set(QT_MIN_VERSION "5.15.0") -find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets Network Sql QuickWidgets PrintSupport WebChannel) -find_package(Qt5WebEngine ${QT_MIN_VERSION} REQUIRED) -find_package(Qt5WebEngineWidgets ${QT_MIN_VERSION} REQUIRED) +# Mandatory: Qt5/6 +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets Network Sql QuickWidgets PrintSupport WebChannel) +if (QT_MAJOR_VERSION STREQUAL "6") + find_package(Qt6WebEngineCore ${QT_MIN_VERSION} REQUIRED) + find_package(Qt6WebEngineWidgets ${QT_MIN_VERSION} REQUIRED) +else() + find_package(Qt5WebEngine ${QT_MIN_VERSION} REQUIRED) + find_package(Qt5WebEngineWidgets ${QT_MIN_VERSION} REQUIRED) +endif() if (BUILD_TESTING) - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test) + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Test) endif() if (NOT DISABLE_DBUS) - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus) + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus) endif() if (UNIX AND NOT APPLE AND NOT NO_X11) add_definitions(-DQZ_WS_X11) find_package(XCB REQUIRED COMPONENTS XCB UTIL) - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) endif() if (WIN32) add_definitions(-DW7API) - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS WinExtras) + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS WinExtras) # taken from https://stackoverflow.com/a/40217291 macro(get_WIN32_WINNT version) @@ -93,15 +106,19 @@ if (WIN32) add_definitions(-D_WIN32_WINNT=${ver}) endif() +if (QT_MAJOR_VERSION STREQUAL "6") + find_package(Qt6Core5Compat) +endif() + # Mandatory: OpenSSL find_package(OpenSSL REQUIRED) -# Mandatory: KF5 -find_package(KF5 REQUIRED COMPONENTS Archive) +# Mandatory: KF5/6 +find_package(KF${KF_MAJOR_VERSION} REQUIRED COMPONENTS Archive) # KF5I18n: Mandatory with downloaded translations (only for ki18n_install) if (EXISTS "${CMAKE_SOURCE_DIR}/po") - find_package(KF5I18n REQUIRED) + find_package(KF${KF_MAJOR_VERSION}I18n REQUIRED) endif() # Optional: GnomeKeyring @@ -114,34 +131,47 @@ if (PKG_CONFIG_FOUND) endif() # Optional: KWallet, KIO, KCrash, KCoreAddons -set(KF5_MIN_VERSION "5.78.0") -find_package(KF5Wallet ${KF5_MIN_VERSION} CONFIG) -set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG) -set_package_properties(KF5KIO PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -find_package(KF5Crash ${KF5_MIN_VERSION} CONFIG) -set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG) -set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG) -find_package(KF5JobWidgets ${KF5_MIN_VERSION} CONFIG) -set_package_properties(KF5JobWidgets PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) -if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND AND KF5Purpose_FOUND AND KF5JobWidgets_FOUND) +find_package(KF${KF_MAJOR_VERSION}Wallet ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}Wallet PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +find_package(KF${KF_MAJOR_VERSION}KIO ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}KIO PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +find_package(KF${KF_MAJOR_VERSION}Crash ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}Crash PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +find_package(KF${KF_MAJOR_VERSION}CoreAddons ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +find_package(KF${KF_MAJOR_VERSION}Purpose ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}Purpose PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +find_package(KF${KF_MAJOR_VERSION}JobWidgets ${KF_MIN_VERSION} CONFIG) +set_package_properties(KF${KF_MAJOR_VERSION}JobWidgets PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL) +if (KF${KF_MAJOR_VERSION}Wallet_FOUND AND KF${KF_MAJOR_VERSION}KIO_FOUND AND KF${KF_MAJOR_VERSION}Crash_FOUND AND KF${KF_MAJOR_VERSION}CoreAddons_FOUND AND KF${KF_MAJOR_VERSION}Purpose_FOUND AND KF${KF_MAJOR_VERSION}JobWidgets_FOUND) set(ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN TRUE) endif() # Optional: PySide2 option(BUILD_PYTHON_SUPPORT "Support for Python plugins" ON) if (BUILD_PYTHON_SUPPORT) - find_package(PySide2 "2.0.0") - find_package(Shiboken2 "2.0.0") - find_package(Python3 COMPONENTS Development) - set_package_properties(PySide2 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) - set_package_properties(Shiboken2 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) - set_package_properties(Python3 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) - if (PySide2_FOUND AND Shiboken2_FOUND AND Python3_FOUND) - set(ENABLE_PYTHON_PLUGINS TRUE) + if (QT_MAJOR_VERSION STREQUAL "6") + # Optional: PySide6 + find_package(PySide6 "6.4.0") + find_package(Shiboken6 "6.4.0") + find_package(Python3 COMPONENTS Development) + set_package_properties(PySide6 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + set_package_properties(Shiboken6 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + set_package_properties(Python3 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + if (PySide6_FOUND AND Shiboken6_FOUND AND Python3_FOUND) + set(ENABLE_PYTHON_PLUGINS TRUE) + endif() + else() + # Optional: PySide2 + find_package(PySide2 "2.0.0") + find_package(Shiboken2 "2.0.0") + find_package(Python3 COMPONENTS Development) + set_package_properties(PySide2 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + set_package_properties(Shiboken2 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + set_package_properties(Python3 PROPERTIES DESCRIPTION "Python plugins" TYPE OPTIONAL) + if (PySide2_FOUND AND Shiboken2_FOUND AND Python3_FOUND) + set(ENABLE_PYTHON_PLUGINS TRUE) + endif() endif() endif() diff --git a/autotests/qml/qmluserscriptapitest.cpp b/autotests/qml/qmluserscriptapitest.cpp index 3a7e28cb8..c7e90a045 100644 --- a/autotests/qml/qmluserscriptapitest.cpp +++ b/autotests/qml/qmluserscriptapitest.cpp @@ -41,7 +41,7 @@ void QmlUserScriptApiTest::testCount() void QmlUserScriptApiTest::testSize() { int size = m_testHelper.evaluate("Falkon.UserScripts.size").toInt(); - QCOMPARE(size, mApp->webProfile()->scripts()->size()); + QCOMPARE(size, mApp->webProfile()->scripts()->count()); } void QmlUserScriptApiTest::testEmpty() diff --git a/src/lib/3rdparty/fancytabwidget.cpp b/src/lib/3rdparty/fancytabwidget.cpp index 582f833b5..384a64fdf 100644 --- a/src/lib/3rdparty/fancytabwidget.cpp +++ b/src/lib/3rdparty/fancytabwidget.cpp @@ -39,10 +39,11 @@ #include #include #include -#include +#include #include #include #include +#include //#include using namespace Core; @@ -306,7 +307,11 @@ void FancyTabBar::paintEvent(QPaintEvent* event) } } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void FancyTab::enterEvent(QEvent*) +#else +void FancyTab::enterEvent(QEnterEvent*) +#endif { fadeIn(); } diff --git a/src/lib/3rdparty/fancytabwidget.h b/src/lib/3rdparty/fancytabwidget.h index d7b87851d..eceff02c8 100644 --- a/src/lib/3rdparty/fancytabwidget.h +++ b/src/lib/3rdparty/fancytabwidget.h @@ -86,7 +86,11 @@ public: QString text; protected: - void enterEvent(QEvent*) override; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + void enterEvent(QEvent *event) override; +#else + void enterEvent(QEnterEvent *event) override; +#endif void leaveEvent(QEvent*) override; private: diff --git a/src/lib/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/src/lib/3rdparty/qtsingleapplication/qtlocalpeer.cpp index 83e397c94..3160d6743 100644 --- a/src/lib/3rdparty/qtsingleapplication/qtlocalpeer.cpp +++ b/src/lib/3rdparty/qtsingleapplication/qtlocalpeer.cpp @@ -44,6 +44,10 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + #include "../config.h" #if defined(Q_OS_LINUX) && !defined(DISABLE_DBUS) #define USE_DBUS @@ -110,7 +114,11 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) #endif prefix = id.section(QLatin1Char('/'), -1); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) prefix.remove(QRegExp("[^a-zA-Z]")); +#else + prefix = QRegExp("[^a-zA-Z]").removeIn(prefix); +#endif prefix.truncate(6); QByteArray idc = id.toUtf8(); diff --git a/src/lib/3rdparty/stylehelper.cpp b/src/lib/3rdparty/stylehelper.cpp index ca0372aa7..9324af89e 100644 --- a/src/lib/3rdparty/stylehelper.cpp +++ b/src/lib/3rdparty/stylehelper.cpp @@ -160,7 +160,11 @@ void StyleHelper::verticalGradient(QPainter* painter, const QRect &spanRect, con clipRect.height(), keyColor.rgb()); QPixmap pixmap; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (!QPixmapCache::find(key, pixmap)) { +#else + if (!QPixmapCache::find(key, &pixmap)) { +#endif pixmap = QPixmap(clipRect.size()); QPainter p(&pixmap); QRect rect(0, 0, clipRect.width(), clipRect.height()); @@ -183,7 +187,11 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, QPixmap cache; QString pixmapName = QSL("icon %0 %1 %2").arg(icon.cacheKey()).arg(iconMode).arg(rect.height()); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (!QPixmapCache::find(pixmapName, cache)) { +#else + if (!QPixmapCache::find(pixmapName, &cache)) { +#endif QPixmap px = icon.pixmap(rect.size(), iconMode); px.setDevicePixelRatio(qApp->devicePixelRatio()); cache = QPixmap(px.size() + QSize(radius * 2, radius * 2)); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 806800aeb..d66a8582c 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -577,20 +577,41 @@ qt_add_resources(SRCS add_library(FalkonPrivate SHARED ${SRCS} ${LOGGING_SRCS}) -get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +if (QT_MAJOR_VERSION STREQUAL "6") + get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt6::WebEngineCore PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +else() + get_property(QT_WEBENGINE_INCLUDE_DIRS TARGET Qt::WebEngine PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +endif() + target_include_directories(FalkonPrivate SYSTEM PUBLIC ${QT_WEBENGINE_INCLUDE_DIRS}) -target_link_libraries(FalkonPrivate - Qt::Widgets - Qt::WebEngineWidgets - Qt::Network - Qt::Sql - Qt::PrintSupport - Qt::QuickWidgets - Qt::WebChannel - KF5::Archive - ${OPENSSL_CRYPTO_LIBRARY} -) +if (QT_MAJOR_VERSION STREQUAL "6") + target_link_libraries(FalkonPrivate + Qt6::Widgets + Qt6::WebEngineWidgets + Qt6::Network + Qt6::NetworkPrivate + Qt6::Sql + Qt6::PrintSupport + Qt6::QuickWidgets + Qt6::WebChannel + Qt6::Core5Compat + KF6::Archive + ${OPENSSL_CRYPTO_LIBRARY} + ) +else() + target_link_libraries(FalkonPrivate + Qt::Widgets + Qt::WebEngineWidgets + Qt::Network + Qt::Sql + Qt::PrintSupport + Qt::QuickWidgets + Qt::WebChannel + KF5::Archive + ${OPENSSL_CRYPTO_LIBRARY} + ) +endif() if (HAVE_LIBINTL) target_include_directories(FalkonPrivate SYSTEM PUBLIC ${Intl_INCLUDE_DIRS}) diff --git a/src/lib/adblock/adblockmanager.cpp b/src/lib/adblock/adblockmanager.cpp index 98d111235..6d36445a7 100644 --- a/src/lib/adblock/adblockmanager.cpp +++ b/src/lib/adblock/adblockmanager.cpp @@ -296,7 +296,11 @@ void AdBlockManager::load() } QTextStream textStream(&file); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) textStream.setCodec("UTF-8"); +#else + textStream.setEncoding(QStringConverter::Utf8); +#endif QString title = textStream.readLine(1024).remove(QLatin1String("Title: ")); QUrl url = QUrl(textStream.readLine(1024).remove(QLatin1String("Url: "))); diff --git a/src/lib/adblock/adblockrule.cpp b/src/lib/adblock/adblockrule.cpp index 10ceac2f6..2eaddb864 100644 --- a/src/lib/adblock/adblockrule.cpp +++ b/src/lib/adblock/adblockrule.cpp @@ -53,9 +53,40 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#include +#endif + +static QString getTopLevelDomain(const QUrl &url) +{ +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + return url.topLevelDomain(); +#else + // QUrl::topLevelDomain() was removed in Qt6. + // The following is copied from the old "qTopLevelDomain" code in Qt6::Network. + // It was removed in this commit: https://github.com/qt/qtbase/commit/50b30976837be0969efdccced68cfb584d99981a + const QString domainLower = url.host().toLower(); + QVector sections = QStringView{domainLower}.split(QLatin1Char('.'), Qt::SkipEmptyParts); + if (sections.isEmpty()) + return QString(); + + QString level, tld; + for (int j = sections.count() - 1; j >= 0; --j) { + level.prepend(QLatin1Char('.') + sections.at(j)); + if (qIsEffectiveTLD(QStringView{level}.right(level.size() - 1))) + tld = level; + } + + //return qt_ACE_do(tld, ToAceOnly, AllowLeadingDot, {}); + // TODO - QUrl::toAce() uses ForbidLeadingDot, while the old QUrl::topLevelDomain() used AllowLeadingDot. Does this matter? + return QString(QUrl::toAce(tld)); +#endif +} + static QString toSecondLevelDomain(const QUrl &url) { - const QString topLevelDomain = url.topLevelDomain(); + const QString topLevelDomain = getTopLevelDomain(url); const QString urlHost = url.host(); if (topLevelDomain.isEmpty() || urlHost.isEmpty()) { diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index c8cf58686..4ef128ea2 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -103,7 +103,11 @@ void AdBlockSubscription::loadSubscription(const QStringList &disabledRules) } QTextStream textStream(&file); - textStream.setCodec("UTF-8"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + textStream.setCodec("UTF-8"); +#else + textStream.setEncoding(QStringConverter::Utf8); +#endif // Header is on 3rd line textStream.readLine(1024); textStream.readLine(1024); @@ -306,7 +310,11 @@ void AdBlockCustomList::loadSubscription(const QStringList &disabledRules) if (file.open(QFile::WriteOnly | QFile::Append)) { QTextStream stream(&file); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) stream.setCodec("UTF-8"); +#else + stream.setEncoding(QStringConverter::Utf8); +#endif if (!rules.contains(ddg1 + QL1S("\n"))) stream << ddg1 << Qt::endl; @@ -329,7 +337,11 @@ void AdBlockCustomList::saveSubscription() } QTextStream textStream(&file); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) textStream.setCodec("UTF-8"); +#else + textStream.setEncoding(QStringConverter::Utf8); +#endif textStream << "Title: " << title() << Qt::endl; textStream << "Url: " << url().toString() << Qt::endl; textStream << "[Adblock Plus 1.1.1]" << Qt::endl; diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index bf1381d73..e4806bb83 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -72,11 +72,14 @@ #include #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include +#endif #include #include #include #include +#include #ifdef QZ_WS_X11 #include @@ -400,7 +403,11 @@ void BrowserWindow::setupUi() m_statusBar->addButton(downloadsButton); m_navigationToolbar->addToolButton(downloadsButton); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QDesktopWidget* desktop = mApp->desktop(); +#else + auto desktop = QGuiApplication::primaryScreen(); +#endif int windowWidth = desktop->availableGeometry().width() / 1.3; int windowHeight = desktop->availableGeometry().height() / 1.3; @@ -1341,7 +1348,7 @@ void BrowserWindow::keyPressEvent(QKeyEvent* event) break; case Qt::Key_Backtab: - if (event->modifiers() == (Qt::ControlModifier + Qt::ShiftModifier)) { + if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { static_cast(m_tabWidget)->event(event); } break; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 53e6cb062..89a876fd5 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -62,7 +62,9 @@ #include #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #include +#endif #include #include #include @@ -930,7 +932,11 @@ void MainApplication::runDeferredPostLaunchActions() checkOptimizeDatabase(); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void MainApplication::downloadRequested(QWebEngineDownloadItem *download) +#else +void MainApplication::downloadRequested(QWebEngineDownloadRequest *download) +#endif { downloadManager()->download(download); } @@ -1187,10 +1193,16 @@ void MainApplication::setUserStyleSheet(const QString &filePath) const QString name = QStringLiteral("_falkon_userstylesheet"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QWebEngineScript oldScript = m_webProfile->scripts()->findScript(name); if (!oldScript.isNull()) { m_webProfile->scripts()->remove(oldScript); } +#else + for (const QWebEngineScript &oldScript : m_webProfile->scripts()->find(name)) { + m_webProfile->scripts()->remove(oldScript); + } +#endif if (userCss.isEmpty()) return; diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 5bffe26b2..aea5c8270 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -31,7 +31,11 @@ class QMenu; class QWebEngineProfile; class QWebEngineSettings; class QNetworkAccessManager; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) class QWebEngineDownloadItem; +#else +class QWebEngineDownloadRequest; +#endif class History; class AutoFill; @@ -146,7 +150,11 @@ private Q_SLOTS: void onFocusChanged(); void runDeferredPostLaunchActions(); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void downloadRequested(QWebEngineDownloadItem *download); +#else + void downloadRequested(QWebEngineDownloadRequest *download); +#endif private: enum PostLaunchAction { diff --git a/src/lib/app/qzcommon.h b/src/lib/app/qzcommon.h index 5b51c3cdf..3d43426ca 100644 --- a/src/lib/app/qzcommon.h +++ b/src/lib/app/qzcommon.h @@ -20,7 +20,7 @@ #include #include -#include +#include #ifdef FALKON_SHAREDLIBRARY #define FALKON_EXPORT Q_DECL_EXPORT diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index 8c54356e6..d191a59ca 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -249,7 +249,11 @@ QByteArray AutoFill::exportPasswords() QByteArray output; QXmlStreamWriter stream(&output); - stream.setCodec("UTF-8"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + stream.setCodec("UTF-8"); +#else + stream.setEncoding(QStringConverter::Utf8); +#endif stream.setAutoFormatting(true); stream.writeStartDocument(); diff --git a/src/lib/bookmarks/bookmarksexport/htmlexporter.cpp b/src/lib/bookmarks/bookmarksexport/htmlexporter.cpp index edd82caa8..e0e78e994 100644 --- a/src/lib/bookmarks/bookmarksexport/htmlexporter.cpp +++ b/src/lib/bookmarks/bookmarksexport/htmlexporter.cpp @@ -49,7 +49,11 @@ bool HtmlExporter::exportBookmarks(BookmarkItem* root) } QTextStream stream(&file); - stream.setCodec("UTF-8"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + stream.setCodec("UTF-8"); +#else + stream.setEncoding(QStringConverter::Utf8); +#endif stream << "" << Qt::endl; stream << "