1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Initial support for building with Qt6/KF6.

This commit is contained in:
Tiernan Hubble 2023-04-10 08:49:53 -06:00 committed by Juraj Oravec
parent b52c1e3655
commit 632cd4c4ba
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
86 changed files with 711 additions and 165 deletions

View File

@ -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()

View File

@ -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()

View File

@ -39,10 +39,11 @@
#include <QSignalMapper>
#include <QSplitter>
#include <QStackedLayout>
#include <QStyleOptionTabV3>
#include <QStyleOptionTab>
#include <QToolButton>
#include <QToolTip>
#include <QVBoxLayout>
#include <QActionGroup>
//#include <QWindowsStyle>
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();
}

View File

@ -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:

View File

@ -44,6 +44,10 @@
#include <QDataStream>
#include <QTime>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRegExp>
#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();

View File

@ -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));

View File

@ -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})

View File

@ -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: ")));

View File

@ -53,9 +53,40 @@
#include <QWebEnginePage>
#include <QWebEngineUrlRequestInfo>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QtCore/private/qurl_p.h>
#include <QtNetwork/private/qtldurl_p.h>
#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<QStringView> 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()) {

View File

@ -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;

View File

@ -72,11 +72,14 @@
#include <QWebEngineHistory>
#include <QWebEngineSettings>
#include <QMessageBox>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QDesktopWidget>
#endif
#include <QToolTip>
#include <QScrollArea>
#include <QCollator>
#include <QTemporaryFile>
#include <QActionGroup>
#ifdef QZ_WS_X11
#include <QX11Info>
@ -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<QObject*>(m_tabWidget)->event(event);
}
break;

View File

@ -62,7 +62,9 @@
#include <QDir>
#include <QStandardPaths>
#include <QWebEngineProfile>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineDownloadItem>
#endif
#include <QWebEngineScriptCollection>
#include <QRegularExpression>
#include <QtWebEngineWidgetsVersion>
@ -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;

View File

@ -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 {

View File

@ -20,7 +20,7 @@
#include <QDebug>
#include <QFlags>
#include <QtWebEngine/QtWebEngineVersion>
#include <QtWebEngineCore/QtWebEngineCoreVersion>
#ifdef FALKON_SHAREDLIBRARY
#define FALKON_EXPORT Q_DECL_EXPORT

View File

@ -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();

View File

@ -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 << "<!DOCTYPE NETSCAPE-Bookmark-file-1>" << Qt::endl;
stream << "<!-- This is an automatically generated file." << Qt::endl;

View File

@ -25,7 +25,11 @@
OperaImporter::OperaImporter(QObject* parent)
: BookmarksImporter(parent)
{
m_stream.setCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_stream.setCodec("UTF-8");
#else
m_stream.setEncoding(QStringConverter::Utf8);
#endif
}
QString OperaImporter::description() const

View File

@ -23,6 +23,8 @@
#include "qzcommon.h"
#include "bookmarkitem.h"
namespace Ui
{
class BookmarksManager;
@ -32,7 +34,6 @@ class QUrl;
class BrowserWindow;
class Bookmarks;
class BookmarkItem;
class FALKON_EXPORT BookmarksManager : public QWidget
{

View File

@ -22,6 +22,7 @@
#include <QApplication>
#include <QTimer>
#include <QStyle>
#include <QIODevice>
//#define BOOKMARKSMODEL_DEBUG

View File

@ -44,8 +44,9 @@ BookmarksToolbar::BookmarksToolbar(BrowserWindow* window, QWidget* parent)
setContextMenuPolicy(Qt::CustomContextMenu);
m_layout = new QHBoxLayout(this);
m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this)
+ style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this));
auto contentsMargin = style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this)
+ style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);
m_layout->setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin);
m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
setLayout(m_layout);

View File

