From 23bebb3b9d757ffaccf76d0cc4591ce88154bb03 Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 21 Jul 2011 17:16:53 +0200 Subject: [PATCH] Pressing ESC in LocationBar now fill it with address from current tab --- src/navigation/locationbar.cpp | 13 ++++++++++--- src/webview/webtab.cpp | 1 + src/webview/webview.cpp | 12 ++++++++++++ src/webview/webview.h | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/navigation/locationbar.cpp b/src/navigation/locationbar.cpp index 98222286f..62ebcd3f1 100644 --- a/src/navigation/locationbar.cpp +++ b/src/navigation/locationbar.cpp @@ -215,10 +215,17 @@ void LocationBar::clearIcon() void LocationBar::setPrivacy(bool state) { + QString img; if (state) - m_siteIcon->setStyleSheet("QToolButton{border-image: url(:/icons/locationbar/safeline.png); margin-left:2px;}"); + img = "safeline.png"; else - m_siteIcon->setStyleSheet("QToolButton{border-image: url(:/icons/locationbar/searchchoose.png); margin-left:2px;}"); + img = "searchchoose.png"; + +#if QT_VERSION == 0x040800 + m_siteIcon->setStyleSheet("QToolButton{border-image: url(:/icons/locationbar/"+img+"); margin-left:2px; padding-left: 4px; }"); +#else + m_siteIcon->setStyleSheet("QToolButton{border-image: url(:/icons/locationbar/"+img+"); margin-left:2px;}"); +#endif } void LocationBar::focusOutEvent(QFocusEvent* e) @@ -242,7 +249,7 @@ void LocationBar::dropEvent(QDropEvent* event) } } else if (event->mimeData()->hasText()) { - QUrl dropUrl = QUrl(event->mimeData()->text()); + QUrl dropUrl = QUrl(event->mimeData()->text().trimmed()); if (WebView::isUrlValid(dropUrl)) { setText(dropUrl.toString()); p_QupZilla->loadAddress(dropUrl); diff --git a/src/webview/webtab.cpp b/src/webview/webtab.cpp index 7cb6ff878..dbd80f92a 100644 --- a/src/webview/webtab.cpp +++ b/src/webview/webtab.cpp @@ -34,6 +34,7 @@ WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar) m_layout->setSpacing(0); m_view = new WebView(p_QupZilla, this); + m_view->setLocationBar(locationBar); m_layout->addWidget(m_view); setLayout(m_layout); diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index befc56d0c..93245c173 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -569,6 +569,18 @@ void WebView::contextMenuEvent(QContextMenuEvent* event) QWebView::contextMenuEvent(event); } +void WebView::stop() +{ + if (page()) { + emit ipChanged(m_currentIp); + page()->triggerAction(QWebPage::Stop); + loadFinished(true); + + if (m_locationBar->text().isEmpty()) + m_locationBar->setText(url().toEncoded()); + } +} + void WebView::addNotification(QWidget* notif) { emit showNotification(notif); diff --git a/src/webview/webview.h b/src/webview/webview.h index 16476be49..1c3b0accc 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -69,7 +69,7 @@ public: int tabIndex() const; public slots: - void stop(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Stop); loadFinished(true);} } + void stop(); void back(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Back);} } void forward(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Forward);} } void slotReload(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Reload);} }