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

Bring back show source support (using view-source: url)

This commit is contained in:
David Rosca 2015-05-24 21:26:17 +02:00
parent b6fcfba09a
commit 7d9a07b379
7 changed files with 28 additions and 31 deletions

View File

@ -742,17 +742,11 @@ void BrowserWindow::showHistoryManager()
mApp->browsingLibrary()->showHistory(this);
}
void BrowserWindow::showSource(QWebEngineFrame* frame, const QString &selectedHtml)
void BrowserWindow::showSource(WebView *view)
{
#if QTWEBENGINE_DISABLED
if (!frame) {
frame = weView()->page()->mainFrame();
}
SourceViewer* source = new SourceViewer(frame, selectedHtml);
QzTools::centerWidgetToParent(source, this);
source->show();
#endif
if (!view)
view = weView();
view->showSource();
}
SideBar* BrowserWindow::addSideBar()

View File

@ -43,6 +43,7 @@ class BookmarksToolbar;
class AutoFill;
class MainApplication;
class WebTab;
class WebView;
class AdBlockIcon;
class SideBar;
class SideBarManager;
@ -140,7 +141,7 @@ public slots:
void bookmarkPage();
void bookmarkAllTabs();
void loadAddress(const QUrl &url);
void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString());
void showSource(WebView *view = Q_NULLPTR);
void printPage(QWebEngineFrame* frame = 0);
private slots:

View File

@ -30,9 +30,9 @@ class QUPZILLA_EXPORT PopupWebView : public WebView
public:
explicit PopupWebView(QWidget* parent = 0);
QWidget* overlayWidget();
void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position);
void openNewTab(Qz::NewTabPositionFlags position);
QWidget* overlayWidget() Q_DECL_OVERRIDE;
void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE;
void openNewTab(Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE;
signals:

View File

@ -86,7 +86,7 @@ PopupWindow::PopupWindow(PopupWebView* view)
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), m_view, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), m_view, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
m_menuView->addSeparator();
//m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
m_menuBar->addMenu(m_menuView);
// Make shortcuts available even with hidden menubar

View File

@ -41,6 +41,8 @@
#include "macwebviewscroller.h"
#endif
#include <iostream>
#include <QDir>
#include <QTimer>
#include <QDesktopServices>
@ -626,18 +628,21 @@ void WebView::openActionUrl()
}
}
#if QTWEBENGINE_DISABLED
void WebView::showSource(QWebEngineFrame* frame, const QString &selectedHtml)
void WebView::showSource()
{
if (!frame) {
frame = page()->mainFrame();
// view-source: doesn't work on itself and custom schemes
if (url().scheme() == QL1S("view-source") || url().scheme() == QL1S("qupzilla")) {
page()->toHtml([](const QString &html) {
std::cout << html.toLocal8Bit().constData() << std::endl;
});
return;
}
SourceViewer* source = new SourceViewer(frame, selectedHtml);
QzTools::centerWidgetToParent(source, this);
source->show();
QUrl u;
u.setScheme(QSL("view-source"));
u.setPath(url().toString());
openUrlInNewTab(u, Qz::NT_SelectedTab);
}
#endif
void WebView::showSiteInfo()
{

View File

@ -103,6 +103,7 @@ public slots:
#if QTWEBENGINE_DISABLED
void printPage(QWebEngineFrame* frame = 0);
#endif
void showSource();
void sendPageByMail();
void savePageAs();
@ -126,9 +127,6 @@ protected slots:
void downloadUrlToDisk();
void copyImageToClipboard();
void openActionUrl();
#if QTWEBENGINE_DISABLED
void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString());
#endif
void showSiteInfo();
void searchSelectedText();
void searchSelectedTextInBackgroundTab();

View File

@ -47,7 +47,10 @@ public:
QString getIp() const;
int tabIndex() const;
QWidget* overlayWidget();
QWidget* overlayWidget() Q_DECL_OVERRIDE;
void closeView() Q_DECL_OVERRIDE;
void openNewTab(Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE;
void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE;
signals:
void wantsCloseTab(int);
@ -58,10 +61,6 @@ public slots:
void setAsCurrentTab();
void userLoadAction(const LoadRequest &req);
void closeView();
void openNewTab(Qz::NewTabPositionFlags position);
void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position);
private slots:
void slotLoadStarted();
void slotLoadFinished();