From 10f91c4973c8d464b06149525c6eb7be979453f9 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Sat, 14 Sep 2013 22:55:23 +0200
Subject: Enable WebKit's Inspector if Swift is run in debug mode.

Change-Id: I758eb9e7df06887e9946d2a1fa56efed41796bb6
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 2536d39..31b9915 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -58,7 +58,9 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScro
 
 	webPage_ = new QWebPage(this);
 	webPage_->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
-	//webPage_->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+	if (Log::getLogLevel() == Log::debug) {
+		webPage_->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+	}
 	webView_->setPage(webPage_);
 	connect(webPage_, SIGNAL(selectionChanged()), SLOT(copySelectionToClipboard()));
 	connect(webPage_, SIGNAL(scrollRequested(int, int, const QRect&)), SLOT(handleScrollRequested(int, int, const QRect&)));
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index 1222ee2..33fa817 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -11,6 +11,7 @@
 #include <QFocusEvent>
 #include <boost/numeric/conversion/cast.hpp>
 #include <QMenu>
+#include <Swiften/Base/Log.h>
 
 namespace Swift {
 QtWebView::QtWebView(QWidget* parent) : QWebView(parent), fontSizeIsMinimal(false) {
@@ -18,6 +19,9 @@ QtWebView::QtWebView(QWidget* parent) : QWebView(parent), fontSizeIsMinimal(fals
 	filteredActions.push_back(QWebPage::CopyLinkToClipboard);
 	filteredActions.push_back(QWebPage::CopyImageToClipboard);
 	filteredActions.push_back(QWebPage::Copy);
+	if (Log::getLogLevel() == Log::debug) {
+		filteredActions.push_back(QWebPage::InspectElement);
+	}
 }
 
 void QtWebView::keyPressEvent(QKeyEvent* event) {
-- 
cgit v0.10.2-6-g49f6