mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 22:55:11 +00:00
Use install_base_filter for lib_base.
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "core/event_filter.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
EventFilter::EventFilter(
|
||||
not_null<QObject*> parent,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter)
|
||||
: QObject(parent)
|
||||
, _filter(std::move(filter)) {
|
||||
object->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool EventFilter::eventFilter(QObject *watched, QEvent *event) {
|
||||
return (_filter(event) == Result::Cancel);
|
||||
}
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter) {
|
||||
return InstallEventFilter(object, object, std::move(filter));
|
||||
}
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> context,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter) {
|
||||
return new EventFilter(context, object, std::move(filter));
|
||||
}
|
||||
|
||||
} // namespace Core
|
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Core {
|
||||
|
||||
class EventFilter : public QObject {
|
||||
public:
|
||||
enum Result {
|
||||
Continue,
|
||||
Cancel,
|
||||
};
|
||||
|
||||
EventFilter(
|
||||
not_null<QObject*> parent,
|
||||
not_null<QObject*> object,
|
||||
Fn<Result(not_null<QEvent*>)> filter);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
Fn<Result(not_null<QEvent*>)> _filter;
|
||||
|
||||
};
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter);
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> context,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter);
|
||||
|
||||
} // namespace Core
|
Reference in New Issue
Block a user