@ -256,7 +256,11 @@ QString BookmarksToolbarButton::createTooltip() const
return m_bookmark->urlString();
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void BookmarksToolbarButton::enterEvent(QEvent* event)
#else
void BookmarksToolbarButton::enterEvent(QEnterEvent* event)
#endif
{
QPushButton::enterEvent(event);

View File

@ -63,7 +63,11 @@ private:
void init();
QString createTooltip() const;
void enterEvent(QEvent* event) 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* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;

View File

@ -35,7 +35,11 @@
#include <QMessageBox>
#include <QFileIconProvider>
#include <QDesktopServices>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineDownloadItem>
#else
#include <QWebEngineDownloadRequest>
#endif
#include <QtWebEngineWidgetsVersion>
#ifdef Q_OS_WIN
@ -45,7 +49,7 @@
//#define DOWNMANAGER_DEBUG
DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager)
DownloadItem::DownloadItem(QListWidgetItem *item, Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager)
: QWidget()
, ui(new Ui::DownloadItem)
, m_item(item)
@ -81,11 +85,17 @@ DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downlo
void DownloadItem::startDownloading()
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
connect(m_download, &QWebEngineDownloadItem::finished, this, &DownloadItem::finished);
connect(m_download, &QWebEngineDownloadItem::downloadProgress, this, &DownloadItem::downloadProgress);
#else
connect(m_download, &QWebEngineDownloadRequest::isFinishedChanged, this, &DownloadItem::finished);
connect(m_download, &QWebEngineDownloadRequest::receivedBytesChanged, this, &DownloadItem::receivedOrTotalBytesChanged);
connect(m_download, &QWebEngineDownloadRequest::totalBytesChanged, this, &DownloadItem::receivedOrTotalBytesChanged);
#endif
m_downloading = true;
if (m_downTimer.elapsed() < 1) {
if (!m_downTimer.isValid()) {
m_downTimer.start();
}
@ -123,16 +133,16 @@ void DownloadItem::finished()
QString host = m_download->url().host();
switch (m_download->state()) {
case QWebEngineDownloadItem::DownloadCompleted:
case Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::DownloadCompleted:
success = true;
ui->downloadInfo->setText(tr("Done - %1 (%2)").arg(host, QDateTime::currentDateTime().toString(Qt::DefaultLocaleShortDate)));
ui->downloadInfo->setText(tr("Done - %1 (%2)").arg(host, QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat)));
break;
case QWebEngineDownloadItem::DownloadInterrupted:
case Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::DownloadInterrupted:
ui->downloadInfo->setText(tr("Error - %1").arg(host));
break;
case QWebEngineDownloadItem::DownloadCancelled:
case Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::DownloadCancelled:
ui->downloadInfo->setText(tr("Cancelled - %1").arg(host));
break;
@ -154,8 +164,15 @@ void DownloadItem::finished()
Q_EMIT downloadFinished(true);
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void DownloadItem::downloadProgress(qint64 received, qint64 total)
{
#else
void DownloadItem::receivedOrTotalBytesChanged()
{
qint64 received = m_download->receivedBytes();
qint64 total = m_download->totalBytes();
#endif
#ifdef DOWNMANAGER_DEBUG
qDebug() << __FUNCTION__ << received << total;
#endif

View File

@ -25,6 +25,7 @@
#include <QNetworkReply>
#include <QElapsedTimer>
#include <QTime>
#include <QElapsedTimer>
#include "qzcommon.h"
@ -34,7 +35,13 @@ class DownloadItem;
}
class QListWidgetItem;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QWebEngineDownloadItem;
#define Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS QWebEngineDownloadItem
#else
class QWebEngineDownloadRequest;
#define Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS QWebEngineDownloadRequest
#endif
class DownloadManager;
@ -43,7 +50,7 @@ class FALKON_EXPORT DownloadItem : public QWidget
Q_OBJECT
public:
explicit DownloadItem(QListWidgetItem* item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager);
explicit DownloadItem(QListWidgetItem* item, Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager);
bool isDownloading() const { return m_downloading; }
bool isCancelled();
QTime remainingTime() const { return m_remTime; }
@ -68,7 +75,11 @@ Q_SIGNALS:
private Q_SLOTS:
void parentResized(const QSize &size);
void finished();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void downloadProgress(qint64 received, qint64 total);
#else
void receivedOrTotalBytesChanged();
#endif
void stop();
void pauseResume();
void openFile();
@ -85,7 +96,7 @@ private:
Ui::DownloadItem* ui;
QListWidgetItem* m_item;
QWebEngineDownloadItem* m_download;
Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS* m_download;
QString m_path;
QString m_fileName;
QElapsedTimer m_downTimer;

View File

@ -40,7 +40,11 @@
#include <QShortcut>
#include <QStandardPaths>
#include <QWebEngineHistory>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineDownloadItem>
#else
#include <QWebEngineDownloadRequest>
#endif
#include <QtWebEngineWidgetsVersion>
#ifdef Q_OS_WIN
@ -123,7 +127,11 @@ void DownloadManager::keyPressEvent(QKeyEvent* e)
QWidget::keyPressEvent(e);
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void DownloadManager::closeDownloadTab(QWebEngineDownloadItem *item) const
#else
void DownloadManager::closeDownloadTab(QWebEngineDownloadRequest *item) const
#endif
{
// Attempt to close empty tab that was opened only for loading the download url
auto testWebView = [](TabbedWebView *view, const QUrl &url) {
@ -258,7 +266,7 @@ void DownloadManager::clearList()
Q_EMIT downloadsCountChanged();
}
void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
void DownloadManager::download(Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS *downloadItem)
{
QElapsedTimer downloadTimer;
downloadTimer.start();
@ -268,10 +276,14 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
QString downloadPath;
bool openFile = false;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const QString fileName = QFileInfo(downloadItem->path()).fileName();
#else
const QString fileName = downloadItem->downloadFileName();
#endif
const bool forceAsk = downloadItem->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat
|| downloadItem->type() == QWebEngineDownloadItem::UserRequested;
const bool forceAsk = downloadItem->savePageFormat() != Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::UnknownSaveFormat
|| downloadItem->isSavePageDownload();
if (m_useExternalManager) {
startExternalManager(downloadItem->url());
@ -279,10 +291,10 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
enum Result { Open = 1, Save = 2, ExternalManager = 3, SavePage = 4, Unknown = 0 };
Result result = Unknown;
if (downloadItem->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat) {
if (downloadItem->savePageFormat() != Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::UnknownSaveFormat) {
// Save Page requested
result = SavePage;
} else if (downloadItem->type() == QWebEngineDownloadItem::UserRequested) {
} else if (downloadItem->isSavePageDownload()) {
// Save x as... requested
result = Save;
} else {
@ -326,17 +338,17 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
Settings().setValue(QSL("DownloadManager/lastDownloadPath"), m_lastDownloadPath);
m_lastDownloadOption = SaveFile;
QWebEngineDownloadItem::SavePageFormat format = QWebEngineDownloadItem::UnknownSaveFormat;
Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::SavePageFormat format = Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::UnknownSaveFormat;
if (selectedFilter == mhtml) {
format = QWebEngineDownloadItem::MimeHtmlSaveFormat;
format = Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::MimeHtmlSaveFormat;
} else if (selectedFilter == htmlSingle) {
format = QWebEngineDownloadItem::SingleHtmlSaveFormat;
format = Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::SingleHtmlSaveFormat;
} else if (selectedFilter == htmlComplete) {
format = QWebEngineDownloadItem::CompleteHtmlSaveFormat;
format = Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::CompleteHtmlSaveFormat;
}
if (format != QWebEngineDownloadItem::UnknownSaveFormat) {
if (format != Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS::UnknownSaveFormat) {
downloadItem->setSavePageFormat(format);
}
}
@ -361,7 +373,12 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
}
// Set download path and accept
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
downloadItem->setPath(downloadPath);
#else
downloadItem->setDownloadDirectory(QFileInfo(downloadPath).absoluteDir().absolutePath());
downloadItem->setDownloadFileName(QFileInfo(downloadPath).fileName());
#endif
downloadItem->accept();
// Create download item

View File

@ -32,7 +32,11 @@ class DownloadManager;
class QUrl;
class QNetworkAccessManager;
class QListWidgetItem;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QWebEngineDownloadItem;
#else
class QWebEngineDownloadRequest;
#endif
class QWinTaskbarButton;
class DownloadItem;
@ -65,7 +69,11 @@ public:
void loadSettings();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void download(QWebEngineDownloadItem *downloadItem);
#else
void download(QWebEngineDownloadRequest *downloadItem);
#endif
int downloadsCount() const;
int activeDownloadsCount() const;
@ -98,7 +106,11 @@ private:
void resizeEvent(QResizeEvent* e) override;
void keyPressEvent(QKeyEvent* e) override;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void closeDownloadTab(QWebEngineDownloadItem *item) const;
#else
void closeDownloadTab(QWebEngineDownloadRequest *item) const;
#endif
QWinTaskbarButton *taskbarButton();
Ui::DownloadManager* ui;

View File

@ -21,9 +21,13 @@
#include <QClipboard>
#include <QMimeDatabase>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineDownloadItem>
#else
#include <QWebEngineDownloadRequest>
#endif
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, QWebEngineDownloadItem *downloadItem, QWidget *parent)
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS *downloadItem, QWidget *parent)
: QDialog(parent)
, ui(new Ui::DownloadOptionsDialog)
, m_downloadItem(downloadItem)

View File

@ -23,20 +23,25 @@
#include "qzcommon.h"
#include "downloadmanager.h"
#include "downloaditem.h"
namespace Ui
{
class DownloadOptionsDialog;
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QWebEngineDownloadItem;
#else
class QWebEngineDownloadRequest;
#endif
class FALKON_EXPORT DownloadOptionsDialog : public QDialog
{
Q_OBJECT
public:
explicit DownloadOptionsDialog(const QString &fileName, QWebEngineDownloadItem *downloadItem, QWidget* parent = nullptr);
explicit DownloadOptionsDialog(const QString &fileName, Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS *downloadItem, QWidget* parent = nullptr);
~DownloadOptionsDialog() override;
void showExternalManagerOption(bool show);
@ -56,7 +61,7 @@ Q_SIGNALS:
private:
Ui::DownloadOptionsDialog* ui;
QWebEngineDownloadItem *m_downloadItem;
Q_WEB_ENGINE_DOWNLOAD_ITEM_CLASS *m_downloadItem;
bool m_signalEmited;
};

View File

@ -242,10 +242,10 @@ void HistoryMenu::init()
act->setShortcut(QzTools::actionShortcut(QKeySequence::Forward, Qt::ALT + Qt::Key_Right, QKeySequence::Back, Qt::ALT + Qt::Key_Left));
act = addAction(QIcon::fromTheme("go-home"), tr("&Home"), this, &HistoryMenu::goHome);
act->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Home));
act->setShortcut(QKeySequence(Qt::ALT | Qt::Key_Home));
act = addAction(QIcon::fromTheme("deep-history", QIcon(":/icons/menu/history.svg")), tr("Show &All History"), this, &HistoryMenu::showHistoryManager);
act->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_H));
act->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H));
addSeparator();

