2011-10-29 12:24:12 +02:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 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"
|
2012-01-21 20:27:45 +01:00
|
|
|
#include "tabbedwebview.h"
|
2011-10-14 20:14:57 +02:00
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2012-03-16 16:57:24 +01:00
|
|
|
void WebInspectorDockWidget::toggleVisibility()
|
|
|
|
{
|
|
|
|
if (isVisible()) {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-14 20:14:57 +02:00
|
|
|
void WebInspectorDockWidget::close()
|
|
|
|
{
|
|
|
|
p_QupZilla->weView()->webTab()->setInspectorVisible(false);
|
2012-01-29 17:46:02 +01:00
|
|
|
p_QupZilla->weView()->setFocus();
|
2011-10-14 20:14:57 +02:00
|
|
|
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebInspectorDockWidget::show()
|
|
|
|
{
|
2012-01-29 14:05:57 +01:00
|
|
|
QWebPage* page = p_QupZilla->weView()->page();
|
|
|
|
QWeakPointer<WebInspector> inspector = m_inspectors[page];
|
|
|
|
|
|
|
|
if (!inspector) {
|
|
|
|
inspector = new WebInspector(this);
|
|
|
|
inspector.data()->setPage(p_QupZilla->weView()->page());
|
|
|
|
|
|
|
|
m_inspectors[page] = inspector;
|
2011-10-14 20:14:57 +02:00
|
|
|
}
|
|
|
|
|
2012-01-29 14:05:57 +01:00
|
|
|
if (m_currentInspector != inspector) {
|
|
|
|
setWidget(inspector.data());
|
|
|
|
m_currentInspector = inspector;
|
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()
|
|
|
|
{
|
|
|
|
}
|