akregator: remove internal browser support

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-16 04:29:35 +02:00
parent bcb18eae8f
commit 47455da734
14 changed files with 33 additions and 324 deletions

View file

@ -3,67 +3,19 @@
<author>Gary Cramblitt</author> <author>Gary Cramblitt</author>
<class>Akregator::SettingsBrowser</class> <class>Akregator::SettingsBrowser</class>
<widget class="QWidget" name="Akregator::SettingsBrowser"> <widget class="QWidget" name="Akregator::SettingsBrowser">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1"> <property name="geometry">
<item> <rect>
<layout class="QFormLayout" name="formLayout"> <x>0</x>
<item row="0" column="0"> <y>0</y>
<widget class="QLabel" name="LMBlabel"> <width>334</width>
<property name="text"> <height>169</height>
<string>Left mouse click:</string> </rect>
</property> </property>
</widget> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
</item>
<item row="0" column="1">
<widget class="KComboBox" name="kcfg_LMBBehaviour">
<item>
<property name="text">
<string>Open in Tab</string>
</property>
</item>
<item>
<property name="text">
<string>Open in Background Tab</string>
</property>
</item>
<item>
<property name="text">
<string>Open in External Browser</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="MMBlabel">
<property name="text">
<string>Middle mouse click:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="kcfg_MMBBehaviour">
<item>
<property name="text">
<string>Open in Tab</string>
</property>
</item>
<item>
<property name="text">
<string>Open in Background Tab</string>
</property>
</item>
<item>
<property name="text">
<string>Open in External Browser</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QGroupBox" name="externalBrowserGroupBox"> <widget class="QGroupBox" name="externalBrowserGroupBox">
<property name="title"> <property name="title">
<string>External Browsing</string> <string>Browser</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout">
<item row="1" column="1"> <item row="1" column="1">
@ -96,38 +48,11 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="kcfg_AlwaysShowTabBar">
<property name="text">
<string>Always show the tab bar</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_CloseButtonOnTabs">
<property name="text">
<string>Show close button on each tab</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="kcfg_NewWindowInTab">
<property name="text">
<string>Open links in new tab instead of in new window</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer> <spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
@ -144,11 +69,6 @@
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>klineedit.h</header> <header>klineedit.h</header>
</customwidget> </customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View file

@ -183,9 +183,8 @@
</entry> </entry>
<entry key="LMB Behaviour" type="Enum" > <entry key="LMB Behaviour" type="Enum" >
<whatsthis>What the click with left mouse button should do.</whatsthis> <whatsthis>What the click with left mouse button should do.</whatsthis>
<default>OpenInInternalBrowser</default> <default>OpenInExternalBrowser</default>
<choices> <choices>
<choice name="OpenInInternalBrowser" />
<choice name="OpenInBackground" /> <choice name="OpenInBackground" />
<choice name="OpenInExternalBrowser" /> <choice name="OpenInExternalBrowser" />
</choices> </choices>
@ -194,7 +193,6 @@
<whatsthis>What the click with middle mouse button should do.</whatsthis> <whatsthis>What the click with middle mouse button should do.</whatsthis>
<default>OpenInExternalBrowser</default> <default>OpenInExternalBrowser</default>
<choices> <choices>
<choice name="OpenInInternalBrowser" />
<choice name="OpenInBackground" /> <choice name="OpenInBackground" />
<choice name="OpenInExternalBrowser" /> <choice name="OpenInExternalBrowser" />
</choices> </choices>

View file

@ -42,7 +42,6 @@ set(akregatorprivate_LIB_SRCS
fetchqueue.cpp fetchqueue.cpp
frame.cpp frame.cpp
framemanager.cpp framemanager.cpp
browserrun.cpp
openurlrequest.cpp openurlrequest.cpp
actionmanager.cpp actionmanager.cpp
actions.cpp actions.cpp

View file

@ -280,12 +280,6 @@ void ActionManagerImpl::initMainWidget(MainWidget* mainWidget)
connect(sqf, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotToggleShowQuickFilter())); connect(sqf, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotToggleShowQuickFilter()));
sqf->setChecked( Settings::showQuickFilter() ); sqf->setChecked( Settings::showQuickFilter() );
action = coll->addAction("article_open" );
action->setIcon(KIcon("tab-new"));
action->setText(i18n("Open in Tab"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenSelectedArticles()));
action->setShortcuts(KShortcut( "Shift+Return" ));
action = coll->addAction("article_open_in_background" ); action = coll->addAction("article_open_in_background" );
action->setIcon(KIcon("tab-new")); action->setIcon(KIcon("tab-new"));
action->setText(i18n("Open in Background Tab")); action->setText(i18n("Open in Background Tab"));

