2
0
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:
John Preston
2019-09-19 12:28:36 +03:00
parent a6b96662c4
commit f677b116f9
14 changed files with 43 additions and 124 deletions

View File

@@ -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

View File

@@ -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