From 66edb6d66102e2ae7c0fd234f932b515fe101635 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Nov 2012 22:47:42 +0100 Subject: Restoring inspector, part 1 restored action and code to activate/deactivate it --- src/webtab/webtab.cpp | 9 +++++++++ src/webtab/webtab.h | 2 ++ src/webtab/webview.cpp | 18 ++---------------- src/webtab/webview.h | 1 - src/webwindow/webwindow.cpp | 6 ++++++ src/webwindow/webwindow.h | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp index 510177e6..5349d599 100644 --- a/src/webtab/webtab.cpp +++ b/src/webtab/webtab.cpp @@ -63,6 +63,8 @@ #include #include +#include + WebTab::WebTab(QWidget *parent) : QWidget(parent) @@ -420,3 +422,10 @@ void WebTab::webAppIconChanged() { setWindowIcon(IconManager::self()->iconForUrl(url())); } + + +void WebTab::toggleInspector(bool on) +{ + page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); + kDebug() << "TOGGLED: " << on; +} diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h index 361da2c4..0a12c756 100644 --- a/src/webtab/webtab.h +++ b/src/webtab/webtab.h @@ -102,6 +102,8 @@ private Q_SLOTS: void webAppTitleChanged(QString); void webAppIconChanged(); + void toggleInspector(bool); + Q_SIGNALS: void loadProgressing(); void titleChanged(const QString &); diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp index 0cc09574..ec74be1e 100644 --- a/src/webtab/webview.cpp +++ b/src/webtab/webview.cpp @@ -274,9 +274,6 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) KMenu menu(this); QAction *a; - KAction *inspectAction = new KAction(KIcon("layer-visible-on"), i18n("Inspect Element"), this); - connect(inspectAction, SIGNAL(triggered(bool)), this, SLOT(inspect())); - KAction *sendByMailAction = new KAction(this); sendByMailAction->setIcon(KIcon("mail-send")); connect(sendByMailAction, SIGNAL(triggered(bool)), this, SLOT(sendByMail())); @@ -359,7 +356,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (webwin) { menu.addAction(webwin->actionByName("page_source")); - menu.addAction(inspectAction); + menu.addAction(webwin->actionByName("web_inspector")); } } @@ -542,7 +539,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addAction(sendByMailAction); if (webwin) - menu.addAction(inspectAction); + menu.addAction(webwin->actionByName("web_inspector")); // SPELL CHECK Actions if (m_contextMenuHitResult.isContentEditable()) @@ -1045,17 +1042,6 @@ void WebView::wheelEvent(QWheelEvent *event) } -void WebView::inspect() -{ - WebTab *tab = qobject_cast(parent()); - WebWindow *webwin = tab->webWindow(); - QAction *a = webwin->actionByName("web_inspector"); - if (a && !a->isChecked()) - a->trigger(); - pageAction(QWebPage::InspectElement)->trigger(); -} - - void WebView::scrollFrameChanged() { // do the scrolling diff --git a/src/webtab/webview.h b/src/webtab/webview.h index 2ff877e1..f7c16546 100644 --- a/src/webtab/webview.h +++ b/src/webtab/webview.h @@ -108,7 +108,6 @@ private Q_SLOTS: void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); void slotCopyImageLocation(); - void inspect(); void scrollFrameChanged(); void scrollTick(); diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index be2ba5da..35c6aed9 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -323,6 +323,12 @@ void WebWindow::setupActions() a = new KAction(KIcon("tools-wizard"), i18n("Sync"), this); // FIXME sync icon!! actionCollection()->addAction(QL1S("sync"), a); connect(a, SIGNAL(triggered(bool)), SyncManager::self(), SLOT(showSettings())); + + // web inspector + a = new KAction(KIcon("layer-visible-on"), i18n("&Inspect"), this); + a->setCheckable(true); + actionCollection()->addAction(QL1S("web_inspector"), a); + connect(a, SIGNAL(triggered(bool)), _tab, SLOT(toggleInspector(bool))); } diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index c37704d5..ce71e7b9 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -112,7 +112,7 @@ private Q_SLOTS: void updateHistoryActions(); void openNewWindow(); - + /** * Notifies a message in a popup */ -- cgit v1.2.1