View file

@ -152,9 +152,6 @@ void ArticleViewer::slotOpenUrlRequestDelayed(const KUrl& url, const KParts::Ope
{ {
switch (Settings::lMBBehaviour()) switch (Settings::lMBBehaviour())
{ {
case Settings::EnumLMBBehaviour::OpenInExternalBrowser:
req.setOptions(OpenUrlRequest::ExternalBrowser);
break;
case Settings::EnumLMBBehaviour::OpenInBackground: case Settings::EnumLMBBehaviour::OpenInBackground:
req.setOpenInBackground(true); req.setOpenInBackground(true);
break; break;
@ -166,9 +163,6 @@ void ArticleViewer::slotOpenUrlRequestDelayed(const KUrl& url, const KParts::Ope
{ {
switch (Settings::mMBBehaviour()) switch (Settings::mMBBehaviour())
{ {
case Settings::EnumMMBBehaviour::OpenInExternalBrowser:
req.setOptions(OpenUrlRequest::ExternalBrowser);
break;
case Settings::EnumMMBBehaviour::OpenInBackground: case Settings::EnumMMBBehaviour::OpenInBackground:
req.setOpenInBackground(true); req.setOpenInBackground(true);
break; break;
@ -267,7 +261,6 @@ void ArticleViewer::slotOpenLinkInBackgroundTab()
void ArticleViewer::slotOpenLinkInBrowser() void ArticleViewer::slotOpenLinkInBrowser()
{ {
OpenUrlRequest req(m_url); OpenUrlRequest req(m_url);
req.setOptions(OpenUrlRequest::ExternalBrowser);
emit signalOpenUrlRequest(req); emit signalOpenUrlRequest(req);
} }

View file

@ -1,70 +0,0 @@
/*
This file is part of Akregator.
Copyright (C) 2004 Sashmit Bhaduri <smt@vfemail.net>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include "browserrun.h"
#include "openurlrequest.h"
#include "frame.h"
#include <kdebug.h>
namespace Akregator {
BrowserRun::BrowserRun(const OpenUrlRequest& request, QWidget* parent)
: KParts::BrowserRun(request.url(), request.args(), request.browserArgs(), 0L, parent, /*removeReferrer=*/false, /*trustedSource=*/false, /*hideErrorDialog=*/true), m_request(request)
{
setEnableExternalBrowser(false);
m_window = parent; // remove member and use KRun::window() instead once we can depend on kdelibs >= 4.10
}
BrowserRun::~BrowserRun()
{}
void BrowserRun::foundMimeType(const QString& type)
{
KParts::OpenUrlArguments args = m_request.args();
args.setMimeType( type );
m_request.setArgs( args );
m_request.setWasHandled( false );
emit signalFoundMimeType( m_request );
if ( m_request.wasHandled() ) {
setFinished(true);
return;
}
KService::Ptr selectedService;
if ( handleNonEmbeddable( type, &selectedService ) == KParts::BrowserRun::NotHandled ) {
if ( selectedService ) {
KRun::setPreferredService( selectedService->desktopEntryName() );
KRun::foundMimeType( type );
} else {
KRun::displayOpenWithDialog( url(), m_window, false, suggestedFileName() );
setFinished(true);
}
}
}
} // namespace Akregator

View file

@ -1,58 +0,0 @@
/*
This file is part of Akregator.
Copyright (C) 2004 Sashmit Bhaduri <smt@vfemail.net>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef AKREGATOR_BROWSERRUN_H
#define AKREGATOR_BROWSERRUN_H
#include <kparts/browserrun.h>
#include "openurlrequest.h"
namespace Akregator
{
class BrowserRun : public KParts::BrowserRun
{
Q_OBJECT
public:
BrowserRun(const OpenUrlRequest& request, QWidget* parent);
~BrowserRun();
signals:
void signalFoundMimeType(Akregator::OpenUrlRequest& request);
private:
/* reimp */ void foundMimeType(const QString& type);
private:
OpenUrlRequest m_request;
QWidget* m_window;
};
} // namespace Akregator
#endif // AKREGATOR_BROWSERRUN_H
// vim: set et ts=4 sts=4 sw=4:

View file

@ -26,7 +26,6 @@
#include "akregatorconfig.h" #include "akregatorconfig.h"
#include "frame.h" #include "frame.h"
#include "actionmanager.h" #include "actionmanager.h"
#include "browserrun.h"
#include "openurlrequest.h" #include "openurlrequest.h"
#include <kaction.h> #include <kaction.h>
@ -36,6 +35,7 @@
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <ktoolinvocation.h> #include <ktoolinvocation.h>
#include <kparts/event.h> #include <kparts/event.h>
#include <krun.h>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtGui/QApplication> #include <QtGui/QApplication>
@ -274,8 +274,10 @@ void FrameManager::openUrl(OpenUrlRequest& request)
emit signalSelectFrame(request.frameId()); emit signalSelectFrame(request.frameId());
} }
void FrameManager::openInExternalBrowser(const OpenUrlRequest& request) void FrameManager::slotOpenUrlRequest(OpenUrlRequest& request )
{ {
kDebug() <<"FrameManager::slotOpenUrlRequest():" << request.debugInfo();
KUrl url = request.url(); KUrl url = request.url();
if (!url.isValid()) if (!url.isValid())
return; return;
@ -299,40 +301,6 @@ void FrameManager::openInExternalBrowser(const OpenUrlRequest& request)
KRun::runUrl(url, request.args().mimeType(), 0 /*window*/, false, false); KRun::runUrl(url, request.args().mimeType(), 0 /*window*/, false, false);
} }
void FrameManager::slotOpenUrlRequest(OpenUrlRequest& request, bool useOpenInBackgroundSetting )
{
kDebug() <<"FrameManager::slotOpenUrlRequest():" << request.debugInfo();
if (request.options() == OpenUrlRequest::ExternalBrowser)
{
openInExternalBrowser(request);
return;
}
if( useOpenInBackgroundSetting ) {
// Honour user's preference for foreground/background tabs
if (request.options() == OpenUrlRequest::NewTab ||
request.browserArgs().newTab())
{
request.setOpenInBackground(Settings::lMBBehaviour() ==
Settings::EnumLMBBehaviour::OpenInBackground);
}
}
// if no service type is set, determine it using BrowserRun.
if (request.args().mimeType().isEmpty())
{
BrowserRun* run = new BrowserRun(request, m_mainWin);
connect(run, SIGNAL(signalFoundMimeType(Akregator::OpenUrlRequest&)),
this, SLOT(openUrl(Akregator::OpenUrlRequest&)) );
}
else // serviceType is already set, so we open the page synchronously.
{
openUrl(request);
}
}
void FrameManager::slotBrowserBackAboutToShow() void FrameManager::slotBrowserBackAboutToShow()
{ {
if (m_currentFrame) if (m_currentFrame)

View file

@ -64,7 +64,7 @@ class AKREGATOR_EXPORT FrameManager : public QObject
void slotRemoveFrame(int frameId); void slotRemoveFrame(int frameId);
void slotChangeFrame(int frameId); void slotChangeFrame(int frameId);
void slotOpenUrlRequest(Akregator::OpenUrlRequest& request,bool useOpenInBackgroundSetting = true ); void slotOpenUrlRequest(Akregator::OpenUrlRequest& request);
void slotBrowserBack(); void slotBrowserBack();
void slotBrowserForward(); void slotBrowserForward();
@ -97,11 +97,6 @@ class AKREGATOR_EXPORT FrameManager : public QObject
void signalLoadingProgress(int); void signalLoadingProgress(int);
void signalStatusText(const QString&); void signalStatusText(const QString&);
private:
void openInExternalBrowser(const OpenUrlRequest& request);
private slots: private slots:
void openUrl(Akregator::OpenUrlRequest& request); void openUrl(Akregator::OpenUrlRequest& request);
void slotSetStarted(Akregator::Frame* frame); void slotSetStarted(Akregator::Frame* frame);

View file

@ -727,9 +727,6 @@ void Akregator::MainWidget::slotMouseButtonPressed(int button, const KUrl& url)
switch (Settings::mMBBehaviour()) switch (Settings::mMBBehaviour())
{ {
case Settings::EnumMMBBehaviour::OpenInExternalBrowser:
req.setOptions(OpenUrlRequest::ExternalBrowser);
break;
case Settings::EnumMMBBehaviour::OpenInBackground: case Settings::EnumMMBBehaviour::OpenInBackground:
req.setOptions(OpenUrlRequest::NewTab); req.setOptions(OpenUrlRequest::NewTab);
req.setOpenInBackground(true); req.setOpenInBackground(true);
@ -754,7 +751,6 @@ void Akregator::MainWidget::slotOpenHomepage()
if (url.isValid()) if (url.isValid())
{ {
OpenUrlRequest req(feed->htmlUrl()); OpenUrlRequest req(feed->htmlUrl());
req.setOptions(OpenUrlRequest::ExternalBrowser);
Kernel::self()->frameManager()->slotOpenUrlRequest(req); Kernel::self()->frameManager()->slotOpenUrlRequest(req);
} }
} }
@ -772,34 +768,10 @@ void Akregator::MainWidget::slotOpenArticleInBrowser(const Akregator::Article& a
if (!article.isNull() && article.link().isValid()) if (!article.isNull() && article.link().isValid())
{ {
OpenUrlRequest req(article.link()); OpenUrlRequest req(article.link());
req.setOptions(OpenUrlRequest::ExternalBrowser);
Kernel::self()->frameManager()->slotOpenUrlRequest(req); Kernel::self()->frameManager()->slotOpenUrlRequest(req);
} }
} }
void Akregator::MainWidget::openSelectedArticles( bool openInBackground )
{
const QList<Article> articles = m_selectionController->selectedArticles();
Q_FOREACH( const Akregator::Article& article, articles )
{
const KUrl url = article.link();
if ( !url.isValid() )
continue;
OpenUrlRequest req( url );
req.setOptions( OpenUrlRequest::NewTab );
if( openInBackground ) {
req.setOpenInBackground( true );
Kernel::self()->frameManager()->slotOpenUrlRequest( req, false /*don't use settings for open in background*/ );
} else {
Kernel::self()->frameManager()->slotOpenUrlRequest( req );
}
}
}
void Akregator::MainWidget::slotCopyLinkAddress() void Akregator::MainWidget::slotCopyLinkAddress()
{ {
const Article article = m_selectionController->currentArticle(); const Article article = m_selectionController->currentArticle();
@ -1036,15 +1008,21 @@ void MainWidget::slotNetworkStatusChanged(Solid::Networking::Status status)
} }
} }
void Akregator::MainWidget::slotOpenSelectedArticles()
{
openSelectedArticles( false );
}
void Akregator::MainWidget::slotOpenSelectedArticlesInBackground() void Akregator::MainWidget::slotOpenSelectedArticlesInBackground()
{ {
openSelectedArticles( true ); const QList<Article> articles = m_selectionController->selectedArticles();
Q_FOREACH( const Akregator::Article& article, articles )
{
const KUrl url = article.link();
if ( !url.isValid() )
continue;
OpenUrlRequest req( url );
req.setOptions( OpenUrlRequest::NewTab );
req.setOpenInBackground( true );
Kernel::self()->frameManager()->slotOpenUrlRequest( req );
}
} }

View file

@ -129,7 +129,6 @@ class AKREGATORPART_EXPORT MainWidget : public QWidget
void slotOpenSelectedArticlesInBrowser(); void slotOpenSelectedArticlesInBrowser();
/** opens current article in new tab, background/foreground depends on settings TODO: use selected instead of current? */ /** opens current article in new tab, background/foreground depends on settings TODO: use selected instead of current? */
void slotOpenSelectedArticles();
void slotOpenSelectedArticlesInBackground(); void slotOpenSelectedArticlesInBackground();
void slotOnShutdown(); void slotOnShutdown();
@ -237,9 +236,6 @@ class AKREGATORPART_EXPORT MainWidget : public QWidget
private: private:
void deleteExpiredArticles( const boost::shared_ptr<FeedList>& feedList ); void deleteExpiredArticles( const boost::shared_ptr<FeedList>& feedList );
/** opens current article in new tab, background/foreground depends on settings TODO: use selected instead of current? */
void openSelectedArticles(bool openInBackground);
AbstractSelectionController* m_selectionController; AbstractSelectionController* m_selectionController;
boost::shared_ptr<FeedList> m_feedList; boost::shared_ptr<FeedList> m_feedList;

View file

@ -89,8 +89,6 @@ OpenUrlRequest::Options OpenUrlRequest::options() const
{ {
if (Settings::newWindowInTab()) if (Settings::newWindowInTab())
return (NewTab); return (NewTab);
else
return (ExternalBrowser);
} }
return m_options; return m_options;

View file

@ -50,8 +50,7 @@ class AKREGATOR_EXPORT OpenUrlRequest
enum Options enum Options
{ {
None=0, /**< no explicit options, use default */ None=0, /**< no explicit options, use default */
NewTab, /**< open in new tab */ NewTab=1 /**< open in new tab */
ExternalBrowser /**< open in external browser */
}; };
explicit OpenUrlRequest(const KUrl& url=KUrl()); explicit OpenUrlRequest(const KUrl& url=KUrl());

View file

@ -368,7 +368,6 @@ void TabWidget::slotDetachTab()
{ {
OpenUrlRequest request; OpenUrlRequest request;
request.setUrl(frame->url()); request.setUrl(frame->url());
request.setOptions(OpenUrlRequest::ExternalBrowser);
emit signalOpenUrlRequest(request); emit signalOpenUrlRequest(request);
slotCloseTab(); slotCloseTab();
} }