/* 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 #include #include #include "base/basic_types.h" namespace base { class InvokeQueuedEvent : public QEvent { public: static constexpr auto kType = QEvent::Type(60666); explicit InvokeQueuedEvent(FnMut &&method) : QEvent(kType) , _method(std::move(method)) { } void invoke() { _method(); } private: FnMut _method; }; } // namespace base template inline void InvokeQueued(const QObject *context, Lambda &&lambda) { QCoreApplication::postEvent( const_cast(context), new base::InvokeQueuedEvent(std::forward(lambda))); }