1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Rewritten WebInspector. Hopefully fixes #3

When you show Web Inspector panel, it will be open only for actual tab.
So when you change tab, the web inspector panel will hide, and if you go
back to tab with open web inspector, inspector will show.
This commit is contained in:
nowrep 2011-10-14 20:14:57 +02:00
parent 1ded15ab24
commit edbcb5e541
12 changed files with 123 additions and 42 deletions

Binary file not shown.

View File

@ -148,7 +148,8 @@ SOURCES += main.cpp\
tools/globalfunctions.cpp \ tools/globalfunctions.cpp \
other/pagescreen.cpp \ other/pagescreen.cpp \
downloads/downloadfilehelper.cpp \ downloads/downloadfilehelper.cpp \
tools/certificateinfowidget.cpp tools/certificateinfowidget.cpp \
webview/webinspectordockwidget.cpp
HEADERS += \ HEADERS += \
3rdparty/qtwin.h \ 3rdparty/qtwin.h \
@ -245,7 +246,8 @@ HEADERS += \
tools/globalfunctions.h \ tools/globalfunctions.h \
other/pagescreen.h \ other/pagescreen.h \
downloads/downloadfilehelper.h \ downloads/downloadfilehelper.h \
tools/certificateinfowidget.h tools/certificateinfowidget.h \
webview/webinspectordockwidget.h
FORMS += \ FORMS += \
preferences/autofillmanager.ui \ preferences/autofillmanager.ui \

View File

@ -56,6 +56,7 @@
#include "browsinglibrary.h" #include "browsinglibrary.h"
#include "navigationbar.h" #include "navigationbar.h"
#include "pagescreen.h" #include "pagescreen.h"
#include "webinspectordockwidget.h"
const QString QupZilla::VERSION = "1.0.0-rc1"; const QString QupZilla::VERSION = "1.0.0-rc1";
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
@ -886,32 +887,17 @@ void QupZilla::showStatusbar()
settings.setValue("Browser-View-Settings/showStatusbar", !status); settings.setValue("Browser-View-Settings/showStatusbar", !status);
} }
void QupZilla::showInspector() void QupZilla::showWebInspector()
{ {
if (!m_webInspectorDock) { if (m_webInspectorDock) {
m_webInspectorDock = new QDockWidget(this); m_webInspectorDock->setPage(weView()->webPage());
if (m_webInspector) m_webInspectorDock->show();
delete m_webInspector; return;
m_webInspector = new QWebInspector(this); }
m_webInspector->setPage(weView()->page());
m_webInspectorDock = new WebInspectorDockWidget(this);
connect(m_tabWidget, SIGNAL(currentChanged(int)), m_webInspectorDock, SLOT(tabChanged()));
addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock); addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock);
m_webInspectorDock->setWindowTitle(tr("Web Inspector"));
m_webInspectorDock->setTitleBarWidget(new DockTitleBarWidget(tr("Web Inspector"), m_webInspectorDock));
m_webInspectorDock->setObjectName("WebInspector");
m_webInspectorDock->setWidget(m_webInspector);
m_webInspectorDock->setFeatures(0);
m_webInspectorDock->setContextMenuPolicy(Qt::CustomContextMenu);
} else if (m_webInspectorDock->isVisible()) { //Next tab
m_webInspectorDock->show();
m_webInspector->setPage(weView()->page());
m_webInspectorDock->setWidget(m_webInspector);
} else { //Showing hidden dock
m_webInspectorDock->show();
if (m_webInspector->page() != weView()->page()) {
m_webInspector->setPage(weView()->page());
m_webInspectorDock->setWidget(m_webInspector);
}
}
} }
void QupZilla::refreshHistory() void QupZilla::refreshHistory()
@ -1093,8 +1079,6 @@ QupZilla::~QupZilla()
delete m_bookmarksToolbar; delete m_bookmarksToolbar;
delete m_progressBar; delete m_progressBar;
if (m_webInspectorDock) { if (m_webInspectorDock)
delete m_webInspector;
delete m_webInspectorDock; delete m_webInspectorDock;
}
} }

View File

