1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[Fix] Bad behaviour on clicking into selected text in locationbar.

Closes #751
This commit is contained in:
nowrep 2013-02-09 21:55:23 +01:00
parent d81b77a004
commit fcbf1e636b
4 changed files with 42 additions and 4 deletions

View File

@ -453,10 +453,10 @@ void LocationBar::mouseDoubleClickEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton && qzSettings->selectAllOnDoubleClick) {
selectAll();
return;
}
else {
QLineEdit::mouseDoubleClickEvent(event);
}
QLineEdit::mouseDoubleClickEvent(event);
}
void LocationBar::mousePressEvent(QMouseEvent* event)
@ -469,6 +469,24 @@ void LocationBar::mousePressEvent(QMouseEvent* event)
LineEdit::mousePressEvent(event);
}
void LocationBar::mouseReleaseEvent(QMouseEvent* event)
{
// Workaround issue in QLineEdit::setDragEnabled
// It will incorrectly set cursor position at the end
// of selection when clicking into selected text
bool wasSelectedText = !selectedText().isEmpty();
LineEdit::mouseReleaseEvent(event);
bool isSelectedText = !selectedText().isEmpty();
if (wasSelectedText && !isSelectedText) {
QMouseEvent ev(QEvent::MouseButtonPress, event->pos(), event->button(),
event->buttons(), event->modifiers());
mousePressEvent(&ev);
}
}
void LocationBar::keyPressEvent(QKeyEvent* event)
{
switch (event->key()) {

View File

@ -95,6 +95,7 @@ private:
void focusOutEvent(QFocusEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
void dropEvent(QDropEvent* event);

View File

@ -387,3 +387,21 @@ void WebSearchBar::keyPressEvent(QKeyEvent* event)
LineEdit::keyPressEvent(event);
}
void WebSearchBar::mouseReleaseEvent(QMouseEvent* event)
{
// Workaround issue in QLineEdit::setDragEnabled
// It will incorrectly set cursor position at the end
// of selection when clicking into selected text
bool wasSelectedText = !selectedText().isEmpty();
LineEdit::mouseReleaseEvent(event);
bool isSelectedText = !selectedText().isEmpty();
if (wasSelectedText && !isSelectedText) {
QMouseEvent ev(QEvent::MouseButtonPress, event->pos(), event->button(),
event->buttons(), event->modifiers());
mousePressEvent(&ev);
}
}

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -76,6 +76,7 @@ private:
void focusOutEvent(QFocusEvent* e);
void dropEvent(QDropEvent* event);
void keyPressEvent(QKeyEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void completeMenuWithAvailableEngines(QMenu* menu);
void contextMenuEvent(QContextMenuEvent* event);