KIO

kurlnavigatorpathselectoreventfilter.cpp
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 *>(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"
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
MouseButtonRelease
virtual bool eventFilter(QObject *watched, QEvent *event)
Qt::MouseButton button() const const
MiddleButton
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.