1/*
2 SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "kurlnavigatorpathselectoreventfilter_p.h"
8
9#include <QEvent>
10#include <QMenu>
11#include <QMouseEvent>
12
13using namespace KDEPrivate;
14
15KUrlNavigatorPathSelectorEventFilter::KUrlNavigatorPathSelectorEventFilter(QObject *parent)
16 : QObject(parent)
17{
18}
19
20KUrlNavigatorPathSelectorEventFilter::~KUrlNavigatorPathSelectorEventFilter()
21{
22}
23
24bool KUrlNavigatorPathSelectorEventFilter::eventFilter(QObject *watched, QEvent *event)
25{
26 if (event->type() == QEvent::MouseButtonRelease) {
27 QMouseEvent *me = static_cast<QMouseEvent *>(event);
28 if (me->button() == Qt::MiddleButton) {
29 if (QMenu *menu = qobject_cast<QMenu *>(object: watched)) {
30 if (QAction *action = menu->activeAction()) {
31 const QUrl url(action->data().toString());
32 if (url.isValid()) {
33 menu->close();
34
35 Q_EMIT tabRequested(url);
36 return true;
37 }
38 }
39 }
40 }
41 }
42
43 return QObject::eventFilter(watched, event);
44}
45
46#include "moc_kurlnavigatorpathselectoreventfilter_p.cpp"
47

source code of kio/src/filewidgets/kurlnavigatorpathselectoreventfilter.cpp