View File

@ -324,7 +324,11 @@ int LocationCompleterDelegate::viewItemDrawText(QPainter *p, const QStyleOptionV
highlightParts << highlightedPart;
}
textLayout.setAdditionalFormats(highlightParts);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
textLayout.setFormats(QVector<QTextLayout::FormatRange>::fromList(highlightParts));
#else
textLayout.setFormats(highlightParts);
#endif
}
}

View File

@ -40,7 +40,11 @@ LocationCompleterRefreshJob::LocationCompleterRefreshJob(const QString &searchSt
m_watcher = new QFutureWatcher<void>(this);
connect(m_watcher, &QFutureWatcherBase::finished, this, &LocationCompleterRefreshJob::slotFinished);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QFuture<void> future = QtConcurrent::run(this, &LocationCompleterRefreshJob::runJob);
#else
QFuture<void> future = QtConcurrent::run(&LocationCompleterRefreshJob::runJob, this);
#endif
m_watcher->setFuture(future);
}

View File

@ -41,7 +41,7 @@
#include <QCompleter>
#include <QStringListModel>
#include <QContextMenuEvent>
#include <QStyleOptionFrameV3>
#include <QStyleOptionFrame>
LocationBar::LocationBar(QWidget *parent)
: LineEdit(parent)

View File

@ -66,8 +66,9 @@ NavigationBar::NavigationBar(BrowserWindow* window)
setObjectName(QSL("navigationbar"));
m_layout = new QHBoxLayout(this);
m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this)
+ style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this));
auto contentsMargin = style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this)
+ style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);
m_layout->setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin);
m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
setLayout(m_layout);
@ -281,12 +282,13 @@ void NavigationBar::setSuperMenuVisible(bool visible)
int NavigationBar::layoutMargin() const
{
return m_layout->margin();
// NOTE: This assumes margins are always the same.
return m_layout->contentsMargins().left();
}
void NavigationBar::setLayoutMargin(int margin)
{
m_layout->setMargin(margin);
m_layout->setContentsMargins(margin, margin, margin, margin);
}
int NavigationBar::layoutSpacing() const

View File

@ -178,7 +178,11 @@ void WebSearchBar::setupEngines()
item.icon = en.icon;
item.text = en.name;
QVariant v;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
v.setValue<SearchEngine>(en);
#else
v.setValue(en);
#endif
item.userData = v;
m_boxSearchType->addItem(item);

View File

