1 // This file is part of Desktop App Toolkit, 2 // a set of libraries for developing nice desktop applications. 3 // 4 // For license and copyright information please follow this link: 5 // https://github.com/desktop-app/legal/blob/master/LEGAL 6 // 7 #pragma once 8 9 #include "base/basic_types.h" 10 11 #include <QtCore/QObject> 12 13 namespace base { 14 15 enum class EventFilterResult { 16 Continue, 17 Cancel, 18 }; 19 20 not_null<QObject*> install_event_filter( 21 not_null<QObject*> object, 22 Fn<EventFilterResult(not_null<QEvent*>)> filter); 23 24 not_null<QObject*> install_event_filter( 25 not_null<QObject*> context, 26 not_null<QObject*> object, 27 Fn<EventFilterResult(not_null<QEvent*>)> filter); 28 29 namespace details { 30 31 class EventFilter : public QObject { 32 public: 33 EventFilter( 34 not_null<QObject*> parent, 35 not_null<QObject*> object, 36 Fn<EventFilterResult(not_null<QEvent*>)> filter); 37 38 protected: 39 bool eventFilter(QObject *watched, QEvent *event); 40 41 private: 42 Fn<EventFilterResult(not_null<QEvent*>)> _filter; 43 44 }; 45 46 } // namespace details 47 } // namespace base 48