summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-12-03 01:17:51 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-12-03 01:17:51 +0100
commit033ceeaf69a031ef706797a577fe8f1e14256970 (patch)
tree111fc073946568704eace728071574bff4fea3b8
parentpush startup on disabled adblock (don't load filters) (diff)
parentfix copyright (diff)
downloadrekonq-033ceeaf69a031ef706797a577fe8f1e14256970.tar.xz
Merge commit 'refs/merge-requests/62' of git://gitorious.org/rekonq/mainline into AdFixes
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/mainwindow.cpp47
-rw-r--r--src/mainwindow.h14
-rw-r--r--src/webinspectordock.cpp82
-rw-r--r--src/webinspectordock.h58
5 files changed, 171 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1c452aeb..66b68664 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,6 +42,8 @@ SET( rekonq_KDEINIT_SRCS
#----------------------------------------
urlbar/urlbar.cpp
urlbar/lineedit.cpp
+#----------------------------------------
+ webinspectordock.cpp
)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8b43f6ae..583825af 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -42,6 +42,7 @@
#include "findbar.h"
#include "sidepanel.h"
#include "bookmarkspanel.h"
+#include "webinspectordock.h"
#include "urlbar.h"
#include "tabbar.h"
#include "newtabpage.h"
@@ -99,7 +100,8 @@ MainWindow::MainWindow()
, m_view(new MainView(this))
, m_findBar(new FindBar(this))
, m_sidePanel(0)
- , m_bookmarksPanel(0)
+ , m_bookmarksPanel(0)
+ , m_webInspectorDock(0)
, m_historyBackMenu(0)
, m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) )
, m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) )
@@ -136,7 +138,8 @@ MainWindow::MainWindow()
// setting Side Panel
setupSidePanel();
- setupBookmarksPanel();
+ setupBookmarksPanel();
+ setupWebInspector();
// setting up rekonq tools
setupTools();
@@ -336,11 +339,6 @@ void MainWindow::setupActions()
actionCollection()->addAction(QLatin1String("page_source"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));
- a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this);
- a->setCheckable(true);
- actionCollection()->addAction(QLatin1String("web_inspector"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleInspector(bool)));
-
a = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
a->setCheckable(true);
actionCollection()->addAction(QLatin1String("private_browsing"), a);
@@ -490,6 +488,22 @@ void MainWindow::setupBookmarksPanel()
}
+void MainWindow::setupWebInspector()
+{
+ m_webInspectorDock = new WebInspectorDock(i18n("Web Inspector"), this);
+ connect(mainView(), SIGNAL(currentChanged(int)), m_webInspectorDock, SLOT(changeCurrentPage()));
+
+ KAction *a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this);
+ a->setCheckable(true);
+ actionCollection()->addAction(QLatin1String("web_inspector"), a);
+ connect(a, SIGNAL(triggered(bool)), m_webInspectorDock, SLOT(toggle(bool)));
+
+ addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock);
+ m_webInspectorDock->hide();
+}
+
+
+
void MainWindow::updateConfiguration()
{
// ============== General ==================
@@ -847,25 +861,6 @@ void MainWindow::homePage()
}
-void MainWindow::toggleInspector(bool enable)
-{
- QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable);
- if (enable)
- {
- int result = KMessageBox::questionYesNo(this,
- i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" \
- "Do you want to reload all pages?"),
- i18n("Web Inspector")
- );
-
- if (result == KMessageBox::Yes)
- {
- m_view->reloadAllTabs();
- }
- }
-}
-
-
MainView *MainWindow::mainView() const
{
return m_view;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index d47b0d50..f141c5a2 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -48,6 +48,7 @@ class KPassivePopup;
class FindBar;
class SidePanel;
class BookmarksPanel;
+class WebInspectorDock;
class WebView;
class MainView;
@@ -81,8 +82,10 @@ private:
void setupSidePanel();
SidePanel *sidePanel();
- void setupBookmarksPanel();
- BookmarksPanel *bookmarksPanel();
+ void setupBookmarksPanel();
+ BookmarksPanel *bookmarksPanel();
+
+ void setupWebInspector();
public slots:
void updateBrowser();
@@ -99,8 +102,7 @@ public slots:
void notifyMessage(const QString &msg, Rekonq::Notify status = Rekonq::Info);
void printRequested(QWebFrame *frame = 0);
-
-
+
signals:
// switching tabs
void ctrlTabPressed();
@@ -146,7 +148,6 @@ private slots:
void viewFullScreen(bool enable);
// Tools Menu slots
- void toggleInspector(bool enable);
void privateBrowsing(bool enable);
// Settings Menu slot
@@ -162,7 +163,8 @@ private:
MainView *m_view;
FindBar *m_findBar;
SidePanel *m_sidePanel;
- BookmarksPanel *m_bookmarksPanel;
+ BookmarksPanel *m_bookmarksPanel;
+ WebInspectorDock *m_webInspectorDock;
KAction *m_stopReloadAction;
KMenu *m_historyBackMenu;
diff --git a/src/webinspectordock.cpp b/src/webinspectordock.cpp
new file mode 100644
index 00000000..51fdbdaf
--- /dev/null
+++ b/src/webinspectordock.cpp
@@ -0,0 +1,82 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Matthieu Gicquel<matgic78@gmail.com>
+*
+*
+* 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 the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+// Self Includes
+#include "webinspectordock.h"
+
+// Local Includes
+#include "webview.h"
+#include "webpage.h"
+
+// Qt Includes
+#include <QWebInspector>
+
+// KDE Includes
+#include "KAction"
+#include "KDebug"
+
+
+WebInspectorDock::WebInspectorDock(QString title, QWidget *parent)
+ : QDockWidget(title, parent)
+{
+ setObjectName("webInspectorDock");
+ QWebInspector *inspector = new QWebInspector(this);
+ setWidget(inspector);
+}
+
+void WebInspectorDock::closeEvent(QCloseEvent *event)
+{
+ Q_UNUSED(event);
+ toggle(false);
+}
+
+MainWindow* WebInspectorDock::mainWindow()
+{
+ return qobject_cast< MainWindow* >(parentWidget());
+}
+
+
+void WebInspectorDock::toggle(bool enable)
+{
+ mainWindow()->actionByName("web_inspector")->setChecked(enable);
+ if (enable)
+ {
+ mainWindow()->currentTab()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+ findChild<QWebInspector *>()->setPage(mainWindow()->currentTab()->page());
+ show();
+ }
+ else
+ {
+ hide();
+ mainWindow()->currentTab()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
+ }
+}
+
+
+void WebInspectorDock::changeCurrentPage()
+{
+ bool enable = mainWindow()->currentTab()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled);
+ toggle(enable);
+}
diff --git a/src/webinspectordock.h b/src/webinspectordock.h
new file mode 100644
index 00000000..c6697361
--- /dev/null
+++ b/src/webinspectordock.h
@@ -0,0 +1,58 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Matthieu Gicquel<matgic78@gmail.com>
+*
+*
+* 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 the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+#ifndef WEBINSPECTORDOCK_H
+#define WEBINSPECTORDOCK_H
+
+
+// Local Includes
+#include "mainwindow.h"
+
+// Qt Includes
+#include <QDockWidget>
+
+/**
+ Docked web inspector
+ behaviour : hide/show by tab, not globally
+*/
+class WebInspectorDock : public QDockWidget
+{
+ Q_OBJECT
+public:
+ WebInspectorDock(QString title, QWidget *parent);
+
+public slots:
+ void toggle(bool enable);
+ void changeCurrentPage();
+
+protected:
+ virtual void closeEvent(QCloseEvent *event);
+
+ MainWindow *mainWindow();
+
+};
+
+#endif \ No newline at end of file