@ -70,24 +70,45 @@ NetworkManager::NetworkManager(QObject *parent)
});
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
bool NetworkManager::certificateError(const QWebEngineCertificateError &error, QWidget *parent)
#else
bool NetworkManager::certificateError(QWebEngineCertificateError &error, QWidget *parent)
#endif
{
const QString &host = error.url().host();
if (m_rejectedSslErrors.contains(host) && m_rejectedSslErrors.value(host) == error.error()) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const auto errorType = error.error();
#else
const auto errorType = error.type();
#endif
if (m_rejectedSslErrors.contains(host) && m_rejectedSslErrors.value(host) == errorType) {
return false;
}
if ((m_ignoredSslErrors.contains(host) && m_ignoredSslErrors.value(host) == error.error())
if ((m_ignoredSslErrors.contains(host) && m_ignoredSslErrors.value(host) == errorType)
|| m_ignoredSslHosts.contains(host)) {
return true;
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
// Defer loading the URL until the user prompt has completed.
if (error.isOverridable())
error.defer();
#endif
QString title = tr("SSL Certificate Error!");
QString text1 = tr("The page you are trying to access has the following errors in the SSL certificate:");
QString text2 = tr("Would you like to make an exception for this certificate?");
QString message = QSL("<b>%1</b><p>%2</p><ul><li>%3</li></ul><p>%4</p>").arg(title, text1, error.errorDescription(), text2);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const auto errorDescription = error.errorDescription();
#else
const auto errorDescription = error.description();
#endif
QString message = QSL("<b>%1</b><p>%2</p><ul><li>%3</li></ul><p>%4</p>").arg(title, text1, errorDescription, text2);
SslErrorDialog dialog(parent);
dialog.setText(message);
@ -100,11 +121,11 @@ bool NetworkManager::certificateError(const QWebEngineCertificateError &error, Q
return true;
case SslErrorDialog::OnlyForThisSession:
m_ignoredSslErrors[host] = error.error();
m_ignoredSslErrors[host] = errorType;
return true;
case SslErrorDialog::NoForThisSession:
m_rejectedSslErrors[host] = error.error();
m_rejectedSslErrors[host] = errorType;
return false;
default:
@ -329,8 +350,11 @@ void NetworkManager::registerSchemes()
QNetworkReply *NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
QNetworkRequest req = request;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// These have either been removed or changed to the default in Qt 6.
req.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
return QNetworkAccessManager::createRequest(op, req, outgoingData);
}

View File

@ -35,7 +35,11 @@ class FALKON_EXPORT NetworkManager : public QNetworkAccessManager
public:
explicit NetworkManager(QObject *parent = nullptr);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
bool certificateError(const QWebEngineCertificateError &error, QWidget *parent = nullptr);
#else
bool certificateError(QWebEngineCertificateError &error, QWidget *parent = nullptr);
#endif
void authentication(const QUrl &url, QAuthenticator *auth, QWidget *parent = nullptr);
void proxyAuthentication(const QString &proxyHost, QAuthenticator *auth, QWidget *parent = nullptr);
@ -58,8 +62,13 @@ private:
NetworkUrlInterceptor *m_urlInterceptor;
ExtensionSchemeManager *m_extensionScheme;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QHash<QString, QWebEngineCertificateError::Error> m_ignoredSslErrors;
QHash<QString, QWebEngineCertificateError::Error> m_rejectedSslErrors;
#else
QHash<QString, QWebEngineCertificateError::Type> m_ignoredSslErrors;
QHash<QString, QWebEngineCertificateError::Type> m_rejectedSslErrors;
#endif
QStringList m_ignoredSslHosts;
};

View File

@ -81,7 +81,11 @@ void EditSearchEngine::setShortcut(const QString &shortcut)
QIcon EditSearchEngine::icon()
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
return QIcon(*ui->icon->pixmap());
#else
return QIcon(ui->icon->pixmap());
#endif
}
void EditSearchEngine::setIcon(const QIcon &icon)

View File

@ -173,7 +173,11 @@ SearchEngine SearchEnginesDialog::getEngine(QTreeWidgetItem* item)
void SearchEnginesDialog::setEngine(QTreeWidgetItem* item, const SearchEngine &engine)
{
QVariant v;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
v.setValue<SearchEngine>(engine);
#else
v.setValue(engine);
#endif
item->setData(0, EngineRole, v);
item->setText(0, engine.name);
}

View File

@ -138,7 +138,7 @@ void TipLabel::paintEvent(QPaintEvent* ev)
{
QStylePainter p(this);
QStyleOptionFrame opt;
opt.init(this);
opt.initFrom(this);
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
p.end();

View File

@ -28,7 +28,11 @@
#include <QUrlQuery>
#include <QNetworkReply>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <KArchive/KZip>
#else
#include <KZip>
#endif
Q_GLOBAL_STATIC(OcsSupport, qz_ocs_support)

View File

@ -342,7 +342,7 @@ Plugins::Plugin Plugins::loadPlugin(const QString &id)
const int colon = id.indexOf(QL1C(':'));
if (colon > -1) {
const auto t = id.leftRef(colon);
const auto t = QStringView{id}.left(colon);
if (t == QL1S("internal")) {
type = Plugin::InternalPlugin;
} else if (t == QL1S("lib")) {

View File

@ -21,6 +21,7 @@
#include <QObject>
#include <QVariant>
#include <QPointer>
#include <QPixmap>
#include "qzcommon.h"
#include "plugininterface.h"

View File

@ -18,6 +18,8 @@
#pragma once
#include "bookmarkitem.h"
#include <QObject>
/**
* @brief The class exposing the bookmark item to QML
*/

View File

@ -69,7 +69,7 @@ int QmlWheelEvent::globalY() const
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->globalPosition().toPoint().x();
return m_wheelEvent->globalPosition().toPoint().y();
}
bool QmlWheelEvent::inverted() const

View File

@ -20,6 +20,9 @@
QmlUserScript::QmlUserScript(QObject *parent)
: QObject(parent)
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_isNull(true)
#endif
{
}
@ -35,12 +38,17 @@ QWebEngineScript QmlUserScript::webEngineScript() const
void QmlUserScript::setWebEngineScript(const QWebEngineScript &script)
{
setNotNull();
m_webEngineScript = script;
}
bool QmlUserScript::null() const
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
return m_webEngineScript.isNull();
#else
return m_isNull;
#endif
}
QString QmlUserScript::name() const
@ -50,6 +58,7 @@ QString QmlUserScript::name() const
void QmlUserScript::setName(const QString &name)
{
setNotNull();
m_webEngineScript.setName(name);
Q_EMIT nameChanged(name);
aboutToUpdateUnderlyingScript();
@ -62,6 +71,7 @@ bool QmlUserScript::runsOnSubFrames() const
void QmlUserScript::setRunsOnSubFrames(bool runsOnSubFrames)
{
setNotNull();
m_webEngineScript.setRunsOnSubFrames(runsOnSubFrames);
Q_EMIT runsOnSubFramesChanged(runsOnSubFrames);
aboutToUpdateUnderlyingScript();
@ -74,6 +84,7 @@ int QmlUserScript::worldId() const
void QmlUserScript::setWorldId(int worldId)
{
setNotNull();
switch (worldId) {
case QWebEngineScript::MainWorld:
m_webEngineScript.setWorldId(QWebEngineScript::MainWorld);
@ -98,6 +109,7 @@ QString QmlUserScript::sourceCode() const
void QmlUserScript::setSourceCode(const QString &sourceCode)
{
setNotNull();
m_webEngineScript.setSourceCode(sourceCode);
Q_EMIT sourceCodeChanged(sourceCode);
aboutToUpdateUnderlyingScript();
@ -110,6 +122,7 @@ QmlUserScript::InjectionPoint QmlUserScript::injectionPoint() const
void QmlUserScript::setInjectionPoint(InjectionPoint injectionPoint)
{
setNotNull();
switch (static_cast<QWebEngineScript::InjectionPoint>(injectionPoint)) {
case QWebEngineScript::DocumentCreation:
m_webEngineScript.setInjectionPoint(QWebEngineScript::DocumentCreation);

View File

@ -100,6 +100,9 @@ Q_SIGNALS:
void injectionPointChanged(int injectionPoint);
private:
QWebEngineScript m_webEngineScript;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool m_isNull;
#endif
QBasicTimer m_basicTimer;
bool null() const;
@ -116,4 +119,12 @@ private:
void timerEvent(QTimerEvent *e) override;
void aboutToUpdateUnderlyingScript();
void setNotNull()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
// TODO: This is a really hacky way of keeping track of whether the script has been initialized - and is it even necessary?
m_isNull = false;
#endif
}
};

View File

@ -33,7 +33,7 @@ int QmlUserScripts::count() const
int QmlUserScripts::size() const
{
return mApp->webProfile()->scripts()->size();
return mApp->webProfile()->scripts()->count();
}
bool QmlUserScripts::empty() const
@ -65,15 +65,28 @@ bool QmlUserScripts::contains(QObject *object) const
QObject *QmlUserScripts::findScript(const QString &name) const
{
QWebEngineScript webEngineScript = mApp->webProfile()->scripts()->findScript(name);
auto *qmlUserScript = new QmlUserScript();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QWebEngineScript webEngineScript = mApp->webProfile()->scripts()->findScript(name);
qmlUserScript->setWebEngineScript(webEngineScript);
#else
auto scripts = mApp->webProfile()->scripts()->find(name);
if (!scripts.empty()) {
qmlUserScript->setWebEngineScript(scripts.first());
}
#endif
return qmlUserScript;
}
QList<QObject*> QmlUserScripts::findScripts(const QString &name) const
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QList<QWebEngineScript> list = mApp->webProfile()->scripts()->findScripts(name);
#else
QList<QWebEngineScript> list = mApp->webProfile()->scripts()->find(name);
#endif
return toQObjectList(list);
}

View File

@ -42,7 +42,7 @@ public:
return !url.isEmpty();
}
bool operator==(const Page &other) {
bool operator==(const Page &other) const {
return (this->title == other.title &&
this->url == other.url);
}

View File

@ -92,7 +92,11 @@ void AutoFillManager::loadPasswords()
item->setText(2, "*****");
QVariant v;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
v.setValue<PasswordEntry>(entry);
#else
v.setValue(entry);
#endif
item->setData(0, Qt::UserRole + 10, v);
ui->treePass->addTopLevelItem(item);
}
@ -253,12 +257,17 @@ void AutoFillManager::editPass()
if (ok && !text.isEmpty() && text != entry.password) {
QByteArray oldPass = "=" + PasswordManager::urlEncodePassword(entry.password);
entry.data.replace(oldPass, "=" + PasswordManager::urlEncodePassword(text));
QByteArray newPass = "=" + PasswordManager::urlEncodePassword(text);
entry.data.replace(oldPass, newPass);
entry.password = text;
if (mApp->autoFill()->updateEntry(entry)) {
QVariant v;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
v.setValue<PasswordEntry>(entry);
#else
v.setValue(entry);
#endif
curItem->setData(0, Qt::UserRole + 10, v);
if (m_passwordsShown) {

View File

@ -72,9 +72,9 @@ void PluginListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
const int checkboxYPos = center - (checkboxSize / 2);
QStyleOptionViewItem opt2 = opt;
opt2.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off;
QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt2, w);
QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt2, w);
opt2.rect = QRect(leftPosition, checkboxYPos, styleCheckBoxRect.width(), styleCheckBoxRect.height());
style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w);
style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &opt2, painter, w);
leftPosition = opt2.rect.right() + m_padding;
// Draw icon

View File

@ -57,7 +57,9 @@
#include <QMessageBox>
#include <QCloseEvent>
#include <QColorDialog>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QDesktopWidget>
#endif
#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QLibraryInfo>
@ -530,13 +532,17 @@ Preferences::Preferences(BrowserWindow* window)
ui->listWidget->setCurrentRow(currentSettingsPage);
QDesktopWidget* desktop = QApplication::desktop();
QSize s = size();
if (desktop->availableGeometry(this).size().width() < s.width()) {
s.setWidth(desktop->availableGeometry(this).size().width() - 50);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const QRect &availableGeometryForScreen = QApplication::desktop()->availableGeometry(this);
#else
const QRect &availableGeometryForScreen = screen()->availableGeometry();
#endif
if (availableGeometryForScreen.size().width() < s.width()) {
s.setWidth(availableGeometryForScreen.size().width() - 50);
}
if (desktop->availableGeometry(this).size().height() < s.height()) {
s.setHeight(desktop->availableGeometry(this).size().height() - 50);
if (availableGeometryForScreen.size().height() < s.height()) {
s.setHeight(availableGeometryForScreen.size().height() - 50);
}
resize(s);

View File

@ -25,6 +25,7 @@
#include "settings.h"
#include <QAction>
#include <QActionGroup>
#include <QComboBox>
#include <QDateTime>
#include <QDialogButtonBox>

View File

@ -114,7 +114,7 @@ void SessionManagerDialog::refresh()
for (const auto &session : sessions) {
auto *item = new QTreeWidgetItem;
item->setText(0, session.name);
item->setText(1, QFileInfo(session.filePath).lastModified().toString(Qt::DefaultLocaleShortDate));
item->setText(1, QLocale().toString(QFileInfo(session.filePath).lastModified(), QLocale::ShortFormat));
item->setData(0, SessionFileRole, session.filePath);
item->setData(0, IsBackupSessionRole, session.isBackup);
item->setData(0, IsActiveSessionRole, session.isActive);

View File

@ -25,6 +25,7 @@
#include "settings.h"
#include <QMenu>
#include <QActionGroup>
QHash<QString, QPointer<SideBarInterface> > s_sidebars;

View File

@ -27,8 +27,8 @@
#include <QIcon>
#include <QHBoxLayout>
#include <QStylePainter>
#include <QStyleOptionTabV3>
#include <QStyleOptionTabBarBaseV2>
#include <QStyleOptionTab>
#include <QStyleOptionTabBarBase>
#include <QPropertyAnimation>
#include <QScrollArea>
#include <QTimer>
@ -682,7 +682,7 @@ void ComboTabBar::paintEvent(QPaintEvent* ev)
// This is needed to apply style sheets
QStyleOption option;
option.init(this);
option.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &option, &p, this);
@ -1230,7 +1230,7 @@ void TabBarHelper::initStyleBaseOption(QStyleOptionTabBarBase *optTabBase, QTabB
tabOverlap.shape = tabbar->shape();
int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
QWidget* theParent = tabbar->parentWidget();
optTabBase->init(tabbar);
optTabBase->initFrom(tabbar);
optTabBase->shape = tabbar->shape();
optTabBase->documentMode = tabbar->documentMode();
if (theParent && overlap > 0) {
@ -1359,7 +1359,9 @@ void TabBarHelper::paintEvent(QPaintEvent *)
grabImage.setDevicePixelRatio(devicePixelRatioF());
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, this);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
p.initFrom(this);
#endif
if (tabDragOffset != 0) {
tab.position = QStyleOptionTab::OnlyOneTab;
}
@ -1537,7 +1539,7 @@ TabBarScrollWidget::TabBarScrollWidget(QTabBar* tabBar, QWidget* parent)
: QWidget(parent)
, m_tabBar(tabBar)
, m_usesScrollButtons(false)
, m_totalDeltas(0)
, m_totalVerticalDeltas(0)
{
m_scrollArea = new QScrollArea(this);
m_scrollArea->setFocusPolicy(Qt::NoFocus);
@ -1696,30 +1698,33 @@ void TabBarScrollWidget::scrollByWheel(QWheelEvent* event)
{
event->accept();
// Check if direction has changed from last time
if (m_totalDeltas * event->delta() < 0) {
m_totalDeltas = 0;
// Process horizontal wheel scrolling first
// Slower scrolling for horizontal wheel scrolling
if (event->angleDelta().x() > 0) {
scrollToLeft();
}
else if (event->angleDelta().x() < 0) {
scrollToRight();
}
m_totalDeltas += event->delta();
// Slower scrolling for horizontal wheel scrolling
if (event->orientation() == Qt::Horizontal) {
if (event->delta() > 0) {
scrollToLeft();
}
else if (event->delta() < 0) {
scrollToRight();
}
auto verticalDelta = event->angleDelta().y();
if (verticalDelta == 0) {
return;
}
// Check if vertical direction has changed from last time
if (m_totalVerticalDeltas * verticalDelta < 0) {
m_totalVerticalDeltas = 0;
}
m_totalVerticalDeltas += verticalDelta;
// Faster scrolling with control modifier
if (event->orientation() == Qt::Vertical && event->modifiers() == Qt::ControlModifier) {
if (event->delta() > 0) {
if (event->modifiers() == Qt::ControlModifier) {
if (verticalDelta > 0) {
scrollToLeft(10);
}
else if (event->delta() < 0) {
else if (verticalDelta < 0) {
scrollToRight(10);
}
return;
@ -1731,7 +1736,7 @@ void TabBarScrollWidget::scrollByWheel(QWheelEvent* event)
factor = m_scrollBar->pageStep();
}
int offset = (m_totalDeltas / 120) * factor;
int offset = (m_totalVerticalDeltas / 120) * factor;
if (offset != 0) {
if (isRightToLeft()) {
m_scrollBar->animateToValue(m_scrollBar->value() + offset);
@ -1740,7 +1745,7 @@ void TabBarScrollWidget::scrollByWheel(QWheelEvent* event)
m_scrollBar->animateToValue(m_scrollBar->value() - offset);
}
m_totalDeltas -= (offset / factor) * 120;
m_totalVerticalDeltas -= (offset / factor) * 120;
}
}
@ -1809,7 +1814,11 @@ QSize CloseButton::sizeHint() const
return QSize(width, height);
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void CloseButton::enterEvent(QEvent* event)
#else
void CloseButton::enterEvent(QEnterEvent* event)
#endif
{
if (isEnabled()) {
update();
@ -1831,7 +1840,7 @@ void CloseButton::paintEvent(QPaintEvent*)
{
QPainter p(this);
QStyleOption opt;
opt.init(this);
opt.initFrom(this);
opt.state |= QStyle::State_AutoRaise;
// update raised state on scrolling

View File

@ -350,7 +350,7 @@ private:
ToolButton* m_rightScrollButton;
ToolButton* m_leftScrollButton;
bool m_usesScrollButtons;
int m_totalDeltas;
int m_totalVerticalDeltas;
};
// Class for close button on tabs
@ -364,7 +364,11 @@ public:
QSize sizeHint() const 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 *event) override;
void paintEvent(QPaintEvent *event) override;
};

View File

@ -24,6 +24,7 @@
#include <QTimer>
#include <QToolTip>
#include <QMouseEvent>
#include <QPainter>
TabIcon::TabIcon(QWidget* parent)
: QWidget(parent)

View File

@ -160,7 +160,11 @@ void ButtonWithMenu::generateMenu()
for (const Item &item : qAsConst(m_items)) {
QVariant variant;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
variant.setValue<Item>(item);
#else
variant.setValue(item);
#endif
m_menu->addAction(item.icon, item.text, this, SLOT(setCurrentItem()))->setData(variant);
}
}

View File

@ -38,7 +38,7 @@ public:
icon = b;
}
bool operator==(const Item &a) {
bool operator==(const Item &a) const {
return (a.text == text) && (a.icon.pixmap(16).toImage() == icon.pixmap(16).toImage());
}

View File

@ -19,6 +19,7 @@
#include <QSettings>
#include <QStandardPaths>
#include <QLocale>
DesktopFile::DesktopFile()
= default;
@ -26,7 +27,9 @@ DesktopFile::DesktopFile()
DesktopFile::DesktopFile(const QString &fileName)
{
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_settings->setIniCodec("UTF-8");
#endif
m_settings->beginGroup(QSL("Desktop Entry"));
}

View File

@ -23,6 +23,7 @@
#include <QTimer>
#include <QWebEnginePage>
#include <QWebEngineView>
#include <QtWebEngineWidgetsVersion>
@ -100,7 +101,11 @@ void HTML5PermissionsNotification::grantPermissions()
QTimer::singleShot(0, this, [this]() {
// We need to have cursor inside view to correctly grab mouse
if (m_feature == QWebEnginePage::MouseLock) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QWidget *view = m_page->view();
#else
QWidget *view = QWebEngineView::forPage(m_page);
#endif
QCursor::setPos(view->mapToGlobal(view->rect().center()));
}

View File

@ -18,7 +18,7 @@
#include "progressbar.h"
#include <QStylePainter>
#include <QStyleOptionProgressBarV2>
#include <QStyleOptionProgressBar>
ProgressBar::ProgressBar(QWidget* parent)
: QWidget(parent)

View File

@ -32,7 +32,11 @@
#include <QWidget>
#include <QApplication>
#include <QSslCertificate>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QDesktopWidget>
#else
#include <QScreen>
#endif
#include <QUrl>
#include <QIcon>
#include <QFileIconProvider>
@ -115,7 +119,11 @@ QByteArray QzTools::readAllFileByteContents(const QString &filename)
void QzTools::centerWidgetOnScreen(QWidget* w)
{
const QRect screen = QApplication::desktop()->screenGeometry(w);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QRect screen = QApplication::desktop()->screenGeometry(w);
#else
QRect screen = w->screen()->geometry();
#endif
const QRect size = w->geometry();
w->move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2);
}

View File

@ -18,7 +18,11 @@
#include "webhittestresult.h"
#include "webpage.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineContextMenuData>
#else
#include <QWebEngineContextMenuRequest>
#endif
WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
: m_isNull(true)
@ -92,9 +96,14 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
init(p->url(), p->execJavaScript(js, WebPage::SafeJsWorld).toMap());
}
void WebHitTestResult::updateWithContextMenuData(const QWebEngineContextMenuData &data)
void WebHitTestResult::updateWithContextMenuData(const Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS &data)
{
if (!data.isValid() || data.position() != m_pos) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (!data.isValid()) {
return;
}
#endif
if (data.position() != m_pos) {
return;
}
@ -104,12 +113,12 @@ void WebHitTestResult::updateWithContextMenuData(const QWebEngineContextMenuData
m_isContentSelected = !data.selectedText().isEmpty();
switch (data.mediaType()) {
case QWebEngineContextMenuData::MediaTypeImage:
case Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS::MediaTypeImage:
m_imageUrl = data.mediaUrl();
break;
case QWebEngineContextMenuData::MediaTypeVideo:
case QWebEngineContextMenuData::MediaTypeAudio:
case Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS::MediaTypeVideo:
case Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS::MediaTypeAudio:
m_mediaUrl = data.mediaUrl();
break;

View File

@ -25,7 +25,13 @@
#include "qzcommon.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QWebEngineContextMenuData;
#define Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS QWebEngineContextMenuData
#else
class QWebEngineContextMenuRequest;
#define Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS QWebEngineContextMenuRequest
#endif
class WebPage;
@ -34,7 +40,7 @@ class FALKON_EXPORT WebHitTestResult
public:
explicit WebHitTestResult(const WebPage *page, const QPoint &pos);
void updateWithContextMenuData(const QWebEngineContextMenuData &data);
void updateWithContextMenuData(const Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS &data);
QUrl baseUrl() const;
QString alternateText() const;

View File

@ -89,6 +89,9 @@ WebPage::WebPage(QObject* parent)
connect(this, &QWebEnginePage::windowCloseRequested, this, &WebPage::windowCloseRequested);
connect(this, &QWebEnginePage::fullScreenRequested, this, &WebPage::fullScreenRequested);
connect(this, &QWebEnginePage::renderProcessTerminated, this, &WebPage::renderProcessTerminated);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
connect(this, &QWebEnginePage::certificateError, this, &WebPage::onCertificateError);
#endif
connect(this, &QWebEnginePage::authenticationRequired, this, [this](const QUrl &url, QAuthenticator *auth) {
mApp->networkManager()->authentication(url, auth, view());
@ -137,7 +140,11 @@ WebPage::~WebPage()
WebView *WebPage::view() const
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
return static_cast<WebView*>(QWebEnginePage::view());
#else
return static_cast<WebView*>(QWebEngineView::forPage(this));
#endif
}
bool WebPage::execPrintPage(QPrinter *printer, int timeout)
@ -146,12 +153,22 @@ bool WebPage::execPrintPage(QPrinter *printer, int timeout)
bool result = false;
QTimer::singleShot(timeout, loop.data(), &QEventLoop::quit);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
print(printer, [loop, &result](bool res) {
if (loop && loop->isRunning()) {
result = res;
loop->quit();
}
});
#else
connect(view(), &QWebEngineView::printFinished, this, [loop, &result](bool res) {
if (loop && loop->isRunning()) {
result = res;
loop->quit();
}
});
view()->print(printer);
#endif
loop->exec();
delete loop;
@ -463,10 +480,21 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio
return result;
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
bool WebPage::certificateError(const QWebEngineCertificateError &error)
{
return mApp->networkManager()->certificateError(error, view());
}
#else
void WebPage::onCertificateError(QWebEngineCertificateError error)
{
auto mutableError = const_cast<QWebEngineCertificateError&>(error);
if (mApp->networkManager()->certificateError(mutableError, view()))
mutableError.acceptCertificate();
else
mutableError.rejectCertificate();
}
#endif
QStringList WebPage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
{

View File

@ -21,6 +21,9 @@
#include <QWebEnginePage>
#include <QWebEngineScript>
#include <QWebEngineFullScreenRequest>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QPrinter>
#endif
#include <QVector>
#include <QElapsedTimer>
@ -93,10 +96,15 @@ private Q_SLOTS:
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature);
void renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void onCertificateError(QWebEngineCertificateError error);
#endif
private:
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
bool certificateError(const QWebEngineCertificateError &error) override;
#endif
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) override;
QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) override;

View File

@ -21,6 +21,7 @@
#include "webpage.h"
#include <QPaintEvent>
#include <QPainter>
WebScrollBar::WebScrollBar(Qt::Orientation orientation, WebView *view)
: QScrollBar(orientation)

View File

@ -26,6 +26,7 @@
#include <QPointer>
#include <QPaintEvent>
#include <QPainter>
#include <QWebEngineProfile>
#include <QWebEngineScriptCollection>
#include <QStyle>
@ -210,8 +211,14 @@ void WebScrollBarManager::createUserScript(int thickness)
void WebScrollBarManager::removeUserScript()
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QWebEngineScript script = mApp->webProfile()->scripts()->findScript(QSL("_falkon_scrollbar"));
mApp->webProfile()->scripts()->remove(script);
#else
for (const QWebEngineScript &script : mApp->webProfile()->scripts()->find(QSL("_falkon_scrollbar"))) {
mApp->webProfile()->scripts()->remove(script);
}
#endif
}
QSize WebScrollBarManager::viewportSize(WebView *view, int thickness) const

View File

@ -44,7 +44,11 @@
#include <QWebEngineHistory>
#include <QClipboard>
#include <QMimeData>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QWebEngineContextMenuData>
#else
#include <QWebEngineContextMenuRequest>
#endif
#include <QStackedLayout>
#include <QScrollBar>
#include <QPrintDialog>
@ -146,7 +150,9 @@ void WebView::setPage(WebPage *page)
Q_EMIT m_page->loadFinished(true);
}
mApp->plugins()->emitWebPageDeleted(m_page);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_page->setView(nullptr);
#endif
}
page->setParent(this);
@ -403,10 +409,17 @@ void WebView::printPage()
m_page->printToPdf(dialog->printer()->outputFileName(), dialog->printer()->pageLayout());
delete dialog;
} else {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_page->print(dialog->printer(), [=](bool success) {
Q_UNUSED(success);
delete dialog;
});
#else
connect(this, &QWebEngineView::printFinished, this, [&dialog](bool success) {
Q_UNUSED(success);
delete dialog;
});
#endif
}
}
}
@ -670,7 +683,15 @@ void WebView::createContextMenu(QMenu *menu, WebHitTestResult &hitTest)
// cppcheck-suppress variableScope
int spellCheckActionCount = 0;
const QWebEngineContextMenuData &contextMenuData = page()->contextMenuData();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS &contextMenuData = page()->contextMenuData();
#else
const Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS *contextMenuDataPtr = lastContextMenuRequest();
if (contextMenuDataPtr == NULL)
return;
const Q_WEB_ENGINE_CONTEXT_MENU_DATA_CLASS &contextMenuData = *contextMenuDataPtr;
#endif
hitTest.updateWithContextMenuData(contextMenuData);
if (!contextMenuData.misspelledWord().isEmpty()) {

View File

@ -121,7 +121,12 @@ void SearchToolBar::searchText(const QString &text)
{
m_searchRequests++;
QPointer<SearchToolBar> guard = this;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_view->findText(text, m_findFlags, [=](bool found) {
#else
m_view->findText(text, m_findFlags, [=](QWebEngineFindTextResult result) {
bool found = result.numberOfMatches() > 0;
#endif
if (!guard) {
return;
}

View File

@ -18,6 +18,7 @@
#ifndef SEARCHTOOLBAR_H
#define SEARCHTOOLBAR_H
#include <QWidget>
#include <QWebEnginePage>
#include <QtWebEngineCoreVersion>

View File

@ -32,10 +32,11 @@ endif()
if (UNIX AND NOT APPLE)
install(TARGETS falkon ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/themes DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/falkon)
if (KF5I18n_FOUND)
if (KF${KF_MAJOR_VERSION}I18n_FOUND)
ki18n_install(${CMAKE_SOURCE_DIR}/po)
endif()
ecm_install_po_files_as_qm(${CMAKE_SOURCE_DIR}/poqm)
# TODO Qt6 port ?
#ecm_install_po_files_as_qm(${CMAKE_SOURCE_DIR}/poqm)
install(PROGRAMS ../../linux/applications/org.kde.falkon.desktop DESTINATION ${KDE_INSTALL_APPDIR})

View File

@ -25,6 +25,7 @@
#include <QMouseEvent>
#include <QSettings>
#include <QIcon>
#include <QPainter>
ScrollIndicator::ScrollIndicator(QWidget *parent)
: QLabel(parent)

View File

@ -6,8 +6,8 @@ add_subdirectory(GreaseMonkey)
add_subdirectory(MouseGestures)
add_subdirectory(PIM)
add_subdirectory(StatusBarIcons)
add_subdirectory(TabManager)
add_subdirectory(VerticalTabs)
## TODO ## add_subdirectory(TabManager)
## TODO ## add_subdirectory(VerticalTabs)
if (GNOME_KEYRING_FOUND)
add_subdirectory(GnomeKeyringPasswords)

View File

@ -37,7 +37,7 @@ struct FlashCookie {
QString contents;
QDateTime lastModification;
bool operator ==(const FlashCookie &other) {
bool operator ==(const FlashCookie &other) const {
return (this->name == other.name && this->path == other.path);
}
};

View File

@ -182,7 +182,13 @@ void GM_Manager::disableScript(GM_Script* script)
m_disabledScripts.append(script->fullName());
QWebEngineScriptCollection *collection = mApp->webProfile()->scripts();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
collection->remove(collection->findScript(script->fullName()));
#else
for (const auto &script : collection->find(script->fullName())) {
collection->remove(script);
}
#endif
}
bool GM_Manager::addScript(GM_Script* script)
@ -210,7 +216,13 @@ bool GM_Manager::removeScript(GM_Script* script, bool removeFile)
m_scripts.removeOne(script);
QWebEngineScriptCollection *collection = mApp->webProfile()->scripts();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
collection->remove(collection->findScript(script->fullName()));
#else
for (const auto &script : collection->find(script->fullName())) {
collection->remove(script);
}
#endif
m_disabledScripts.removeOne(script->fullName());
@ -279,7 +291,13 @@ void GM_Manager::scriptChanged()
return;
QWebEngineScriptCollection *collection = mApp->webProfile()->scripts();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
collection->remove(collection->findScript(script->fullName()));
#else
for (const auto &script : collection->find(script->fullName())) {
collection->remove(script);
}
#endif
collection->insert(script->webScript());
}

View File

@ -90,9 +90,9 @@ void GM_SettingsListDelegate::paint(QPainter* painter, const QStyleOptionViewIte
const int checkboxYPos = center - (checkboxSize / 2);
QStyleOptionViewItem opt2 = opt;
opt2.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off;
QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt2, w);
QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt2, w);
opt2.rect = QRect(leftPosition, checkboxYPos, styleCheckBoxRect.width(), styleCheckBoxRect.height());
style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w);
style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &opt2, painter, w);
leftPosition = opt2.rect.right() + m_padding;
// Draw icon

View File

@ -4,13 +4,13 @@ if(POLICY CMP0071)
endif()
# Get all relevant Qt include dirs, to pass them on to shiboken.
get_property(QT_CORE_INCLUDE_DIRS TARGET Qt5::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_GUI_INCLUDE_DIRS TARGET Qt5::Gui PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_SQL_INCLUDE_DIRS TARGET Qt5::Sql PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WIDGETS_INCLUDE_DIRS TARGET Qt5::Widgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_NETWORK_INCLUDE_DIRS TARGET Qt5::Network PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WEBENGINECORE_INCLUDE_DIRS TARGET Qt5::WebEngineCore PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WEBENGINEWIDGETS_INCLUDE_DIRS TARGET Qt5::WebEngineWidgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_CORE_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_GUI_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::Gui PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_SQL_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::Sql PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WIDGETS_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::Widgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_NETWORK_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::Network PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WEBENGINECORE_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::WebEngineCore PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(QT_WEBENGINEWIDGETS_INCLUDE_DIRS TARGET Qt${QT_MAJOR_VERSION}::WebEngineWidgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set(QT_INCLUDE_DIRS
${QT_CORE_INCLUDE_DIRS}
${QT_GUI_INCLUDE_DIRS}
@ -134,9 +134,15 @@ set(GENERATED_SOURCES_DEPENDENCIES
${TYPESYSTEM_FILE}
)
if (QT_MAJOR_VERSION STREQUAL "6")
set(PYSIDE_VERSION "6")
else()
set(PYSIDE_VERSION "2")
endif()
# Add custom target to run shiboken.
add_custom_command(OUTPUT ${GENERATED_SOURCES}
COMMAND Shiboken2::shiboken2
COMMAND Shiboken${PYSIDE_VERSION}::shiboken${PYSIDE_VERSION}
${SHIBOKEN_OPTIONS} ${GLOBAL_HEADER} ${TYPESYSTEM_FILE}
DEPENDS ${GENERATED_SOURCES_DEPENDENCIES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@ -144,7 +150,7 @@ add_custom_command(OUTPUT ${GENERATED_SOURCES}
# We need to include the headers for the module bindings that we use.
set(PYSIDE_ADDITIONAL_INCLUDES "")
get_target_property(PYSIDE_INCLUDE_DIRS PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(PYSIDE_INCLUDE_DIRS PySide${PYSIDE_VERSION}::pyside${PYSIDE_VERSION} INTERFACE_INCLUDE_DIRECTORIES)
foreach(INCLUDE_DIR ${PYSIDE_INCLUDE_DIRS})
list(APPEND PYSIDE_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtCore")
list(APPEND PYSIDE_ADDITIONAL_INCLUDES "${INCLUDE_DIR}/QtGui")
@ -175,8 +181,8 @@ target_include_directories(PyFalkon
target_link_libraries(PyFalkon
PRIVATE
FalkonPrivate
Shiboken2::libshiboken
PySide2::pyside2
Shiboken${PYSIDE_VERSION}::libshiboken
PySide${PYSIDE_VERSION}::pyside${PYSIDE_VERSION}
Python3::Python
)

View File

@ -6,7 +6,7 @@ macro(pyfalkon_tests)
endmacro()
add_executable(pyfalkontestrunner pyfalkontestrunner.cpp)
target_link_libraries(pyfalkontestrunner FalkonPrivate Qt5::Test)
target_link_libraries(pyfalkontestrunner FalkonPrivate Qt${QT_MAJOR_VERSION}::Test)
pyfalkon_tests(
basictest

View File

@ -23,18 +23,26 @@
#include "browserwindow.h"
#include <QMenu>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfigurationManager>
#endif
SBI_NetworkIcon::SBI_NetworkIcon(BrowserWindow* window)
: SBI_Icon(window)
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, m_networkConfiguration(new QNetworkConfigurationManager(this))
#endif
{
setObjectName(QSL("sbi_networkicon"));
setCursor(Qt::PointingHandCursor);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
onlineStateChanged(m_networkConfiguration->isOnline());
connect(m_networkConfiguration, &QNetworkConfigurationManager::onlineStateChanged, this, &SBI_NetworkIcon::onlineStateChanged);
#else
onlineStateChanged(true);
#endif
connect(this, &ClickableLabel::clicked, this, &SBI_NetworkIcon::showMenu);
}
@ -97,12 +105,16 @@ void SBI_NetworkIcon::updateToolTip()
{
QString tooltip = tr("Shows network status and manages proxy<br/><br/><b>Network:</b><br/>%1<br/><br/><b>Proxy:</b><br/>%2");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (m_networkConfiguration->isOnline()) {
tooltip = tooltip.arg(tr("Connected"));
}
else {
tooltip = tooltip.arg(tr("Offline"));
}
#else
tooltip = tooltip.arg(tr("Connected"));
#endif
switch (QNetworkProxy::applicationProxy().type()) {
case QNetworkProxy::DefaultProxy:
@ -125,7 +137,11 @@ void SBI_NetworkIcon::updateToolTip()
setToolTip(tooltip);
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void SBI_NetworkIcon::enterEvent(QEvent* event)
#else
void SBI_NetworkIcon::enterEvent(QEnterEvent* event)
#endif
{
updateToolTip();

View File

@ -40,9 +40,16 @@ private Q_SLOTS:
private:
void updateToolTip();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEvent* event) override;
#else
void enterEvent(QEnterEvent* event) override;
#endif
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// TODO - should we try to replace the online status detection using Qt 6?
QNetworkConfigurationManager* m_networkConfiguration;
#endif
};
#endif // SBI_NETWORKICON_H

View File

@ -34,7 +34,9 @@
#include "tabcontextmenu.h"
#include "tabbar.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QDesktopWidget>
#endif
#include <QDialogButtonBox>
#include <QStackedWidget>
#include <QDialog>
@ -561,7 +563,12 @@ void TabManagerWidget::detachSelectedTabs(const QMultiHash<BrowserWindow*, WebTa
}
BrowserWindow* newWindow = mApp->createWindow(Qz::BW_OtherRestoredWindow);
newWindow->move(mApp->desktop()->availableGeometry(this).topLeft() + QPoint(30, 30));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const QRect &availableGeometryForScreen = mApp->desktop()->availableGeometry(this);
#else
const QRect &availableGeometryForScreen = screen()->availableGeometry();
#endif
newWindow->move(availableGeometryForScreen.topLeft() + QPoint(30, 30));
detachTabsTo(newWindow, tabsHash);
}
@ -880,7 +887,11 @@ QStringList TabTreeWidget::mimeTypes() const
return types;
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QMimeData *TabTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
#else
QMimeData *TabTreeWidget::mimeData(const QList<QTreeWidgetItem*> &items) const
#endif
{
auto* mimeData = new QMimeData();
QByteArray encodedData;

View File

@ -44,7 +44,11 @@ public:
Qt::DropActions supportedDropActions() const override;
QStringList mimeTypes() const override;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const override;
#else
QMimeData* mimeData(const QList<QTreeWidgetItem*> &items) const override;
#endif
bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) override;
void setEnableDragTabs(bool enable);

View File

@ -25,7 +25,9 @@
#include "statusbar.h"
#include "navigationbar.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QDesktopWidget>
#endif
#include <QAction>
#include <QStyle>
@ -212,7 +214,12 @@ void TabManagerWidgetController::showSideBySide()
if (!defaultTabManager()) {
return;
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const QRect &availableGeometry = mApp->desktop()->availableGeometry(defaultTabManager());
#else
const QRect &availableGeometry = defaultTabManager()->screen()->availableGeometry();
#endif
static int frameWidth = (defaultTabManager()->frameGeometry().width() - defaultTabManager()->geometry().width()) / 2;
static int titleBarHeight = defaultTabManager()->style()->pixelMetric(QStyle::PM_TitleBarHeight);

View File

@ -213,7 +213,7 @@ void TabTreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
// Draw close button
if (m_closeButton->isVisible(hovered, selected)) {
QStyleOptionButton o;
o.init(m_closeButton);
o.initFrom(m_closeButton);
const bool hovered = closeButtonRect(index).contains(m_view->viewport()->mapFromGlobal(QCursor::pos()));
const bool pressed = hovered && QApplication::mouseButtons() == Qt::LeftButton;