mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Added Show source of selection feature. However, in Qt 4.8 beta it is
buggy, so it is disabled until it will be fixed
This commit is contained in:
parent
65d0542dc0
commit
b13e71162d
@ -911,9 +911,9 @@ void QupZilla::showPreferences()
|
||||
prefs->show();
|
||||
}
|
||||
|
||||
void QupZilla::showSource()
|
||||
void QupZilla::showSource(const QString &selectedHtml)
|
||||
{
|
||||
SourceViewer* source = new SourceViewer(weView()->page());
|
||||
SourceViewer* source = new SourceViewer(weView()->page(), selectedHtml);
|
||||
source->show();
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public slots:
|
||||
void loadActionUrl();
|
||||
void bookmarkPage();
|
||||
void loadAddress(QUrl url) { weView()->load(url); locationBar()->setText(url.toEncoded()); }
|
||||
void showSource();
|
||||
void showSource(const QString& selectedHtml = "");
|
||||
void showPageInfo();
|
||||
void receiveMessage(MainApplication::MessageType mes, bool state);
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "htmlhighlighter.h"
|
||||
#include "sourceviewersearch.h"
|
||||
|
||||
SourceViewer::SourceViewer(QWebPage* page, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
SourceViewer::SourceViewer(QWebPage* page, const QString &selectedHtml) :
|
||||
QWidget(0)
|
||||
,m_page(page)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -94,6 +94,10 @@ SourceViewer::SourceViewer(QWebPage* page, QWidget* parent) :
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
|
||||
//Highlight selectedHtml
|
||||
if (!selectedHtml.isEmpty())
|
||||
m_sourceEdit->find(selectedHtml, QTextDocument::FindWholeWords);
|
||||
}
|
||||
|
||||
void SourceViewer::save()
|
||||
@ -117,7 +121,7 @@ void SourceViewer::save()
|
||||
void SourceViewer::findText()
|
||||
{
|
||||
if (m_layout->count() > 2) {
|
||||
SourceViewerSearch* search= qobject_cast<SourceViewerSearch*>( m_layout->itemAt(1)->widget() );
|
||||
SourceViewerSearch* search = qobject_cast<SourceViewerSearch*>( m_layout->itemAt(1)->widget() );
|
||||
search->activateLineEdit();
|
||||
return;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class SourceViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SourceViewer(QWebPage* page, QWidget* parent = 0);
|
||||
explicit SourceViewer(QWebPage* page, const QString &selectedHtml);
|
||||
QTextEdit* sourceEdit() { return m_sourceEdit; }
|
||||
signals:
|
||||
|
||||
|
@ -468,7 +468,7 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu->addAction(tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(r.linkUrl());
|
||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(r.linkUrl());
|
||||
menu->addSeparator();
|
||||
if (!page()->selectedText().isEmpty())
|
||||
if (!selectedText().isEmpty())
|
||||
menu->addAction(pageAction(QWebPage::Copy));
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu->addAction(tr("Send image..."), this, SLOT(sendLinkByMail()))->setData(r.linkUrl());
|
||||
menu->addSeparator();
|
||||
//menu->addAction(tr("Block image"), this, SLOT(blockImage()))->setData(r.imageUrl().toString());
|
||||
if (!page()->selectedText().isEmpty())
|
||||
if (!selectedText().isEmpty())
|
||||
menu->addAction(pageAction(QWebPage::Copy));
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu->addAction(tr("Send page..."), this, SLOT(sendLinkByMail()))->setData(url());
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &all"), this, SLOT(selectAll()));
|
||||
if (!page()->selectedText().isEmpty())
|
||||
if (!selectedText().isEmpty())
|
||||
menu->addAction(pageAction(QWebPage::Copy));
|
||||
|
||||
menu->addSeparator();
|
||||
@ -545,13 +545,18 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
||||
mApp->plugins()->populateWebViewMenu(menu, this, r);
|
||||
|
||||
if (!page()->selectedText().isEmpty()) {
|
||||
if (!selectedText().isEmpty()) {
|
||||
menu->addSeparator();
|
||||
QString selectedText = page()->selectedText();
|
||||
selectedText.truncate(20);
|
||||
menu->addAction(QIcon(":icons/menu/google.png"), tr("Search \"%1 ..\" on &Google").arg(selectedText), this, SLOT(searchOnGoogle()))->setData(page()->selectedText());
|
||||
}
|
||||
|
||||
#if QT_VERSION == 0x040800
|
||||
// if (!selectedHtml().isEmpty())
|
||||
// menu->addAction(tr("Show source of selection"), this, SLOT(showSourceOfSelection()));
|
||||
#endif
|
||||
|
||||
if (!menu->isEmpty()) {
|
||||
//Prevent choosing first option with double rightclick
|
||||
QPoint pos = QCursor::pos();
|
||||
@ -635,6 +640,11 @@ void WebView::showSource()
|
||||
p_QupZilla->showSource();
|
||||
}
|
||||
|
||||
void WebView::showSourceOfSelection()
|
||||
{
|
||||
p_QupZilla->showSource(selectedHtml());
|
||||
}
|
||||
|
||||
void WebView::downloadLinkToDisk()
|
||||
{
|
||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||
|
@ -101,6 +101,7 @@ private slots:
|
||||
void sendLinkByMail();
|
||||
void bookmarkLink();
|
||||
void showSource();
|
||||
void showSourceOfSelection();
|
||||
void showSiteInfo();
|
||||
void getFocus(const QUrl &urla);
|
||||
void showInspector();
|
||||
|
Loading…
Reference in New Issue
Block a user