1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

LocationBar: Replace all contents when dropping text

This commit is contained in:
David Rosca 2016-12-24 11:41:50 +01:00
parent 299d554a8e
commit 1a0ec338de

View File

@ -436,7 +436,7 @@ void LocationBar::focusOutEvent(QFocusEvent* event)
void LocationBar::dropEvent(QDropEvent* event)
{
if (event->mimeData()->hasUrls()) {
QUrl dropUrl = event->mimeData()->urls().at(0);
const QUrl dropUrl = event->mimeData()->urls().at(0);
if (WebView::isUrlValid(dropUrl)) {
setText(dropUrl.toString());
@ -449,7 +449,8 @@ void LocationBar::dropEvent(QDropEvent* event)
}
}
else if (event->mimeData()->hasText()) {
QUrl dropUrl = QUrl(event->mimeData()->text().trimmed());
const QString dropText = event->mimeData()->text().trimmed();
const QUrl dropUrl = QUrl(dropText);
if (WebView::isUrlValid(dropUrl)) {
setText(dropUrl.toString());
@ -459,8 +460,11 @@ void LocationBar::dropEvent(QDropEvent* event)
QFocusEvent event(QFocusEvent::FocusOut);
LineEdit::focusOutEvent(&event);
return;
} else {
setText(dropText);
setFocus();
return;
}
}
LineEdit::dropEvent(event);