1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[sourceviewer] Option to load edited source code in page.

Also fixed showing AdBlock css rules when reloading source.
This commit is contained in:
nowrep 2013-02-05 15:17:36 +01:00
parent dfb69be90e
commit fc41e1516d
3 changed files with 29 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -68,6 +68,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
QzTools::centerWidgetToParent(this, frame->page()->view()); QzTools::centerWidgetToParent(this, frame->page()->view());
QMenu* menuFile = new QMenu(tr("File")); QMenu* menuFile = new QMenu(tr("File"));
menuFile->addAction(tr("Load in page"), this, SLOT(loadInPage()));
menuFile->addAction(QIcon::fromTheme("document-save"), tr("Save as..."), this, SLOT(save()))->setShortcut(QKeySequence("Ctrl+S")); menuFile->addAction(QIcon::fromTheme("document-save"), tr("Save as..."), this, SLOT(save()))->setShortcut(QKeySequence("Ctrl+S"));
menuFile->addSeparator(); menuFile->addSeparator();
menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W")); menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W"));
@ -130,6 +131,17 @@ void SourceViewer::pasteAvailable()
m_actionPaste->setEnabled(m_sourceEdit->canPaste()); m_actionPaste->setEnabled(m_sourceEdit->canPaste());
} }
void SourceViewer::loadInPage()
{
if (m_frame) {
m_frame.data()->setHtml(m_sourceEdit->toPlainText(), m_frame.data()->baseUrl());
m_statusBar->showMessage(tr("Source loaded in page"));
}
else {
m_statusBar->showMessage(tr("Cannot load in page. Page has been closed."));
}
}
void SourceViewer::loadSource() void SourceViewer::loadSource()
{ {
m_actionUndo->setEnabled(false); m_actionUndo->setEnabled(false);
@ -143,7 +155,7 @@ void SourceViewer::loadSource()
html.remove(QRegExp("<style type=\"text/css\">\n/\\* AdBlock for QupZilla \\*/\n.*\\{display: none !important;\\}\n</style>")); html.remove(QRegExp("<style type=\"text/css\">\n/\\* AdBlock for QupZilla \\*/\n.*\\{display: none !important;\\}\n</style>"));
m_sourceEdit->setPlainText(html); m_sourceEdit->setPlainText(html);
//Highlight selectedHtml // Highlight selectedHtml
if (!m_selectedHtml.isEmpty()) { if (!m_selectedHtml.isEmpty()) {
m_sourceEdit->find(m_selectedHtml, QTextDocument::FindWholeWords); m_sourceEdit->find(m_selectedHtml, QTextDocument::FindWholeWords);
} }
@ -187,7 +199,7 @@ void SourceViewer::reload()
{ {
if (m_frame) { if (m_frame) {
m_sourceEdit->clear(); m_sourceEdit->clear();
m_sourceEdit->setPlainText(m_frame.data()->toHtml()); loadSource();
m_statusBar->showMessage(tr("Source reloaded")); m_statusBar->showMessage(tr("Source reloaded"));
} }

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* QupZilla - WebKit based browser * QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -42,6 +42,7 @@ private slots:
void undoAvailable(bool available); void undoAvailable(bool available);
void pasteAvailable(); void pasteAvailable();
void loadInPage();
void loadSource(); void loadSource();
void save(); void save();
void findText(); void findText();

View File

@ -4198,6 +4198,18 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla
<source>Enter line number</source> <source>Enter line number</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Load in page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source loaded in page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cannot load in page. Page has been closed.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SourceViewerSearch</name> <name>SourceViewerSearch</name>