summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2009-12-02 18:01:30 +0100
committermatgic78 <matgic78@gmail.com>2009-12-02 18:01:30 +0100
commit2e96585d9a36d95a5dd33859365b6047a133a051 (patch)
treecbb802c6beff6fedb3f37e925825419c5a586fda /src
parentsrc/CMakeLists.txt fix (diff)
downloadrekonq-2e96585d9a36d95a5dd33859365b6047a133a051.tar.xz
Docked web inspector
Diffstat (limited to 'src')
-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.h59
5 files changed, 172 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 23d5595e..78ca3106 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,6 +39,8 @@ SET( rekonq_KDEINIT_SRCS
#----------------------------------------
urlbar/urlbar.cpp
urlbar/lineedit.cpp
+#----------------------------------------
+ webinspectordock.cpp
)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 628743ee..fc005014 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 ==================
@@ -843,25 +857,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..ada3af3f
--- /dev/null
+++ b/src/webinspectordock.cpp
@@ -0,0 +1,82 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot 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..b8ffa6c3
--- /dev/null
+++ b/src/webinspectordock.h
@@ -0,0 +1,59 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+*
+*
+* 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