diff --git a/CMakeLists.txt b/CMakeLists.txt index c1f1a7987..8734b354c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # # This file is part of RSS Guard. # -# Copyright (C) 2011-2015 by Martin Rotter +# Copyright (C) 2011-2016 by Martin Rotter # # RSS Guard is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,22 +25,15 @@ # # Usage: # a) DEBUG build for testing. -# cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr -DUSE_QT_5=ON +# cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr # # b) RELEASE build for production use. -# cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr -DUSE_QT_5=ON +# cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr # # Arguments: # -DCMAKE_INSTALL_PREFIX=/usr # Installation path, replace with something like "C:\rssguard" on Windows. # -# -DUSE_QT_5=OFF -# Specifies which major Qt version to use. Qt 4 and Qt 5 are supported. -# If "OFF" is passed as an argument, then Qt 4 is used. Default is "OFF". -# -# -DENABLE_OS2_RC=OFF -# If "ON" then icon is compiled into executable file on OS/2. Defaults to "OFF". -# # Refreshing translation sources: # make lupdate # @@ -52,7 +45,7 @@ # # Other information: # - supports Windows, Linux, OS/2 (eComStation), -# - Qt 4.7.3 and higher is required, +# - Qt 5.6 and higher is required, # - resource compiler (windres.exe) is needed on MinGW, # - resource compiler (rc.exe) is recommended on OS/2. # @@ -77,7 +70,7 @@ set(APP_URL_ISSUES_NEW_GITHUB "https://github.com/martinrotter/rssguard/issues/n set(APP_URL_ISSUES_NEW_BITBUCKET "http://bitbucket.org/skunkos/rssguard/issues/new") set(APP_URL_WIKI "https://bitbucket.org/skunkos/rssguard/wiki/Home") set(APP_EMAIL "rotter.martinos@gmail.com") -set(MINIMUM_QT_VERSION 4.7.3) +set(MINIMUM_QT_VERSION 5.6) set(EXE_NAME ${APP_LOW_NAME}) if(APPLE) @@ -85,13 +78,8 @@ if(APPLE) endif(APPLE) # Options declaration. -option(USE_QT_5 "Use Qt 5 for building" OFF) option(ENABLE_ADDITIONAL_ICONS "Install additional icons" ON) -if(OS2) - option(ENABLE_OS2_RC "Compile application icon on OS/2" OFF) -endif(OS2) - if(WIN32) option(USE_NSIS "Use NSIS generator to produce installer" OFF) endif(WIN32) @@ -101,27 +89,16 @@ if(POLICY CMP0012) cmake_policy(SET CMP0012 NEW) endif() -if(USE_QT_5) - cmake_minimum_required(VERSION 2.8.10) -else(USE_QT_5) - cmake_minimum_required(VERSION 2.6.0) -endif(USE_QT_5) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() -if(${APPLE}) - if(NOT USE_QT_5) - message(FATAL_ERROR "[${APP_LOW_NAME}] Only Qt 5.x.x is supported on Mac OS X.") - endif(NOT USE_QT_5) -endif(${APPLE}) +cmake_minimum_required(VERSION 2.8.10) message(STATUS "") message(STATUS "[${APP_LOW_NAME}] ==== Options summary ====") -message(STATUS "[${APP_LOW_NAME}] Use Qt 5 for building -> ${USE_QT_5}") message(STATUS "[${APP_LOW_NAME}] Install additional icons -> ${ENABLE_ADDITIONAL_ICONS}") -if(OS2) - message(STATUS "[${APP_LOW_NAME}] Compile application icon on OS/2 -> ${ENABLE_OS2_RC}") -endif(OS2) - if(WIN32) message(STATUS "[${APP_LOW_NAME}] Use NSIS generator to produce installer -> ${USE_NSIS}") endif(WIN32) @@ -148,15 +125,10 @@ if(POLICY CMP0020) cmake_policy(SET CMP0020 NEW) endif(POLICY CMP0020) -# Select which Qt version to use. -if(USE_QT_5) - message(STATUS "[${APP_LOW_NAME}] Using Qt 5 library for building.") - - # Instruct CMake to run moc automatically when needed. - set(CMAKE_AUTOMOC ON) -else(USE_QT_5) - message(STATUS "[${APP_LOW_NAME}] Using Qt 4 library for building.") -endif(USE_QT_5) +message(STATUS "[${APP_LOW_NAME}] Using Qt 5 library for building.") + +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) # Obtain revision number if available. message(STATUS "[${APP_LOW_NAME}] Obtaining revision number.") @@ -230,61 +202,37 @@ add_definitions(-DUNICODE -D_UNICODE) # Check for C++ 11 features availability. # See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake -if(USE_QT_5) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - execute_process( - COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION - ) - - if(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) - add_definitions(-std=c++11) - elseif(GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3) - add_definitions(-std=gnu++0x) - else(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) - message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.") - endif(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) - - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - add_definitions(-std=c++11 -stdlib=libc++) - elseif(${MSVC_VERSION} VERSION_LESS 1600) +if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION + ) + if(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) + add_definitions(-std=c++11) + elseif(GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3) + add_definitions(-std=gnu++0x) + else(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.") - endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") -endif(USE_QT_5) + endif(${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7) + +elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + add_definitions(-std=c++11 -stdlib=libc++) +elseif(${MSVC_VERSION} VERSION_LESS 1600) + message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.") +endif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") # Setup libraries. if(UNIX) # On Unices, enable D-Bus support. - if(USE_QT_5) - find_package(Qt5 REQUIRED DBus Sql WebKit WebKitWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) - else(USE_QT_5) - set(QT_MIN_VERSION ${MINIMUM_QT_VERSION}) - find_package(Qt4 REQUIRED QtDBus QtCore QtGui QtSql QtNetwork QtWebkit QtXml QtXmlPatterns) - include(${QT_USE_FILE}) - endif(USE_QT_5) + find_package(Qt5 REQUIRED DBus Sql WebEngineWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) else(UNIX) - if(USE_QT_5) - find_package(Qt5 REQUIRED Sql WebKit WebKitWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) - else(USE_QT_5) - set(QT_MIN_VERSION ${MINIMUM_QT_VERSION}) - find_package(Qt4 REQUIRED QtCore QtGui QtSql QtNetwork QtWebkit QtXml QtXmlPatterns) - include(${QT_USE_FILE}) - endif(USE_QT_5) + find_package(Qt5 REQUIRED Sql WebEngineWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) endif(UNIX) # Configure QStringBuilder behavior. -if(USE_QT_5) - message(STATUS "[${APP_LOW_NAME}] Enabling fast QString concatenation.") +message(STATUS "[${APP_LOW_NAME}] Enabling fast QString concatenation.") - add_definitions(-DQT_USE_FAST_CONCATENATION) - add_definitions(-DQT_USE_FAST_OPERATOR_PLUS) -elseif(NOT ${QTVERSION} VERSION_LESS 4.8.0) - message(STATUS "[${APP_LOW_NAME}] Enabling fast QString concatenation.") - - add_definitions(-DQT_USE_FAST_CONCATENATION) - add_definitions(-DQT_USE_FAST_OPERATOR_PLUS) -else(NOT ${QTVERSION} VERSION_LESS 4.8.0) - message(STATUS "[${APP_LOW_NAME}] Disabling fast QString concatenation.") -endif(USE_QT_5) +add_definitions(-DQT_USE_FAST_CONCATENATION) +add_definitions(-DQT_USE_FAST_OPERATOR_PLUS) # Configure executable "properties" for Windows or OS2. if(WIN32) @@ -293,12 +241,6 @@ if(WIN32) ${PROJECT_SOURCE_DIR}/resources/executable_properties/rssguard_win.rc.in ${CMAKE_BINARY_DIR}/resources/executable_properties/rssguard_win.rc ) -elseif(OS2 AND ENABLE_OS2_RC) - message(STATUS "[${APP_LOW_NAME}] Generating executable file properties for OS2.") - configure_file ( - ${PROJECT_SOURCE_DIR}/resources/executable_properties/rssguard_os2.rc.in - ${CMAKE_BINARY_DIR}/resources/executable_properties/rssguard_os2.rc - ) endif(WIN32) # Set special linker flag for Windows XP & MSVC++ 2013 support. @@ -318,21 +260,6 @@ if(WIN32 AND MINGW) set(APP_SOURCES ${APP_SOURCES} ${CMAKE_BINARY_DIR}/resources/executable_properties/rssguard_win.rc) -elseif(OS2) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Zstack 0x2000 -Zlinker \"DISABLE 1121\" -s -Zlinker /PM:PM -Zno-fork -Zhigh-mem -Zmap") - - if(${ENABLE_OS2_RC}) - enable_language(RC) - set(CMAKE_RC_COMPILER_INIT rc) - message(STATUS "[${APP_LOW_NAME}] Icon file binary will be builded for OS2.") - message(STATUS "[${APP_LOW_NAME}] Used tool is: ${CMAKE_RC_COMPILER}") - set(CMAKE_RC_COMPILE_OBJECT - " -n -r ") - - set(APP_SOURCES - ${APP_SOURCES} - ${CMAKE_BINARY_DIR}/resources/executable_properties/rssguard_os2.rc) - endif(${ENABLE_OS2_RC}) elseif(WIN32 AND MSVC) # MSVC takes care of this automatically - no need to use windres.exe # for MSVC compilers. @@ -419,15 +346,6 @@ file( GLOB APP_TEXT "resources/text/C*") if(WIN32) - file( GLOB APP_DLLS_QT4_MSVC2013 - "resources/binaries/windows/qt4-msvc2013/*.dll") - - file( GLOB APP_DLLS_QT4_MSVC2013_IMAGEFORMATS - "resources/binaries/windows/qt4-msvc2013/imageformats/*.dll") - - file( GLOB APP_DLLS_QT4_MSVC2013_SQLDRIVERS - "resources/binaries/windows/qt4-msvc2013/sqldrivers/*.dll") - file( GLOB APP_DLLS_QT5_MSVC2013 "resources/binaries/windows/qt5-msvc2013/*.dll") @@ -450,23 +368,15 @@ if(APPLE) endif(APPLE) # Wrap files, create moc files. -if(USE_QT_5) - qt5_wrap_ui(APP_UI ${APP_FORMS}) - - # Load translations. - if(${Qt5LinguistTools_FOUND}) - message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get compiled.") - qt5_add_translation(APP_QM ${APP_TRANSLATIONS}) - else(${Qt5LinguistTools_FOUND}) - message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No compilation for translations.") - endif(${Qt5LinguistTools_FOUND}) -else(USE_QT_5) - qt4_wrap_cpp(APP_MOC ${APP_HEADERS}) - qt4_wrap_ui(APP_UI ${APP_FORMS}) - - # Load translations. - qt4_add_translation(APP_QM ${APP_TRANSLATIONS}) -endif(USE_QT_5) +qt5_wrap_ui(APP_UI ${APP_FORMS}) + +# Load translations. +if(${Qt5LinguistTools_FOUND}) + message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get compiled.") + qt5_add_translation(APP_QM ${APP_TRANSLATIONS}) +else(${Qt5LinguistTools_FOUND}) + message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No compilation for translations.") +endif(${Qt5LinguistTools_FOUND}) # Include additional directory paths. include_directories ( @@ -481,99 +391,55 @@ include_directories ( ) # Compile "rssguard" -if(USE_QT_5) - add_executable(${EXE_NAME} WIN32 MACOSX_BUNDLE - ${APP_SOURCES} - ${APP_FORMS} - ${APP_RCC} - ${APP_QM} - ) +add_executable(${EXE_NAME} WIN32 MACOSX_BUNDLE + ${APP_SOURCES} + ${APP_FORMS} + ${APP_RCC} + ${APP_QM} +) - if(WIN32) - target_link_libraries(${EXE_NAME} Qt5::WinMain) - endif(WIN32) +if(WIN32) + target_link_libraries(${EXE_NAME} Qt5::WinMain) +endif(WIN32) - if(UNIX) - # Use modules from Qt. - qt5_use_modules(${EXE_NAME} - DBus - Core - Widgets - Sql - Network - Xml - WebKit - WebKitWidgets - PrintSupport - ) - else(UNIX) +if(UNIX) # Use modules from Qt. - qt5_use_modules(${EXE_NAME} - Core - Widgets - Sql - Network - Xml - WebKit - WebKitWidgets - PrintSupport - ) - endif(UNIX) -# Setup compilation for Qt 4. -else(USE_QT_5) - add_executable(${EXE_NAME} WIN32 MACOSX_BUNDLE - ${APP_SOURCES} - ${APP_FORMS} - ${APP_MOC} - ${APP_RCC} - ${APP_QM} + qt5_use_modules(${EXE_NAME} + DBus + Core + Widgets + Sql + Network + Xml + WebEngineWidgets + PrintSupport ) - - if(UNIX) - # Link modules from Qt. - target_link_libraries(${EXE_NAME} - ${QT_QTDBUS_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${QT_QTXML_LIBRARY} - ${QT_QTMAIN_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} - ) - else(UNIX) - # Link modules from Qt. - target_link_libraries(${EXE_NAME} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${QT_QTXML_LIBRARY} - ${QT_QTMAIN_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} - ) - endif(UNIX) -endif(USE_QT_5) +else(UNIX) +# Use modules from Qt. + qt5_use_modules(${EXE_NAME} + Core + Widgets + Sql + Network + Xml + WebEngineWidgets + PrintSupport + ) +endif(UNIX) # Installation stage. -if(WIN32 OR OS2) +if(WIN32) message(STATUS "[${APP_LOW_NAME}] You will probably install on Windows or OS/2.") install(TARGETS ${EXE_NAME} RUNTIME DESTINATION ./) # Copy DLLs and other binary files for main installation. - if(WIN32 AND USE_QT_5) + if(WIN32) install(FILES ${APP_DLLS_QT5_MSVC2013} DESTINATION ./) install(FILES ${APP_DLLS_QT5_MSVC2013_IMAGEFORMATS} DESTINATION ./imageformats) install(FILES ${APP_DLLS_QT5_MSVC2013_SQLDRIVERS} DESTINATION ./sqldrivers) install(FILES ${APP_DLLS_QT5_MSVC2013_PLATFORMS} DESTINATION ./platforms) install(FILES ${APP_DLLS_QT5_MSVC2013_PRINTSUPPORT} DESTINATION ./printsupport) - endif(WIN32 AND USE_QT_5) - - if(WIN32 AND NOT USE_QT_5) - install(FILES ${APP_DLLS_QT4_MSVC2013} DESTINATION ./) - install(FILES ${APP_DLLS_QT4_MSVC2013_IMAGEFORMATS} DESTINATION ./imageformats) - install(FILES ${APP_DLLS_QT4_MSVC2013_SQLDRIVERS} DESTINATION ./sqldrivers) - endif(WIN32 AND NOT USE_QT_5) + endif(WIN32) install(DIRECTORY resources/graphics/icons/mini-kfaenza DESTINATION ./icons) @@ -661,7 +527,7 @@ elseif(UNIX) install(FILES resources/graphics/${APP_LOW_NAME}_plain_128.png DESTINATION share/rssguard/icons RENAME ${APP_LOW_NAME}_plain.png) install(FILES ${APP_QM} DESTINATION share/${APP_LOW_NAME}/l10n) install(FILES ${APP_TEXT} DESTINATION share/${APP_LOW_NAME}/information) -endif(WIN32 OR OS2) +endif(WIN32) # Custom target for packaging. if(WIN32) @@ -702,16 +568,8 @@ configure_file( add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) # make lupdate implementation. -if(USE_QT_5) - add_custom_target(lupdate - ${Qt5Core_QMAKE_EXECUTABLE} -project -o ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro - COMMAND ${Qt5_LUPDATE_EXECUTABLE} -no-obsolete -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) -else(USE_QT_5) - add_custom_target(lupdate - ${QT_QMAKE_EXECUTABLE} -project -o ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro - COMMAND ${QT_LUPDATE_EXECUTABLE} -no-obsolete -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) -endif(USE_QT_5) +add_custom_target(lupdate + ${Qt5Core_QMAKE_EXECUTABLE} -project -o ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro + COMMAND ${Qt5_LUPDATE_EXECUTABLE} -no-obsolete -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_BINARY_DIR}/${APP_LOW_NAME}.pro + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +) diff --git a/resources/executable_properties/rssguard_os2.rc.in b/resources/executable_properties/rssguard_os2.rc.in deleted file mode 100644 index 4a8cf3ef1..000000000 --- a/resources/executable_properties/rssguard_os2.rc.in +++ /dev/null @@ -1 +0,0 @@ -ICON 1 DISCARDABLE "@PROJECT_SOURCE_DIR@/resources/graphics/rssguard_os2.ico" \ No newline at end of file diff --git a/resources/graphics/rssguard_os2.ico b/resources/graphics/rssguard_os2.ico deleted file mode 100644 index 3b017e99b..000000000 Binary files a/resources/graphics/rssguard_os2.ico and /dev/null differ diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 6d8b807d9..90285b22a 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include @@ -118,9 +119,9 @@ void FeedMessageViewer::loadSize() { void FeedMessageViewer::loadMessageViewerFonts() { const Settings *settings = qApp->settings(); - QWebSettings *view_settings = m_messagesBrowser->view()->settings(); + QWebEngineSettings *view_settings = m_messagesBrowser->view()->settings(); - view_settings->setFontFamily(QWebSettings::StandardFont, settings->value(GROUP(Messages), + view_settings->setFontFamily(QWebEngineSettings::StandardFont, settings->value(GROUP(Messages), SETTING(Messages::PreviewerFontStandard)).toString()); } diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 5649dd6dd..e901730c0 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include @@ -304,7 +304,7 @@ DKEY CategoriesExpandStates::ID = "categories_expand_sta Settings::Settings(const QString &file_name, Format format, const SettingsProperties::SettingsType &status, QObject *parent) : QSettings(file_name, format, parent), m_initializationStatus(status) { // Perform last-minute initializations. - Messages::PreviewerFontStandardDef = QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont); + Messages::PreviewerFontStandardDef = QWebEngineSettings::globalSettings()->fontFamily(QWebEngineSettings::StandardFont); } Settings::~Settings() { @@ -357,11 +357,6 @@ Settings *Settings::setupSettings(QObject *parent) { // Portable settings are available, use them. new_settings = new Settings(properties.m_absoluteSettingsFileName, QSettings::IniFormat, properties.m_type, parent); - // Construct icon cache in the same path. - const QString web_path = properties.m_baseDirectory + QDir::separator() + QString(APP_DB_WEB_PATH); - QDir(web_path).mkpath(web_path); - QWebSettings::setIconDatabasePath(web_path); - // Check if portable settings are available. if (properties.m_type == SettingsProperties::Portable) { qDebug("Initializing settings in '%s' (portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); diff --git a/src/network-web/adblock/adblockicon.cpp b/src/network-web/adblock/adblockicon.cpp index 4d281c823..d138eea51 100755 --- a/src/network-web/adblock/adblockicon.cpp +++ b/src/network-web/adblock/adblockicon.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include AdBlockIcon::AdBlockIcon(QWidget *window, QWidget *parent) @@ -71,7 +71,7 @@ void AdBlockIcon::createMenu(QMenu *menu) { AdBlockCustomList *custom_list = manager->customList(); WebPage *page = qApp->mainForm()->tabWidget()->currentWidget()->webBrowser()->view()->page(); - const QUrl page_url = page->mainFrame()->url(); + const QUrl page_url = page->url(); menu->addAction(tr("Show Adblock &settings"), manager, SLOT(showDialog())); menu->addSeparator(); diff --git a/src/network-web/adblock/adblockmanager.cpp b/src/network-web/adblock/adblockmanager.cpp index fcbe85c98..9cdea163f 100755 --- a/src/network-web/adblock/adblockmanager.cpp +++ b/src/network-web/adblock/adblockmanager.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include AdBlockManager *AdBlockManager::s_adBlockManager = NULL; @@ -90,7 +90,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request) { WebPage *web_page = static_cast(v.value()); if (WebPage::isPointerSafeToUse(web_page)) { - if (!canBeBlocked(web_page->mainFrame()->url())) { + if (!canBeBlocked(web_page->url())) { return NULL; } diff --git a/src/network-web/adblock/adblockrule.cpp b/src/network-web/adblock/adblockrule.cpp index 5eaea3e98..e364c959e 100755 --- a/src/network-web/adblock/adblockrule.cpp +++ b/src/network-web/adblock/adblockrule.cpp @@ -56,8 +56,7 @@ #include #include #include -#include -#include +#include AdBlockRule::AdBlockRule(const QString &filter, AdBlockSubscription* subscription) @@ -289,21 +288,7 @@ bool AdBlockRule::matchObject(const QNetworkRequest &request) const { } bool AdBlockRule::matchSubdocument(const QNetworkRequest &request) const { - QWebFrame *originatingFrame = static_cast(request.originatingObject()); - - if (originatingFrame == NULL) { - return false; - } - - QWebPage *page = originatingFrame->page(); - - if (page == NULL) { - return false; - } - - bool match = !(originatingFrame == page->mainFrame()); - - return hasException(SubdocumentOption) ? !match : match; + return false; } bool AdBlockRule::matchXmlHttpRequest(const QNetworkRequest &request) const { diff --git a/src/network-web/adblock/adblocksubscription.cpp b/src/network-web/adblock/adblocksubscription.cpp index 2006a5a9f..fa92b473d 100755 --- a/src/network-web/adblock/adblocksubscription.cpp +++ b/src/network-web/adblock/adblocksubscription.cpp @@ -57,7 +57,7 @@ #include #include #include -#include +#include AdBlockSubscription::AdBlockSubscription(const QString &title, QObject *parent) diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index caac56e75..8f35a3047 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include DownloadItem::DownloadItem(bool is_direct_download, QNetworkReply *reply, QWidget *parent) : QWidget(parent), @@ -603,14 +603,12 @@ void DownloadManager::updateRow(DownloadItem *item) { int old_height = m_ui->m_viewDownloads->rowHeight(row); m_ui->m_viewDownloads->setRowHeight(row, qMax(old_height, item->minimumSizeHint().height())); - QWebSettings *globalSettings = QWebSettings::globalSettings(); // Remove the item if: // a) It is not downloading and private browsing is enabled. // OR // b) Item is already downloaded and it should be remove from downloader list. - bool remove = (!item->downloading() && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) || - (item->downloadedSuccessfully() && removePolicy() == DownloadManager::OnSuccessfullDownload); + bool remove = item->downloadedSuccessfully() && removePolicy() == DownloadManager::OnSuccessfullDownload; if (remove) { m_model->removeRow(row); diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp index ad6443737..89f1695da 100755 --- a/src/network-web/webbrowser.cpp +++ b/src/network-web/webbrowser.cpp @@ -18,7 +18,6 @@ #include "network-web/webbrowser.h" #include "definitions/definitions.h" -#include "network-web/webbrowsernetworkaccessmanager.h" #include "network-web/webpage.h" #include "network-web/webview.h" #include "network-web/networkfactory.h" @@ -33,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,10 +49,10 @@ WebBrowser::WebBrowser(QWidget *parent) m_toolBar(new QToolBar(tr("Navigation panel"), this)), m_webView(new WebView(this)), m_txtLocation(new LocationLineEdit(this)), - m_actionBack(m_webView->pageAction(QWebPage::Back)), - m_actionForward(m_webView->pageAction(QWebPage::Forward)), - m_actionReload(m_webView->pageAction(QWebPage::Reload)), - m_actionStop(m_webView->pageAction(QWebPage::Stop)) { + m_actionBack(m_webView->pageAction(QWebEnginePage::Back)), + m_actionForward(m_webView->pageAction(QWebEnginePage::Forward)), + m_actionReload(m_webView->pageAction(QWebEnginePage::Reload)), + m_actionStop(m_webView->pageAction(QWebEnginePage::Stop)) { // Add this new instance to the global list of web browsers. // NOTE: This is used primarily for dynamic icon theme switching. m_runningWebBrowsers.append(this); @@ -168,7 +167,8 @@ void WebBrowser::onLoadingStarted() { void WebBrowser::onLoadingProgress(int progress) { m_loadingProgress->setValue(progress); - m_lblProgress->setText(QString(QSL(" %1 kB / %2 kB")).arg(m_webView->page()->bytesReceived() / 1000).arg(m_webView->page()->totalBytes() / 1000)); + // TODO: TODO + //m_lblProgress->setText(QString(QSL(" %1 kB / %2 kB")).arg(m_webView->page()-> / 1000).arg(m_webView->page()->totalBytes() / 1000)); } void WebBrowser::onLoadingFinished(bool success) { @@ -209,7 +209,8 @@ void WebBrowser::createConnections() { } void WebBrowser::onIconChanged() { - emit iconChanged(m_index, m_webView->icon()); + // TODO: todo + //emit iconChanged(m_index, m_webView->icon()); } void WebBrowser::onTitleChanged(const QString &new_title) { @@ -319,3 +320,11 @@ void WebBrowser::setupIcons() { m_actionStop->setIcon(qApp->icons()->fromTheme(QSL("go-stop"))); m_webView->setupIcons(); } + +QIcon WebBrowser::icon() const { + + return QIcon(); + + // TODO: TODO. + //return m_webView->iconUrl(); +} diff --git a/src/network-web/webbrowser.h b/src/network-web/webbrowser.h index 6d3c143f8..603b80c2a 100755 --- a/src/network-web/webbrowser.h +++ b/src/network-web/webbrowser.h @@ -37,7 +37,6 @@ class QHBoxLayout; class QProgressBar; class QMenu; class QLabel; -class WebBrowserNetworkAccessManager; class TabWidget; class WebBrowser : public TabContent { @@ -52,9 +51,7 @@ class WebBrowser : public TabContent { void setupIcons(); // Returns icon associated with currently loaded website. - inline QIcon icon() const { - return m_webView->icon(); - } + QIcon icon() const; inline WebView *view() const { return m_webView; diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp index ecd6ebc2b..8e876f8bc 100755 --- a/src/network-web/webfactory.cpp +++ b/src/network-web/webfactory.cpp @@ -3,7 +3,7 @@ #include "miscellaneous/application.h" #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ QPointer WebFactory::s_instance; WebFactory::WebFactory(QObject *parent) : QObject(parent), m_escapes(QMap()), m_deEscapes(QMap()), - m_globalSettings(QWebSettings::globalSettings()) { + m_globalSettings(QWebEngineSettings::globalSettings()) { } WebFactory::~WebFactory() { @@ -34,7 +34,7 @@ bool WebFactory::sendMessageViaEmail(const Message &message) { const QString arguments = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString(); return QProcess::startDetached(QString("\"") + browser + QSL("\" ") + arguments.arg(message.m_title, - stripTags(message.m_contents))); + stripTags(message.m_contents))); } else { // Send it via mailto protocol. @@ -71,7 +71,7 @@ void WebFactory::switchJavascript(bool enable, bool save_settings) { qApp->settings()->setValue(GROUP(Browser), Browser::JavascriptEnabled, enable); } - m_globalSettings->setAttribute(QWebSettings::JavascriptEnabled, enable); + m_globalSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, enable); emit javascriptSwitched(enable); } @@ -80,7 +80,7 @@ void WebFactory::switchPlugins(bool enable, bool save_settings) { qApp->settings()->setValue(GROUP(Browser), Browser::PluginsEnabled, enable); } - m_globalSettings->setAttribute(QWebSettings::PluginsEnabled, enable); + m_globalSettings->setAttribute(QWebEngineSettings::PluginsEnabled, enable); emit pluginsSwitched(enable); } @@ -89,7 +89,7 @@ void WebFactory::switchImages(bool enable, bool save_settings) { qApp->settings()->setValue(GROUP(Browser), Browser::ImagesEnabled, enable); } - m_globalSettings->setAttribute(QWebSettings::AutoLoadImages, enable); + m_globalSettings->setAttribute(QWebEngineSettings::AutoLoadImages, enable); emit imagesLoadingSwitched(enable); } @@ -102,15 +102,15 @@ WebFactory *WebFactory::instance() { } bool WebFactory::javascriptEnabled() const { - return m_globalSettings->testAttribute(QWebSettings::JavascriptEnabled); + return m_globalSettings->testAttribute(QWebEngineSettings::JavascriptEnabled); } bool WebFactory::pluginsEnabled() const { - return m_globalSettings->testAttribute(QWebSettings::PluginsEnabled); + return m_globalSettings->testAttribute(QWebEngineSettings::PluginsEnabled); } bool WebFactory::autoloadImages() const { - return m_globalSettings->testAttribute(QWebSettings::AutoLoadImages); + return m_globalSettings->testAttribute(QWebEngineSettings::AutoLoadImages); } QString WebFactory::stripTags(QString text) { diff --git a/src/network-web/webfactory.h b/src/network-web/webfactory.h index b7a24dda0..922eb6ddc 100755 --- a/src/network-web/webfactory.h +++ b/src/network-web/webfactory.h @@ -9,7 +9,7 @@ #include -class QWebSettings; +class QWebEngineSettings; class WebFactory : public QObject { Q_OBJECT @@ -67,7 +67,7 @@ class WebFactory : public QObject { QMap m_escapes; QMap m_deEscapes; - QWebSettings *m_globalSettings; + QWebEngineSettings *m_globalSettings; // Singleton. static QPointer s_instance; diff --git a/src/network-web/webpage.cpp b/src/network-web/webpage.cpp index 378239375..74063dc1c 100755 --- a/src/network-web/webpage.cpp +++ b/src/network-web/webpage.cpp @@ -17,29 +17,21 @@ #include "network-web/webpage.h" -#include "network-web/webbrowsernetworkaccessmanager.h" #include "network-web/webbrowser.h" #include "miscellaneous/application.h" #include "network-web/adblock/adblockmanager.h" #include -#include -#include QList WebPage::s_livingPages; WebPage::WebPage(QObject *parent) - : QWebPage(parent), m_loadProgress(-1) { - // Setup global network access manager. - // NOTE: This makes network settings easy for all web browsers. - setNetworkAccessManager(new WebBrowserNetworkAccessManager(this, this)); - setForwardUnsupportedContent(true); - connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); - + : QWebEnginePage(parent), m_loadProgress(-1) { connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished())); + connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); s_livingPages.append(this); } @@ -58,65 +50,6 @@ void WebPage::progress(int prog) { void WebPage::finished() { progress(100); - cleanBlockedObjects(); -} - -void WebPage::cleanBlockedObjects() { - AdBlockManager *manager = AdBlockManager::instance(); - - if (!manager->isEnabled()) { - return; - } - - const QWebElement doc_element = mainFrame()->documentElement(); - - foreach (const AdBlockedEntry &entry, m_adBlockedEntries) { - const QString url_string = entry.url.toString(); - if (url_string.endsWith(QL1S(".js")) || url_string.endsWith(QL1S(".css"))) { - continue; - } - - QString url_end; - - int pos = url_string.lastIndexOf(QL1C('/')); - if (pos > 8) { - url_end = url_string.mid(pos + 1); - } - - if (url_string.endsWith(QL1C('/'))) { - url_end = url_string.left(url_string.size() - 1); - } - - QString selector(QSL("img[src$=\"%1\"], iframe[src$=\"%1\"],embed[src$=\"%1\"]")); - QWebElementCollection elements = doc_element.findAll(selector.arg(url_end)); - - foreach (QWebElement element, elements) { - QString src = element.attribute(QSL("src")); - src.remove(QL1S("../")); - - if (url_string.contains(src)) { - element.setStyleProperty(QSL("display"), QSL("none")); - } - } - } - - // Apply domain-specific element hiding rules - QString element_hiding = manager->elementHidingRulesForDomain(mainFrame()->url()); - - if (element_hiding.isEmpty()) { - return; - } - - element_hiding.append(QL1S("\n")); - - QWebElement body_element = doc_element.findFirst(QSL("body")); - body_element.appendInside(QSL("