From edbcb5e54124f6580c182200cb1d42f7aafc6692 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 14 Oct 2011 20:14:57 +0200 Subject: [PATCH] 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. --- bin/locale/sk_SK.qm | Bin 74861 -> 75465 bytes src/QupZilla.pro | 6 ++- src/app/qupzilla.cpp | 36 +++++----------- src/app/qupzilla.h | 7 ++- src/webview/tabwidget.cpp | 2 - src/webview/webinspectordockwidget.cpp | 57 +++++++++++++++++++++++++ src/webview/webinspectordockwidget.h | 34 +++++++++++++++ src/webview/webpage.h | 1 + src/webview/webtab.cpp | 11 ++--- src/webview/webtab.h | 5 +++ src/webview/webview.cpp | 2 +- translations/sk_SK.ts | 4 +- 12 files changed, 123 insertions(+), 42 deletions(-) create mode 100644 src/webview/webinspectordockwidget.cpp create mode 100644 src/webview/webinspectordockwidget.h diff --git a/bin/locale/sk_SK.qm b/bin/locale/sk_SK.qm index ef885ca7347685f765b87793076b97929fad9cc0..709acd580a78b737ecec81ba9a430f005f5a66ef 100644 GIT binary patch delta 2503 zcmY+Fc~sL^7RSH8UzQ*F{UA{m5jxO-kcyPpv6?eO)e*5cVL{Wzb4rL0sxuYCEnY)u|%ZrF3MJ+EGwkuqwDv1w=u#pw1;ZXU>^FlF!S%_uY55 z_tJhwURN()=g)mv8ldAZMwgBY)@@hHYSLfmW3J=>k$bXCk z_V;?&QBRx%bo7@tCh(pAU?H3#x$7Ym=l=y%M|=1<2#Raf!02d1wA}`te1tc0lY!7k z55s@LaJwG(X#$2n7!7>52_sf)0xE;tHi{3hj9|iQWT=peWk9?DJZdZWwp2^L-WCZS=Wn<)e{%H-f z$ZfuDNBQAHU4VKfAM=G1oFHd+`EKLrh`Vf!!pJuzux5pB%9Bg7 zoWDAN_9mIDf&!1pl`V|x06x7V+w`9Xk}r^b-u)7ISu8s+gY>%u*|&jX04Y;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@5b#bN@IWi@r4vAjhoC%C z3QX*z)sl&HYv`b)_Z@5!Qir;LgQ>!fm=tz;LD+FJ7C5_$@psJ?G{D8M@U|ozPEP~m zr^3-MSc2?oq3B)aMO%Sz%+CJ4^gH1z8{;F1X1JKicmr*6F_4yeI>FEyKz&?8$q1nq zSEH`2Nu4cT0!GfLKfCcdFjPv*T#aPt7ix7i5UG$lT=k@53H8yMbVE8#amY15^^T^r z>UU{&Qj0b==!TDGpdg7U^qOX<_6*>bsd3C<@$pR5I5ODP9Tg(>@j%sfkv~=i?9LL! z{9E8OTc|^8B4R2Hlugl`Rs7Sx*{^@Li{Wt=Ah=WvFK0#kpNNrppRrl8#3+f`w&Z;= zx}guab4^TWA7kE{5-r8+m_2Jn%Vm}`#S(GDoJ=6-Eiv`db(XJkdRcx}E_j<|ab>r7 zyj%+o`=~=U1aW)C^YbsUY<(l1zh?&S%@=D{e+R^ch!=BMswxu1?+^O3QY*#A;{CwB zR`Gv(*jDZo(U=*Ah`aN|@sMmF{;oK_c^=zFxWt{^4O}_n$&gFIK@I_W7vQ8>m9?$r!bi6+T_$FF9 z(c!`t93z!=X@N^A(wEy=7nvVR<%gbQIwjLnZl}pe7>&_|lG{DBOqWDj!stwQvu?oV z;^0^TV#9I;q1wN;l=@`a{EV*7hAIZ7)-chk>+x zN^?E*z8YSuyV}H}cTMX~J^?xtwcgQwKvRcy_6pY3{kgQsBg(rwUb|&+HG7yloqSj^ zO-_A*2G7)gsA|y`{9y>l-J(6=#T4wCt37?an$3PnTOYrNZQzgEwj=EJEk)YlkRn$wTLv@gDpnPhPnR>}Z!C mKXU{4d&6Iuttxo{URaK~bmXQ_)qPLWOh@g;s)T;avi}44Se#e@ diff --git a/src/QupZilla.pro b/src/QupZilla.pro index 5d9cd12e9..c35c61c49 100644 --- a/src/QupZilla.pro +++ b/src/QupZilla.pro @@ -148,7 +148,8 @@ SOURCES += main.cpp\ tools/globalfunctions.cpp \ other/pagescreen.cpp \ downloads/downloadfilehelper.cpp \ - tools/certificateinfowidget.cpp + tools/certificateinfowidget.cpp \ + webview/webinspectordockwidget.cpp HEADERS += \ 3rdparty/qtwin.h \ @@ -245,7 +246,8 @@ HEADERS += \ tools/globalfunctions.h \ other/pagescreen.h \ downloads/downloadfilehelper.h \ - tools/certificateinfowidget.h + tools/certificateinfowidget.h \ + webview/webinspectordockwidget.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index f88ae7c29..0cf6de4c3 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -56,6 +56,7 @@ #include "browsinglibrary.h" #include "navigationbar.h" #include "pagescreen.h" +#include "webinspectordockwidget.h" const QString QupZilla::VERSION = "1.0.0-rc1"; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; @@ -886,32 +887,17 @@ void QupZilla::showStatusbar() settings.setValue("Browser-View-Settings/showStatusbar", !status); } -void QupZilla::showInspector() +void QupZilla::showWebInspector() { - if (!m_webInspectorDock) { - m_webInspectorDock = new QDockWidget(this); - if (m_webInspector) - delete m_webInspector; - m_webInspector = new QWebInspector(this); - m_webInspector->setPage(weView()->page()); - 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 + if (m_webInspectorDock) { + m_webInspectorDock->setPage(weView()->webPage()); 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); - } + return; } + + m_webInspectorDock = new WebInspectorDockWidget(this); + connect(m_tabWidget, SIGNAL(currentChanged(int)), m_webInspectorDock, SLOT(tabChanged())); + addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorDock); } void QupZilla::refreshHistory() @@ -1093,8 +1079,6 @@ QupZilla::~QupZilla() delete m_bookmarksToolbar; delete m_progressBar; - if (m_webInspectorDock) { - delete m_webInspector; + if (m_webInspectorDock) delete m_webInspectorDock; - } } diff --git a/src/app/qupzilla.h b/src/app/qupzilla.h index 783dca42d..e77793f2c 100644 --- a/src/app/qupzilla.h +++ b/src/app/qupzilla.h @@ -63,6 +63,7 @@ class ProgressBar; class StatusBarMessage; class NavigationBar; class ClickableLabel; +class WebInspectorDockWidget; class QupZilla : public QMainWindow { Q_OBJECT @@ -85,7 +86,6 @@ public: void addBookmark(const QUrl &url, const QString &title, const QIcon &icon); void installTranslator(); void loadSettings(); - void showInspector(); void showNavigationWithFullscreen(); inline WebView* weView() const { WebTab* webTab = qobject_cast(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 QString activeProfil(){ return m_activeProfil; } inline QString activeLanguage(){ return m_activeLanguage; } - inline QDockWidget* inspectorDock(){ return m_webInspectorDock; } inline QLabel* ipLabel(){ return m_ipLabel; } inline QColor menuTextColor() { return m_menuTextColor; } inline QMenu* menuHelp() { return m_menuHelp; } @@ -115,6 +114,7 @@ signals: public slots: void setWindowTitle(const QString &t); + void showWebInspector(); void showBookmarksToolbar(); void loadActionUrl(); void loadActionUrlInNewTab(); @@ -224,8 +224,7 @@ private: QLabel* m_privateBrowsing; ClickableLabel* m_adblockIcon; - QPointer m_webInspector; - QPointer m_webInspectorDock; + QPointer m_webInspectorDock; BookmarksToolbar* m_bookmarksToolbar; TabWidget* m_tabWidget; diff --git a/src/webview/tabwidget.cpp b/src/webview/tabwidget.cpp index 121f85e1a..1575cb495 100644 --- a/src/webview/tabwidget.cpp +++ b/src/webview/tabwidget.cpp @@ -340,8 +340,6 @@ void TabWidget::currentTabChanged(int index) p_QupZilla->ipLabel()->show(); } - if (p_QupZilla->inspectorDock() && p_QupZilla->inspectorDock()->isVisible()) - p_QupZilla->showInspector(); webView->setFocus(); m_tabBar->updateCloseButton(index); diff --git a/src/webview/webinspectordockwidget.cpp b/src/webview/webinspectordockwidget.cpp new file mode 100644 index 000000000..0801e96a5 --- /dev/null +++ b/src/webview/webinspectordockwidget.cpp @@ -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; +} diff --git a/src/webview/webinspectordockwidget.h b/src/webview/webinspectordockwidget.h new file mode 100644 index 000000000..4ca955efc --- /dev/null +++ b/src/webview/webinspectordockwidget.h @@ -0,0 +1,34 @@ +#ifndef WEBINSPECTORDOCKWIDGET_H +#define WEBINSPECTORDOCKWIDGET_H + +#include +#include +#include +#include + +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 m_inspector; + WebPage* m_page; +}; + +#endif // WEBINSPECTORDOCKWIDGET_H diff --git a/src/webview/webpage.h b/src/webview/webpage.h index 91a677abe..a86f6f24d 100644 --- a/src/webview/webpage.h +++ b/src/webview/webpage.h @@ -30,6 +30,7 @@ #include #include #include +#include class QupZilla; class WebView; diff --git a/src/webview/webtab.cpp b/src/webview/webtab.cpp index dbd80f92a..b1d81b6a1 100644 --- a/src/webview/webtab.cpp +++ b/src/webview/webtab.cpp @@ -23,11 +23,12 @@ #include "locationbar.h" WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar) - :QWidget() - ,p_QupZilla(mainClass) - ,m_view(0) - ,m_locationBar(locationBar) - ,m_pinned(false) + : QWidget() + , p_QupZilla(mainClass) + , m_view(0) + , m_locationBar(locationBar) + , m_pinned(false) + , m_inspectorVisible(false) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0,0,0,0); diff --git a/src/webview/webtab.h b/src/webview/webtab.h index bf9bddd89..d7eb4a142 100644 --- a/src/webview/webtab.h +++ b/src/webview/webtab.h @@ -39,17 +39,22 @@ public: void setLocationBar(LocationBar* bar) { m_locationBar = bar; } LocationBar* locationBar() { return m_locationBar; } + bool inspectorVisible() { return m_inspectorVisible; } + void setInspectorVisible(bool v) { m_inspectorVisible = v; } + private slots: void showNotification(QWidget* notif); private: int tabIndex(); + QupZilla* p_QupZilla; QPointer m_view; QVBoxLayout* m_layout; LocationBar* m_locationBar; bool m_pinned; + bool m_inspectorVisible; }; #endif // WEBTAB_H diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index 1b3527c91..8971a35d7 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -669,7 +669,7 @@ void WebView::bookmarkLink() void WebView::showInspector() { - p_QupZilla->showInspector(); + p_QupZilla->showWebInspector(); } void WebView::showSiteInfo() diff --git a/translations/sk_SK.ts b/translations/sk_SK.ts index f63597d1a..fc361967b 100644 --- a/translations/sk_SK.ts +++ b/translations/sk_SK.ts @@ -3070,7 +3070,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku. After adding or removing certificate paths, it is neccessary to restart browser in order to changes take effect. - + Po pridaní či odstránení ciest k certifikátom je nutné k zobrazeniu zmien reštart počítača. @@ -3095,7 +3095,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku. <b>NOTE:</b> Setting this option is big security risk! - + <b>Poznámka:</b> Zaškrtnutím tejto možnosti sa vystavujete veľkému bezpečnostnému riziku!