@ -63,6 +63,7 @@ class ProgressBar;
class StatusBarMessage; class StatusBarMessage;
class NavigationBar; class NavigationBar;
class ClickableLabel; class ClickableLabel;
class WebInspectorDockWidget;
class QupZilla : public QMainWindow class QupZilla : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -85,7 +86,6 @@ public:
void addBookmark(const QUrl &url, const QString &title, const QIcon &icon); void addBookmark(const QUrl &url, const QString &title, const QIcon &icon);
void installTranslator(); void installTranslator();
void loadSettings(); void loadSettings();
void showInspector();
void showNavigationWithFullscreen(); void showNavigationWithFullscreen();
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); } inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
@ -99,7 +99,6 @@ public:
inline ProgressBar* progressBar(){ return m_progressBar; } inline ProgressBar* progressBar(){ return m_progressBar; }
inline QString activeProfil(){ return m_activeProfil; } inline QString activeProfil(){ return m_activeProfil; }
inline QString activeLanguage(){ return m_activeLanguage; } inline QString activeLanguage(){ return m_activeLanguage; }
inline QDockWidget* inspectorDock(){ return m_webInspectorDock; }
inline QLabel* ipLabel(){ return m_ipLabel; } inline QLabel* ipLabel(){ return m_ipLabel; }
inline QColor menuTextColor() { return m_menuTextColor; } inline QColor menuTextColor() { return m_menuTextColor; }
inline QMenu* menuHelp() { return m_menuHelp; } inline QMenu* menuHelp() { return m_menuHelp; }
@ -115,6 +114,7 @@ signals:
public slots: public slots:
void setWindowTitle(const QString &t); void setWindowTitle(const QString &t);
void showWebInspector();
void showBookmarksToolbar(); void showBookmarksToolbar();
void loadActionUrl(); void loadActionUrl();
void loadActionUrlInNewTab(); void loadActionUrlInNewTab();
@ -224,8 +224,7 @@ private:
QLabel* m_privateBrowsing; QLabel* m_privateBrowsing;
ClickableLabel* m_adblockIcon; ClickableLabel* m_adblockIcon;
QPointer<QWebInspector> m_webInspector; QPointer<WebInspectorDockWidget> m_webInspectorDock;
QPointer<QDockWidget> m_webInspectorDock;
BookmarksToolbar* m_bookmarksToolbar; BookmarksToolbar* m_bookmarksToolbar;
TabWidget* m_tabWidget; TabWidget* m_tabWidget;

View File

@ -340,8 +340,6 @@ void TabWidget::currentTabChanged(int index)
p_QupZilla->ipLabel()->show(); p_QupZilla->ipLabel()->show();
} }
if (p_QupZilla->inspectorDock() && p_QupZilla->inspectorDock()->isVisible())
p_QupZilla->showInspector();
webView->setFocus(); webView->setFocus();
m_tabBar->updateCloseButton(index); m_tabBar->updateCloseButton(index);

View File

@ -0,0 +1,57 @@
#include "webinspectordockwidget.h"
#include "docktitlebarwidget.h"
#include "webpage.h"
#include "webview.h"
#include "webtab.h"
#include "qupzilla.h"
WebInspectorDockWidget::WebInspectorDockWidget(QupZilla* mainClass)
: QDockWidget()
, p_QupZilla(mainClass)
, m_inspector(0)
{
setWindowTitle(tr("Web Inspector"));
setObjectName("WebInspector");
setFeatures(0);
setTitleBarWidget(new DockTitleBarWidget(tr("Web Inspector"), this));
show();
}
void WebInspectorDockWidget::close()
{
delete m_inspector;
p_QupZilla->weView()->webTab()->setInspectorVisible(false);
hide();
}
void WebInspectorDockWidget::show()
{
if (!m_inspector) {
m_inspector = new QWebInspector(this);
m_inspector->setPage(p_QupZilla->weView()->page());
setWidget(m_inspector);
}
if (m_inspector->page() != p_QupZilla->weView()->page())
m_inspector->setPage(p_QupZilla->weView()->page());
p_QupZilla->weView()->webTab()->setInspectorVisible(true);
QDockWidget::show();
}
void WebInspectorDockWidget::tabChanged()
{
if (p_QupZilla->weView()->webTab()->inspectorVisible())
show();
else
close();
}
WebInspectorDockWidget::~WebInspectorDockWidget()
{
if (m_inspector)
delete m_inspector;
}

