diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 81377856d..ca3aa3e2e 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -389,7 +389,7 @@ void BrowserWindow::setupMenu() connect(openLocationAction, SIGNAL(activated()), this, SLOT(openLocation())); QShortcut* inspectorAction = new QShortcut(QKeySequence(QSL("F12")), this); - connect(inspectorAction, SIGNAL(activated()), this, SLOT(showWebInspector())); + connect(inspectorAction, SIGNAL(activated()), this, SLOT(toggleWebInspector())); } QAction* BrowserWindow::createEncodingAction(const QString &codecName, @@ -807,6 +807,13 @@ void BrowserWindow::showWebInspector() } } +void BrowserWindow::toggleWebInspector() +{ + if (weView() && weView()->webTab()) { + weView()->webTab()->toggleWebInspector(); + } +} + void BrowserWindow::refreshHistory() { m_navigationToolbar->refreshHistory(); diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h index 971658457..59fcc881a 100644 --- a/src/lib/app/browserwindow.h +++ b/src/lib/app/browserwindow.h @@ -121,6 +121,7 @@ public slots: void setWindowTitle(const QString &t); void showWebInspector(); + void toggleWebInspector(); void showHistoryManager(); void toggleShowMenubar(); diff --git a/src/lib/app/mainmenu.cpp b/src/lib/app/mainmenu.cpp index 6c3f01056..fcf26819f 100644 --- a/src/lib/app/mainmenu.cpp +++ b/src/lib/app/mainmenu.cpp @@ -326,9 +326,9 @@ void MainMenu::showAdBlockDialog() AdBlockManager::instance()->showDialog(); } -void MainMenu::showWebInspector() +void MainMenu::toggleWebInspector() { - callSlot("showWebInspector"); + callSlot("toggleWebInspector"); } void MainMenu::showClearRecentHistoryDialog() @@ -600,7 +600,7 @@ void MainMenu::init() ADD_ACTION("Tools/DownloadManager", m_menuTools, QIcon(), tr("&Download Manager"), SLOT(showDownloadManager()), "Ctrl+Y"); ADD_ACTION("Tools/CookiesManager", m_menuTools, QIcon(), tr("&Cookies Manager"), SLOT(showCookieManager()), ""); ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), ""); - ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(showWebInspector()), "Ctrl+Shift+I"); + ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(toggleWebInspector()), "Ctrl+Shift+I"); ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del"); m_menuTools->addSeparator(); diff --git a/src/lib/app/mainmenu.h b/src/lib/app/mainmenu.h index bedc6983f..5a657cb7d 100644 --- a/src/lib/app/mainmenu.h +++ b/src/lib/app/mainmenu.h @@ -89,7 +89,7 @@ private slots: void showDownloadManager(); void showCookieManager(); void showAdBlockDialog(); - void showWebInspector(); + void toggleWebInspector(); void showClearRecentHistoryDialog(); // Help menu diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp index 5fe02d316..39190baaf 100644 --- a/src/lib/webtab/tabbedwebview.cpp +++ b/src/lib/webtab/tabbedwebview.cpp @@ -69,8 +69,7 @@ void TabbedWebView::setBrowserWindow(BrowserWindow* window) void TabbedWebView::inspectElement() { - if (m_window) - m_window->showWebInspector(); + m_webTab->showWebInspector(); } WebTab* TabbedWebView::webTab() const diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 83a92806c..2c85d7170 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -151,6 +151,17 @@ void WebTab::showWebInspector() m_splitter->addWidget(inspector); } +void WebTab::toggleWebInspector() +{ + if (m_splitter->count() == 1) { + showWebInspector(); + return; + } + + if (m_splitter->count() > 1 && m_splitter->widget(1)->inherits("WebInspector")) + delete m_splitter->widget(1); +} + QUrl WebTab::url() const { if (isRestored()) { diff --git a/src/lib/webtab/webtab.h b/src/lib/webtab/webtab.h index 842453b13..9bfd7e5dd 100644 --- a/src/lib/webtab/webtab.h +++ b/src/lib/webtab/webtab.h @@ -84,7 +84,9 @@ public: int tabIndex() const; bool isCurrentTab() const; + void showWebInspector(); + void toggleWebInspector(); bool isRestored() const; void restoreTab(const SavedTab &tab);