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

Handling Ctrl+Middle clicks on links in keyReleaseEvent.

- fixes problems when you open link in new tab (with middle
  mouse click) and also paste text to focused input element
This commit is contained in:
nowrep 2012-01-24 19:12:31 +01:00
parent a09766a2ee
commit 16526b0177
33 changed files with 1056 additions and 1100 deletions

View File

@ -83,8 +83,8 @@ private:
SearchEnginesManager* m_searchManager;
QWeakPointer<SearchEnginesDialog> m_searchDialog;
QAction* m_pasteAndGoAction;
QMenu* m_menu;
QAction* m_pasteAndGoAction;
};

View File

@ -771,37 +771,60 @@ void WebView::mousePressEvent(QMouseEvent* event)
break;
case Qt::MiddleButton: {
QWebFrame* frame = page()->frameAt(event->pos());
if (frame) {
QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (isUrlValid(link)) {
openUrlInNewTab(link, m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab);
event->accept();
return;
}
}
#ifdef Q_WS_WIN
else {
QWebFrame* frame = page()->frameAt(event->pos());
if (frame && frame->hitTestContent(event->pos()).linkUrl().isEmpty()) {
// Creating auto scroll on Windows
m_clickedUrl = QUrl();
QWebView::mouseDoubleClickEvent(event);
return;
}
#endif
}
case Qt::LeftButton: {
QWebFrame* frame = page()->frameAt(event->pos());
if (frame) {
m_clickedUrl = frame->hitTestContent(event->pos()).linkUrl();
}
}
default:
break;
}
QWebView::mousePressEvent(event);
}
void WebView::mouseReleaseEvent(QMouseEvent* event)
{
switch (event->button()) {
case Qt::MiddleButton: {
QWebFrame* frame = page()->frameAt(event->pos());
if (frame) {
QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && isUrlValid(link)) {
openUrlInNewTab(link, Qz::NT_NotSelectedTab);
event->accept();
return;
}
}
break;
}
case Qt::LeftButton: {
QWebFrame* frame = page()->frameAt(event->pos());
if (frame && event->modifiers() == Qt::ControlModifier) {
if (frame) {
QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && event->modifiers() == Qt::ControlModifier) {
if (isUrlValid(link)) {
openUrlInNewTab(link, m_newTabAfterActive ? Qz::NT_NotSelectedTab : Qz::NT_CleanTab);
event->accept();
return;
}
}
}
break;
}
@ -810,7 +833,7 @@ void WebView::mousePressEvent(QMouseEvent* event)
break;
}
QWebView::mousePressEvent(event);
QWebView::mouseReleaseEvent(event);
}
void WebView::keyPressEvent(QKeyEvent* event)

View File

@ -108,6 +108,7 @@ protected slots:
protected:
void wheelEvent(QWheelEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void resizeEvent(QResizeEvent* event);
@ -143,6 +144,7 @@ private:
QWebElement m_mediaElement;
QWebFrame* m_clickedFrame;
QUrl m_clickedUrl;
bool m_actionsHaveImages;
bool m_newTabAfterActive;

File diff suppressed because it is too large Load Diff