mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 12: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:
parent
1ded15ab24
commit
edbcb5e541
Binary file not shown.
@ -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 \
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<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 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<QWebInspector> m_webInspector;
|
||||
QPointer<QDockWidget> m_webInspectorDock;
|
||||
QPointer<WebInspectorDockWidget> m_webInspectorDock;
|
||||
|
||||
BookmarksToolbar* m_bookmarksToolbar;
|
||||
TabWidget* m_tabWidget;
|
||||
|
@ -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);
|
||||
|
57
src/webview/webinspectordockwidget.cpp
Normal file
57
src/webview/webinspectordockwidget.cpp
Normal 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;
|
||||
}
|
34
src/webview/webinspectordockwidget.h
Normal file
34
src/webview/webinspectordockwidget.h
Normal 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
|
@ -30,6 +30,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QStyle>
|
||||
#include <QFileDialog>
|
||||
#include <QWebInspector>
|
||||
|
||||
class QupZilla;
|
||||
class WebView;
|
||||
|
@ -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);
|
||||
|
@ -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<WebView> m_view;
|
||||
QVBoxLayout* m_layout;
|
||||
LocationBar* m_locationBar;
|
||||
|
||||
bool m_pinned;
|
||||
bool m_inspectorVisible;
|
||||
};
|
||||
|
||||
#endif // WEBTAB_H
|
||||
|
@ -669,7 +669,7 @@ void WebView::bookmarkLink()
|
||||
|
||||
void WebView::showInspector()
|
||||
{
|
||||
p_QupZilla->showInspector();
|
||||
p_QupZilla->showWebInspector();
|
||||
}
|
||||
|
||||
void WebView::showSiteInfo()
|
||||
|
@ -3070,7 +3070,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku.</tran
|
||||
<message>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<location filename="../src/preferences/sslmanager.ui" line="171"/>
|
||||
<source><b>NOTE:</b> Setting this option is big security risk!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation><b>Poznámka:</b> Zaškrtnutím tejto možnosti sa vystavujete veľkému bezpečnostnému riziku!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/preferences/sslmanager.ui" line="210"/>
|
||||
|
Loading…
Reference in New Issue
Block a user