diff --git a/src/lib/other/sourceviewer.cpp b/src/lib/other/sourceviewer.cpp index b6ac27798..970bb786a 100644 --- a/src/lib/other/sourceviewer.cpp +++ b/src/lib/other/sourceviewer.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * 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 @@ -68,6 +68,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml) QzTools::centerWidgetToParent(this, frame->page()->view()); 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->addSeparator(); 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()); } +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() { m_actionUndo->setEnabled(false); @@ -143,7 +155,7 @@ void SourceViewer::loadSource() html.remove(QRegExp("")); m_sourceEdit->setPlainText(html); - //Highlight selectedHtml + // Highlight selectedHtml if (!m_selectedHtml.isEmpty()) { m_sourceEdit->find(m_selectedHtml, QTextDocument::FindWholeWords); } @@ -187,7 +199,7 @@ void SourceViewer::reload() { if (m_frame) { m_sourceEdit->clear(); - m_sourceEdit->setPlainText(m_frame.data()->toHtml()); + loadSource(); m_statusBar->showMessage(tr("Source reloaded")); } diff --git a/src/lib/other/sourceviewer.h b/src/lib/other/sourceviewer.h index 4895bee29..c64575a4a 100644 --- a/src/lib/other/sourceviewer.h +++ b/src/lib/other/sourceviewer.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * 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 @@ -42,6 +42,7 @@ private slots: void undoAvailable(bool available); void pasteAvailable(); + void loadInPage(); void loadSource(); void save(); void findText(); diff --git a/translations/empty.ts b/translations/empty.ts index f5a8221b7..d501d0f17 100644 --- a/translations/empty.ts +++ b/translations/empty.ts @@ -4198,6 +4198,18 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla Enter line number + + Load in page + + + + Source loaded in page + + + + Cannot load in page. Page has been closed. + + SourceViewerSearch