View File

@ -0,0 +1,34 @@
#ifndef WEBINSPECTORDOCKWIDGET_H
#define WEBINSPECTORDOCKWIDGET_H
#include <QDockWidget>
#include <QWebInspector>
#include <QPair>
#include <QPointer>
class WebPage;
class QupZilla;
class WebInspectorDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit WebInspectorDockWidget(QupZilla* mainClass);
~WebInspectorDockWidget();
void setPage(WebPage* page) { m_page = page; }
signals:
public slots:
void tabChanged();
void close();
void show();
private:
QupZilla* p_QupZilla;
QPointer<QWebInspector> m_inspector;
WebPage* m_page;
};
#endif // WEBINSPECTORDOCKWIDGET_H

View File

@ -30,6 +30,7 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QStyle> #include <QStyle>
#include <QFileDialog> #include <QFileDialog>
#include <QWebInspector>
class QupZilla; class QupZilla;
class WebView; class WebView;

View File

@ -23,11 +23,12 @@
#include "locationbar.h" #include "locationbar.h"
WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar) WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
:QWidget() : QWidget()
,p_QupZilla(mainClass) , p_QupZilla(mainClass)
,m_view(0) , m_view(0)
,m_locationBar(locationBar) , m_locationBar(locationBar)
,m_pinned(false) , m_pinned(false)
, m_inspectorVisible(false)
{ {
m_layout = new QVBoxLayout(this); m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0,0,0,0); m_layout->setContentsMargins(0,0,0,0);

View File

@ -39,17 +39,22 @@ public:
void setLocationBar(LocationBar* bar) { m_locationBar = bar; } void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
LocationBar* locationBar() { return m_locationBar; } LocationBar* locationBar() { return m_locationBar; }
bool inspectorVisible() { return m_inspectorVisible; }
void setInspectorVisible(bool v) { m_inspectorVisible = v; }
private slots: private slots:
void showNotification(QWidget* notif); void showNotification(QWidget* notif);
private: private:
int tabIndex(); int tabIndex();
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
QPointer<WebView> m_view; QPointer<WebView> m_view;
QVBoxLayout* m_layout; QVBoxLayout* m_layout;
LocationBar* m_locationBar; LocationBar* m_locationBar;
bool m_pinned; bool m_pinned;
bool m_inspectorVisible;
}; };
#endif // WEBTAB_H #endif // WEBTAB_H

View File

@ -669,7 +669,7 @@ void WebView::bookmarkLink()
void WebView::showInspector() void WebView::showInspector()
{ {
p_QupZilla->showInspector(); p_QupZilla->showWebInspector();
} }
void WebView::showSiteInfo() void WebView::showSiteInfo()

View File

@ -3070,7 +3070,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku.</tran
<message> <message>
<location filename="../src/preferences/sslmanager.ui" line="232"/> <location filename="../src/preferences/sslmanager.ui" line="232"/>
<source>After adding or removing certificate paths, it is neccessary to restart browser in order to changes take effect.</source> <source>After adding or removing certificate paths, it is neccessary to restart browser in order to changes take effect.</source>
<translation type="unfinished"></translation> <translation>Po pridaní či odstránení ciest k certifikátom je nutné k zobrazeniu zmien reštart počítača.</translation>
</message> </message>
<message> <message>
<location filename="../src/preferences/sslmanager.ui" line="108"/> <location filename="../src/preferences/sslmanager.ui" line="108"/>
@ -3095,7 +3095,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku.</tran
<message> <message>
<location filename="../src/preferences/sslmanager.ui" line="171"/> <location filename="../src/preferences/sslmanager.ui" line="171"/>
<source>&lt;b&gt;NOTE:&lt;/b&gt; Setting this option is big security risk!</source> <source>&lt;b&gt;NOTE:&lt;/b&gt; Setting this option is big security risk!</source>
<translation type="unfinished"></translation> <translation>&lt;b&gt;Poznámka:&lt;/b&gt; Zaškrtnutím tejto možnosti sa vystavujete veľkému bezpečnostnému riziku!</translation>
</message> </message>
<message> <message>
<location filename="../src/preferences/sslmanager.ui" line="210"/> <location filename="../src/preferences/sslmanager.ui" line="210"/>