2011-10-29 12:24:12 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2011-12-15 18:34:48 +01:00
|
|
|
* Copyright (C) 2010-2011 David Rosca <nowrep@gmail.com>
|
2011-10-29 12:24:12 +02:00
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
* ============================================================ */
|
2011-10-14 20:14:57 +02:00
|
|
|
#include "webinspectordockwidget.h"
|
|
|
|
#include "docktitlebarwidget.h"
|
|
|
|
#include "webpage.h"
|
|
|
|
#include "webview.h"
|
|
|
|
#include "webtab.h"
|
|
|
|
#include "qupzilla.h"
|
|
|
|
|
|
|
|
WebInspectorDockWidget::WebInspectorDockWidget(QupZilla* mainClass)
|
2011-10-14 23:12:10 +02:00
|
|
|
: QDockWidget(mainClass)
|
2011-10-14 20:14:57 +02:00
|
|
|
, p_QupZilla(mainClass)
|
|
|
|
{
|
|
|
|
setWindowTitle(tr("Web Inspector"));
|
|
|
|
setObjectName("WebInspector");
|
|
|
|
setFeatures(0);
|
|
|
|
setTitleBarWidget(new DockTitleBarWidget(tr("Web Inspector"), this));
|
|
|
|
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebInspectorDockWidget::close()
|
|
|
|
{
|
2011-12-18 16:57:14 +01:00
|
|
|
#if (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 2, 0))
|
2011-12-09 21:56:01 +01:00
|
|
|
delete m_inspector.data();
|
2011-12-18 16:57:14 +01:00
|
|
|
#endif
|
2011-10-14 20:14:57 +02:00
|
|
|
p_QupZilla->weView()->webTab()->setInspectorVisible(false);
|
|
|
|
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebInspectorDockWidget::show()
|
|
|
|
{
|
2011-12-09 21:56:01 +01:00
|
|
|
if (!m_inspector.data()) {
|
2011-10-14 20:14:57 +02:00
|
|
|
m_inspector = new QWebInspector(this);
|
2011-12-09 21:56:01 +01:00
|
|
|
m_inspector.data()->setPage(p_QupZilla->weView()->page());
|
|
|
|
setWidget(m_inspector.data());
|
2011-10-14 20:14:57 +02:00
|
|
|
}
|
|
|
|
|
2011-12-09 21:56:01 +01:00
|
|
|
if (m_inspector.data()->page() != p_QupZilla->weView()->page()) {
|
|
|
|
m_inspector.data()->setPage(p_QupZilla->weView()->page());
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-14 20:14:57 +02:00
|
|
|
|
|
|
|
p_QupZilla->weView()->webTab()->setInspectorVisible(true);
|
|
|
|
|
|
|
|
QDockWidget::show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebInspectorDockWidget::tabChanged()
|
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
if (p_QupZilla->weView()->webTab()->inspectorVisible()) {
|
2011-10-14 20:14:57 +02:00
|
|
|
show();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-10-14 20:14:57 +02:00
|
|
|
close();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-10-14 20:14:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WebInspectorDockWidget::~WebInspectorDockWidget()
|
|
|
|
{
|
|
|
|
}
|