1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

WebInspector: Show close button only when docked

This commit is contained in:
David Rosca 2015-10-15 17:21:51 +02:00
parent 74fc271e25
commit 1af76cb2a9
2 changed files with 15 additions and 14 deletions

View File

@ -55,7 +55,6 @@ PopupWindow::PopupWindow(PopupWebView* view)
m_menuBar = new QMenuBar(this);
QMenu* menuFile = new QMenu(tr("File"));
menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), m_view, SLOT(savePageAs()))->setShortcut(QKeySequence("Ctrl+S"));
menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), m_view, SLOT(sendPageByMail()));
//menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
menuFile->addSeparator();

View File

@ -89,19 +89,21 @@ void WebInspector::unregisterView(QWebEngineView *view)
void WebInspector::loadFinished()
{
// Update close button
page()->runJavaScript(QL1S("var toolbar = document.getElementsByClassName('inspector-view-toolbar')[1];"
"var button = document.createElement('button');"
"button.style.width = '22px';"
"button.style.height = '22px';"
"button.style.border = 'none';"
"button.style.cursor = 'pointer';"
"button.style.background = 'url(qrc:html/close.png) no-repeat';"
"button.style.backgroundPosition = 'center center';"
"button.addEventListener('click', function() {"
" window.close();"
"});"
"toolbar.appendChild(button);"));
// Show close button only when docked
if (!isWindow()) {
page()->runJavaScript(QL1S("var toolbar = document.getElementsByClassName('inspector-view-toolbar')[1];"
"var button = document.createElement('button');"
"button.style.width = '22px';"
"button.style.height = '22px';"
"button.style.border = 'none';"
"button.style.cursor = 'pointer';"
"button.style.background = 'url(qrc:html/close.png) no-repeat';"
"button.style.backgroundPosition = 'center center';"
"button.addEventListener('click', function() {"
" window.close();"
"});"
"toolbar.appendChild(button);"));
}
// Inspect element
if (m_inspectElement) {