From 322aef972dd8502588c312dae007b840ebc49bef Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 1 Apr 2016 08:44:59 +0200 Subject: [PATCH] Removed that webengine shit. --- CMakeLists.txt | 8 +- src/gui/dialogs/formmain.cpp | 59 ----- src/gui/dialogs/formmain.h | 3 - src/gui/dialogs/formmain.ui | 100 --------- src/gui/dialogs/formsettings.cpp | 12 - src/gui/dialogs/formsettings.ui | 42 ---- src/gui/discoverfeedsbutton.cpp | 92 -------- src/gui/discoverfeedsbutton.h | 45 ---- src/gui/feedmessageviewer.cpp | 59 +++-- src/gui/feedmessageviewer.h | 8 +- src/gui/locationlineedit.cpp | 53 ----- src/gui/locationlineedit.h | 44 ---- src/gui/messagesview.cpp | 37 +--- src/gui/messagesview.h | 2 - src/gui/tabcontent.h | 6 - src/gui/tabwidget.cpp | 118 +--------- src/gui/tabwidget.h | 15 -- src/main.cpp | 5 - src/miscellaneous/application.cpp | 1 - src/miscellaneous/settings.cpp | 21 +- src/miscellaneous/settings.h | 18 -- src/network-web/downloadmanager.cpp | 10 - src/network-web/downloadmanager.h | 3 - src/network-web/googlesuggest.cpp | 204 ----------------- src/network-web/googlesuggest.h | 82 ------- src/network-web/webbrowser.cpp | 328 ---------------------------- src/network-web/webbrowser.h | 168 -------------- src/network-web/webfactory.cpp | 68 ++---- src/network-web/webfactory.h | 38 ++-- src/network-web/webview.cpp | 69 ------ src/network-web/webview.h | 47 ---- 31 files changed, 92 insertions(+), 1673 deletions(-) delete mode 100755 src/gui/discoverfeedsbutton.cpp delete mode 100755 src/gui/discoverfeedsbutton.h delete mode 100755 src/gui/locationlineedit.cpp delete mode 100755 src/gui/locationlineedit.h delete mode 100755 src/network-web/googlesuggest.cpp delete mode 100755 src/network-web/googlesuggest.h delete mode 100755 src/network-web/webbrowser.cpp delete mode 100755 src/network-web/webbrowser.h delete mode 100755 src/network-web/webview.cpp delete mode 100755 src/network-web/webview.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f095e5730..36620879e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,9 +223,9 @@ endif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") # Setup libraries. if(UNIX) # On Unices, enable D-Bus support. - find_package(Qt5 REQUIRED DBus Sql WebEngineCore WebEngineWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) + find_package(Qt5 REQUIRED DBus Sql Widgets Xml XmlPatterns Network LinguistTools PrintSupport) else(UNIX) - find_package(Qt5 REQUIRED Sql WebEngineCore WebEngineWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport) + find_package(Qt5 REQUIRED Sql Widgets Xml XmlPatterns Network LinguistTools PrintSupport) endif(UNIX) message(STATUS "[${APP_LOW_NAME}] Found Qt version: '${Qt5_VERSION}'.") @@ -413,8 +413,6 @@ if(UNIX) Sql Network Xml - WebEngineCore - WebEngineWidgets PrintSupport ) else(UNIX) @@ -425,8 +423,6 @@ else(UNIX) Sql Network Xml - WebEngineCore - WebEngineWidgets PrintSupport ) endif(UNIX) diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 7c9900649..a921cbf02 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -25,7 +25,6 @@ #include "miscellaneous/databasefactory.h" #include "miscellaneous/iconfactory.h" #include "network-web/webfactory.h" -#include "network-web/webbrowser.h" #include "gui/feedsview.h" #include "gui/messagebox.h" #include "gui/systemtrayicon.h" @@ -84,9 +83,6 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f) loadSize(); m_statusBar->loadChangeableActions(); - - // Initialize the web factory. - WebFactory::instance()->loadState(); } FormMain::~FormMain() { @@ -113,14 +109,8 @@ QList FormMain::allActions() const { actions << m_ui->m_actionSwitchStatusBar; actions << m_ui->m_actionSwitchMessageListOrientation; - // Add web browser actions. - actions << m_ui->m_actionAddBrowser; - actions << m_ui->m_actionCloseCurrentTab; - actions << m_ui->m_actionCloseAllTabs; - // Add feeds/messages actions. actions << m_ui->m_actionOpenSelectedSourceArticlesExternally; - actions << m_ui->m_actionOpenSelectedSourceArticlesInternally; actions << m_ui->m_actionOpenSelectedMessagesInternally; actions << m_ui->m_actionMarkAllItemsRead; actions << m_ui->m_actionMarkSelectedItemsAsRead; @@ -362,16 +352,6 @@ void FormMain::setupIcons() { m_ui->m_actionSwitchMessageListOrientation->setIcon(icon_theme_factory->fromTheme(QSL("view-switch-layout-direction"))); m_ui->m_menuShowHide->setIcon(icon_theme_factory->fromTheme(QSL("view-switch"))); - // Web browser. - m_ui->m_actionAddBrowser->setIcon(icon_theme_factory->fromTheme(QSL("list-add"))); - m_ui->m_actionCloseCurrentTab->setIcon(icon_theme_factory->fromTheme(QSL("list-remove"))); - m_ui->m_actionCloseAllTabs->setIcon(icon_theme_factory->fromTheme(QSL("list-remove"))); - m_ui->m_menuCurrentTab->setIcon(icon_theme_factory->fromTheme(QSL("list-current"))); - m_ui->m_menuWebSettings->setIcon(icon_theme_factory->fromTheme(QSL("application-settings"))); - m_ui->m_actionWebAutoloadImages->setIcon(icon_theme_factory->fromTheme(QSL("image-generic"))); - m_ui->m_actionWebEnableExternalPlugins->setIcon(icon_theme_factory->fromTheme(QSL("web-flash"))); - m_ui->m_actionWebEnableJavascript->setIcon(icon_theme_factory->fromTheme(QSL("web-javascript"))); - // Feeds/messages. m_ui->m_menuAddItem->setIcon(icon_theme_factory->fromTheme(QSL("item-new"))); m_ui->m_actionStopRunningItemsUpdate->setIcon(icon_theme_factory->fromTheme(QSL("go-stop"))); @@ -388,7 +368,6 @@ void FormMain::setupIcons() { m_ui->m_actionMarkSelectedMessagesAsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read"))); m_ui->m_actionMarkSelectedMessagesAsUnread->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread"))); m_ui->m_actionSwitchImportanceOfSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-favorite"))); - m_ui->m_actionOpenSelectedSourceArticlesInternally->setIcon(icon_theme_factory->fromTheme(QSL("item-open-internal"))); m_ui->m_actionOpenSelectedSourceArticlesExternally->setIcon(icon_theme_factory->fromTheme(QSL("item-open-external"))); m_ui->m_actionOpenSelectedMessagesInternally->setIcon(icon_theme_factory->fromTheme(QSL("item-open-internal"))); m_ui->m_actionSendMessageViaEmail->setIcon(icon_theme_factory->fromTheme(QSL("item-send-email"))); @@ -409,11 +388,6 @@ void FormMain::setupIcons() { m_ui->m_actionAddFeedIntoSelectedAccount->setIcon(icon_theme_factory->fromTheme(QSL("folder-feed"))); m_ui->m_actionAddCategoryIntoSelectedAccount->setIcon(icon_theme_factory->fromTheme(QSL("folder-category"))); - // Setup icons for underlying components: opened web browsers... - foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) { - browser->setupIcons(); - } - // Setup icons on TabWidget too. m_ui->m_tabWidget->setupIcons(); @@ -508,39 +482,6 @@ void FormMain::createConnections() { connect(m_ui->m_actionReportBugBitBucket, SIGNAL(triggered()), this, SLOT(reportABugOnBitBucket())); connect(m_ui->m_actionDonate, SIGNAL(triggered()), this, SLOT(donate())); connect(m_ui->m_actionDisplayWiki, SIGNAL(triggered()), this, SLOT(showWiki())); - - // Menu "Web browser" connections. - connect(m_ui->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(loadWebBrowserMenu(int))); - connect(m_ui->m_actionCloseCurrentTab, SIGNAL(triggered()), m_ui->m_tabWidget, SLOT(closeCurrentTab())); - connect(m_ui->m_actionAddBrowser, SIGNAL(triggered()), m_ui->m_tabWidget, SLOT(addEmptyBrowser())); - connect(m_ui->m_actionCloseAllTabs, SIGNAL(triggered()), m_ui->m_tabWidget, SLOT(closeAllTabsExceptCurrent())); - connect(m_ui->m_actionWebAutoloadImages, SIGNAL(toggled(bool)), WebFactory::instance(), SLOT(switchImages(bool))); - connect(m_ui->m_actionWebEnableExternalPlugins, SIGNAL(toggled(bool)), WebFactory::instance(), SLOT(switchPlugins(bool))); - connect(m_ui->m_actionWebEnableJavascript, SIGNAL(toggled(bool)), WebFactory::instance(), SLOT(switchJavascript(bool))); - - connect(WebFactory::instance(), SIGNAL(imagesLoadingSwitched(bool)), m_ui->m_actionWebAutoloadImages, SLOT(setChecked(bool))); - connect(WebFactory::instance(), SIGNAL(javascriptSwitched(bool)), m_ui->m_actionWebEnableJavascript, SLOT(setChecked(bool))); - connect(WebFactory::instance(), SIGNAL(pluginsSwitched(bool)), m_ui->m_actionWebEnableExternalPlugins, SLOT(setChecked(bool))); -} - -void FormMain::loadWebBrowserMenu(int index) { - const WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser(); - - m_ui->m_menuCurrentTab->clear(); - - if (active_browser != NULL) { - m_ui->m_menuCurrentTab->setEnabled(true); - m_ui->m_menuCurrentTab->addActions(active_browser->globalMenu()); - - if (m_ui->m_menuCurrentTab->actions().size() == 0) { - m_ui->m_menuCurrentTab->insertAction(NULL, m_ui->m_actionNoActions); - } - } - else { - m_ui->m_menuCurrentTab->setEnabled(false); - } - - m_ui->m_actionCloseCurrentTab->setEnabled(m_ui->m_tabWidget->tabBar()->tabType(index) == TabBar::Closable); } void FormMain::backupDatabaseSettings() { diff --git a/src/gui/dialogs/formmain.h b/src/gui/dialogs/formmain.h index 2bdfda3fa..06b28244f 100755 --- a/src/gui/dialogs/formmain.h +++ b/src/gui/dialogs/formmain.h @@ -78,9 +78,6 @@ class FormMain : public QMainWindow { void updateRecycleBinMenu(); void updateAccountsMenu(); - // Loads web browser menu if user selects to change tabs. - void loadWebBrowserMenu(int index); - // Displays various dialogs. void backupDatabaseSettings(); void restoreDatabaseSettings(); diff --git a/src/gui/dialogs/formmain.ui b/src/gui/dialogs/formmain.ui index 847ec7a70..191c09c09 100755 --- a/src/gui/dialogs/formmain.ui +++ b/src/gui/dialogs/formmain.ui @@ -100,30 +100,6 @@ - - - &Web browser - - - - &Current tab - - - - - Settings - - - - - - - - - - - - Feeds && categories @@ -160,7 +136,6 @@ &Messages - @@ -195,7 +170,6 @@ - @@ -252,39 +226,6 @@ F - - - &Add tab - - - Add new web browser tab. - - - Ctrl+T - - - - - &Close all tabs except current one - - - Close all tabs except current one. - - - - - - - - &Close current tab - - - Close current web browser tab. - - - - - Update &all items @@ -398,14 +339,6 @@ - - - Open selected source articles in &internal browser - - - - - false @@ -544,39 +477,6 @@ M - - - true - - - Enable &JavaScript - - - J - - - - - true - - - Enable external &plugins - - - P - - - - - true - - - Auto-load &images - - - I - - Report a &bug (GitHub)... diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index 3c43fad51..df40fbcf1 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -31,7 +31,6 @@ #include "miscellaneous/textfactory.h" #include "network-web/webfactory.h" #include "network-web/silentnetworkaccessmanager.h" -#include "network-web/webbrowser.h" #include "gui/systemtrayicon.h" #include "gui/feedmessageviewer.h" #include "gui/feedsview.h" @@ -382,15 +381,10 @@ void FormSettings::onProxyTypeChanged(int index) { void FormSettings::loadBrowser() { // Load settings of web browser GUI. - m_ui->m_checkQueueTabs->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool()); m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); m_ui->m_txtExternalBrowserExecutable->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString()); m_ui->m_txtExternalBrowserArguments->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString()); m_ui->m_grpCustomExternalBrowser->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); - m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages()); - m_ui->m_checkEnableJavascript->setChecked(WebFactory::instance()->javascriptEnabled()); - m_ui->m_checkEnablePlugins->setChecked(WebFactory::instance()->pluginsEnabled()); - m_ui->m_checkRememberOpenedTabs->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::RememberBrowserTabs)).toBool()); // Load settings of e-mail. m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); @@ -402,19 +396,13 @@ void FormSettings::loadBrowser() { void FormSettings::saveBrowser() { // Save settings of GUI of web browser. m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); - m_settings->setValue(GROUP(Browser), Browser::QueueTabs, m_ui->m_checkQueueTabs->isChecked()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); - m_settings->setValue(GROUP(Browser), Browser::RememberBrowserTabs, m_ui->m_checkRememberOpenedTabs->isChecked()); // Save settings of e-mail. m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked()); - - WebFactory::instance()->switchImages(m_ui->m_checkAutoLoadImages->isChecked()); - WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked()); - WebFactory::instance()->switchPlugins(m_ui->m_checkEnablePlugins->isChecked()); } void FormSettings::loadProxy() { diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui index b958a898d..07eb791f9 100755 --- a/src/gui/dialogs/formsettings.ui +++ b/src/gui/dialogs/formsettings.ui @@ -888,44 +888,6 @@ Authors of this application are NOT responsible for lost data. 0 - - - Internal web browser - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Queue new tabs (with hyperlinks) after the active tab - - - - - - - Enable JavaScript - - - - - - - Enable external plugins - - - - - - - Auto-load images - - - - - External web browser @@ -1609,10 +1571,6 @@ Authors of this application are NOT responsible for lost data. m_cmbSelectToolBar m_treeLanguages m_tabBrowserProxy - m_checkQueueTabs - m_checkEnableJavascript - m_checkEnablePlugins - m_checkAutoLoadImages m_grpCustomExternalBrowser m_txtExternalBrowserExecutable m_btnExternalBrowserExecutable diff --git a/src/gui/discoverfeedsbutton.cpp b/src/gui/discoverfeedsbutton.cpp deleted file mode 100755 index f633ba7db..000000000 --- a/src/gui/discoverfeedsbutton.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "gui/discoverfeedsbutton.h" - -#include "miscellaneous/application.h" -#include "miscellaneous/iconfactory.h" -#include "gui/dialogs/formmain.h" -#include "gui/tabwidget.h" -#include "gui/feedmessageviewer.h" -#include "gui/feedsview.h" -#include "core/feedsmodel.h" -#include "services/abstract/serviceroot.h" - -#include - - -DiscoverFeedsButton::DiscoverFeedsButton(QWidget *parent) : QToolButton(parent), m_addresses(QStringList()) { - setEnabled(false); - setIcon(qApp->icons()->fromTheme(QSL("folder-feed"))); - setPopupMode(QToolButton::InstantPopup); -} - -DiscoverFeedsButton::~DiscoverFeedsButton() { -} - -void DiscoverFeedsButton::clearFeedAddresses() { - setFeedAddresses(QStringList()); -} - -void DiscoverFeedsButton::setFeedAddresses(const QStringList &addresses) { - setEnabled(!addresses.isEmpty()); - setToolTip(addresses.isEmpty() ? - tr("This website does not contain any feeds.") : - tr("Click me to add feeds from this website.\nThis website contains %n feed(s).", 0, addresses.size())); - - if (menu() == NULL) { - // Initialize the menu. - setMenu(new QMenu(this)); - connect(menu(), SIGNAL(triggered(QAction*)), this, SLOT(linkTriggered(QAction*))); - connect(menu(), SIGNAL(aboutToShow()), this, SLOT(fillMenu())); - } - - menu()->hide(); - m_addresses = addresses; -} - -void DiscoverFeedsButton::linkTriggered(QAction *action) { - const QString url = action->property("url").toString(); - ServiceRoot *root = static_cast(action->property("root").value()); - - if (root->supportsFeedAdding()) { - root->addNewFeed(url); - } - else { - qApp->showGuiMessage(tr("Not supported"), - tr("Given account does not support adding feeds."), - QSystemTrayIcon::Warning, - qApp->mainForm(), true); - } -} - -void DiscoverFeedsButton::fillMenu() { - menu()->clear(); - - foreach (const ServiceRoot *root, qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->serviceRoots()) { - QMenu *root_menu = menu()->addMenu(root->icon(), root->title()); - - foreach (const QString &url, m_addresses) { - if (root->supportsFeedAdding()) { - QAction *url_action = root_menu->addAction(root->icon(), url); - - url_action->setProperty("url", url); - url_action->setProperty("root", QVariant::fromValue((void*) root)); - } - } - } -} diff --git a/src/gui/discoverfeedsbutton.h b/src/gui/discoverfeedsbutton.h deleted file mode 100755 index 5b8000737..000000000 --- a/src/gui/discoverfeedsbutton.h +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#ifndef DISCOVERFEEDSBUTTON_H -#define DISCOVERFEEDSBUTTON_H - -#include - - -class DiscoverFeedsButton : public QToolButton { - Q_OBJECT - - public: - // Constructors. - explicit DiscoverFeedsButton(QWidget *parent = 0); - virtual ~DiscoverFeedsButton(); - - // Feed addresses manipulators. - void clearFeedAddresses(); - void setFeedAddresses(const QStringList &addresses); - - private slots: - // User chose any of addresses. - void linkTriggered(QAction *action); - void fillMenu(); - - private: - QStringList m_addresses; -}; - -#endif // DISCOVERFEEDSBUTTON_H diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 90285b22a..e2eb6c532 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -29,7 +29,6 @@ #include "services/standard/standardserviceroot.h" #include "services/standard/standardfeed.h" #include "services/standard/standardfeedsimportexportmodel.h" -#include "network-web/webbrowser.h" #include "gui/messagesview.h" #include "gui/feedsview.h" #include "gui/statusbar.h" @@ -53,7 +52,6 @@ #include #include #include -#include #include @@ -65,7 +63,7 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent) m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)), m_messagesView(new MessagesView(this)), m_feedsView(new FeedsView(this)), - m_messagesBrowser(new WebBrowser(this)) { + m_messagesBrowser(new QTextBrowser(this)) { initialize(); initializeViews(); loadMessageViewerFonts(); @@ -119,10 +117,12 @@ void FeedMessageViewer::loadSize() { void FeedMessageViewer::loadMessageViewerFonts() { const Settings *settings = qApp->settings(); - QWebEngineSettings *view_settings = m_messagesBrowser->view()->settings(); + + // TODO: TODO + //QWebEngineSettings *view_settings = m_messagesBrowser->view()->settings(); - view_settings->setFontFamily(QWebEngineSettings::StandardFont, settings->value(GROUP(Messages), - SETTING(Messages::PreviewerFontStandard)).toString()); + //view_settings->setFontFamily(QWebEngineSettings::StandardFont, settings->value(GROUP(Messages), + // SETTING(Messages::PreviewerFontStandard)).toString()); } void FeedMessageViewer::quit() { @@ -193,7 +193,6 @@ void FeedMessageViewer::updateMessageButtonsAvailability() { form_main->m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected); form_main->m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected); form_main->m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected); - form_main->m_ui->m_actionOpenSelectedSourceArticlesInternally->setEnabled(atleast_one_message_selected); form_main->m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected); form_main->m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected); } @@ -240,7 +239,7 @@ void FeedMessageViewer::createConnections() { // Message changers. connect(m_messagesView, SIGNAL(currentMessagesRemoved()), m_messagesBrowser, SLOT(clear())); - connect(m_messagesView, SIGNAL(currentMessagesChanged(QList)), m_messagesBrowser, SLOT(navigateToMessages(QList))); + connect(m_messagesView, SIGNAL(currentMessagesChanged(QList)), this, SLOT(navigateToMessages(QList))); connect(m_messagesView, SIGNAL(currentMessagesRemoved()), this, SLOT(updateMessageButtonsAvailability())); connect(m_messagesView, SIGNAL(currentMessagesChanged(QList)), this, SLOT(updateMessageButtonsAvailability())); @@ -283,8 +282,6 @@ void FeedMessageViewer::createConnections() { SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesUnread())); connect(form_main->m_ui->m_actionOpenSelectedSourceArticlesExternally, SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceMessagesExternally())); - connect(form_main->m_ui->m_actionOpenSelectedSourceArticlesInternally, - SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceMessagesInternally())); connect(form_main->m_ui->m_actionOpenSelectedMessagesInternally, SIGNAL(triggered()), m_messagesView, SLOT(openSelectedMessagesInternally())); connect(form_main->m_ui->m_actionSendMessageViaEmail, @@ -352,10 +349,7 @@ void FeedMessageViewer::initialize() { m_toolBarMessages->setMovable(false); m_toolBarMessages->setAllowedAreas(Qt::TopToolBarArea); m_toolBarMessages->loadChangeableActions(); - - // Finish web/message browser setup. - m_messagesBrowser->setNavigationBarVisible(false); - + // Now refresh visual setup. refreshVisualProperties(); } @@ -444,6 +438,43 @@ void FeedMessageViewer::refreshVisualProperties() { m_toolBarMessages->setToolButtonStyle(button_style); } +void FeedMessageViewer::navigateToMessages(const QList &messages) { + Skin skin = qApp->skins()->currentSkin(); + QString messages_layout; + QString single_message_layout = skin.m_layoutMarkup; + + foreach (const Message &message, messages) { + QString enclosures; + + foreach (const Enclosure &enclosure, message.m_enclosures) { + enclosures += skin.m_enclosureMarkup.arg(enclosure.m_url); + + if (!enclosure.m_mimeType.isEmpty()) { + enclosures += QL1S(" [") + enclosure.m_mimeType + QL1S("]"); + } + + enclosures += QL1S("
"); + } + + if (!enclosures.isEmpty()) { + enclosures = enclosures.prepend(QSL("
")); + } + + messages_layout.append(single_message_layout.arg(message.m_title, + tr("Written by ") + (message.m_author.isEmpty() ? + tr("unknown author") : + message.m_author), + message.m_url, + message.m_contents, + message.m_created.toString(Qt::DefaultLocaleShortDate), + enclosures)); + } + + QString layout_wrapper = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"), messages_layout); + + m_messagesBrowser->setHtml(layout_wrapper); +} + void FeedMessageViewer::onFeedsUpdateFinished() { m_messagesView->reloadSelections(true); } diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index a5288997c..90213b851 100755 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -23,6 +23,8 @@ #include "core/messagesmodel.h" #include "core/feeddownloader.h" +#include + class WebBrowser; class MessagesView; @@ -44,7 +46,7 @@ class FeedMessageViewer : public TabContent { // WebBrowser getter from TabContent interface. inline WebBrowser *webBrowser() const { - return m_messagesBrowser; + return NULL; } // FeedsView getter. @@ -93,6 +95,8 @@ class FeedMessageViewer : public TabContent { // Reloads some changeable visual settings. void refreshVisualProperties(); + void navigateToMessages(const QList &messages); + private slots: // Called when feed update finishes. void onFeedsUpdateFinished(); @@ -131,7 +135,7 @@ class FeedMessageViewer : public TabContent { FeedsView *m_feedsView; QWidget *m_feedsWidget; QWidget *m_messagesWidget; - WebBrowser *m_messagesBrowser; + QTextBrowser *m_messagesBrowser; }; #endif // FEEDMESSAGEVIEWER_H diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp deleted file mode 100755 index 134c78379..000000000 --- a/src/gui/locationlineedit.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "gui/locationlineedit.h" - -#include "network-web/googlesuggest.h" - -#include - - -LocationLineEdit::LocationLineEdit(QWidget *parent) - : BaseLineEdit(parent), m_mouseSelectsAllText(true), m_googleSuggest(new GoogleSuggest(this)) { - setPlaceholderText(tr("Website address goes here")); - connect(this, SIGNAL(submitted(QString)), m_googleSuggest, SLOT(preventSuggest())); -} - -LocationLineEdit::~LocationLineEdit() { -} - -void LocationLineEdit::focusOutEvent(QFocusEvent *event) { - BaseLineEdit::focusOutEvent(event); - - // User now left text box, when he enters it again and clicks, - // then all text should be selected. - m_mouseSelectsAllText = true; -} - -void LocationLineEdit::mousePressEvent(QMouseEvent *event) { - if (m_mouseSelectsAllText) { - event->ignore(); - selectAll(); - - // User clicked and all text was selected. - m_mouseSelectsAllText = false; - } - else { - BaseLineEdit::mousePressEvent(event); - } -} diff --git a/src/gui/locationlineedit.h b/src/gui/locationlineedit.h deleted file mode 100755 index 7fbe4ae8f..000000000 --- a/src/gui/locationlineedit.h +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#ifndef LOCATIONLINEEDIT_H -#define LOCATIONLINEEDIT_H - -#include "gui/baselineedit.h" - - -class WebBrowser; -class GoogleSuggest; - -class LocationLineEdit : public BaseLineEdit { - Q_OBJECT - - public: - // Constructors and destructors. - explicit LocationLineEdit(QWidget *parent = 0); - virtual ~LocationLineEdit(); - - protected: - void focusOutEvent(QFocusEvent *event); - void mousePressEvent(QMouseEvent *event); - - private: - bool m_mouseSelectsAllText; - GoogleSuggest *m_googleSuggest; -}; - -#endif // LOCATIONLINEEDIT_H diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 8ff574b03..bd98d093e 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -51,7 +51,7 @@ MessagesView::~MessagesView() { } void MessagesView::createConnections() { - connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesInternallyNoNewTab())); + connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesExternally())); // Adjust columns when layout gets changed. connect(header(), SIGNAL(geometriesChanged()), this, SLOT(adjustColumns())); @@ -149,7 +149,6 @@ void MessagesView::initializeContextMenu() { m_contextMenu->addActions(QList() << qApp->mainForm()->m_ui->m_actionSendMessageViaEmail << qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << - qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesInternally << qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << @@ -181,12 +180,6 @@ void MessagesView::mousePressEvent(QMouseEvent *event) { break; } - case Qt::MiddleButton: { - // Open selected messages in new tab on mouse middle button click. - openSelectedSourceMessagesInternally(); - break; - } - default: break; } @@ -256,34 +249,6 @@ void MessagesView::openSelectedSourceMessagesExternally() { } } -void MessagesView::openSelectedSourceMessagesInternally() { - foreach (const QModelIndex &index, selectionModel()->selectedRows()) { - const Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()); - - if (message.m_url.isEmpty()) { - MessageBox::show(this, - QMessageBox::Warning, - tr("Meesage without URL"), - tr("Message '%s' does not contain URL.").arg(message.m_title)); - } - else { - emit openLinkNewTab(message.m_url); - } - } - - // Finally, mark opened messages as read. - if (!selectionModel()->selectedRows().isEmpty()) { - QTimer::singleShot(0, this, SLOT(markSelectedMessagesRead())); - } -} - -void MessagesView::openSelectedSourceMessagesInternallyNoNewTab() { - if (selectionModel()->selectedRows().size() == 1) { - emit openLinkMiniBrowser( - m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row()).m_url); - } -} - void MessagesView::openSelectedMessagesInternally() { QList messages; diff --git a/src/gui/messagesview.h b/src/gui/messagesview.h index 4e3eb9f4d..d40efa6f1 100755 --- a/src/gui/messagesview.h +++ b/src/gui/messagesview.h @@ -59,8 +59,6 @@ class MessagesView : public QTreeView { // Message manipulators. void openSelectedSourceMessagesExternally(); - void openSelectedSourceMessagesInternally(); - void openSelectedSourceMessagesInternallyNoNewTab(); void openSelectedMessagesInternally(); void sendSelectedMessageViaEmail(); diff --git a/src/gui/tabcontent.h b/src/gui/tabcontent.h index 06a3af685..ec27c5d46 100755 --- a/src/gui/tabcontent.h +++ b/src/gui/tabcontent.h @@ -21,8 +21,6 @@ #include -class WebBrowser; - // Base class for all widgets which are placed inside tabs of TabWidget class TabContent : public QWidget { Q_OBJECT @@ -43,10 +41,6 @@ class TabContent : public QWidget { m_index = index; } - // Obtains instance contained in this TabContent or nullptr. - // This can be used for obtaining the menu from the instance and so on. - virtual WebBrowser *webBrowser() const = 0; - protected: int m_index; }; diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp index 576b40158..babb07e59 100755 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -22,7 +22,6 @@ #include "miscellaneous/settings.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/iconfactory.h" -#include "network-web/webbrowser.h" #include "gui/tabbar.h" #include "gui/feedmessageviewer.h" #include "gui/plaintoolbutton.h" @@ -34,7 +33,6 @@ TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent), m_menuMain(NULL) { setTabBar(new TabBar(this)); - setupCornerButton(); setupMainMenuButton(); createConnections(); } @@ -43,16 +41,6 @@ TabWidget::~TabWidget() { qDebug("Destroying TabWidget instance."); } -void TabWidget::setupCornerButton() { - m_btnAddTab = new PlainToolButton(this); - m_btnAddTab->setAutoRaise(true); - m_btnAddTab->setPadding(3); - m_btnAddTab->setToolTip(tr("Open new web browser tab.")); - m_btnAddTab->setIcon(qApp->icons()->fromTheme(QSL("list-add"))); - - connect(m_btnAddTab, SIGNAL(clicked()), this, SLOT(addEmptyBrowser())); -} - void TabWidget::setupMainMenuButton() { m_btnMainMenu = new PlainToolButton(this); m_btnMainMenu->setAutoRaise(true); @@ -71,7 +59,6 @@ void TabWidget::openMainMenu() { m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuView); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuFeeds); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuMessages); - m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuWebBrowser); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuTools); m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuHelp); } @@ -104,17 +91,12 @@ void TabWidget::checkTabBarVisibility() { if (should_be_visible) { setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner); - setCornerWidget(m_btnAddTab, Qt::TopRightCorner); - m_btnMainMenu->setVisible(true); - m_btnAddTab->setVisible(true); } else { setCornerWidget(0, Qt::TopLeftCorner); setCornerWidget(0, Qt::TopRightCorner); - m_btnMainMenu->setVisible(false); - m_btnAddTab->setVisible(false); } tabBar()->setVisible(should_be_visible); @@ -158,13 +140,6 @@ void TabWidget::initializeTabs() { tr("Feeds"), TabBar::FeedReader); setTabToolTip(index_of_browser, tr("Browse your feeds and messages")); - - if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::RememberBrowserTabs)).toBool()) { - foreach (const QString &url, qApp->settings()->value(GROUP(Browser), SETTING(Browser::OpenedBrowserTabs)).toString().split(QL1S("##"), - QString::SkipEmptyParts)) { - addBrowser(true, false, QUrl::fromUserInput(url)); - } - } } void TabWidget::setupIcons() { @@ -175,38 +150,6 @@ void TabWidget::setupIcons() { if (tabBar()->tabType(index) == TabBar::FeedReader) { setTabIcon(index, qApp->icons()->fromTheme(QSL("folder-feed"))); } - // Other indexes probably contain WebBrowsers. - else { - const WebBrowser *active_browser = widget(index)->webBrowser(); - - if (active_browser != NULL && active_browser->icon().isNull()) { - // We found WebBrowser instance of this tab page, which - // has no suitable icon, load a new one from the icon theme. - setTabIcon(index, qApp->icons()->fromTheme(QSL("text-html"))); - } - } - } - - // Setup corner button icon. - m_btnAddTab->setIcon(qApp->icons()->fromTheme(QSL("list-add"))); -} - -void TabWidget::quit() { - if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::RememberBrowserTabs)).toBool()) { - QStringList store_urls; - - for (int i = 0; i < count(); i++) { - if (tabBar()->tabType(i) == TabBar::Closable) { - // We have tab with web browser. - QUrl url = widget(i)->webBrowser()->view()->url(); - - if (url.isValid() && !url.isEmpty()) { - store_urls.append(url.toString()); - } - } - } - - qApp->settings()->setValue(GROUP(Browser), Browser::OpenedBrowserTabs, store_urls.join(QSL("##"))); } } @@ -297,66 +240,9 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label, const } int TabWidget::addBrowserWithMessages(const QList &messages) { - const int new_index = addBrowser(false, true); - WebBrowser *browser = static_cast(widget(new_index)); + // TODO: TODO - volano kdyz se maji zobrazit zpravy v novinovem nahledu - browser->setNavigationBarVisible(false); - browser->navigateToMessages(messages); - - return new_index; -} - -int TabWidget::addEmptyBrowser() { - return addBrowser(false, true); -} - -int TabWidget::addLinkedBrowser(const QString &initial_url) { - return addLinkedBrowser(QUrl(initial_url)); -} - -int TabWidget::addLinkedBrowser(const QUrl &initial_url) { - return addBrowser(qApp->settings()->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool(), false, initial_url); -} - -int TabWidget::addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url) { - // Create new WebBrowser. - WebBrowser *browser = new WebBrowser(this); - browser->setupIcons(); - - int final_index; - - if (move_after_current) { - // Insert web browser after current tab. - final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme(QSL("text-html")), - tr("Web browser"), TabBar::Closable); - } - else { - // Add new browser as the last tab. - final_index = addTab(browser, qApp->icons()->fromTheme(QSL("text-html")), - //: Web browser default tab title. - tr("Web browser"), - TabBar::Closable); - } - - // Make connections. - connect(browser, SIGNAL(titleChanged(int,QString)), this, SLOT(changeTitle(int,QString))); - connect(browser, SIGNAL(iconChanged(int,QIcon)), this, SLOT(changeIcon(int,QIcon))); - - // Setup the tab index. - browser->setIndex(final_index); - - // Load initial web page if desired. - if (initial_url.isValid()) { - browser->navigateToUrl(initial_url); - } - - // Make new web browser active if desired. - if (make_active) { - setCurrentIndex(final_index); - browser->setFocus(Qt::OtherFocusReason); - } - - return final_index; + return 0; /* new index */ } void TabWidget::changeIcon(int index, const QIcon &new_icon) { diff --git a/src/gui/tabwidget.h b/src/gui/tabwidget.h index 717175c38..cb09a1e1d 100755 --- a/src/gui/tabwidget.h +++ b/src/gui/tabwidget.h @@ -75,14 +75,11 @@ class TabWidget : public QTabWidget { return m_feedMessageViewer; } - void quit(); - protected: // Creates necesary connections. void createConnections(); // Sets up properties of custom corner button. - void setupCornerButton(); void setupMainMenuButton(); // Handlers of insertin/removing of tabs. @@ -116,19 +113,7 @@ class TabWidget : public QTabWidget { // Open single or multiple (newspaper mode) messages in new tab. int addBrowserWithMessages(const QList &messages); - // Adds new WebBrowser tab to global TabWidget. - int addEmptyBrowser(); - - // Adds new WebBrowser with link. This is used when user - // selects to "Open link in new tab.". - int addLinkedBrowser(const QUrl &initial_url = QUrl()); - int addLinkedBrowser(const QString &initial_url); - - // General method for adding WebBrowsers. - int addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url = QUrl()); - private: - PlainToolButton *m_btnAddTab; PlainToolButton *m_btnMainMenu; QMenu *m_menuMain; FeedMessageViewer *m_feedMessageViewer; diff --git a/src/main.cpp b/src/main.cpp index 7eb6c2317..b74bf92c0 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,6 @@ #include #include #include -#include int main(int argc, char *argv[]) { @@ -134,10 +133,6 @@ int main(int argc, char *argv[]) { QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup())); } - // Make sure that all download requests from web views are handled. - QObject::connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), - qApp->downloadManager(), SLOT(download(QWebEngineDownloadItem*))); - // Enter global event loop. return Application::exec(); } diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index 4345e886d..0b58466ca 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -281,7 +281,6 @@ void Application::onAboutToQuit() { system()->removeTrolltechJunkRegistryKeys(); #endif - mainForm()->tabWidget()->quit(); mainForm()->tabWidget()->feedMessageViewer()->quit(); database()->saveDatabase(); mainForm()->saveSize(); diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index ba4009a54..b8c8a16cd 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -22,9 +22,7 @@ #include #include #include -#include #include -#include // Feeds. @@ -238,21 +236,6 @@ DKEY Keyboard::ID = "keyboard"; // Web browser. DKEY Browser::ID = "browser"; -DKEY Browser::JavascriptEnabled = "enable_javascript"; -DVALUE(bool) Browser::JavascriptEnabledDef = true; - -DKEY Browser::ImagesEnabled = "enable_images"; -DVALUE(bool) Browser::ImagesEnabledDef = true; - -DKEY Browser::PluginsEnabled = "enable_plugins"; -DVALUE(bool) Browser::PluginsEnabledDef = false; - -DKEY Browser::RememberBrowserTabs = "remember_browser_tabs"; -DVALUE(bool)Browser::RememberBrowserTabsDef = false; - -DKEY Browser::OpenedBrowserTabs = "opened_browser_tabs"; -DVALUE(QString)Browser::OpenedBrowserTabsDef = QString(); - DKEY Browser::CustomExternalBrowserEnabled = "custom_external_browser"; DVALUE(bool) Browser::CustomExternalBrowserEnabledDef = false; @@ -271,8 +254,6 @@ DVALUE(QString) Browser::CustomExternalEmailExecutableDef = QString(); DKEY Browser::CustomExternalEmailArguments = "external_email_arguments"; DVALUE(char*) Browser::CustomExternalEmailArgumentsDef = ""; -DKEY Browser::QueueTabs = "queue_tabs"; -DVALUE(bool) Browser::QueueTabsDef = true; // Categories. DKEY CategoriesExpandStates::ID = "categories_expand_states"; @@ -280,7 +261,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 = QWebEngineSettings::globalSettings()->fontFamily(QWebEngineSettings::StandardFont); + Messages::PreviewerFontStandardDef = qApp->font().family(); } Settings::~Settings() { diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index ed5113e8f..68e7d3cdc 100755 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -267,21 +267,6 @@ namespace Keyboard { namespace Browser { KEY ID; - KEY JavascriptEnabled; - VALUE(bool) JavascriptEnabledDef; - - KEY ImagesEnabled; - VALUE(bool) ImagesEnabledDef; - - KEY PluginsEnabled; - VALUE(bool) PluginsEnabledDef; - - KEY RememberBrowserTabs; - VALUE(bool)RememberBrowserTabsDef; - - KEY OpenedBrowserTabs; - VALUE(QString)OpenedBrowserTabsDef; - KEY CustomExternalBrowserEnabled; VALUE(bool) CustomExternalBrowserEnabledDef; @@ -299,9 +284,6 @@ namespace Browser { KEY CustomExternalEmailArguments; VALUE(char*) CustomExternalEmailArgumentsDef; - - KEY QueueTabs; - VALUE(bool) QueueTabsDef; } // Categories. diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index 51dfb3ab8..6bb4d3c36 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -38,8 +38,6 @@ #include #include #include -#include -#include DownloadItem::DownloadItem(bool is_direct_download, QNetworkReply *reply, QWidget *parent) : QWidget(parent), @@ -513,10 +511,6 @@ void DownloadManager::download(const QUrl &url, bool direct_download) { download(QNetworkRequest(url), direct_download); } -void DownloadManager::download(QWebEngineDownloadItem *down) { - download(down->url(), true); -} - void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct_download) { if (reply == NULL || reply->url().isEmpty()) { return; @@ -832,7 +826,3 @@ QMimeData *DownloadModel::mimeData(const QModelIndexList &indexes) const { mimeData->setUrls(urls); return mimeData; } - -WebBrowser *DownloadManager::webBrowser() const { - return NULL; -} diff --git a/src/network-web/downloadmanager.h b/src/network-web/downloadmanager.h index 75a1af274..395f8fa05 100755 --- a/src/network-web/downloadmanager.h +++ b/src/network-web/downloadmanager.h @@ -32,7 +32,6 @@ class AutoSaver; class DownloadModel; class QFileIconProvider; class QMimeData; -class QWebEngineDownloadItem; class DownloadItem : public QWidget { Q_OBJECT @@ -109,7 +108,6 @@ class DownloadManager : public TabContent { explicit DownloadManager(QWidget *parent = 0); virtual ~DownloadManager(); - WebBrowser *webBrowser() const; QNetworkAccessManager *networkManager() const; int totalDownloads() const; @@ -128,7 +126,6 @@ class DownloadManager : public TabContent { public slots: void download(const QNetworkRequest &request, bool direct_download = false); void download(const QUrl &url, bool direct_download = false); - void download(QWebEngineDownloadItem *down); void handleUnsupportedContent(QNetworkReply *reply, bool direct_download = false); void cleanup(); diff --git a/src/network-web/googlesuggest.cpp b/src/network-web/googlesuggest.cpp deleted file mode 100755 index 4a914f9ac..000000000 --- a/src/network-web/googlesuggest.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -// You may use this file under the terms of the BSD license as follows: -// -// "Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -// of its contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - -#include "network-web/googlesuggest.h" - -#include "definitions/definitions.h" -#include "network-web/silentnetworkaccessmanager.h" -#include "gui/locationlineedit.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -GoogleSuggest::GoogleSuggest(LocationLineEdit *editor, QObject *parent) - : QObject(parent), editor(editor), popup(new QListWidget()), m_enteredText(QString()) { - popup->setWindowFlags(Qt::Popup); - popup->setFocusPolicy(Qt::NoFocus); - popup->setFocusProxy(editor); - popup->setMouseTracking(true); - popup->setSelectionBehavior(QAbstractItemView::SelectRows); - popup->setFrameStyle(QFrame::Box | QFrame::Plain); - popup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - popup->installEventFilter(this); - - timer = new QTimer(this); - timer->setSingleShot(true); - timer->setInterval(500); - - connect(popup.data(), SIGNAL(itemClicked(QListWidgetItem*)), SLOT(doneCompletion())); - connect(timer, SIGNAL(timeout()), SLOT(autoSuggest())); - connect(editor, SIGNAL(textEdited(QString)), timer, SLOT(start())); -} - -GoogleSuggest::~GoogleSuggest() { -} - -bool GoogleSuggest::eventFilter(QObject *object, QEvent *event) { - if (object != popup.data()) { - return false; - } - - if (event->type() == QEvent::MouseButtonPress) { - popup->hide(); - editor->setFocus(); - return true; - } - - if (event->type() == QEvent::KeyPress) { - bool consumed = false; - const int key = static_cast(event)->key(); - - switch (key) { - case Qt::Key_Enter: - case Qt::Key_Return: - doneCompletion(); - consumed = true; - - case Qt::Key_Escape: - editor->setFocus(); - popup->hide(); - consumed = true; - - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_Home: - case Qt::Key_End: - case Qt::Key_PageUp: - case Qt::Key_PageDown: - break; - - default: - editor->setFocus(); - editor->event(event); - popup->hide(); - break; - } - - return consumed; - } - - return false; -} - -void GoogleSuggest::showCompletion(const QStringList &choices) { - if (choices.isEmpty()) { - return; - } - - popup->setUpdatesEnabled(false); - popup->clear(); - - foreach (const QString &choice, choices) { - new QListWidgetItem(choice, popup.data()); - } - - popup->setCurrentItem(popup->item(0)); - popup->adjustSize(); - popup->setUpdatesEnabled(true); - popup->resize(editor->width(), popup->sizeHintForRow(0) * qMin(7, choices.count()) + 3); - popup->move(editor->mapToGlobal(QPoint(0, editor->height()))); - popup->setFocus(); - popup->show(); -} - -void GoogleSuggest::doneCompletion() { - timer->stop(); - popup->hide(); - editor->setFocus(); - - QListWidgetItem *item = popup->currentItem(); - - if (item != NULL) { - editor->submit(QString(GOOGLE_SEARCH_URL).arg(item->text())); - } -} - -void GoogleSuggest::preventSuggest() { - timer->stop(); -} - -void GoogleSuggest::autoSuggest() { - m_enteredText = QUrl::toPercentEncoding(editor->text()); - QString url = QString(GOOGLE_SUGGEST_URL).arg(m_enteredText); - - connect(SilentNetworkAccessManager::instance()->get(QNetworkRequest(QString(url))), SIGNAL(finished()), - this, SLOT(handleNetworkData())); -} - -void GoogleSuggest::handleNetworkData() { - QScopedPointer reply(static_cast(sender())); - - if (!reply->error()) { - QStringList choices; - QDomDocument xml; - QByteArray response = reply->readAll(); - - const QTextCodec *c = QTextCodec::codecForUtfText(response); - xml.setContent(c->toUnicode(response)); - - QDomNodeList suggestions = xml.elementsByTagName(QSL("suggestion")); - - for (int i = 0; i < suggestions.size(); i++) { - const QDomElement element = suggestions.at(i).toElement(); - - if (element.attributes().contains(QSL("data"))) { - choices.append(element.attribute(QSL("data"))); - } - } - - if (choices.isEmpty()) { - choices.append(m_enteredText); - } - - showCompletion(choices); - } -} diff --git a/src/network-web/googlesuggest.h b/src/network-web/googlesuggest.h deleted file mode 100755 index 5c07a794b..000000000 --- a/src/network-web/googlesuggest.h +++ /dev/null @@ -1,82 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -// You may use this file under the terms of the BSD license as follows: -// -// "Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -// of its contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - -#ifndef GOOGLESUGGEST_H -#define GOOGLESUGGEST_H - -#include - - -class LocationLineEdit; -class QNetworkReply; -class QTimer; -class QListWidget; -class QNetworkAccessManager; - -class GoogleSuggest : public QObject { - Q_OBJECT - - public: - // Constructors. - explicit GoogleSuggest(LocationLineEdit *editor, QObject *parent = 0); - virtual ~GoogleSuggest(); - - bool eventFilter(QObject *object, QEvent *event); - void showCompletion(const QStringList &choices); - - public slots: - void doneCompletion(); - void preventSuggest(); - void autoSuggest(); - void handleNetworkData(); - - private: - LocationLineEdit *editor; - QScopedPointer popup; - QTimer *timer; - QString m_enteredText; -}; - -#endif // GOOGLESUGGEST_H diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp deleted file mode 100755 index 79e3942c6..000000000 --- a/src/network-web/webbrowser.cpp +++ /dev/null @@ -1,328 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "network-web/webbrowser.h" - -#include "definitions/definitions.h" -#include "network-web/webview.h" -#include "network-web/networkfactory.h" -#include "miscellaneous/skinfactory.h" -#include "gui/dialogs/formmain.h" -#include "gui/tabwidget.h" -#include "gui/feedmessageviewer.h" -#include "gui/feedsview.h" -#include "services/standard/standardserviceroot.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -QList WebBrowser::m_runningWebBrowsers; - -WebBrowser::WebBrowser(QWidget *parent) - : TabContent(parent), - m_layout(new QVBoxLayout(this)), - m_toolBar(new QToolBar(tr("Navigation panel"), this)), - m_webView(new WebView(this)), - m_txtLocation(new LocationLineEdit(this)), - 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); - - // Initialize the components and layout. - initializeLayout(); - - setTabOrder(m_txtLocation, m_toolBar); - setTabOrder(m_toolBar, m_webView); - - createConnections(); - initializeZoomWidget(); -} - -void WebBrowser::initializeZoomWidget() { - // Initializations. - m_zoomButtons = new QWidget(this); - QLabel *zoom_label = new QLabel(tr("Zoom "), m_zoomButtons); - QHBoxLayout *layout = new QHBoxLayout(m_zoomButtons); - QToolButton *button_decrease = new QToolButton(m_zoomButtons); - m_btnResetZoom = new QToolButton(m_zoomButtons); - QToolButton *button_increase = new QToolButton(m_zoomButtons); - - // Set texts. - button_decrease->setText(QSL("-")); - button_decrease->setToolTip(tr("Decrease zoom.")); - m_btnResetZoom->setText(QSL("100%")); - m_btnResetZoom->setToolTip(tr("Reset zoom to default.")); - button_increase->setText(QSL("+")); - button_increase->setToolTip(tr("Increase zoom.")); - - // Setup layout. - layout->addWidget(zoom_label); - layout->addWidget(button_decrease); - layout->addWidget(m_btnResetZoom); - layout->addWidget(button_increase); - layout->setSpacing(2); - layout->setMargin(3); - m_zoomButtons->setLayout(layout); - - // Make connections. - connect(button_increase, SIGNAL(clicked()), this, SLOT(increaseZoom())); - connect(button_decrease, SIGNAL(clicked()), this, SLOT(decreaseZoom())); - connect(m_btnResetZoom, SIGNAL(clicked()), this, SLOT(resetZoom())); - - m_actionZoom = new QWidgetAction(this); - m_actionZoom->setDefaultWidget(m_zoomButtons); -} - -void WebBrowser::initializeLayout() { - m_toolBar->setFloatable(false); - m_toolBar->setMovable(false); - m_toolBar->setAllowedAreas(Qt::TopToolBarArea); - - // Modify action texts. - m_actionBack->setText(tr("Back")); - m_actionBack->setToolTip(tr("Go back.")); - m_actionForward->setText(tr("Forward")); - m_actionForward->setToolTip(tr("Go forward.")); - m_actionReload->setText(tr("Reload")); - m_actionReload->setToolTip(tr("Reload current web page.")); - m_actionStop->setText(tr("Stop")); - m_actionStop->setToolTip(tr("Stop web page loading.")); - - m_btnDiscoverFeeds = new DiscoverFeedsButton(this); - - QWidgetAction *act_discover = new QWidgetAction(this); - - act_discover->setDefaultWidget(m_btnDiscoverFeeds); - - // Add needed actions into toolbar. - m_toolBar->addAction(m_actionBack); - m_toolBar->addAction(m_actionForward); - m_toolBar->addAction(m_actionReload); - m_toolBar->addAction(m_actionStop); - m_toolBar->addAction(act_discover); - m_toolBar->addWidget(m_txtLocation); - - m_loadingWidget = new QWidget(this); - m_loadingWidget->setFixedHeight(15); - - // Initialize dynamic progress bar which will be displayed - // at the bottom of web browser. - m_lblProgress = new QLabel(this); - m_loadingProgress = new QProgressBar(this); - m_loadingProgress->setFixedHeight(15); - m_loadingProgress->setMinimum(0); - m_loadingProgress->setTextVisible(false); - m_loadingProgress->setMaximum(100); - m_loadingProgress->setAttribute(Qt::WA_TranslucentBackground); - - m_loadingLayout = new QHBoxLayout(); - m_loadingLayout->setMargin(0); - m_loadingLayout->addWidget(m_lblProgress, 0, Qt::AlignVCenter); - m_loadingLayout->addWidget(m_loadingProgress, 1, Qt::AlignVCenter); - m_loadingWidget->setLayout(m_loadingLayout); - - // Setup layout. - m_layout->addWidget(m_toolBar); - m_layout->addWidget(m_webView); - m_layout->addWidget(m_loadingWidget); - m_layout->setMargin(0); - m_layout->setSpacing(0); - - m_loadingWidget->hide(); -} - -void WebBrowser::onLoadingStarted() { - m_loadingProgress->setValue(0); - m_loadingWidget->show(); - m_btnDiscoverFeeds->setEnabled(false); -} - -void WebBrowser::onLoadingProgress(int progress) { - m_loadingProgress->setValue(progress); -} - -void WebBrowser::onLoadingFinished(bool success) { - if (success) { - m_webView->page()->toHtml([this](const QString &html) { - this->m_btnDiscoverFeeds->setFeedAddresses(NetworkFactory::extractFeedLinksFromHtmlPage(m_webView->url(), html)); - }); - } - else { - m_btnDiscoverFeeds->clearFeedAddresses(); - } - - m_loadingWidget->hide(); -} - -void WebBrowser::createConnections() { - // When user confirms new url, then redirect to it. - connect(m_txtLocation,SIGNAL(submitted(QString)), this, SLOT(navigateToUrl(QString))); - // If new page loads, then update current url. - connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl))); - - // Connect this WebBrowser to global TabWidget. - TabWidget *tab_widget = qApp->mainForm()->tabWidget(); - - // Change location textbox status according to webpage status. - connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadingStarted())); - connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(onLoadingProgress(int))); - connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadingFinished(bool))); - - // Forward title/icon changes. - connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString))); - connect(m_webView, SIGNAL(iconUrlChanged(QUrl)), this, SLOT(onIconChanged())); -} - -void WebBrowser::onIconChanged() { - emit iconChanged(m_index, icon()); -} - -void WebBrowser::onTitleChanged(const QString &new_title) { - if (new_title.isEmpty()) { - //: Webbrowser tab title when no title is available. - emit titleChanged(m_index, tr("No title")); - } - else { - emit titleChanged(m_index, new_title); - } -} - -void WebBrowser::updateUrl(const QUrl &url) { - QString url_string = url.toString(); - - m_txtLocation->setText(url_string); - setNavigationBarVisible(url_string != INTERNAL_URL_EMPTY && url_string != INTERNAL_URL_NEWSPAPER); -} - -void WebBrowser::navigateToUrl(const QUrl &url) { - if (url.isValid()) { - m_webView->load(url); - } -} - -void WebBrowser::navigateToMessages(const QList &messages) { - Skin skin = qApp->skins()->currentSkin(); - QString messages_layout; - QString single_message_layout = skin.m_layoutMarkup; - - foreach (const Message &message, messages) { - QString enclosures; - - foreach (const Enclosure &enclosure, message.m_enclosures) { - enclosures += skin.m_enclosureMarkup.arg(enclosure.m_url); - - if (!enclosure.m_mimeType.isEmpty()) { - enclosures += QL1S(" [") + enclosure.m_mimeType + QL1S("]"); - } - - enclosures += QL1S("
"); - } - - if (!enclosures.isEmpty()) { - enclosures = enclosures.prepend(QSL("
")); - } - - messages_layout.append(single_message_layout.arg(message.m_title, - tr("Written by ") + (message.m_author.isEmpty() ? - tr("unknown author") : - message.m_author), - message.m_url, - message.m_contents, - message.m_created.toString(Qt::DefaultLocaleShortDate), - enclosures)); - } - - QString layout_wrapper = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"), messages_layout); - - m_webView->setHtml(layout_wrapper, QUrl(INTERNAL_URL_NEWSPAPER)); - emit iconChanged(m_index, qApp->icons()->fromTheme(QSL("item-newspaper"))); -} - -void WebBrowser::updateZoomGui() { - m_btnResetZoom->setText(QString(QSL("%1%")).arg(QString::number(m_webView->zoomFactor() * 100, 'f', 0))); -} - -void WebBrowser::increaseZoom() { - m_webView->increaseWebPageZoom(); - updateZoomGui(); -} - -void WebBrowser::decreaseZoom() { - m_webView->decreaseWebPageZoom(); - updateZoomGui(); -} - -void WebBrowser::resetZoom() { - m_webView->resetWebPageZoom(); - updateZoomGui(); -} - -void WebBrowser::navigateToUrl(const QString &textual_url) { - // Prepare input url. - QString better_url = textual_url; - better_url = better_url.replace(QL1C('\\'), QL1C('/')); - - navigateToUrl(QUrl::fromUserInput(better_url)); -} - -WebBrowser::~WebBrowser() { - qDebug("Destroying WebBrowser instance."); - - // Remove this instance from the global list of web browsers. - m_runningWebBrowsers.removeAll(this); - - // Delete members. Do not use scoped pointers here. - delete m_layout; - delete m_zoomButtons; - delete m_actionZoom; -} - -void WebBrowser::setupIcons() { - m_actionBack->setIcon(qApp->icons()->fromTheme(QSL("go-previous"))); - m_actionForward->setIcon(qApp->icons()->fromTheme(QSL("go-next"))); - m_actionReload->setIcon(qApp->icons()->fromTheme(QSL("go-refresh"))); - m_actionStop->setIcon(qApp->icons()->fromTheme(QSL("go-stop"))); -} - -QIcon WebBrowser::icon() const { - QUrl url = m_webView->iconUrl(); - - if (url.isValid()) { - QByteArray output; - if (NetworkFactory::downloadFile(url.toString(), DOWNLOAD_TIMEOUT, output).first == QNetworkReply::NoError) { - QPixmap icon_pixmap; - icon_pixmap.loadFromData(output); - return QIcon(icon_pixmap); - } - } - - return QIcon(); -} diff --git a/src/network-web/webbrowser.h b/src/network-web/webbrowser.h deleted file mode 100755 index 603b80c2a..000000000 --- a/src/network-web/webbrowser.h +++ /dev/null @@ -1,168 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#ifndef WEBBROWSER_H -#define WEBBROWSER_H - -#include "gui/tabcontent.h" - -#include "core/messagesmodel.h" -#include "network-web/webview.h" -#include "gui/locationlineedit.h" -#include "gui/discoverfeedsbutton.h" - -#include -#include -#include -#include - - -class QToolButton; -class QVBoxLayout; -class QHBoxLayout; -class QProgressBar; -class QMenu; -class QLabel; -class TabWidget; - -class WebBrowser : public TabContent { - Q_OBJECT - - public: - // Constructors and destructors. - explicit WebBrowser(QWidget *parent = 0); - virtual ~WebBrowser(); - - // Reloads icons for all buttons. - void setupIcons(); - - // Returns icon associated with currently loaded website. - QIcon icon() const; - - inline WebView *view() const { - return m_webView; - } - - // Sets this WebBrowser instance as focused. - inline void setFocus(Qt::FocusReason reason) { - m_txtLocation->setFocus(reason); - } - - // Returns this instance. - // NOTE: This is needed due to TabContent interface. - inline WebBrowser *webBrowser() const { - return const_cast(this); - } - - // Returns global menu for this web browser. - inline virtual QList globalMenu() const { - QList browser_menu; - - // Add needed actions into the menu. - browser_menu.append(m_actionZoom); - - return browser_menu; - } - - // Returns list of all running web browsers. - static inline QList runningWebBrowsers() { - return m_runningWebBrowsers; - } - - public slots: - // Switches visibility of navigation bar. - inline void setNavigationBarVisible(bool visible) { - m_toolBar->setVisible(visible); - } - - // Loads new url into the web browser. - void navigateToUrl(const QString &url); - void navigateToUrl(const QUrl &url); - - // Navigates to messages, used also as "newspaper" view. - void navigateToMessages(const QList &messages); - - // Clears contents. - inline void clear() { - if (m_webView->url() != QUrl()) { - m_webView->setHtml("", QUrl(INTERNAL_URL_EMPTY)); - } - } - - // Zoom manipulators. - void increaseZoom(); - void decreaseZoom(); - void resetZoom(); - - protected: - // Creates necessary connections. - void createConnections(); - - // Initializes all buttons and widgets, which are needed for "Zoom" menu item. - void initializeZoomWidget(); - - // Initializes layout. - void initializeLayout(); - - protected slots: - void onLoadingStarted(); - void onLoadingProgress(int progress); - void onLoadingFinished(bool success); - - // Updates zoom-related gui. - void updateZoomGui(); - - // Updates url (for example on location text box). - void updateUrl(const QUrl &url); - - // Title/icon is changed. - void onTitleChanged(const QString &new_title); - void onIconChanged(); - - signals: - // User requests opening of new tab or clicks the link - // with middle mouse button - void newTabRequested(); - void linkMiddleClicked(const QUrl &link_url); - - // Title/icon is changed. - void iconChanged(int index, const QIcon &icon); - void titleChanged(int index, const QString &title); - - private: - QVBoxLayout *m_layout; - QToolBar *m_toolBar; - WebView *m_webView; - LocationLineEdit *m_txtLocation; - QWidget *m_zoomButtons; - QToolButton *m_btnResetZoom; - QWidget *m_loadingWidget; - QHBoxLayout *m_loadingLayout; - QProgressBar *m_loadingProgress; - QLabel *m_lblProgress; - DiscoverFeedsButton *m_btnDiscoverFeeds; - - QWidgetAction *m_actionZoom; - QAction *m_actionBack; - QAction *m_actionForward; - QAction *m_actionReload; - QAction *m_actionStop; - - static QList m_runningWebBrowsers; -}; - -#endif // WEBBROWSER_H diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp index 968481cfe..b68e1501d 100755 --- a/src/network-web/webfactory.cpp +++ b/src/network-web/webfactory.cpp @@ -1,9 +1,25 @@ +// This file is part of RSS Guard. +// +// 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + #include "network-web/webfactory.h" #include "miscellaneous/application.h" #include -#include #include #include #include @@ -13,21 +29,12 @@ QPointer WebFactory::s_instance; WebFactory::WebFactory(QObject *parent) : QObject(parent), m_escapes(QMap()), - m_deEscapes(QMap()), - m_globalSettings(QWebEngineSettings::globalSettings()) { + m_deEscapes(QMap()) { } WebFactory::~WebFactory() { } -void WebFactory::loadState() { - const Settings *settings = qApp->settings(); - - switchJavascript(settings->value(GROUP(Browser), SETTING(Browser::JavascriptEnabled)).toBool(), false); - switchImages(settings->value(GROUP(Browser), SETTING(Browser::ImagesEnabled)).toBool(), false); - switchPlugins(settings->value(GROUP(Browser), SETTING(Browser::PluginsEnabled)).toBool(), false); -} - bool WebFactory::sendMessageViaEmail(const Message &message) { if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()) { const QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString(); @@ -66,33 +73,6 @@ bool WebFactory::openUrlInExternalBrowser(const QString &url) { } } -void WebFactory::switchJavascript(bool enable, bool save_settings) { - if (save_settings) { - qApp->settings()->setValue(GROUP(Browser), Browser::JavascriptEnabled, enable); - } - - m_globalSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, enable); - emit javascriptSwitched(enable); -} - -void WebFactory::switchPlugins(bool enable, bool save_settings) { - if (save_settings) { - qApp->settings()->setValue(GROUP(Browser), Browser::PluginsEnabled, enable); - } - - m_globalSettings->setAttribute(QWebEngineSettings::PluginsEnabled, enable); - emit pluginsSwitched(enable); -} - -void WebFactory::switchImages(bool enable, bool save_settings) { - if (save_settings) { - qApp->settings()->setValue(GROUP(Browser), Browser::ImagesEnabled, enable); - } - - m_globalSettings->setAttribute(QWebEngineSettings::AutoLoadImages, enable); - emit imagesLoadingSwitched(enable); -} - WebFactory *WebFactory::instance() { if (s_instance.isNull()) { s_instance = new WebFactory(qApp); @@ -101,18 +81,6 @@ WebFactory *WebFactory::instance() { return s_instance; } -bool WebFactory::javascriptEnabled() const { - return m_globalSettings->testAttribute(QWebEngineSettings::JavascriptEnabled); -} - -bool WebFactory::pluginsEnabled() const { - return m_globalSettings->testAttribute(QWebEngineSettings::PluginsEnabled); -} - -bool WebFactory::autoloadImages() const { - return m_globalSettings->testAttribute(QWebEngineSettings::AutoLoadImages); -} - QString WebFactory::stripTags(QString text) { return text.remove(QRegExp(QSL("<[^>]*>"))); } diff --git a/src/network-web/webfactory.h b/src/network-web/webfactory.h index 922eb6ddc..8a16ad230 100755 --- a/src/network-web/webfactory.h +++ b/src/network-web/webfactory.h @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + #ifndef WEBFACTORY_H #define WEBFACTORY_H @@ -18,11 +35,6 @@ class WebFactory : public QObject { // Destructor. virtual ~WebFactory(); - // Loads the web settings directly from - // application settings and notifies the rest of - // the world about current situation. - void loadState(); - // Strips "<....>" (HTML, XML) tags from given text. QString stripTags(QString text); @@ -34,11 +46,6 @@ class WebFactory : public QObject { // count .co.uk (and others) as second-level domain QString toSecondLevelDomain(const QUrl &url); - // Switchers. - bool javascriptEnabled() const; - bool pluginsEnabled() const; - bool autoloadImages() const; - // Singleton getter. static WebFactory *instance(); @@ -47,16 +54,6 @@ class WebFactory : public QObject { bool openUrlInExternalBrowser(const QString &url); bool sendMessageViaEmail(const Message &message); - // Switchers. - void switchJavascript(bool enable, bool save_settings = true); - void switchPlugins(bool enable, bool save_settings = true); - void switchImages(bool enable, bool save_settings = true); - - signals: - void javascriptSwitched(bool enabled); - void pluginsSwitched(bool enabled); - void imagesLoadingSwitched(bool enabled); - private: // Constructor. explicit WebFactory(QObject *parent = 0); @@ -67,7 +64,6 @@ class WebFactory : public QObject { QMap m_escapes; QMap m_deEscapes; - QWebEngineSettings *m_globalSettings; // Singleton. static QPointer s_instance; diff --git a/src/network-web/webview.cpp b/src/network-web/webview.cpp deleted file mode 100755 index 9e226a548..000000000 --- a/src/network-web/webview.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "network-web/webview.h" - -#include "definitions/definitions.h" - -#include -#include - - -WebView::WebView(QWidget *parent) - : QWebEngineView(parent), m_page(new QWebEnginePage(this)) { - setPage(m_page); -} - -WebView::~WebView() { - qDebug("Destroying WebView."); -} - -bool WebView::increaseWebPageZoom() { - const qreal new_factor = zoomFactor() + 0.1; - - if (new_factor >= 0.0 && new_factor <= MAX_ZOOM_FACTOR) { - setZoomFactor(new_factor); - return true; - } - else { - return false; - } -} - -bool WebView::decreaseWebPageZoom() { - const qreal new_factor = zoomFactor() - 0.1; - - if (new_factor >= 0.0 && new_factor <= MAX_ZOOM_FACTOR) { - setZoomFactor(new_factor); - return true; - } - else { - return false; - } -} - -bool WebView::resetWebPageZoom() { - const qreal new_factor = 1.0; - - if (new_factor != zoomFactor()) { - setZoomFactor(new_factor); - return true; - } - else { - return false; - } -} diff --git a/src/network-web/webview.h b/src/network-web/webview.h deleted file mode 100755 index f896d5de6..000000000 --- a/src/network-web/webview.h +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of RSS Guard. -// -// 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#ifndef BASEWEBVIEW_H -#define BASEWEBVIEW_H - -#include - - -class WebView : public QWebEngineView { - Q_OBJECT - - public: - // Constructors and destructors. - explicit WebView(QWidget *parent = 0); - virtual ~WebView(); - - // Page accessor. - inline QWebEnginePage *page() const { - return m_page; - } - - public slots: - // Page zoom modifiers. - bool increaseWebPageZoom(); - bool decreaseWebPageZoom(); - bool resetWebPageZoom(); - - private: - QWebEnginePage *m_page; -}; - -#endif // BASEWEBVIEW_H