mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-20 18:28:11 +00:00
Replace base::lambda with shorter term.
base::lambda -> Fn (type alias for std::function). base::lambda_once -> FnMut (type alias for base::unique_function). base::lambda_guarded -> crl::guard. base::lambda_call_type_t -> crl::deduced_call_type.
This commit is contained in:
parent
8d1cdea31a
commit
dd81f5d59f
@ -149,7 +149,7 @@ ApiWrap::ApiWrap(not_null<AuthSession*> session)
|
||||
|
||||
void ApiWrap::requestChangelog(
|
||||
const QString &sinceVersion,
|
||||
base::lambda<void(const MTPUpdates &result)> callback) {
|
||||
Fn<void(const MTPUpdates &result)> callback) {
|
||||
request(MTPhelp_GetAppChangelog(
|
||||
MTP_string(sinceVersion)
|
||||
)).done(
|
||||
@ -235,7 +235,7 @@ void ApiWrap::proxyPromotionDone(const MTPhelp_ProxyData &proxy) {
|
||||
|
||||
void ApiWrap::requestDeepLinkInfo(
|
||||
const QString &path,
|
||||
base::lambda<void(const MTPDhelp_deepLinkInfo &result)> callback) {
|
||||
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback) {
|
||||
request(_deepLinkInfoRequestId).cancel();
|
||||
_deepLinkInfoRequestId = request(MTPhelp_GetDeepLinkInfo(
|
||||
MTP_string(path)
|
||||
@ -276,7 +276,7 @@ void ApiWrap::savePinnedOrder() {
|
||||
//void ApiWrap::toggleChannelGrouping(
|
||||
// not_null<ChannelData*> channel,
|
||||
// bool group,
|
||||
// base::lambda<void()> callback) {
|
||||
// Fn<void()> callback) {
|
||||
// if (const auto already = _channelGroupingRequests.take(channel)) {
|
||||
// request(already->first).cancel();
|
||||
// }
|
||||
@ -1419,7 +1419,7 @@ void ApiWrap::deleteAllFromUserSend(
|
||||
|
||||
void ApiWrap::requestChannelMembersForAdd(
|
||||
not_null<ChannelData*> channel,
|
||||
base::lambda<void(const MTPchannels_ChannelParticipants&)> callback) {
|
||||
Fn<void(const MTPchannels_ChannelParticipants&)> callback) {
|
||||
_channelMembersForAddCallback = std::move(callback);
|
||||
if (_channelMembersForAdd == channel) {
|
||||
return;
|
||||
@ -2617,10 +2617,10 @@ void ApiWrap::readFeaturedSets() {
|
||||
void ApiWrap::parseChannelParticipants(
|
||||
not_null<ChannelData*> channel,
|
||||
const MTPchannels_ChannelParticipants &result,
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list)> callbackList,
|
||||
base::lambda<void()> callbackNotModified) {
|
||||
Fn<void()> callbackNotModified) {
|
||||
TLHelp::VisitChannelParticipants(result, base::overload([&](
|
||||
const MTPDchannels_channelParticipants &data) {
|
||||
App::feedUsers(data.vusers);
|
||||
@ -2654,10 +2654,10 @@ void ApiWrap::refreshChannelAdmins(
|
||||
void ApiWrap::parseRecentChannelParticipants(
|
||||
not_null<ChannelData*> channel,
|
||||
const MTPchannels_ChannelParticipants &result,
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list)> callbackList,
|
||||
base::lambda<void()> callbackNotModified) {
|
||||
Fn<void()> callbackNotModified) {
|
||||
parseChannelParticipants(channel, result, [&](
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list) {
|
||||
@ -3536,12 +3536,12 @@ void ApiWrap::sendAction(const SendOptions &options) {
|
||||
void ApiWrap::forwardMessages(
|
||||
HistoryItemsList &&items,
|
||||
const SendOptions &options,
|
||||
base::lambda_once<void()> &&successCallback) {
|
||||
FnMut<void()> &&successCallback) {
|
||||
Expects(!items.empty());
|
||||
|
||||
struct SharedCallback {
|
||||
int requestsLeft = 0;
|
||||
base::lambda_once<void()> callback;
|
||||
FnMut<void()> callback;
|
||||
};
|
||||
const auto shared = successCallback
|
||||
? std::make_shared<SharedCallback>()
|
||||
|
@ -63,10 +63,10 @@ public:
|
||||
//void toggleChannelGrouping( // #feed
|
||||
// not_null<ChannelData*> channel,
|
||||
// bool group,
|
||||
// base::lambda<void()> callback);
|
||||
// Fn<void()> callback);
|
||||
//void ungroupAllFromFeed(not_null<Data::Feed*> feed);
|
||||
|
||||
using RequestMessageDataCallback = base::lambda<void(ChannelData*, MsgId)>;
|
||||
using RequestMessageDataCallback = Fn<void(ChannelData*, MsgId)>;
|
||||
void requestMessageData(
|
||||
ChannelData *channel,
|
||||
MsgId msgId,
|
||||
@ -92,15 +92,15 @@ public:
|
||||
|
||||
void requestChangelog(
|
||||
const QString &sinceVersion,
|
||||
base::lambda<void(const MTPUpdates &result)> callback);
|
||||
Fn<void(const MTPUpdates &result)> callback);
|
||||
void refreshProxyPromotion();
|
||||
void requestDeepLinkInfo(
|
||||
const QString &path,
|
||||
base::lambda<void(const MTPDhelp_deepLinkInfo &result)> callback);
|
||||
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback);
|
||||
|
||||
void requestChannelMembersForAdd(
|
||||
not_null<ChannelData*> channel,
|
||||
base::lambda<void(const MTPchannels_ChannelParticipants&)> callback);
|
||||
Fn<void(const MTPchannels_ChannelParticipants&)> callback);
|
||||
void processFullPeer(PeerData *peer, const MTPmessages_ChatFull &result);
|
||||
void processFullPeer(UserData *user, const MTPUserFull &result);
|
||||
|
||||
@ -206,17 +206,17 @@ public:
|
||||
void parseChannelParticipants(
|
||||
not_null<ChannelData*> channel,
|
||||
const MTPchannels_ChannelParticipants &result,
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list)> callbackList,
|
||||
base::lambda<void()> callbackNotModified = nullptr);
|
||||
Fn<void()> callbackNotModified = nullptr);
|
||||
void parseRecentChannelParticipants(
|
||||
not_null<ChannelData*> channel,
|
||||
const MTPchannels_ChannelParticipants &result,
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list)> callbackList,
|
||||
base::lambda<void()> callbackNotModified = nullptr);
|
||||
Fn<void()> callbackNotModified = nullptr);
|
||||
|
||||
struct SendOptions {
|
||||
SendOptions(not_null<History*> history) : history(history) {
|
||||
@ -235,7 +235,7 @@ public:
|
||||
void forwardMessages(
|
||||
HistoryItemsList &&items,
|
||||
const SendOptions &options,
|
||||
base::lambda_once<void()> &&successCallback = nullptr);
|
||||
FnMut<void()> &&successCallback = nullptr);
|
||||
void shareContact(
|
||||
const QString &phone,
|
||||
const QString &firstName,
|
||||
@ -462,11 +462,11 @@ private:
|
||||
|
||||
ChannelData *_channelMembersForAdd = nullptr;
|
||||
mtpRequestId _channelMembersForAddRequestId = 0;
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
const MTPchannels_ChannelParticipants&)> _channelMembersForAddCallback;
|
||||
base::flat_map<
|
||||
not_null<ChannelData*>,
|
||||
std::pair<mtpRequestId,base::lambda<void()>>> _channelGroupingRequests;
|
||||
std::pair<mtpRequestId,Fn<void()>>> _channelGroupingRequests;
|
||||
|
||||
using KickRequest = std::pair<
|
||||
not_null<ChannelData*>,
|
||||
|
@ -1150,7 +1150,7 @@ namespace {
|
||||
return i.value();
|
||||
}
|
||||
|
||||
void enumerateUsers(base::lambda<void(not_null<UserData*>)> action) {
|
||||
void enumerateUsers(Fn<void(not_null<UserData*>)> action) {
|
||||
for_const (const auto peer, peersData) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
action(user);
|
||||
@ -1159,7 +1159,7 @@ namespace {
|
||||
}
|
||||
|
||||
void enumerateChatsChannels(
|
||||
base::lambda<void(not_null<PeerData*>)> action) {
|
||||
Fn<void(not_null<PeerData*>)> action) {
|
||||
for_const (const auto peer, peersData) {
|
||||
if (!peer->isUser()) {
|
||||
action(peer);
|
||||
|
@ -135,9 +135,9 @@ namespace App {
|
||||
inline ChannelData *channelLoaded(ChannelId channelId) {
|
||||
return channel(channelId, PeerData::FullLoaded);
|
||||
}
|
||||
void enumerateUsers(base::lambda<void(not_null<UserData*>)> action);
|
||||
void enumerateUsers(Fn<void(not_null<UserData*>)> action);
|
||||
void enumerateChatsChannels(
|
||||
base::lambda<void(not_null<PeerData*>)> action);
|
||||
Fn<void(not_null<PeerData*>)> action);
|
||||
|
||||
UserData *self();
|
||||
PeerData *peerByName(const QString &username);
|
||||
|
@ -1,487 +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
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifndef CUSTOM_LAMBDA_WRAP
|
||||
|
||||
#include <functional>
|
||||
#include "base/unique_function.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename Function>
|
||||
using lambda = std::function<Function>;
|
||||
|
||||
template <typename Function>
|
||||
using lambda_once = unique_function<Function>;
|
||||
|
||||
namespace lambda_internal {
|
||||
|
||||
template <typename Lambda>
|
||||
struct lambda_call_type {
|
||||
using type = decltype(&Lambda::operator());
|
||||
};
|
||||
|
||||
} // namespace lambda_internal
|
||||
|
||||
template <typename Lambda>
|
||||
using lambda_call_type_t
|
||||
= typename lambda_internal::lambda_call_type<Lambda>::type;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#else // CUSTOM_LAMBDA_WRAP
|
||||
|
||||
#ifndef Assert
|
||||
#define LambdaAssertDefined
|
||||
#define Assert(v) ((v) ? ((void)0) : std::abort())
|
||||
#endif // Assert
|
||||
|
||||
#ifndef Unexpected
|
||||
#define LambdaUnexpectedDefined
|
||||
#define Unexpected(v) std::abort()
|
||||
#endif // Unexpected
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename Function> class lambda_once;
|
||||
template <typename Function> class lambda;
|
||||
|
||||
// Get lambda type from a lambda template parameter.
|
||||
|
||||
namespace lambda_internal {
|
||||
|
||||
template <typename FunctionType>
|
||||
struct type_resolver;
|
||||
|
||||
template <typename Lambda, typename R, typename ...Args>
|
||||
struct type_resolver<R(Lambda::*)(Args...) const> {
|
||||
using type = lambda<R(Args...)>;
|
||||
static constexpr auto is_mutable = false;
|
||||
};
|
||||
|
||||
template <typename Lambda, typename R, typename ...Args>
|
||||
struct type_resolver<R(Lambda::*)(Args...)> {
|
||||
using type = lambda_once<R(Args...)>;
|
||||
static constexpr auto is_mutable = true;
|
||||
};
|
||||
|
||||
template <typename Lambda>
|
||||
struct type_helper {
|
||||
using type = typename type_resolver<decltype(&Lambda::operator())>::type;
|
||||
static constexpr auto is_mutable = type_resolver<decltype(&Lambda::operator())>::is_mutable;
|
||||
};
|
||||
|
||||
} // namespace lambda_internal
|
||||
|
||||
template <typename Lambda>
|
||||
using lambda_type = typename lambda_internal::type_helper<std::decay_t<Lambda>>::type;
|
||||
|
||||
namespace lambda_internal {
|
||||
|
||||
constexpr auto kFullStorageSize = 32U;
|
||||
static_assert(kFullStorageSize % sizeof(void*) == 0, "Invalid pointer size!");
|
||||
|
||||
constexpr auto kStorageSize = kFullStorageSize - sizeof(void*);
|
||||
using alignment = std::max_align_t;
|
||||
|
||||
template <typename Lambda>
|
||||
constexpr bool is_large = (sizeof(std::decay_t<Lambda>) > kStorageSize);
|
||||
|
||||
[[noreturn]] inline void bad_construct_copy(void *lambda, const void *source) {
|
||||
Unexpected("base::lambda bad_construct_copy() called!");
|
||||
}
|
||||
|
||||
template <typename Return, typename ...Args>
|
||||
[[noreturn]] Return bad_const_call(const void *lambda, Args...) {
|
||||
Unexpected("base::lambda bad_const_call() called!");
|
||||
}
|
||||
|
||||
template <typename Return, typename ...Args>
|
||||
struct vtable_base {
|
||||
using construct_copy_other_type = void(*)(void *, const void *); // dst, src
|
||||
using construct_move_other_type = void(*)(void *, void *); // dst, src
|
||||
using const_call_type = Return(*)(const void *, Args...);
|
||||
using call_type = Return(*)(void *, Args...);
|
||||
using destruct_type = void(*)(const void *);
|
||||
|
||||
vtable_base() = delete;
|
||||
vtable_base(const vtable_base &other) = delete;
|
||||
vtable_base &operator=(const vtable_base &other) = delete;
|
||||
|
||||
vtable_base(
|
||||
construct_copy_other_type construct_copy_other,
|
||||
construct_move_other_type construct_move_other,
|
||||
const_call_type const_call,
|
||||
call_type call,
|
||||
destruct_type destruct)
|
||||
: construct_copy_other(construct_copy_other)
|
||||
, construct_move_other(construct_move_other)
|
||||
, const_call(const_call)
|
||||
, call(call)
|
||||
, destruct(destruct) {
|
||||
}
|
||||
|
||||
const construct_copy_other_type construct_copy_other;
|
||||
const construct_move_other_type construct_move_other;
|
||||
const const_call_type const_call;
|
||||
const call_type call;
|
||||
const destruct_type destruct;
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda, bool IsLarge, typename Return, typename ...Args> struct vtable_once_impl;
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable_once_impl<Lambda, true, Return, Args...> : public vtable_base<Return, Args...> {
|
||||
using JustLambda = std::decay_t<Lambda>;
|
||||
using LambdaPtr = std::unique_ptr<JustLambda>;
|
||||
using Parent = vtable_base<Return, Args...>;
|
||||
static void construct_move_other_method(void *storage, void *source) {
|
||||
auto source_lambda_ptr = static_cast<LambdaPtr*>(source);
|
||||
new (storage) LambdaPtr(std::move(*source_lambda_ptr));
|
||||
}
|
||||
static Return call_method(void *storage, Args... args) {
|
||||
return (**static_cast<LambdaPtr*>(storage))(std::forward<Args>(args)...);
|
||||
}
|
||||
static void destruct_method(const void *storage) {
|
||||
static_cast<const LambdaPtr*>(storage)->~LambdaPtr();
|
||||
}
|
||||
vtable_once_impl() : Parent(
|
||||
&bad_construct_copy,
|
||||
&vtable_once_impl::construct_move_other_method,
|
||||
&bad_const_call<Return, Args...>,
|
||||
&vtable_once_impl::call_method,
|
||||
&vtable_once_impl::destruct_method) {
|
||||
}
|
||||
|
||||
// Used directly.
|
||||
static void construct_move_lambda_method(void *storage, void *source) {
|
||||
auto source_lambda = static_cast<JustLambda*>(source);
|
||||
new (storage) LambdaPtr(std::make_unique<JustLambda>(static_cast<JustLambda&&>(*source_lambda)));
|
||||
}
|
||||
|
||||
protected:
|
||||
vtable_once_impl(
|
||||
typename Parent::construct_copy_other_type construct_copy_other,
|
||||
typename Parent::const_call_type const_call
|
||||
) : Parent(
|
||||
construct_copy_other,
|
||||
&vtable_once_impl::construct_move_other_method,
|
||||
const_call,
|
||||
&vtable_once_impl::call_method,
|
||||
&vtable_once_impl::destruct_method) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable_once_impl<Lambda, false, Return, Args...> : public vtable_base<Return, Args...> {
|
||||
using JustLambda = std::decay_t<Lambda>;
|
||||
using Parent = vtable_base<Return, Args...>;
|
||||
static void construct_move_other_method(void *storage, void *source) {
|
||||
auto source_lambda = static_cast<JustLambda*>(source);
|
||||
new (storage) JustLambda(static_cast<JustLambda&&>(*source_lambda));
|
||||
}
|
||||
static Return call_method(void *storage, Args... args) {
|
||||
return (*static_cast<JustLambda*>(storage))(std::forward<Args>(args)...);
|
||||
}
|
||||
static void destruct_method(const void *storage) {
|
||||
static_cast<const JustLambda*>(storage)->~JustLambda();
|
||||
}
|
||||
vtable_once_impl() : Parent(
|
||||
&bad_construct_copy,
|
||||
&vtable_once_impl::construct_move_other_method,
|
||||
&bad_const_call<Return, Args...>,
|
||||
&vtable_once_impl::call_method,
|
||||
&vtable_once_impl::destruct_method) {
|
||||
}
|
||||
|
||||
// Used directly.
|
||||
static void construct_move_lambda_method(void *storage, void *source) {
|
||||
auto source_lambda = static_cast<JustLambda*>(source);
|
||||
new (storage) JustLambda(static_cast<JustLambda&&>(*source_lambda));
|
||||
}
|
||||
|
||||
protected:
|
||||
vtable_once_impl(
|
||||
typename Parent::construct_copy_other_type construct_copy_other,
|
||||
typename Parent::const_call_type const_call
|
||||
) : Parent(
|
||||
construct_copy_other,
|
||||
&vtable_once_impl::construct_move_other_method,
|
||||
const_call,
|
||||
&vtable_once_impl::call_method,
|
||||
&vtable_once_impl::destruct_method) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable_once : public vtable_once_impl<Lambda, is_large<Lambda>, Return, Args...> {
|
||||
static const vtable_once instance;
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
const vtable_once<Lambda, Return, Args...> vtable_once<Lambda, Return, Args...>::instance = {};
|
||||
|
||||
template <typename Lambda, bool IsLarge, typename Return, typename ...Args> struct vtable_impl;
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable_impl<Lambda, true, Return, Args...> : public vtable_once_impl<Lambda, true, Return, Args...> {
|
||||
using JustLambda = std::decay_t<Lambda>;
|
||||
using LambdaPtr = std::unique_ptr<JustLambda>;
|
||||
using Parent = vtable_once_impl<Lambda, true, Return, Args...>;
|
||||
static void construct_copy_other_method(void *storage, const void *source) {
|
||||
auto source_lambda = static_cast<const LambdaPtr*>(source);
|
||||
new (storage) LambdaPtr(std::make_unique<JustLambda>(*source_lambda->get()));
|
||||
}
|
||||
static Return const_call_method(const void *storage, Args... args) {
|
||||
auto lambda_ptr = static_cast<const LambdaPtr*>(storage)->get();
|
||||
return (*static_cast<const JustLambda*>(lambda_ptr))(std::forward<Args>(args)...);
|
||||
}
|
||||
vtable_impl() : Parent(
|
||||
&vtable_impl::construct_copy_other_method,
|
||||
&vtable_impl::const_call_method
|
||||
) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable_impl<Lambda, false, Return, Args...> : public vtable_once_impl<Lambda, false, Return, Args...> {
|
||||
using JustLambda = std::decay_t<Lambda>;
|
||||
using Parent = vtable_once_impl<Lambda, false, Return, Args...>;
|
||||
static void construct_copy_other_method(void *storage, const void *source) {
|
||||
auto source_lambda = static_cast<const JustLambda*>(source);
|
||||
new (storage) JustLambda(static_cast<const JustLambda &>(*source_lambda));
|
||||
}
|
||||
static Return const_call_method(const void *storage, Args... args) {
|
||||
return (*static_cast<const JustLambda*>(storage))(std::forward<Args>(args)...);
|
||||
}
|
||||
vtable_impl() : Parent(
|
||||
&vtable_impl::construct_copy_other_method,
|
||||
&vtable_impl::const_call_method
|
||||
) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
struct vtable : public vtable_impl<Lambda, is_large<Lambda>, Return, Args...> {
|
||||
static const vtable instance;
|
||||
};
|
||||
|
||||
template <typename Lambda, typename Return, typename ...Args>
|
||||
const vtable<Lambda, Return, Args...> vtable<Lambda, Return, Args...>::instance = {};
|
||||
|
||||
} // namespace lambda_internal
|
||||
|
||||
template <typename Return, typename ...Args>
|
||||
class lambda_once<Return(Args...)> {
|
||||
using VTable = lambda_internal::vtable_base<Return, Args...>;
|
||||
|
||||
public:
|
||||
using return_type = Return;
|
||||
|
||||
lambda_once() {
|
||||
data_.vtable = nullptr;
|
||||
}
|
||||
lambda_once(const lambda_once &other) = delete;
|
||||
lambda_once &operator=(const lambda_once &other) = delete;
|
||||
|
||||
// Move construct / assign from the same type.
|
||||
lambda_once(lambda_once &&other) {
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_move_other(data_.storage, other.data_.storage);
|
||||
}
|
||||
}
|
||||
lambda_once &operator=(lambda_once &&other) {
|
||||
if (this != &other) {
|
||||
if (data_.vtable) {
|
||||
data_.vtable->destruct(data_.storage);
|
||||
}
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_move_other(data_.storage, other.data_.storage);
|
||||
data_.vtable->destruct(other.data_.storage);
|
||||
other.data_.vtable = nullptr;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Move construct / assign from a derived type.
|
||||
lambda_once(lambda<Return(Args...)> &&other) {
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_move_other(data_.storage, other.data_.storage);
|
||||
data_.vtable->destruct(other.data_.storage);
|
||||
other.data_.vtable = nullptr;
|
||||
}
|
||||
}
|
||||
lambda_once &operator=(lambda<Return(Args...)> &&other) {
|
||||
if (this != &other) {
|
||||
if (data_.vtable) {
|
||||
data_.vtable->destruct(data_.storage);
|
||||
}
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_move_other(data_.storage, other.data_.storage);
|
||||
data_.vtable->destruct(other.data_.storage);
|
||||
other.data_.vtable = nullptr;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy construct / assign from a derived type.
|
||||
lambda_once(const lambda<Return(Args...)> &other) {
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_copy_other(data_.storage, other.data_.storage);
|
||||
}
|
||||
}
|
||||
lambda_once &operator=(const lambda<Return(Args...)> &other) {
|
||||
if (this != &other) {
|
||||
if (data_.vtable) {
|
||||
data_.vtable->destruct(data_.storage);
|
||||
}
|
||||
if ((data_.vtable = other.data_.vtable)) {
|
||||
data_.vtable->construct_copy_other(data_.storage, other.data_.storage);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy / move construct / assign from an arbitrary type.
|
||||
template <typename Lambda, typename = std::enable_if_t<std::is_convertible<decltype(std::declval<Lambda>()(std::declval<Args>()...)),Return>::value>>
|
||||
lambda_once(Lambda other) {
|
||||
data_.vtable = &lambda_internal::vtable_once<Lambda, Return, Args...>::instance;
|
||||
lambda_internal::vtable_once<Lambda, Return, Args...>::construct_move_lambda_method(data_.storage, &other);
|
||||
}
|
||||
template <typename Lambda, typename = std::enable_if_t<std::is_convertible<decltype(std::declval<Lambda>()(std::declval<Args>()...)),Return>::value>>
|
||||
lambda_once &operator=(Lambda other) {
|
||||
if (data_.vtable) {
|
||||
data_.vtable->destruct(data_.storage);
|
||||
}
|
||||
data_.vtable = &lambda_internal::vtable_once<Lambda, Return, Args...>::instance;
|
||||
lambda_internal::vtable_once<Lambda, Return, Args...>::construct_move_lambda_method(data_.storage, &other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(lambda_once &other) {
|
||||
if (this != &other) {
|
||||
std::swap(*this, other);
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename = std::enable_if_t<(sizeof...(Args) == sizeof...(OtherArgs))>>
|
||||
inline Return operator()(OtherArgs&&... args) {
|
||||
Assert(data_.vtable != nullptr);
|
||||
return data_.vtable->call(
|
||||
data_.storage,
|
||||
std::forward<OtherArgs>(args)...);
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return (data_.vtable != nullptr);
|
||||
}
|
||||
|
||||
~lambda_once() {
|
||||
if (data_.vtable) {
|
||||
data_.vtable->destruct(data_.storage);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
struct Private {
|
||||
};
|
||||
lambda_once(const VTable *vtable, const Private &) {
|
||||
data_.vtable = vtable;
|
||||
}
|
||||
|
||||
struct Data {
|
||||
char storage[lambda_internal::kStorageSize];
|
||||
const VTable *vtable;
|
||||
};
|
||||
union {
|
||||
lambda_internal::alignment alignment_;
|
||||
char raw_[lambda_internal::kFullStorageSize];
|
||||
Data data_;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template <typename Return, typename ...Args>
|
||||
class lambda<Return(Args...)> final : public lambda_once<Return(Args...)> {
|
||||
using Parent = lambda_once<Return(Args...)>;
|
||||
|
||||
public:
|
||||
lambda() = default;
|
||||
|
||||
// Move construct / assign from the same type.
|
||||
lambda(lambda<Return(Args...)> &&other) : Parent(std::move(other)) {
|
||||
}
|
||||
lambda &operator=(lambda<Return(Args...)> &&other) {
|
||||
Parent::operator=(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy construct / assign from the same type.
|
||||
lambda(const lambda<Return(Args...)> &other) : Parent(other) {
|
||||
}
|
||||
lambda &operator=(const lambda<Return(Args...)> &other) {
|
||||
Parent::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy / move construct / assign from an arbitrary type.
|
||||
template <typename Lambda, typename = std::enable_if_t<std::is_convertible<decltype(std::declval<Lambda>()(std::declval<Args>()...)),Return>::value>>
|
||||
lambda(Lambda other) : Parent(&lambda_internal::vtable<Lambda, Return, Args...>::instance, typename Parent::Private()) {
|
||||
lambda_internal::vtable<Lambda, Return, Args...>::construct_move_lambda_method(this->data_.storage, &other);
|
||||
}
|
||||
template <typename Lambda, typename = std::enable_if_t<std::is_convertible<decltype(std::declval<Lambda>()(std::declval<Args>()...)),Return>::value>>
|
||||
lambda &operator=(Lambda other) {
|
||||
if (this->data_.vtable) {
|
||||
this->data_.vtable->destruct(this->data_.storage);
|
||||
}
|
||||
this->data_.vtable = &lambda_internal::vtable<Lambda, Return, Args...>::instance;
|
||||
lambda_internal::vtable<Lambda, Return, Args...>::construct_move_lambda_method(this->data_.storage, &other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename = std::enable_if_t<(sizeof...(Args) == sizeof...(OtherArgs))>>
|
||||
inline Return operator()(OtherArgs&&... args) const {
|
||||
Assert(this->data_.vtable != nullptr);
|
||||
return this->data_.vtable->const_call(
|
||||
this->data_.storage,
|
||||
std::forward<OtherArgs>(args)...);
|
||||
}
|
||||
|
||||
void swap(lambda &other) {
|
||||
if (this != &other) {
|
||||
std::swap(*this, other);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#ifdef LambdaAssertDefined
|
||||
#undef Assert
|
||||
#endif // LambdaAssertDefined
|
||||
|
||||
#ifdef LambdaUnexpectedDefined
|
||||
#undef Unexpected
|
||||
#endif // LambdaUnexpectedDefined
|
||||
|
||||
#endif // CUSTOM_LAMBDA_WRAP
|
@ -1,114 +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
|
||||
|
||||
#include <QPointer>
|
||||
#include "base/weak_ptr.h"
|
||||
|
||||
// Guard lambda call by QObject* or has_weak_ptr* pointers.
|
||||
|
||||
namespace base {
|
||||
namespace lambda_internal {
|
||||
|
||||
template <typename Lambda>
|
||||
class guard_with_QObject {
|
||||
public:
|
||||
template <typename OtherLambda>
|
||||
guard_with_QObject(const QObject *object, OtherLambda &&other)
|
||||
: _guard(object)
|
||||
, _callable(std::forward<OtherLambda>(other)) {
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename Return = decltype(std::declval<Lambda>()(std::declval<OtherArgs>()...))>
|
||||
Return operator()(OtherArgs &&...args) {
|
||||
return _guard
|
||||
? _callable(std::forward<OtherArgs>(args)...)
|
||||
: Return();
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename Return = decltype(std::declval<Lambda>()(std::declval<OtherArgs>()...))>
|
||||
Return operator()(OtherArgs &&...args) const {
|
||||
return _guard
|
||||
? _callable(std::forward<OtherArgs>(args)...)
|
||||
: Return();
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<const QObject> _guard;
|
||||
Lambda _callable;
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda>
|
||||
class guard_with_weak {
|
||||
public:
|
||||
template <typename OtherLambda>
|
||||
guard_with_weak(
|
||||
const base::has_weak_ptr *object,
|
||||
OtherLambda &&other)
|
||||
: _guard(base::make_weak(object))
|
||||
, _callable(std::forward<OtherLambda>(other)) {
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename Return = decltype(std::declval<Lambda>()(std::declval<OtherArgs>()...))>
|
||||
Return operator()(OtherArgs &&...args) {
|
||||
return _guard
|
||||
? _callable(std::forward<OtherArgs>(args)...)
|
||||
: Return();
|
||||
}
|
||||
|
||||
template <
|
||||
typename ...OtherArgs,
|
||||
typename Return = decltype(std::declval<Lambda>()(std::declval<OtherArgs>()...))>
|
||||
Return operator()(OtherArgs &&...args) const {
|
||||
return _guard
|
||||
? _callable(std::forward<OtherArgs>(args)...)
|
||||
: Return();
|
||||
}
|
||||
|
||||
private:
|
||||
base::weak_ptr<const base::has_weak_ptr> _guard;
|
||||
Lambda _callable;
|
||||
|
||||
};
|
||||
|
||||
template <typename Lambda>
|
||||
struct lambda_call_type<guard_with_QObject<Lambda>> {
|
||||
using type = lambda_call_type_t<Lambda>;
|
||||
};
|
||||
|
||||
template <typename Lambda>
|
||||
struct lambda_call_type<guard_with_weak<Lambda>> {
|
||||
using type = lambda_call_type_t<Lambda>;
|
||||
};
|
||||
|
||||
} // namespace lambda_internal
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto lambda_guarded(const QObject *object, Lambda &&lambda) {
|
||||
using Guarded = lambda_internal::guard_with_QObject<
|
||||
std::decay_t<Lambda>>;
|
||||
return Guarded(object, std::forward<Lambda>(lambda));
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto lambda_guarded(
|
||||
const base::has_weak_ptr *object,
|
||||
Lambda &&lambda) {
|
||||
using Guarded = lambda_internal::guard_with_weak<
|
||||
std::decay_t<Lambda>>;
|
||||
return Guarded(object, std::forward<Lambda>(lambda));
|
||||
}
|
||||
|
||||
} // namespace base
|
@ -15,19 +15,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace base {
|
||||
namespace internal {
|
||||
|
||||
using ObservableCallHandlers = base::lambda<void()>;
|
||||
using ObservableCallHandlers = Fn<void()>;
|
||||
void RegisterPendingObservable(ObservableCallHandlers *handlers);
|
||||
void UnregisterActiveObservable(ObservableCallHandlers *handlers);
|
||||
void UnregisterObservable(ObservableCallHandlers *handlers);
|
||||
|
||||
template <typename EventType>
|
||||
struct SubscriptionHandlerHelper {
|
||||
using type = base::lambda<void(parameter_type<EventType>)>;
|
||||
using type = Fn<void(parameter_type<EventType>)>;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SubscriptionHandlerHelper<void> {
|
||||
using type = base::lambda<void()>;
|
||||
using type = Fn<void()>;
|
||||
};
|
||||
|
||||
template <typename EventType>
|
||||
|
@ -19,13 +19,13 @@ QObject *TimersAdjuster() {
|
||||
|
||||
Timer::Timer(
|
||||
not_null<QThread*> thread,
|
||||
base::lambda<void()> callback)
|
||||
Fn<void()> callback)
|
||||
: Timer(std::move(callback)) {
|
||||
moveToThread(thread);
|
||||
}
|
||||
|
||||
|
||||
Timer::Timer(base::lambda<void()> callback)
|
||||
Timer::Timer(Fn<void()> callback)
|
||||
: QObject(nullptr)
|
||||
, _callback(std::move(callback))
|
||||
, _type(Qt::PreciseTimer)
|
||||
@ -114,7 +114,7 @@ void Timer::timerEvent(QTimerEvent *e) {
|
||||
|
||||
int DelayedCallTimer::call(
|
||||
TimeMs timeout,
|
||||
lambda_once<void()> callback,
|
||||
FnMut<void()> callback,
|
||||
Qt::TimerType type) {
|
||||
Expects(timeout >= 0);
|
||||
|
||||
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/lambda.h"
|
||||
#include "base/observer.h"
|
||||
|
||||
namespace base {
|
||||
@ -16,15 +15,15 @@ class Timer final : private QObject {
|
||||
public:
|
||||
explicit Timer(
|
||||
not_null<QThread*> thread,
|
||||
base::lambda<void()> callback = nullptr);
|
||||
explicit Timer(base::lambda<void()> callback = nullptr);
|
||||
Fn<void()> callback = nullptr);
|
||||
explicit Timer(Fn<void()> callback = nullptr);
|
||||
|
||||
static Qt::TimerType DefaultType(TimeMs timeout) {
|
||||
constexpr auto kThreshold = TimeMs(1000);
|
||||
return (timeout > kThreshold) ? Qt::CoarseTimer : Qt::PreciseTimer;
|
||||
}
|
||||
|
||||
void setCallback(base::lambda<void()> callback) {
|
||||
void setCallback(Fn<void()> callback) {
|
||||
_callback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ private:
|
||||
return static_cast<Repeat>(_repeat);
|
||||
}
|
||||
|
||||
base::lambda<void()> _callback;
|
||||
Fn<void()> _callback;
|
||||
TimeMs _next = 0;
|
||||
int _timeout = 0;
|
||||
int _timerId = 0;
|
||||
@ -87,7 +86,7 @@ private:
|
||||
|
||||
class DelayedCallTimer final : private QObject {
|
||||
public:
|
||||
int call(TimeMs timeout, lambda_once<void()> callback) {
|
||||
int call(TimeMs timeout, FnMut<void()> callback) {
|
||||
return call(
|
||||
timeout,
|
||||
std::move(callback),
|
||||
@ -96,7 +95,7 @@ public:
|
||||
|
||||
int call(
|
||||
TimeMs timeout,
|
||||
lambda_once<void()> callback,
|
||||
FnMut<void()> callback,
|
||||
Qt::TimerType type);
|
||||
void cancel(int callId);
|
||||
|
||||
@ -104,7 +103,7 @@ protected:
|
||||
void timerEvent(QTimerEvent *e) override;
|
||||
|
||||
private:
|
||||
base::flat_map<int, lambda_once<void()>> _callbacks;
|
||||
base::flat_map<int, FnMut<void()>> _callbacks;
|
||||
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#ifndef Unexpected
|
||||
#define Unexpected(message) std::abort()
|
||||
#define UniqueFunctionUnexpected
|
||||
@ -47,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename ...Args>
|
||||
decltype(auto) operator()(Args &&...args) const {
|
||||
decltype(auto) operator()(Args &&...args) {
|
||||
return _value(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@ -59,7 +61,7 @@ private:
|
||||
Unexpected("Attempt to copy-assign a move-only type.");
|
||||
}
|
||||
|
||||
mutable Callable _value;
|
||||
Callable _value;
|
||||
|
||||
};
|
||||
|
||||
|
@ -20,8 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mainwindow.h"
|
||||
|
||||
QPointer<Ui::RoundButton> BoxContent::addButton(
|
||||
base::lambda<QString()> textFactory,
|
||||
base::lambda<void()> clickCallback) {
|
||||
Fn<QString()> textFactory,
|
||||
Fn<void()> clickCallback) {
|
||||
return addButton(
|
||||
std::move(textFactory),
|
||||
std::move(clickCallback),
|
||||
@ -29,8 +29,8 @@ QPointer<Ui::RoundButton> BoxContent::addButton(
|
||||
}
|
||||
|
||||
QPointer<Ui::RoundButton> BoxContent::addLeftButton(
|
||||
base::lambda<QString()> textFactory,
|
||||
base::lambda<void()> clickCallback) {
|
||||
Fn<QString()> textFactory,
|
||||
Fn<void()> clickCallback) {
|
||||
return getDelegate()->addLeftButton(
|
||||
std::move(textFactory),
|
||||
std::move(clickCallback),
|
||||
@ -290,7 +290,7 @@ void AbstractBox::parentResized() {
|
||||
update();
|
||||
}
|
||||
|
||||
void AbstractBox::setTitle(base::lambda<TextWithEntities()> titleFactory) {
|
||||
void AbstractBox::setTitle(Fn<TextWithEntities()> titleFactory) {
|
||||
_titleFactory = std::move(titleFactory);
|
||||
refreshTitle();
|
||||
}
|
||||
@ -311,7 +311,7 @@ void AbstractBox::refreshTitle() {
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractBox::setAdditionalTitle(base::lambda<QString()> additionalFactory) {
|
||||
void AbstractBox::setAdditionalTitle(Fn<QString()> additionalFactory) {
|
||||
_additionalTitleFactory = std::move(additionalFactory);
|
||||
refreshAdditionalTitle();
|
||||
}
|
||||
@ -373,7 +373,7 @@ void AbstractBox::clearButtons() {
|
||||
_leftButton.destroy();
|
||||
}
|
||||
|
||||
QPointer<Ui::RoundButton> AbstractBox::addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) {
|
||||
QPointer<Ui::RoundButton> AbstractBox::addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) {
|
||||
_buttons.push_back(object_ptr<Ui::RoundButton>(this, std::move(textFactory), st));
|
||||
auto result = QPointer<Ui::RoundButton>(_buttons.back());
|
||||
result->setClickedCallback(std::move(clickCallback));
|
||||
@ -382,7 +382,7 @@ QPointer<Ui::RoundButton> AbstractBox::addButton(base::lambda<QString()> textFac
|
||||
return result;
|
||||
}
|
||||
|
||||
QPointer<Ui::RoundButton> AbstractBox::addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) {
|
||||
QPointer<Ui::RoundButton> AbstractBox::addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) {
|
||||
_leftButton = object_ptr<Ui::RoundButton>(this, std::move(textFactory), st);
|
||||
auto result = QPointer<Ui::RoundButton>(_leftButton);
|
||||
result->setClickedCallback(std::move(clickCallback));
|
||||
|
@ -28,12 +28,12 @@ class BoxContent;
|
||||
class BoxContentDelegate {
|
||||
public:
|
||||
virtual void setLayerType(bool layerType) = 0;
|
||||
virtual void setTitle(base::lambda<TextWithEntities()> titleFactory) = 0;
|
||||
virtual void setAdditionalTitle(base::lambda<QString()> additionalFactory) = 0;
|
||||
virtual void setTitle(Fn<TextWithEntities()> titleFactory) = 0;
|
||||
virtual void setAdditionalTitle(Fn<QString()> additionalFactory) = 0;
|
||||
|
||||
virtual void clearButtons() = 0;
|
||||
virtual QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
|
||||
virtual QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
|
||||
virtual QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) = 0;
|
||||
virtual QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) = 0;
|
||||
virtual void updateButtonsPositions() = 0;
|
||||
|
||||
virtual void showBox(
|
||||
@ -72,17 +72,17 @@ public:
|
||||
getDelegate()->closeBox();
|
||||
}
|
||||
|
||||
void setTitle(base::lambda<QString()> titleFactory) {
|
||||
void setTitle(Fn<QString()> titleFactory) {
|
||||
if (titleFactory) {
|
||||
getDelegate()->setTitle([titleFactory] { return TextWithEntities { titleFactory(), EntitiesInText() }; });
|
||||
} else {
|
||||
getDelegate()->setTitle(base::lambda<TextWithEntities()>());
|
||||
getDelegate()->setTitle(Fn<TextWithEntities()>());
|
||||
}
|
||||
}
|
||||
void setTitle(base::lambda<TextWithEntities()> titleFactory) {
|
||||
void setTitle(Fn<TextWithEntities()> titleFactory) {
|
||||
getDelegate()->setTitle(std::move(titleFactory));
|
||||
}
|
||||
void setAdditionalTitle(base::lambda<QString()> additional) {
|
||||
void setAdditionalTitle(Fn<QString()> additional) {
|
||||
getDelegate()->setAdditionalTitle(std::move(additional));
|
||||
}
|
||||
|
||||
@ -91,9 +91,9 @@ public:
|
||||
void clearButtons() {
|
||||
getDelegate()->clearButtons();
|
||||
}
|
||||
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback);
|
||||
QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback);
|
||||
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) {
|
||||
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback);
|
||||
QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback);
|
||||
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) {
|
||||
return getDelegate()->addButton(std::move(textFactory), std::move(clickCallback), st);
|
||||
}
|
||||
void updateButtonsGeometry() {
|
||||
@ -228,16 +228,16 @@ public:
|
||||
void parentResized() override;
|
||||
|
||||
void setLayerType(bool layerType) override;
|
||||
void setTitle(base::lambda<TextWithEntities()> titleFactory) override;
|
||||
void setAdditionalTitle(base::lambda<QString()> additionalFactory) override;
|
||||
void setTitle(Fn<TextWithEntities()> titleFactory) override;
|
||||
void setAdditionalTitle(Fn<QString()> additionalFactory) override;
|
||||
void showBox(
|
||||
object_ptr<BoxContent> box,
|
||||
LayerOptions options,
|
||||
anim::type animated) override;
|
||||
|
||||
void clearButtons() override;
|
||||
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
|
||||
QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
|
||||
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) override;
|
||||
QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) override;
|
||||
void updateButtonsPositions() override;
|
||||
|
||||
void setDimensions(int newWidth, int maxHeight) override;
|
||||
@ -292,9 +292,9 @@ private:
|
||||
object_ptr<BoxContent> _content;
|
||||
|
||||
object_ptr<Ui::FlatLabel> _title = { nullptr };
|
||||
base::lambda<TextWithEntities()> _titleFactory;
|
||||
Fn<TextWithEntities()> _titleFactory;
|
||||
QString _additionalTitle;
|
||||
base::lambda<QString()> _additionalTitleFactory;
|
||||
Fn<QString()> _additionalTitleFactory;
|
||||
int _titleLeft = 0;
|
||||
int _titleTop = 0;
|
||||
bool _layerType = false;
|
||||
|
@ -57,7 +57,7 @@ QString PeerFloodErrorText(PeerFloodType type) {
|
||||
|
||||
class RevokePublicLinkBox::Inner : public TWidget, private MTP::Sender {
|
||||
public:
|
||||
Inner(QWidget *parent, base::lambda<void()> revokeCallback);
|
||||
Inner(QWidget *parent, Fn<void()> revokeCallback);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
@ -85,7 +85,7 @@ private:
|
||||
int _rowHeight = 0;
|
||||
int _revokeWidth = 0;
|
||||
|
||||
base::lambda<void()> _revokeCallback;
|
||||
Fn<void()> _revokeCallback;
|
||||
mtpRequestId _revokeRequestId = 0;
|
||||
QPointer<ConfirmBox> _weakRevokeConfirmBox;
|
||||
|
||||
@ -592,7 +592,7 @@ SetupChannelBox::SetupChannelBox(QWidget*, ChannelData *channel, bool existing)
|
||||
, _aboutPublicWidth(st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultRadio.diameter - st::defaultBoxCheckbox.textPosition.x())
|
||||
, _aboutPublic(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth)
|
||||
, _aboutPrivate(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth)
|
||||
, _link(this, st::setupChannelLink, base::lambda<QString()>(), channel->username, true) {
|
||||
, _link(this, st::setupChannelLink, Fn<QString()>(), channel->username, true) {
|
||||
}
|
||||
|
||||
void SetupChannelBox::prepare() {
|
||||
@ -819,7 +819,7 @@ void SetupChannelBox::privacyChanged(Privacy value) {
|
||||
if (value == Privacy::Public) {
|
||||
if (_tooMuchUsernames) {
|
||||
_privacyGroup->setValue(Privacy::Private);
|
||||
Ui::show(Box<RevokePublicLinkBox>(base::lambda_guarded(this, [this] {
|
||||
Ui::show(Box<RevokePublicLinkBox>(crl::guard(this, [this] {
|
||||
_tooMuchUsernames = false;
|
||||
_privacyGroup->setValue(Privacy::Public);
|
||||
check();
|
||||
@ -1389,7 +1389,7 @@ void EditChannelBox::onSaveInvitesDone(const MTPUpdates &result) {
|
||||
closeBox();
|
||||
}
|
||||
|
||||
RevokePublicLinkBox::Inner::Inner(QWidget *parent, base::lambda<void()> revokeCallback) : TWidget(parent)
|
||||
RevokePublicLinkBox::Inner::Inner(QWidget *parent, Fn<void()> revokeCallback) : TWidget(parent)
|
||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||
, _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke)))
|
||||
, _revokeCallback(std::move(revokeCallback)) {
|
||||
@ -1425,7 +1425,7 @@ RevokePublicLinkBox::Inner::Inner(QWidget *parent, base::lambda<void()> revokeCa
|
||||
}).send();
|
||||
}
|
||||
|
||||
RevokePublicLinkBox::RevokePublicLinkBox(QWidget*, base::lambda<void()> revokeCallback)
|
||||
RevokePublicLinkBox::RevokePublicLinkBox(QWidget*, Fn<void()> revokeCallback)
|
||||
: _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel)
|
||||
, _revokeCallback(std::move(revokeCallback)) {
|
||||
}
|
||||
@ -1484,7 +1484,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
auto text_method = pressed->isMegagroup() ? lng_channels_too_much_public_revoke_confirm_group : lng_channels_too_much_public_revoke_confirm_channel;
|
||||
auto text = text_method(lt_link, Messenger::Instance().createInternalLink(pressed->userName()), lt_group, pressed->name);
|
||||
auto confirmText = lang(lng_channels_too_much_public_revoke);
|
||||
_weakRevokeConfirmBox = Ui::show(Box<ConfirmBox>(text, confirmText, base::lambda_guarded(this, [this, pressed]() {
|
||||
_weakRevokeConfirmBox = Ui::show(Box<ConfirmBox>(text, confirmText, crl::guard(this, [this, pressed]() {
|
||||
if (_revokeRequestId) return;
|
||||
_revokeRequestId = request(MTPchannels_UpdateUsername(pressed->asChannel()->inputChannel, MTP_string(""))).done([this](const MTPBool &result) {
|
||||
if (_weakRevokeConfirmBox) {
|
||||
|
@ -281,7 +281,7 @@ private:
|
||||
|
||||
class RevokePublicLinkBox : public BoxContent, public RPCSender {
|
||||
public:
|
||||
RevokePublicLinkBox(QWidget*, base::lambda<void()> revokeCallback);
|
||||
RevokePublicLinkBox(QWidget*, Fn<void()> revokeCallback);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@ -295,6 +295,6 @@ private:
|
||||
QPointer<Inner> _inner;
|
||||
|
||||
int _innerTop = 0;
|
||||
base::lambda<void()> _revokeCallback;
|
||||
Fn<void()> _revokeCallback;
|
||||
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ class BackgroundBox::Inner : public TWidget, public RPCSender, private base::Sub
|
||||
public:
|
||||
Inner(QWidget *parent);
|
||||
|
||||
void setBackgroundChosenCallback(base::lambda<void(int index)> callback) {
|
||||
void setBackgroundChosenCallback(Fn<void(int index)> callback) {
|
||||
_backgroundChosenCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ private:
|
||||
void gotWallpapers(const MTPVector<MTPWallPaper> &result);
|
||||
void updateWallpapers();
|
||||
|
||||
base::lambda<void(int index)> _backgroundChosenCallback;
|
||||
Fn<void(int index)> _backgroundChosenCallback;
|
||||
|
||||
int _bgCount = 0;
|
||||
int _rows = 0;
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
return st::calendarPadding.top() + innerHeight + st::calendarPadding.bottom();
|
||||
}
|
||||
|
||||
void setDateChosenCallback(base::lambda<void(QDate)> callback) {
|
||||
void setDateChosenCallback(Fn<void(QDate)> callback) {
|
||||
_dateChosenCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ private:
|
||||
|
||||
std::map<int, std::unique_ptr<Ui::RippleAnimation>> _ripples;
|
||||
|
||||
base::lambda<void(QDate)> _dateChosenCallback;
|
||||
Fn<void(QDate)> _dateChosenCallback;
|
||||
|
||||
static constexpr auto kEmptySelection = -kDaysInWeek;
|
||||
int _selected = kEmptySelection;
|
||||
@ -440,7 +440,7 @@ void CalendarBox::Title::paintEvent(QPaintEvent *e) {
|
||||
p.drawTextLeft((width() - _textWidth) / 2, (height() - st::calendarTitleFont->height) / 2, width(), _text, _textWidth);
|
||||
}
|
||||
|
||||
CalendarBox::CalendarBox(QWidget*, QDate month, QDate highlighted, base::lambda<void(QDate date)> callback)
|
||||
CalendarBox::CalendarBox(QWidget*, QDate month, QDate highlighted, Fn<void(QDate date)> callback)
|
||||
: _context(std::make_unique<Context>(month, highlighted))
|
||||
, _inner(this, _context.get())
|
||||
, _title(this, _context.get())
|
||||
|
@ -15,7 +15,7 @@ class IconButton;
|
||||
|
||||
class CalendarBox : public BoxContent {
|
||||
public:
|
||||
CalendarBox(QWidget*, QDate month, QDate highlighted, base::lambda<void(QDate date)> callback);
|
||||
CalendarBox(QWidget*, QDate month, QDate highlighted, Fn<void(QDate date)> callback);
|
||||
|
||||
void setMinDate(QDate date);
|
||||
void setMaxDate(QDate date);
|
||||
@ -44,6 +44,6 @@ private:
|
||||
object_ptr<Ui::IconButton> _previous;
|
||||
object_ptr<Ui::IconButton> _next;
|
||||
|
||||
base::lambda<void(QDate date)> _callback;
|
||||
Fn<void(QDate date)> _callback;
|
||||
|
||||
};
|
||||
|
@ -144,9 +144,9 @@ void ChangePhoneBox::EnterPhone::submit() {
|
||||
hideError();
|
||||
|
||||
auto phoneNumber = _phone->getLastText().trimmed();
|
||||
_requestId = MTP::send(MTPaccount_SendChangePhoneCode(MTP_flags(0), MTP_string(phoneNumber), MTP_bool(false)), rpcDone(base::lambda_guarded(this, [this, phoneNumber](const MTPauth_SentCode &result) {
|
||||
_requestId = MTP::send(MTPaccount_SendChangePhoneCode(MTP_flags(0), MTP_string(phoneNumber), MTP_bool(false)), rpcDone(crl::guard(this, [this, phoneNumber](const MTPauth_SentCode &result) {
|
||||
return sendPhoneDone(phoneNumber, result);
|
||||
})), rpcFail(base::lambda_guarded(this, [this, phoneNumber](const RPCError &error) {
|
||||
})), rpcFail(crl::guard(this, [this, phoneNumber](const RPCError &error) {
|
||||
return sendPhoneFail(phoneNumber, error);
|
||||
})));
|
||||
}
|
||||
@ -265,13 +265,13 @@ void ChangePhoneBox::EnterCode::submit() {
|
||||
Ui::hideLayer();
|
||||
}
|
||||
Ui::Toast::Show(lang(lng_change_phone_success));
|
||||
}), rpcFail(base::lambda_guarded(this, [this](const RPCError &error) {
|
||||
}), rpcFail(crl::guard(this, [this](const RPCError &error) {
|
||||
return sendCodeFail(error);
|
||||
})));
|
||||
}
|
||||
|
||||
void ChangePhoneBox::EnterCode::sendCall() {
|
||||
MTP::send(MTPauth_ResendCode(MTP_string(_phone), MTP_string(_hash)), rpcDone(base::lambda_guarded(this, [this] {
|
||||
MTP::send(MTPauth_ResendCode(MTP_string(_phone), MTP_string(_hash)), rpcDone(crl::guard(this, [this] {
|
||||
_call.callDone();
|
||||
})));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ TextParseOptions _confirmBoxTextOptions = {
|
||||
Qt::LayoutDirectionAuto, // dir
|
||||
};
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(lang(lng_box_ok))
|
||||
, _cancelText(lang(lng_cancel))
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
@ -43,7 +43,7 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, base::lambda_once<void()>
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(confirmText)
|
||||
, _cancelText(lang(lng_cancel))
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
@ -53,7 +53,7 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const TextWithEntities &text, const QString &confirmText, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const TextWithEntities &text, const QString &confirmText, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(confirmText)
|
||||
, _cancelText(lang(lng_cancel))
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
@ -63,7 +63,7 @@ ConfirmBox::ConfirmBox(QWidget*, const TextWithEntities &text, const QString &co
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(confirmText)
|
||||
, _cancelText(lang(lng_cancel))
|
||||
, _confirmStyle(confirmStyle)
|
||||
@ -73,7 +73,7 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(confirmText)
|
||||
, _cancelText(cancelText)
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
@ -83,7 +83,7 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, base::lambda_once<void()> confirmedCallback, base::lambda_once<void()> cancelledCallback)
|
||||
ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, FnMut<void()> confirmedCallback, FnMut<void()> cancelledCallback)
|
||||
: _confirmText(confirmText)
|
||||
, _cancelText(cancelText)
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
@ -93,7 +93,7 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, base::lambda<void()> closedCallback)
|
||||
ConfirmBox::ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, Fn<void()> closedCallback)
|
||||
: _confirmText(doneText)
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
, _informative(true)
|
||||
@ -103,7 +103,7 @@ ConfirmBox::ConfirmBox(const InformBoxTag &, const QString &text, const QString
|
||||
init(text);
|
||||
}
|
||||
|
||||
ConfirmBox::ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const QString &doneText, base::lambda<void()> closedCallback)
|
||||
ConfirmBox::ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const QString &doneText, Fn<void()> closedCallback)
|
||||
: _confirmText(doneText)
|
||||
, _confirmStyle(st::defaultBoxButton)
|
||||
, _informative(true)
|
||||
@ -113,8 +113,8 @@ ConfirmBox::ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const
|
||||
init(text);
|
||||
}
|
||||
|
||||
base::lambda_once<void()> ConfirmBox::generateInformCallback(base::lambda<void()> closedCallback) {
|
||||
return base::lambda_guarded(this, [this, closedCallback] {
|
||||
FnMut<void()> ConfirmBox::generateInformCallback(Fn<void()> closedCallback) {
|
||||
return crl::guard(this, [this, closedCallback] {
|
||||
closeBox();
|
||||
if (closedCallback) {
|
||||
closedCallback();
|
||||
@ -241,13 +241,13 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
InformBox::InformBox(QWidget*, const QString &text, base::lambda<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) {
|
||||
InformBox::InformBox(QWidget*, const QString &text, Fn<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) {
|
||||
}
|
||||
|
||||
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) {
|
||||
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, Fn<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) {
|
||||
}
|
||||
|
||||
InformBox::InformBox(QWidget*, const TextWithEntities &text, base::lambda<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) {
|
||||
InformBox::InformBox(QWidget*, const TextWithEntities &text, Fn<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) {
|
||||
}
|
||||
|
||||
MaxInviteBox::MaxInviteBox(QWidget*, not_null<ChannelData*> channel) : BoxContent()
|
||||
|
@ -18,12 +18,12 @@ class EmptyUserpic;
|
||||
class InformBox;
|
||||
class ConfirmBox : public BoxContent, public ClickHandlerHost {
|
||||
public:
|
||||
ConfirmBox(QWidget*, const QString &text, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
||||
ConfirmBox(QWidget*, const TextWithEntities &text, const QString &confirmText, base::lambda_once<void()> confirmedCallback = nullptr, base::lambda_once<void()> cancelledCallback = nullptr);
|
||||
ConfirmBox(QWidget*, const QString &text, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
||||
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
||||
ConfirmBox(QWidget*, const TextWithEntities &text, const QString &confirmText, FnMut<void()> confirmedCallback = nullptr, FnMut<void()> cancelledCallback = nullptr);
|
||||
|
||||
void updateLink();
|
||||
|
||||
@ -51,9 +51,9 @@ protected:
|
||||
private:
|
||||
struct InformBoxTag {
|
||||
};
|
||||
ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, base::lambda<void()> closedCallback);
|
||||
ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const QString &doneText, base::lambda<void()> closedCallback);
|
||||
base::lambda_once<void()> generateInformCallback(base::lambda<void()> closedCallback);
|
||||
ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, Fn<void()> closedCallback);
|
||||
ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const QString &doneText, Fn<void()> closedCallback);
|
||||
FnMut<void()> generateInformCallback(Fn<void()> closedCallback);
|
||||
friend class InformBox;
|
||||
|
||||
void confirmed();
|
||||
@ -77,16 +77,16 @@ private:
|
||||
bool _confirmed = false;
|
||||
bool _cancelled = false;
|
||||
bool _strictCancel = false;
|
||||
base::lambda_once<void()> _confirmedCallback;
|
||||
base::lambda_once<void()> _cancelledCallback;
|
||||
FnMut<void()> _confirmedCallback;
|
||||
FnMut<void()> _cancelledCallback;
|
||||
|
||||
};
|
||||
|
||||
class InformBox : public ConfirmBox {
|
||||
public:
|
||||
InformBox(QWidget*, const QString &text, base::lambda<void()> closedCallback = nullptr);
|
||||
InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda<void()> closedCallback = nullptr);
|
||||
InformBox(QWidget*, const TextWithEntities &text, base::lambda<void()> closedCallback = nullptr);
|
||||
InformBox(QWidget*, const QString &text, Fn<void()> closedCallback = nullptr);
|
||||
InformBox(QWidget*, const QString &text, const QString &doneText, Fn<void()> closedCallback = nullptr);
|
||||
InformBox(QWidget*, const TextWithEntities &text, Fn<void()> closedCallback = nullptr);
|
||||
|
||||
};
|
||||
|
||||
@ -172,7 +172,7 @@ public:
|
||||
bool suggestModerateActions);
|
||||
DeleteMessagesBox(QWidget*, MessageIdsList &&selected);
|
||||
|
||||
void setDeleteConfirmedCallback(base::lambda<void()> callback) {
|
||||
void setDeleteConfirmedCallback(Fn<void()> callback) {
|
||||
_deleteConfirmedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ private:
|
||||
object_ptr<Ui::Checkbox> _reportSpam = { nullptr };
|
||||
object_ptr<Ui::Checkbox> _deleteAll = { nullptr };
|
||||
|
||||
base::lambda<void()> _deleteConfirmedCallback;
|
||||
Fn<void()> _deleteConfirmedCallback;
|
||||
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ void SentCodeField::fix() {
|
||||
}
|
||||
}
|
||||
|
||||
SentCodeCall::SentCodeCall(base::lambda_once<void()> callCallback, base::lambda<void()> updateCallback)
|
||||
SentCodeCall::SentCodeCall(FnMut<void()> callCallback, Fn<void()> updateCallback)
|
||||
: _call(std::move(callCallback))
|
||||
, _update(std::move(updateCallback)) {
|
||||
_timer.setCallback([=] {
|
||||
|
@ -18,15 +18,15 @@ class FlatLabel;
|
||||
|
||||
class SentCodeField : public Ui::InputField {
|
||||
public:
|
||||
SentCodeField(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory = base::lambda<QString()>(), const QString &val = QString()) : Ui::InputField(parent, st, std::move(placeholderFactory), val) {
|
||||
SentCodeField(QWidget *parent, const style::InputField &st, Fn<QString()> placeholderFactory = Fn<QString()>(), const QString &val = QString()) : Ui::InputField(parent, st, std::move(placeholderFactory), val) {
|
||||
connect(this, &Ui::InputField::changed, [this] { fix(); });
|
||||
}
|
||||
|
||||
void setAutoSubmit(int length, base::lambda<void()> submitCallback) {
|
||||
void setAutoSubmit(int length, Fn<void()> submitCallback) {
|
||||
_autoSubmitLength = length;
|
||||
_submitCallback = std::move(submitCallback);
|
||||
}
|
||||
void setChangedCallback(base::lambda<void()> changedCallback) {
|
||||
void setChangedCallback(Fn<void()> changedCallback) {
|
||||
_changedCallback = std::move(changedCallback);
|
||||
}
|
||||
|
||||
@ -37,16 +37,16 @@ private:
|
||||
bool _fixing = false;
|
||||
|
||||
int _autoSubmitLength = 0;
|
||||
base::lambda<void()> _submitCallback;
|
||||
base::lambda<void()> _changedCallback;
|
||||
Fn<void()> _submitCallback;
|
||||
Fn<void()> _changedCallback;
|
||||
|
||||
};
|
||||
|
||||
class SentCodeCall {
|
||||
public:
|
||||
SentCodeCall(
|
||||
base::lambda_once<void()> callCallback,
|
||||
base::lambda<void()> updateCallback);
|
||||
FnMut<void()> callCallback,
|
||||
Fn<void()> updateCallback);
|
||||
|
||||
enum class State {
|
||||
Waiting,
|
||||
@ -79,8 +79,8 @@ public:
|
||||
private:
|
||||
Status _status;
|
||||
base::Timer _timer;
|
||||
base::lambda_once<void()> _call;
|
||||
base::lambda<void()> _update;
|
||||
FnMut<void()> _call;
|
||||
Fn<void()> _update;
|
||||
|
||||
};
|
||||
|
||||
|
@ -125,8 +125,8 @@ public:
|
||||
ProxyBox(
|
||||
QWidget*,
|
||||
const ProxyData &data,
|
||||
base::lambda<void(ProxyData)> callback,
|
||||
base::lambda<void(ProxyData)> shareCallback);
|
||||
Fn<void(ProxyData)> callback,
|
||||
Fn<void(ProxyData)> shareCallback);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@ -148,8 +148,8 @@ private:
|
||||
not_null<Ui::VerticalLayout*> parent,
|
||||
const QString &text) const;
|
||||
|
||||
base::lambda<void(ProxyData)> _callback;
|
||||
base::lambda<void(ProxyData)> _shareCallback;
|
||||
Fn<void(ProxyData)> _callback;
|
||||
Fn<void(ProxyData)> _shareCallback;
|
||||
|
||||
object_ptr<Ui::VerticalLayout> _content;
|
||||
|
||||
@ -415,7 +415,7 @@ void ProxyRow::showMenu() {
|
||||
_menuToggle->installEventFilter(_menu);
|
||||
const auto addAction = [&](
|
||||
const QString &text,
|
||||
base::lambda<void()> callback) {
|
||||
Fn<void()> callback) {
|
||||
return _menu->addAction(text, std::move(callback));
|
||||
};
|
||||
addAction(lang(lng_proxy_menu_edit), [=] {
|
||||
@ -677,8 +677,8 @@ void ProxiesBox::setupButtons(int id, not_null<ProxyRow*> button) {
|
||||
ProxyBox::ProxyBox(
|
||||
QWidget*,
|
||||
const ProxyData &data,
|
||||
base::lambda<void(ProxyData)> callback,
|
||||
base::lambda<void(ProxyData)> shareCallback)
|
||||
Fn<void(ProxyData)> callback,
|
||||
Fn<void(ProxyData)> shareCallback)
|
||||
: _callback(std::move(callback))
|
||||
, _shareCallback(std::move(shareCallback))
|
||||
, _content(this) {
|
||||
|
@ -101,7 +101,7 @@ void DownloadPathBox::onEditPath() {
|
||||
this,
|
||||
lang(lng_download_path_choose),
|
||||
initialPath,
|
||||
base::lambda_guarded(this, handleFolder));
|
||||
crl::guard(this, handleFolder));
|
||||
}
|
||||
|
||||
void DownloadPathBox::save() {
|
||||
|
@ -720,7 +720,7 @@ void EditColorBox::fieldSubmitted() {
|
||||
}
|
||||
|
||||
void EditColorBox::saveColor() {
|
||||
_cancelCallback = base::lambda<void()>();
|
||||
_cancelCallback = Fn<void()>();
|
||||
if (_saveCallback) {
|
||||
_saveCallback(_new.toRgb());
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ class EditColorBox : public BoxContent {
|
||||
public:
|
||||
EditColorBox(QWidget*, const QString &title, QColor current = QColor(255, 255, 255));
|
||||
|
||||
void setSaveCallback(base::lambda<void(QColor)> callback) {
|
||||
void setSaveCallback(Fn<void(QColor)> callback) {
|
||||
_saveCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void setCancelCallback(base::lambda<void()> callback) {
|
||||
void setCancelCallback(Fn<void()> callback) {
|
||||
_cancelCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ private:
|
||||
QRect _currentRect;
|
||||
QRect _newRect;
|
||||
|
||||
base::lambda<void(QColor)> _saveCallback;
|
||||
base::lambda<void()> _cancelCallback;
|
||||
Fn<void(QColor)> _saveCallback;
|
||||
Fn<void()> _cancelCallback;
|
||||
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ class EditAdminBox : public EditParticipantBox {
|
||||
public:
|
||||
EditAdminBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, const MTPChannelAdminRights &rights);
|
||||
|
||||
void setSaveCallback(base::lambda<void(MTPChannelAdminRights, MTPChannelAdminRights)> callback) {
|
||||
void setSaveCallback(Fn<void(MTPChannelAdminRights, MTPChannelAdminRights)> callback) {
|
||||
_saveCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ private:
|
||||
|
||||
const MTPChannelAdminRights _oldRights;
|
||||
std::vector<std::pair<Flag, Flag>> _dependencies;
|
||||
base::lambda<void(MTPChannelAdminRights, MTPChannelAdminRights)> _saveCallback;
|
||||
Fn<void(MTPChannelAdminRights, MTPChannelAdminRights)> _saveCallback;
|
||||
|
||||
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;
|
||||
QPointer<Ui::FlatLabel> _aboutAddAdmins;
|
||||
@ -93,7 +93,7 @@ class EditRestrictedBox : public EditParticipantBox {
|
||||
public:
|
||||
EditRestrictedBox(QWidget*, not_null<ChannelData*> channel, not_null<UserData*> user, bool hasAdminRights, const MTPChannelBannedRights &rights);
|
||||
|
||||
void setSaveCallback(base::lambda<void(MTPChannelBannedRights, MTPChannelBannedRights)> callback) {
|
||||
void setSaveCallback(Fn<void(MTPChannelBannedRights, MTPChannelBannedRights)> callback) {
|
||||
_saveCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ private:
|
||||
const MTPChannelBannedRights _oldRights;
|
||||
TimeId _until = 0;
|
||||
std::vector<std::pair<Flag, Flag>> _dependencies;
|
||||
base::lambda<void(MTPChannelBannedRights, MTPChannelBannedRights)> _saveCallback;
|
||||
Fn<void(MTPChannelBannedRights, MTPChannelBannedRights)> _saveCallback;
|
||||
|
||||
std::map<Flags, QPointer<Ui::Checkbox>> _checkboxes;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
|
||||
class PrivacyExceptionsBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
PrivacyExceptionsBoxController(base::lambda<QString()> titleFactory, const std::vector<not_null<UserData*>> &selected);
|
||||
PrivacyExceptionsBoxController(Fn<QString()> titleFactory, const std::vector<not_null<UserData*>> &selected);
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
std::vector<not_null<UserData*>> getResult() const;
|
||||
@ -32,12 +32,12 @@ protected:
|
||||
std::unique_ptr<Row> createRow(not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
base::lambda<QString()> _titleFactory;
|
||||
Fn<QString()> _titleFactory;
|
||||
std::vector<not_null<UserData*>> _selected;
|
||||
|
||||
};
|
||||
|
||||
PrivacyExceptionsBoxController::PrivacyExceptionsBoxController(base::lambda<QString()> titleFactory, const std::vector<not_null<UserData*>> &selected)
|
||||
PrivacyExceptionsBoxController::PrivacyExceptionsBoxController(Fn<QString()> titleFactory, const std::vector<not_null<UserData*>> &selected)
|
||||
: _titleFactory(std::move(titleFactory))
|
||||
, _selected(selected) {
|
||||
}
|
||||
@ -163,11 +163,11 @@ int EditPrivacyBox::countDefaultHeight(int newWidth) {
|
||||
}
|
||||
|
||||
void EditPrivacyBox::editExceptionUsers(Exception exception) {
|
||||
auto controller = std::make_unique<PrivacyExceptionsBoxController>(base::lambda_guarded(this, [this, exception] {
|
||||
auto controller = std::make_unique<PrivacyExceptionsBoxController>(crl::guard(this, [this, exception] {
|
||||
return _controller->exceptionBoxTitle(exception);
|
||||
}), exceptionUsers(exception));
|
||||
auto initBox = [this, exception, controller = controller.get()](not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_settings_save), base::lambda_guarded(this, [this, box, exception, controller] {
|
||||
box->addButton(langFactory(lng_settings_save), crl::guard(this, [this, box, exception, controller] {
|
||||
exceptionUsers(exception) = controller->getResult();
|
||||
exceptionLink(exception)->entity()->setText(exceptionLinkText(exception));
|
||||
auto removeFrom = ([exception] {
|
||||
@ -295,7 +295,7 @@ void EditPrivacyBox::createWidgets() {
|
||||
clearButtons();
|
||||
addButton(langFactory(lng_settings_save), [this] {
|
||||
auto someAreDisallowed = (_option != Option::Everyone) || !_neverUsers.empty();
|
||||
_controller->confirmSave(someAreDisallowed, base::lambda_guarded(this, [this] {
|
||||
_controller->confirmSave(someAreDisallowed, crl::guard(this, [this] {
|
||||
Auth().api().savePrivacy(_controller->key(), collectResult());
|
||||
closeBox();
|
||||
}));
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
virtual QString exceptionBoxTitle(Exception exception) = 0;
|
||||
virtual QString exceptionsDescription() = 0;
|
||||
|
||||
virtual void confirmSave(bool someAreDisallowed, base::lambda_once<void()> saveCallback) {
|
||||
virtual void confirmSave(bool someAreDisallowed, FnMut<void()> saveCallback) {
|
||||
saveCallback();
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ void PasscodeBox::save(bool force) {
|
||||
}
|
||||
if (!_recoverEmail->isHidden() && email.isEmpty() && !force) {
|
||||
_skipEmailWarning = true;
|
||||
_replacedBy = getDelegate()->show(Box<ConfirmBox>(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton, base::lambda_guarded(this, [this] {
|
||||
_replacedBy = getDelegate()->show(Box<ConfirmBox>(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton, crl::guard(this, [this] {
|
||||
save(true);
|
||||
})));
|
||||
} else if (_newPasscode->isHidden()) {
|
||||
@ -679,7 +679,7 @@ void RecoverBox::submit() {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto send = base::lambda_guarded(this, [=] {
|
||||
const auto send = crl::guard(this, [=] {
|
||||
_submitRequest = MTP::send(
|
||||
MTPauth_RecoverPassword(MTP_string(code)),
|
||||
rpcDone(&RecoverBox::codeSubmitDone, true),
|
||||
|
@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
PeerListBox::PeerListBox(
|
||||
QWidget*,
|
||||
std::unique_ptr<PeerListController> controller,
|
||||
base::lambda<void(not_null<PeerListBox*>)> init)
|
||||
Fn<void(not_null<PeerListBox*>)> init)
|
||||
: _controller(std::move(controller))
|
||||
, _init(std::move(init)) {
|
||||
Expects(_controller != nullptr);
|
||||
@ -525,7 +525,7 @@ void PeerListRow::lazyInitialize(const style::PeerListItem &st) {
|
||||
refreshStatus();
|
||||
}
|
||||
|
||||
void PeerListRow::createCheckbox(base::lambda<void()> updateCallback) {
|
||||
void PeerListRow::createCheckbox(Fn<void()> updateCallback) {
|
||||
_checkbox = std::make_unique<Ui::RoundImageCheckbox>(
|
||||
st::contactsPhotoCheckbox,
|
||||
std::move(updateCallback),
|
||||
@ -1022,7 +1022,7 @@ void PeerListContent::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (const auto row = getRow(_contexted.index)) {
|
||||
_contextMenu = _controller->rowContextMenu(row);
|
||||
if (_contextMenu) {
|
||||
_contextMenu->setDestroyedCallback(base::lambda_guarded(
|
||||
_contextMenu->setDestroyedCallback(crl::guard(
|
||||
this,
|
||||
[this] {
|
||||
setContexted(Selected());
|
||||
|
@ -37,7 +37,7 @@ struct PeerUpdate;
|
||||
inline auto PaintUserpicCallback(
|
||||
not_null<PeerData*> peer,
|
||||
bool respectSavedMessagesChat)
|
||||
->base::lambda<void(Painter &p, int x, int y, int outerWidth, int size)> {
|
||||
->Fn<void(Painter &p, int x, int y, int outerWidth, int size)> {
|
||||
if (respectSavedMessagesChat && peer->isSelf()) {
|
||||
return [](Painter &p, int x, int y, int outerWidth, int size) {
|
||||
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
|
||||
@ -95,7 +95,7 @@ public:
|
||||
virtual QMargins actionMargins() const {
|
||||
return QMargins();
|
||||
}
|
||||
virtual void addActionRipple(QPoint point, base::lambda<void()> updateCallback) {
|
||||
virtual void addActionRipple(QPoint point, Fn<void()> updateCallback) {
|
||||
}
|
||||
virtual void stopLastActionRipple() {
|
||||
}
|
||||
@ -200,7 +200,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
void createCheckbox(base::lambda<void()> updateCallback);
|
||||
void createCheckbox(Fn<void()> updateCallback);
|
||||
void setCheckedInternal(bool checked, SetStyle style);
|
||||
void paintDisabledCheckUserpic(
|
||||
Painter &p,
|
||||
@ -236,8 +236,8 @@ struct PeerListState;
|
||||
|
||||
class PeerListDelegate {
|
||||
public:
|
||||
virtual void peerListSetTitle(base::lambda<QString()> title) = 0;
|
||||
virtual void peerListSetAdditionalTitle(base::lambda<QString()> title) = 0;
|
||||
virtual void peerListSetTitle(Fn<QString()> title) = 0;
|
||||
virtual void peerListSetAdditionalTitle(Fn<QString()> title) = 0;
|
||||
virtual void peerListSetDescription(object_ptr<Ui::FlatLabel> description) = 0;
|
||||
virtual void peerListSetSearchLoading(object_ptr<Ui::FlatLabel> loading) = 0;
|
||||
virtual void peerListSetSearchNoResults(object_ptr<Ui::FlatLabel> noResults) = 0;
|
||||
@ -258,8 +258,8 @@ public:
|
||||
virtual void peerListScrollToTop() = 0;
|
||||
virtual int peerListFullRowsCount() = 0;
|
||||
virtual PeerListRow *peerListFindRow(PeerListRowId id) = 0;
|
||||
virtual void peerListSortRows(base::lambda<bool(const PeerListRow &a, const PeerListRow &b)> compare) = 0;
|
||||
virtual int peerListPartitionRows(base::lambda<bool(const PeerListRow &a)> border) = 0;
|
||||
virtual void peerListSortRows(Fn<bool(const PeerListRow &a, const PeerListRow &b)> compare) = 0;
|
||||
virtual int peerListPartitionRows(Fn<bool(const PeerListRow &a)> border) = 0;
|
||||
|
||||
template <typename PeerDataRange>
|
||||
void peerListAddSelectedRows(PeerDataRange &&range) {
|
||||
@ -701,7 +701,7 @@ public:
|
||||
_content->setSearchMode(mode);
|
||||
}
|
||||
void peerListSortRows(
|
||||
base::lambda<bool(const PeerListRow &a, const PeerListRow &b)> compare) override {
|
||||
Fn<bool(const PeerListRow &a, const PeerListRow &b)> compare) override {
|
||||
_content->reorderRows([&](
|
||||
auto &&begin,
|
||||
auto &&end) {
|
||||
@ -711,7 +711,7 @@ public:
|
||||
});
|
||||
}
|
||||
int peerListPartitionRows(
|
||||
base::lambda<bool(const PeerListRow &a)> border) override {
|
||||
Fn<bool(const PeerListRow &a)> border) override {
|
||||
auto result = 0;
|
||||
_content->reorderRows([&](
|
||||
auto &&begin,
|
||||
@ -749,13 +749,13 @@ public:
|
||||
PeerListBox(
|
||||
QWidget*,
|
||||
std::unique_ptr<PeerListController> controller,
|
||||
base::lambda<void(not_null<PeerListBox*>)> init);
|
||||
Fn<void(not_null<PeerListBox*>)> init);
|
||||
|
||||
void peerListSetTitle(base::lambda<QString()> title) override {
|
||||
void peerListSetTitle(Fn<QString()> title) override {
|
||||
setTitle(std::move(title));
|
||||
}
|
||||
void peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) override {
|
||||
Fn<QString()> title) override {
|
||||
setAdditionalTitle(std::move(title));
|
||||
}
|
||||
void peerListSetSearchMode(PeerListSearchMode mode) override;
|
||||
@ -793,7 +793,7 @@ private:
|
||||
object_ptr<Ui::SlideWrap<Ui::MultiSelect>> _select = { nullptr };
|
||||
|
||||
std::unique_ptr<PeerListController> _controller;
|
||||
base::lambda<void(PeerListBox*)> _init;
|
||||
Fn<void(PeerListBox*)> _init;
|
||||
bool _scrollBottomFixed = false;
|
||||
|
||||
};
|
||||
|
@ -901,7 +901,7 @@ void AddBotToGroupBoxController::prepareViewHook() {
|
||||
}
|
||||
|
||||
ChooseRecipientBoxController::ChooseRecipientBoxController(
|
||||
base::lambda_once<void(not_null<PeerData*>)> callback)
|
||||
FnMut<void(not_null<PeerData*>)> callback)
|
||||
: _callback(std::move(callback)) {
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ private:
|
||||
class ChooseRecipientBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
ChooseRecipientBoxController(
|
||||
base::lambda_once<void(not_null<PeerData*>)> callback);
|
||||
FnMut<void(not_null<PeerData*>)> callback);
|
||||
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
@ -244,6 +244,6 @@ protected:
|
||||
not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
base::lambda_once<void(not_null<PeerData*>)> _callback;
|
||||
FnMut<void(not_null<PeerData*>)> _callback;
|
||||
|
||||
};
|
||||
|
@ -42,8 +42,8 @@ constexpr auto kMaxGroupChannelTitle = 255; // See also add_contact_box.
|
||||
constexpr auto kMaxChannelDescription = 255; // See also add_contact_box.
|
||||
|
||||
class Controller
|
||||
: private MTP::Sender
|
||||
, private base::has_weak_ptr {
|
||||
: public base::has_weak_ptr
|
||||
, private MTP::Sender {
|
||||
public:
|
||||
Controller(
|
||||
not_null<BoxContent*> box,
|
||||
@ -101,7 +101,7 @@ private:
|
||||
base::optional<bool> everyoneInvites;
|
||||
};
|
||||
|
||||
base::lambda<QString()> computeTitle() const;
|
||||
Fn<QString()> computeTitle() const;
|
||||
object_ptr<Ui::RpWidget> createPhotoAndTitleEdit();
|
||||
object_ptr<Ui::RpWidget> createTitleEdit();
|
||||
object_ptr<Ui::RpWidget> createPhotoEdit();
|
||||
@ -159,7 +159,7 @@ private:
|
||||
void saveInvites();
|
||||
void saveSignatures();
|
||||
void savePhoto();
|
||||
void pushSaveStage(base::lambda_once<void()> &&lambda);
|
||||
void pushSaveStage(FnMut<void()> &&lambda);
|
||||
void continueSave();
|
||||
void cancelSave();
|
||||
|
||||
@ -174,7 +174,7 @@ private:
|
||||
UsernameState _usernameState = UsernameState::Normal;
|
||||
rpl::event_stream<rpl::producer<QString>> _usernameResultTexts;
|
||||
|
||||
std::deque<base::lambda_once<void()>> _saveStagesQueue;
|
||||
std::deque<FnMut<void()>> _saveStagesQueue;
|
||||
Saving _savingData;
|
||||
|
||||
};
|
||||
@ -195,7 +195,7 @@ Controller::Controller(
|
||||
});
|
||||
}
|
||||
|
||||
base::lambda<QString()> Controller::computeTitle() const {
|
||||
Fn<QString()> Controller::computeTitle() const {
|
||||
return langFactory(_isGroup
|
||||
? lng_edit_group
|
||||
: lng_edit_channel_title);
|
||||
@ -434,7 +434,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
|
||||
object_ptr<Ui::UsernameInput>(
|
||||
container,
|
||||
st::setupChannelLink,
|
||||
base::lambda<QString()>(),
|
||||
Fn<QString()>(),
|
||||
channel->username,
|
||||
true));
|
||||
_controls.username->heightValue(
|
||||
@ -565,7 +565,7 @@ void Controller::checkUsernameAvailability() {
|
||||
|
||||
void Controller::askUsernameRevoke() {
|
||||
_controls.privacy->setValue(Privacy::Private);
|
||||
auto revokeCallback = base::lambda_guarded(this, [this] {
|
||||
auto revokeCallback = crl::guard(this, [this] {
|
||||
_usernameState = UsernameState::Normal;
|
||||
_controls.privacy->setValue(Privacy::Public);
|
||||
checkUsernameAvailability();
|
||||
@ -644,7 +644,7 @@ void Controller::revokeInviteLink() {
|
||||
|
||||
void Controller::exportInviteLink(const QString &confirmation) {
|
||||
auto boxPointer = std::make_shared<QPointer<ConfirmBox>>();
|
||||
auto callback = base::lambda_guarded(this, [=] {
|
||||
auto callback = crl::guard(this, [=] {
|
||||
if (auto strong = *boxPointer) {
|
||||
strong->closeBox();
|
||||
}
|
||||
@ -1185,7 +1185,7 @@ void Controller::save() {
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::pushSaveStage(base::lambda_once<void()> &&lambda) {
|
||||
void Controller::pushSaveStage(FnMut<void()> &&lambda) {
|
||||
_saveStagesQueue.push_back(std::move(lambda));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace {
|
||||
|
||||
base::lambda<QString()> ManagePeerTitle(
|
||||
Fn<QString()> ManagePeerTitle(
|
||||
not_null<ChannelData*> channel) {
|
||||
return langFactory(channel->isMegagroup()
|
||||
? lng_manage_group_title
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
bool isPointAfter(QPoint position) const;
|
||||
void moveInAlbum(QPoint to);
|
||||
QPoint center() const;
|
||||
void suggestMove(float64 delta, base::lambda<void()> callback);
|
||||
void suggestMove(float64 delta, Fn<void()> callback);
|
||||
void finishAnimations();
|
||||
|
||||
private:
|
||||
@ -520,7 +520,7 @@ QPoint AlbumThumb::center() const {
|
||||
return realGeometry.center();
|
||||
}
|
||||
|
||||
void AlbumThumb::suggestMove(float64 delta, base::lambda<void()> callback) {
|
||||
void AlbumThumb::suggestMove(float64 delta, Fn<void()> callback) {
|
||||
if (_suggestedMove != delta) {
|
||||
_suggestedMoveAnimation.start(
|
||||
std::move(callback),
|
||||
@ -889,7 +889,7 @@ rpl::producer<int> SingleFilePreview::desiredHeightValue() const {
|
||||
return rpl::single(st::boxPhotoPadding.top() + h + st::msgShadow);
|
||||
}
|
||||
|
||||
base::lambda<QString()> FieldPlaceholder(const Storage::PreparedList &list) {
|
||||
Fn<QString()> FieldPlaceholder(const Storage::PreparedList &list) {
|
||||
return langFactory(list.files.size() > 1
|
||||
? lng_photos_comment
|
||||
: lng_photo_caption);
|
||||
|
@ -46,14 +46,14 @@ public:
|
||||
CompressConfirm compressed);
|
||||
|
||||
void setConfirmedCallback(
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
Storage::PreparedList &&list,
|
||||
SendFilesWay way,
|
||||
TextWithTags &&caption,
|
||||
bool ctrlShiftEnter)> callback) {
|
||||
_confirmedCallback = std::move(callback);
|
||||
}
|
||||
void setCancelledCallback(base::lambda<void()> callback) {
|
||||
void setCancelledCallback(Fn<void()> callback) {
|
||||
_cancelledCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -107,12 +107,12 @@ private:
|
||||
CompressConfirm _compressConfirmInitial = CompressConfirm::None;
|
||||
CompressConfirm _compressConfirm = CompressConfirm::None;
|
||||
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
Storage::PreparedList &&list,
|
||||
SendFilesWay way,
|
||||
TextWithTags &&caption,
|
||||
bool ctrlShiftEnter)> _confirmedCallback;
|
||||
base::lambda<void()> _cancelledCallback;
|
||||
Fn<void()> _cancelledCallback;
|
||||
bool _confirmed = false;
|
||||
|
||||
object_ptr<Ui::InputField> _caption = { nullptr };
|
||||
|
@ -297,7 +297,7 @@ void SessionsBox::Inner::onTerminate() {
|
||||
for (auto i = _terminateButtons.begin(), e = _terminateButtons.end(); i != e; ++i) {
|
||||
if (i.value()->isOver()) {
|
||||
if (_terminateBox) _terminateBox->deleteLater();
|
||||
_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button), st::attentionBoxButton, base::lambda_guarded(this, [this, terminating = i.key()] {
|
||||
_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button), st::attentionBoxButton, crl::guard(this, [this, terminating = i.key()] {
|
||||
if (_terminateBox) {
|
||||
_terminateBox->closeBox();
|
||||
_terminateBox = nullptr;
|
||||
@ -315,7 +315,7 @@ void SessionsBox::Inner::onTerminate() {
|
||||
|
||||
void SessionsBox::Inner::onTerminateAll() {
|
||||
if (_terminateBox) _terminateBox->deleteLater();
|
||||
_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton, base::lambda_guarded(this, [this] {
|
||||
_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton, crl::guard(this, [this] {
|
||||
if (_terminateBox) {
|
||||
_terminateBox->closeBox();
|
||||
_terminateBox = nullptr;
|
||||
|
@ -551,7 +551,7 @@ void ShareBox::Inner::paintChat(
|
||||
chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true);
|
||||
}
|
||||
|
||||
ShareBox::Inner::Chat::Chat(PeerData *peer, base::lambda<void()> updateCallback)
|
||||
ShareBox::Inner::Chat::Chat(PeerData *peer, Fn<void()> updateCallback)
|
||||
: peer(peer)
|
||||
, checkbox(st::sharePhotoCheckbox, updateCallback, PaintUserpicCallback(peer, true))
|
||||
, name(st::sharePhotoCheckbox.imageRadius * 2) {
|
||||
@ -699,7 +699,7 @@ void ShareBox::Inner::peerUnselected(not_null<PeerData*> peer) {
|
||||
}
|
||||
}
|
||||
|
||||
void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> callback) {
|
||||
void ShareBox::Inner::setPeerSelectedChangedCallback(Fn<void(PeerData *peer, bool selected)> callback) {
|
||||
_peerSelectedChangedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ class ShareBox : public BoxContent, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using CopyCallback = base::lambda<void()>;
|
||||
using SubmitCallback = base::lambda<void(const QVector<PeerData*> &)>;
|
||||
using FilterCallback = base::lambda<bool(PeerData*)>;
|
||||
using CopyCallback = Fn<void()>;
|
||||
using SubmitCallback = Fn<void(const QVector<PeerData*> &)>;
|
||||
using FilterCallback = Fn<bool(PeerData*)>;
|
||||
ShareBox(QWidget*, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback);
|
||||
|
||||
protected:
|
||||
@ -103,7 +103,7 @@ class ShareBox::Inner : public TWidget, public RPCSender, private base::Subscrib
|
||||
public:
|
||||
Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback);
|
||||
|
||||
void setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> callback);
|
||||
void setPeerSelectedChangedCallback(Fn<void(PeerData *peer, bool selected)> callback);
|
||||
void peerUnselected(not_null<PeerData*> peer);
|
||||
|
||||
QVector<PeerData*> selected() const;
|
||||
@ -148,7 +148,7 @@ private:
|
||||
int displayedChatsCount() const;
|
||||
|
||||
struct Chat {
|
||||
Chat(PeerData *peer, base::lambda<void()> updateCallback);
|
||||
Chat(PeerData *peer, Fn<void()> updateCallback);
|
||||
|
||||
PeerData *peer;
|
||||
Ui::RoundImageCheckbox checkbox;
|
||||
@ -201,7 +201,7 @@ private:
|
||||
using SelectedChats = OrderedSet<PeerData*>;
|
||||
SelectedChats _selected;
|
||||
|
||||
base::lambda<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;
|
||||
Fn<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;
|
||||
|
||||
ChatData *data(Dialogs::Row *row);
|
||||
|
||||
|
@ -431,7 +431,7 @@ bool StickerSetBox::Inner::official() const {
|
||||
return _loaded && _setShortName.isEmpty();
|
||||
}
|
||||
|
||||
base::lambda<TextWithEntities()> StickerSetBox::Inner::title() const {
|
||||
Fn<TextWithEntities()> StickerSetBox::Inner::title() const {
|
||||
auto text = TextWithEntities { _setTitle };
|
||||
if (_loaded) {
|
||||
if (_pack.isEmpty()) {
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
bool loaded() const;
|
||||
bool notInstalled() const;
|
||||
bool official() const;
|
||||
base::lambda<TextWithEntities()> title() const;
|
||||
Fn<TextWithEntities()> title() const;
|
||||
QString shortName() const;
|
||||
|
||||
void install();
|
||||
|
@ -154,10 +154,10 @@ public:
|
||||
void setFullOrder(const Stickers::Order &order);
|
||||
void setRemovedSets(const Stickers::Order &removed);
|
||||
|
||||
void setInstallSetCallback(base::lambda<void(uint64 setId)> callback) {
|
||||
void setInstallSetCallback(Fn<void(uint64 setId)> callback) {
|
||||
_installSetCallback = std::move(callback);
|
||||
}
|
||||
void setLoadMoreCallback(base::lambda<void()> callback) {
|
||||
void setLoadMoreCallback(Fn<void()> callback) {
|
||||
_loadMoreCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -280,8 +280,8 @@ private:
|
||||
anim::value _aboveShadowFadeOpacity;
|
||||
BasicAnimation _a_shifting;
|
||||
|
||||
base::lambda<void(uint64 setId)> _installSetCallback;
|
||||
base::lambda<void()> _loadMoreCallback;
|
||||
Fn<void(uint64 setId)> _installSetCallback;
|
||||
Fn<void()> _loadMoreCallback;
|
||||
|
||||
int _visibleTop = 0;
|
||||
int _visibleBottom = 0;
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
int availableWidth,
|
||||
int outerWidth,
|
||||
bool selected) override;
|
||||
void addActionRipple(QPoint point, base::lambda<void()> updateCallback) override;
|
||||
void addActionRipple(QPoint point, Fn<void()> updateCallback) override;
|
||||
void stopLastActionRipple() override;
|
||||
|
||||
int nameIconWidth() const override {
|
||||
@ -191,7 +191,7 @@ BoxController::Row::Type BoxController::Row::ComputeType(
|
||||
return Type::In;
|
||||
}
|
||||
|
||||
void BoxController::Row::addActionRipple(QPoint point, base::lambda<void()> updateCallback) {
|
||||
void BoxController::Row::addActionRipple(QPoint point, Fn<void()> updateCallback) {
|
||||
if (!_actionRipple) {
|
||||
auto mask = Ui::RippleAnimation::ellipseMask(QSize(st::callReDial.rippleAreaSize, st::callReDial.rippleAreaSize));
|
||||
_actionRipple = std::make_unique<Ui::RippleAnimation>(st::callReDial.ripple, std::move(mask), std::move(updateCallback));
|
||||
|
@ -71,7 +71,7 @@ SignalBars::SignalBars(
|
||||
QWidget *parent,
|
||||
not_null<Call*> call,
|
||||
const style::CallSignalBars &st,
|
||||
base::lambda<void()> displayedChangedCallback)
|
||||
Fn<void()> displayedChangedCallback)
|
||||
: RpWidget(parent)
|
||||
, _st(st)
|
||||
, _displayedChangedCallback(std::move(displayedChangedCallback)) {
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
QWidget *parent,
|
||||
not_null<Call*> call,
|
||||
const style::CallSignalBars &st,
|
||||
base::lambda<void()> displayedChangedCallback = nullptr);
|
||||
Fn<void()> displayedChangedCallback = nullptr);
|
||||
|
||||
bool isDisplayed() const;
|
||||
|
||||
@ -44,7 +44,7 @@ private:
|
||||
|
||||
const style::CallSignalBars &_st;
|
||||
int _count = Call::kSignalBarStarting;
|
||||
base::lambda<void()> _displayedChangedCallback;
|
||||
Fn<void()> _displayedChangedCallback;
|
||||
|
||||
};
|
||||
|
||||
|
@ -367,7 +367,7 @@ SuggestionsController::SuggestionsController(QWidget *parent, not_null<QTextEdit
|
||||
}
|
||||
|
||||
void SuggestionsController::setReplaceCallback(
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int from,
|
||||
int till,
|
||||
const QString &replacement)> callback) {
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
SuggestionsController(QWidget *parent, not_null<QTextEdit*> field);
|
||||
|
||||
void raise();
|
||||
void setReplaceCallback(base::lambda<void(
|
||||
void setReplaceCallback(Fn<void(
|
||||
int from,
|
||||
int till,
|
||||
const QString &replacement)> callback);
|
||||
@ -91,7 +91,7 @@ private:
|
||||
bool _ignoreCursorPositionChange = false;
|
||||
bool _textChangeAfterKeyPress = false;
|
||||
QPointer<QTextEdit> _field;
|
||||
base::lambda<void(
|
||||
Fn<void(
|
||||
int from,
|
||||
int till,
|
||||
const QString &replacement)> _replaceCallback;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
QWidget*,
|
||||
const QString &text,
|
||||
const QString &link,
|
||||
base::lambda<void(QString, QString)> callback);
|
||||
Fn<void(QString, QString)> callback);
|
||||
|
||||
void setInnerFocus() override;
|
||||
|
||||
@ -67,8 +67,8 @@ protected:
|
||||
private:
|
||||
QString _startText;
|
||||
QString _startLink;
|
||||
base::lambda<void(QString, QString)> _callback;
|
||||
base::lambda<void()> _setInnerFocus;
|
||||
Fn<void(QString, QString)> _callback;
|
||||
Fn<void()> _setInnerFocus;
|
||||
|
||||
};
|
||||
|
||||
@ -120,7 +120,7 @@ EditLinkBox::EditLinkBox(
|
||||
QWidget*,
|
||||
const QString &text,
|
||||
const QString &link,
|
||||
base::lambda<void(QString, QString)> callback)
|
||||
Fn<void(QString, QString)> callback)
|
||||
: _startText(text)
|
||||
, _startLink(link)
|
||||
, _callback(std::move(callback)) {
|
||||
@ -307,7 +307,7 @@ void SetClipboardWithEntities(
|
||||
}
|
||||
}
|
||||
|
||||
base::lambda<bool(
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
QString link,
|
||||
|
@ -27,7 +27,7 @@ void SetClipboardWithEntities(
|
||||
const TextWithEntities &forClipboard,
|
||||
QClipboard::Mode mode = QClipboard::Clipboard);
|
||||
|
||||
base::lambda<bool(
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
QString link,
|
||||
|
@ -2343,7 +2343,7 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
||||
return;
|
||||
}
|
||||
_removingSetId = Stickers::MegagroupSetId;
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_stickers_remove_group_set), base::lambda_guarded(this, [this, group = _megagroupSet] {
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_stickers_remove_group_set), crl::guard(this, [this, group = _megagroupSet] {
|
||||
Expects(group->mgInfo != nullptr);
|
||||
if (group->mgInfo->stickerSet.type() != mtpc_inputStickerSetEmpty) {
|
||||
Auth().api().setGroupStickerSet(group, MTP_inputStickerSetEmpty());
|
||||
@ -2351,7 +2351,7 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
||||
Ui::hideLayer();
|
||||
_removingSetId = 0;
|
||||
emit checkForHide();
|
||||
}), base::lambda_guarded(this, [this] {
|
||||
}), crl::guard(this, [this] {
|
||||
_removingSetId = 0;
|
||||
emit checkForHide();
|
||||
})));
|
||||
@ -2363,7 +2363,7 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||
if (it != sets.cend()) {
|
||||
_removingSetId = it->id;
|
||||
auto text = lng_stickers_remove_pack(lt_sticker_pack, it->title);
|
||||
Ui::show(Box<ConfirmBox>(text, lang(lng_stickers_remove_pack_confirm), base::lambda_guarded(this, [this] {
|
||||
Ui::show(Box<ConfirmBox>(text, lang(lng_stickers_remove_pack_confirm), crl::guard(this, [this] {
|
||||
Ui::hideLayer();
|
||||
auto &sets = Auth().data().stickerSetsRef();
|
||||
auto it = sets.find(_removingSetId);
|
||||
@ -2400,7 +2400,7 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||
}
|
||||
_removingSetId = 0;
|
||||
emit checkForHide();
|
||||
}), base::lambda_guarded(this, [this] {
|
||||
}), crl::guard(this, [this] {
|
||||
_removingSetId = 0;
|
||||
emit checkForHide();
|
||||
})));
|
||||
|
@ -14,7 +14,7 @@ namespace ChatHelpers {
|
||||
|
||||
TabbedMemento::TabbedMemento(
|
||||
object_ptr<TabbedSelector> selector,
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> returnMethod)
|
||||
Fn<void(object_ptr<TabbedSelector>)> returnMethod)
|
||||
: _selector(std::move(selector))
|
||||
, _returnMethod(std::move(returnMethod)) {
|
||||
}
|
||||
@ -46,14 +46,14 @@ TabbedSection::TabbedSection(
|
||||
parent,
|
||||
controller,
|
||||
object_ptr<TabbedSelector>(this, controller),
|
||||
base::lambda<void(object_ptr<TabbedSelector>)>()) {
|
||||
Fn<void(object_ptr<TabbedSelector>)>()) {
|
||||
}
|
||||
|
||||
TabbedSection::TabbedSection(
|
||||
QWidget *parent,
|
||||
not_null<Window::Controller*> controller,
|
||||
object_ptr<TabbedSelector> selector,
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> returnMethod)
|
||||
Fn<void(object_ptr<TabbedSelector>)> returnMethod)
|
||||
: Window::SectionWidget(parent, controller)
|
||||
, _selector(std::move(selector))
|
||||
, _returnMethod(std::move(returnMethod)) {
|
||||
@ -67,8 +67,8 @@ TabbedSection::TabbedSection(
|
||||
_cancelledCallback();
|
||||
}
|
||||
});
|
||||
_selector->setAfterShownCallback(base::lambda<void(SelectorTab)>());
|
||||
_selector->setBeforeHidingCallback(base::lambda<void(SelectorTab)>());
|
||||
_selector->setAfterShownCallback(Fn<void(SelectorTab)>());
|
||||
_selector->setBeforeHidingCallback(Fn<void(SelectorTab)>());
|
||||
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class TabbedMemento : public Window::SectionMemento {
|
||||
public:
|
||||
TabbedMemento(
|
||||
object_ptr<TabbedSelector> selector,
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> returnMethod);
|
||||
Fn<void(object_ptr<TabbedSelector>)> returnMethod);
|
||||
TabbedMemento(TabbedMemento &&other) = default;
|
||||
TabbedMemento &operator=(TabbedMemento &&other) = default;
|
||||
|
||||
@ -32,7 +32,7 @@ public:
|
||||
|
||||
private:
|
||||
object_ptr<TabbedSelector> _selector;
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> _returnMethod;
|
||||
Fn<void(object_ptr<TabbedSelector>)> _returnMethod;
|
||||
|
||||
};
|
||||
|
||||
@ -45,11 +45,11 @@ public:
|
||||
QWidget *parent,
|
||||
not_null<Window::Controller*> controller,
|
||||
object_ptr<TabbedSelector> selector,
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> returnMethod);
|
||||
Fn<void(object_ptr<TabbedSelector>)> returnMethod);
|
||||
|
||||
void beforeHiding();
|
||||
void afterShown();
|
||||
void setCancelledCallback(base::lambda<void()> callback) {
|
||||
void setCancelledCallback(Fn<void()> callback) {
|
||||
_cancelledCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -77,8 +77,8 @@ protected:
|
||||
|
||||
private:
|
||||
object_ptr<TabbedSelector> _selector;
|
||||
base::lambda<void()> _cancelledCallback;
|
||||
base::lambda<void(object_ptr<TabbedSelector>)> _returnMethod;
|
||||
Fn<void()> _cancelledCallback;
|
||||
Fn<void(object_ptr<TabbedSelector>)> _returnMethod;
|
||||
|
||||
};
|
||||
|
||||
|
@ -63,10 +63,10 @@ public:
|
||||
return _a_slide.animating();
|
||||
}
|
||||
|
||||
void setAfterShownCallback(base::lambda<void(SelectorTab)> callback) {
|
||||
void setAfterShownCallback(Fn<void(SelectorTab)> callback) {
|
||||
_afterShownCallback = std::move(callback);
|
||||
}
|
||||
void setBeforeHidingCallback(base::lambda<void(SelectorTab)> callback) {
|
||||
void setBeforeHidingCallback(Fn<void(SelectorTab)> callback) {
|
||||
_beforeHidingCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -187,8 +187,8 @@ private:
|
||||
std::array<Tab, Tab::kCount> _tabs;
|
||||
SelectorTab _currentTabType = SelectorTab::Emoji;
|
||||
|
||||
base::lambda<void(SelectorTab)> _afterShownCallback;
|
||||
base::lambda<void(SelectorTab)> _beforeHidingCallback;
|
||||
Fn<void(SelectorTab)> _afterShownCallback;
|
||||
Fn<void(SelectorTab)> _beforeHidingCallback;
|
||||
|
||||
rpl::event_stream<> _showRequests;
|
||||
|
||||
|
@ -11,12 +11,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <ctime>
|
||||
#include <functional>
|
||||
|
||||
#include <crl/crl.h>
|
||||
#include "base/build_config.h"
|
||||
#include "base/ordered_set.h"
|
||||
#include "base/unique_function.h"
|
||||
#include "base/functors.h"
|
||||
|
||||
namespace func = base::functors;
|
||||
|
||||
using gsl::not_null;
|
||||
|
||||
template <typename Signature>
|
||||
using Fn = std::function<Signature>;
|
||||
|
||||
template <typename Signature>
|
||||
using FnMut = base::unique_function<Signature>;
|
||||
|
||||
//using uchar = unsigned char; // Qt has uchar
|
||||
using int16 = qint16;
|
||||
using uint16 = quint16;
|
||||
@ -28,4 +40,4 @@ using float32 = float;
|
||||
using float64 = double;
|
||||
|
||||
#define qsl(s) QStringLiteral(s)
|
||||
#define qstr(s) QLatin1String(s, sizeof(s) - 1)
|
||||
#define qstr(s) QLatin1String((s), sizeof(s) - 1)
|
||||
|
@ -177,7 +177,7 @@ void Changelogs::requestCloudLogs() {
|
||||
};
|
||||
_session->api().requestChangelog(
|
||||
FormatVersionPrecise(_oldVersion),
|
||||
base::lambda_guarded(this, callback));
|
||||
crl::guard(this, callback));
|
||||
}
|
||||
|
||||
void Changelogs::addLocalLogs() {
|
||||
|
@ -171,7 +171,7 @@ protected:
|
||||
|
||||
class LambdaClickHandler : public ClickHandler {
|
||||
public:
|
||||
LambdaClickHandler(base::lambda<void()> handler) : _handler(std::move(handler)) {
|
||||
LambdaClickHandler(Fn<void()> handler) : _handler(std::move(handler)) {
|
||||
}
|
||||
void onClick(Qt::MouseButton button) const override final {
|
||||
if (button == Qt::LeftButton && _handler) {
|
||||
@ -180,6 +180,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
base::lambda<void()> _handler;
|
||||
Fn<void()> _handler;
|
||||
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ namespace Core {
|
||||
|
||||
EventFilter::EventFilter(
|
||||
not_null<QObject*> parent,
|
||||
base::lambda<bool(not_null<QEvent*>)> filter)
|
||||
Fn<bool(not_null<QEvent*>)> filter)
|
||||
: QObject(parent)
|
||||
, _filter(std::move(filter)) {
|
||||
parent->installEventFilter(this);
|
||||
@ -23,7 +23,7 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event) {
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
base::lambda<bool(not_null<QEvent*>)> filter) {
|
||||
Fn<bool(not_null<QEvent*>)> filter) {
|
||||
return new EventFilter(object, std::move(filter));
|
||||
}
|
||||
|
||||
|
@ -13,18 +13,18 @@ class EventFilter : public QObject {
|
||||
public:
|
||||
EventFilter(
|
||||
not_null<QObject*> parent,
|
||||
base::lambda<bool(not_null<QEvent*>)> filter);
|
||||
Fn<bool(not_null<QEvent*>)> filter);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
base::lambda<bool(not_null<QEvent*>)> _filter;
|
||||
Fn<bool(not_null<QEvent*>)> _filter;
|
||||
|
||||
};
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
base::lambda<bool(not_null<QEvent*>)> filter);
|
||||
Fn<bool(not_null<QEvent*>)> filter);
|
||||
|
||||
} // namespace Core
|
||||
|
@ -154,8 +154,8 @@ void GetOpenPath(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
base::lambda<void(OpenResult &&result)> callback,
|
||||
base::lambda<void()> failed) {
|
||||
Fn<void(OpenResult &&result)> callback,
|
||||
Fn<void()> failed) {
|
||||
InvokeQueued(QApplication::instance(), [=] {
|
||||
auto files = QStringList();
|
||||
auto remoteContent = QByteArray();
|
||||
@ -187,8 +187,8 @@ void GetOpenPaths(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
base::lambda<void(OpenResult &&result)> callback,
|
||||
base::lambda<void()> failed) {
|
||||
Fn<void(OpenResult &&result)> callback,
|
||||
Fn<void()> failed) {
|
||||
InvokeQueued(QApplication::instance(), [=] {
|
||||
auto files = QStringList();
|
||||
auto remoteContent = QByteArray();
|
||||
@ -217,8 +217,8 @@ void GetWritePath(
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
const QString &initialPath,
|
||||
base::lambda<void(QString &&result)> callback,
|
||||
base::lambda<void()> failed) {
|
||||
Fn<void(QString &&result)> callback,
|
||||
Fn<void()> failed) {
|
||||
InvokeQueued(QApplication::instance(), [=] {
|
||||
auto file = QString();
|
||||
if (filedialogGetSaveFile(parent, file, caption, filter, initialPath)) {
|
||||
@ -235,8 +235,8 @@ void GetFolder(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &initialPath,
|
||||
base::lambda<void(QString &&result)> callback,
|
||||
base::lambda<void()> failed) {
|
||||
Fn<void(QString &&result)> callback,
|
||||
Fn<void()> failed) {
|
||||
InvokeQueued(QApplication::instance(), [=] {
|
||||
auto files = QStringList();
|
||||
auto remoteContent = QByteArray();
|
||||
|
@ -57,27 +57,27 @@ void GetOpenPath(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
base::lambda<void(OpenResult &&result)> callback,
|
||||
base::lambda<void()> failed = base::lambda<void()>());
|
||||
Fn<void(OpenResult &&result)> callback,
|
||||
Fn<void()> failed = Fn<void()>());
|
||||
void GetOpenPaths(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
base::lambda<void(OpenResult &&result)> callback,
|
||||
base::lambda<void()> failed = base::lambda<void()>());
|
||||
Fn<void(OpenResult &&result)> callback,
|
||||
Fn<void()> failed = Fn<void()>());
|
||||
void GetWritePath(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &filter,
|
||||
const QString &initialPath,
|
||||
base::lambda<void(QString &&result)> callback,
|
||||
base::lambda<void()> failed = base::lambda<void()>());
|
||||
Fn<void(QString &&result)> callback,
|
||||
Fn<void()> failed = Fn<void()>());
|
||||
void GetFolder(
|
||||
QPointer<QWidget> parent,
|
||||
const QString &caption,
|
||||
const QString &initialPath,
|
||||
base::lambda<void(QString &&result)> callback,
|
||||
base::lambda<void()> failed = base::lambda<void()>());
|
||||
Fn<void(QString &&result)> callback,
|
||||
Fn<void()> failed = Fn<void()>());
|
||||
|
||||
QString AllFilesFilter();
|
||||
|
||||
|
@ -14,7 +14,7 @@ SingleTimer::SingleTimer(QObject *parent) : QTimer(parent) {
|
||||
Sandbox::connect(SIGNAL(adjustSingleTimers()), this, SLOT(adjust()));
|
||||
}
|
||||
|
||||
void SingleTimer::setTimeoutHandler(base::lambda<void()> handler) {
|
||||
void SingleTimer::setTimeoutHandler(Fn<void()> handler) {
|
||||
if (_handler && !handler) {
|
||||
disconnect(this, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
||||
} else if (handler && !_handler) {
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
void setSingleShot(bool); // is not available
|
||||
void start(); // is not available
|
||||
|
||||
void setTimeoutHandler(base::lambda<void()> handler);
|
||||
void setTimeoutHandler(Fn<void()> handler);
|
||||
|
||||
public slots:
|
||||
void start(int msec);
|
||||
@ -30,6 +30,6 @@ private slots:
|
||||
|
||||
private:
|
||||
TimeMs _finishing = 0;
|
||||
base::lambda<void()> _handler;
|
||||
Fn<void()> _handler;
|
||||
|
||||
};
|
||||
|
@ -211,8 +211,8 @@ public:
|
||||
template <typename T>
|
||||
void send(
|
||||
const T &request,
|
||||
base::lambda<void(const typename T::ResponseType &result)> done,
|
||||
base::lambda<void(const RPCError &error)> fail,
|
||||
Fn<void(const typename T::ResponseType &result)> done,
|
||||
Fn<void(const RPCError &error)> fail,
|
||||
MTP::ShiftedDcId dcId = 0);
|
||||
|
||||
bool valid() const;
|
||||
@ -225,7 +225,7 @@ private:
|
||||
bool removeRequest(mtpRequestId requestId);
|
||||
|
||||
QPointer<MTP::Instance> _instance;
|
||||
std::map<mtpRequestId, base::lambda<void(const RPCError &)>> _requests;
|
||||
std::map<mtpRequestId, Fn<void(const RPCError &)>> _requests;
|
||||
|
||||
};
|
||||
|
||||
@ -248,11 +248,11 @@ private:
|
||||
};
|
||||
|
||||
using Checker::fail;
|
||||
base::lambda<void(const RPCError &error)> failHandler();
|
||||
Fn<void(const RPCError &error)> failHandler();
|
||||
|
||||
void resolveChannel(
|
||||
const QString &username,
|
||||
base::lambda<void(const MTPInputChannel &channel)> callback);
|
||||
Fn<void(const MTPInputChannel &channel)> callback);
|
||||
void gotMessage(const MTPmessages_Messages &result);
|
||||
base::optional<FileLocation> parseMessage(
|
||||
const MTPmessages_Messages &result) const;
|
||||
@ -285,7 +285,7 @@ private:
|
||||
void startLoading() override;
|
||||
void sendRequest();
|
||||
void gotPart(int offset, const MTPupload_File &result);
|
||||
base::lambda<void(const RPCError &)> failHandler();
|
||||
Fn<void(const RPCError &)> failHandler();
|
||||
|
||||
static constexpr auto kRequestsCount = 2;
|
||||
static constexpr auto kNextRequestDelay = TimeMs(20);
|
||||
@ -891,8 +891,7 @@ HttpChecker::HttpChecker(bool testing) : Checker(testing) {
|
||||
|
||||
void HttpChecker::start() {
|
||||
auto url = QUrl(Local::readAutoupdatePrefix() + qstr("/current"));
|
||||
DEBUG_LOG(("Update Info: requesting update state from '%1'"
|
||||
).arg(url.toDisplayString()));
|
||||
DEBUG_LOG(("Update Info: requesting update state"));
|
||||
const auto request = QNetworkRequest(url);
|
||||
_manager = std::make_unique<QNetworkAccessManager>();
|
||||
_reply = _manager->get(request);
|
||||
@ -1193,8 +1192,8 @@ void MtpWeak::die() {
|
||||
template <typename T>
|
||||
void MtpWeak::send(
|
||||
const T &request,
|
||||
base::lambda<void(const typename T::ResponseType &result)> done,
|
||||
base::lambda<void(const RPCError &error)> fail,
|
||||
Fn<void(const typename T::ResponseType &result)> done,
|
||||
Fn<void(const RPCError &error)> fail,
|
||||
MTP::ShiftedDcId dcId) {
|
||||
using Response = typename T::ResponseType;
|
||||
if (!valid()) {
|
||||
@ -1203,14 +1202,14 @@ void MtpWeak::send(
|
||||
});
|
||||
return;
|
||||
}
|
||||
const auto onDone = base::lambda_guarded(this, [=](
|
||||
const auto onDone = crl::guard((QObject*)this, [=](
|
||||
const Response &result,
|
||||
mtpRequestId requestId) {
|
||||
if (removeRequest(requestId)) {
|
||||
done(result);
|
||||
}
|
||||
});
|
||||
const auto onFail = base::lambda_guarded(this, [=](
|
||||
const auto onFail = crl::guard((QObject*)this, [=](
|
||||
const RPCError &error,
|
||||
mtpRequestId requestId) {
|
||||
if (MTP::isDefaultHandledError(error)) {
|
||||
@ -1277,7 +1276,7 @@ void MtpChecker::start() {
|
||||
|
||||
void MtpChecker::resolveChannel(
|
||||
const QString &username,
|
||||
base::lambda<void(const MTPInputChannel &channel)> callback) {
|
||||
Fn<void(const MTPInputChannel &channel)> callback) {
|
||||
const auto failed = [&] {
|
||||
LOG(("Update Error: MTP channel '%1' resolve failed."
|
||||
).arg(username));
|
||||
@ -1467,7 +1466,7 @@ auto MtpChecker::parseFile(const MTPmessages_Messages &result) const
|
||||
return ParsedFile { name, size, fields.vdc_id.v, location };
|
||||
}
|
||||
|
||||
base::lambda<void(const RPCError &error)> MtpChecker::failHandler() {
|
||||
Fn<void(const RPCError &error)> MtpChecker::failHandler() {
|
||||
return [=](const RPCError &error) {
|
||||
LOG(("Update Error: MTP check failed with '%1'"
|
||||
).arg(QString::number(error.code()) + ':' + error.type()));
|
||||
@ -1549,7 +1548,7 @@ void MtpLoader::gotPart(int offset, const MTPupload_File &result) {
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
base::lambda<void(const RPCError &)> MtpLoader::failHandler() {
|
||||
Fn<void(const RPCError &)> MtpLoader::failHandler() {
|
||||
return [=](const RPCError &error) {
|
||||
LOG(("Update Error: MTP load failed with '%1'"
|
||||
).arg(QString::number(error.code()) + ':' + error.type()));
|
||||
|
@ -399,7 +399,7 @@ rpl::producer<SparseIdsMergedSlice> SparseIdsMergedSlice::CreateViewer(
|
||||
SparseIdsMergedSlice::Key key,
|
||||
int limitBefore,
|
||||
int limitAfter,
|
||||
base::lambda<SimpleViewerFunction> simpleViewer) {
|
||||
Fn<SimpleViewerFunction> simpleViewer) {
|
||||
Expects(IsServerMsgId(key.universalId)
|
||||
|| (key.universalId == 0)
|
||||
|| (IsServerMsgId(ServerMaxMsgId + key.universalId) && key.migratedPeerId != 0));
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
SparseIdsMergedSlice::Key key,
|
||||
int limitBefore,
|
||||
int limitAfter,
|
||||
base::lambda<SimpleViewerFunction> simpleViewer);
|
||||
Fn<SimpleViewerFunction> simpleViewer);
|
||||
|
||||
private:
|
||||
static SparseIdsSlice::Key PartKey(const Key &key) {
|
||||
|
@ -1519,7 +1519,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
Window::FillPeerMenu(
|
||||
_controller,
|
||||
history->peer,
|
||||
[&](const QString &text, base::lambda<void()> callback) {
|
||||
[&](const QString &text, Fn<void()> callback) {
|
||||
return _menu->addAction(text, std::move(callback));
|
||||
},
|
||||
Window::PeerMenuSource::ChatsList);
|
||||
@ -1527,7 +1527,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
Window::FillFeedMenu(
|
||||
_controller,
|
||||
feed,
|
||||
[&](const QString &text, base::lambda<void()> callback) {
|
||||
[&](const QString &text, Fn<void()> callback) {
|
||||
return _menu->addAction(text, std::move(callback));
|
||||
},
|
||||
Window::PeerMenuSource::ChatsList);
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
|
||||
PeerData *updateFromParentDrag(QPoint globalPos);
|
||||
|
||||
void setLoadMoreCallback(base::lambda<void()> callback) {
|
||||
void setLoadMoreCallback(Fn<void()> callback) {
|
||||
_loadMoreCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ private:
|
||||
Text _searchFromUserText;
|
||||
Dialogs::Key _menuKey;
|
||||
|
||||
base::lambda<void()> _loadMoreCallback;
|
||||
Fn<void()> _loadMoreCallback;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace Dialogs {
|
||||
RippleRow::RippleRow() = default;
|
||||
RippleRow::~RippleRow() = default;
|
||||
|
||||
void RippleRow::addRipple(QPoint origin, QSize size, base::lambda<void()> updateCallback) {
|
||||
void RippleRow::addRipple(QPoint origin, QSize size, Fn<void()> updateCallback) {
|
||||
if (!_ripple) {
|
||||
auto mask = Ui::RippleAnimation::rectMask(size);
|
||||
_ripple = std::make_unique<Ui::RippleAnimation>(st::dialogsRipple, std::move(mask), std::move(updateCallback));
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
RippleRow();
|
||||
~RippleRow();
|
||||
|
||||
void addRipple(QPoint origin, QSize size, base::lambda<void()> updateCallback);
|
||||
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
|
||||
void stopLastRipple();
|
||||
|
||||
void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const;
|
||||
|
@ -18,8 +18,8 @@ namespace Dialogs {
|
||||
void ShowSearchFromBox(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
base::lambda<void(not_null<UserData*>)> callback,
|
||||
base::lambda<void()> closedCallback) {
|
||||
Fn<void(not_null<UserData*>)> callback,
|
||||
Fn<void()> closedCallback) {
|
||||
auto createController = [
|
||||
navigation,
|
||||
peer,
|
||||
@ -54,7 +54,7 @@ void ShowSearchFromBox(
|
||||
ChatSearchFromController::ChatSearchFromController(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<ChatData*> chat,
|
||||
base::lambda<void(not_null<UserData*>)> callback)
|
||||
Fn<void(not_null<UserData*>)> callback)
|
||||
: PeerListController()
|
||||
, _chat(chat)
|
||||
, _callback(std::move(callback)) {
|
||||
@ -128,7 +128,7 @@ void ChatSearchFromController::appendRow(not_null<UserData*> user) {
|
||||
ChannelSearchFromController::ChannelSearchFromController(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::lambda<void(not_null<UserData*>)> callback)
|
||||
Fn<void(not_null<UserData*>)> callback)
|
||||
: ParticipantsBoxController(
|
||||
navigation,
|
||||
channel,
|
||||
|
@ -15,15 +15,15 @@ namespace Dialogs {
|
||||
void ShowSearchFromBox(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
base::lambda<void(not_null<UserData*>)> callback,
|
||||
base::lambda<void()> closedCallback);
|
||||
Fn<void(not_null<UserData*>)> callback,
|
||||
Fn<void()> closedCallback);
|
||||
|
||||
class ChatSearchFromController : public PeerListController, protected base::Subscriber {
|
||||
public:
|
||||
ChatSearchFromController(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<ChatData*> chat,
|
||||
base::lambda<void(not_null<UserData*>)> callback);
|
||||
Fn<void(not_null<UserData*>)> callback);
|
||||
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
@ -34,7 +34,7 @@ private:
|
||||
void appendRow(not_null<UserData*> user);
|
||||
|
||||
not_null<ChatData*> _chat;
|
||||
base::lambda<void(not_null<UserData*>)> _callback;
|
||||
Fn<void(not_null<UserData*>)> _callback;
|
||||
|
||||
};
|
||||
|
||||
@ -43,7 +43,7 @@ public:
|
||||
ChannelSearchFromController(
|
||||
not_null<Window::Navigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
base::lambda<void(not_null<UserData*>)> callback);
|
||||
Fn<void(not_null<UserData*>)> callback);
|
||||
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
@ -52,7 +52,7 @@ protected:
|
||||
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const override;
|
||||
|
||||
private:
|
||||
base::lambda<void(not_null<UserData*>)> _callback;
|
||||
Fn<void(not_null<UserData*>)> _callback;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1078,13 +1078,13 @@ void DialogsWidget::showSearchFrom() {
|
||||
Dialogs::ShowSearchFromBox(
|
||||
controller(),
|
||||
peer,
|
||||
base::lambda_guarded(this, [=](
|
||||
crl::guard(this, [=](
|
||||
not_null<UserData*> user) {
|
||||
Ui::hideLayer();
|
||||
setSearchInChat(chat, user);
|
||||
onFilterUpdate(true);
|
||||
}),
|
||||
base::lambda_guarded(this, [this] { _filter->setFocus(); }));
|
||||
crl::guard(this, [this] { _filter->setFocus(); }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace App {
|
||||
namespace internal {
|
||||
|
||||
void CallDelayed(int duration, base::lambda_once<void()> &&lambda) {
|
||||
void CallDelayed(int duration, FnMut<void()> &&lambda) {
|
||||
Messenger::Instance().callDelayed(duration, std::move(lambda));
|
||||
}
|
||||
|
||||
|
@ -25,55 +25,30 @@ class ItemBase;
|
||||
namespace App {
|
||||
namespace internal {
|
||||
|
||||
void CallDelayed(int duration, base::lambda_once<void()> &&lambda);
|
||||
void CallDelayed(int duration, FnMut<void()> &&lambda);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename Lambda>
|
||||
template <typename Guard, typename Lambda>
|
||||
inline void CallDelayed(
|
||||
int duration,
|
||||
base::lambda_internal::guard_with_QObject<Lambda> &&guarded) {
|
||||
crl::guarded_wrap<Guard, Lambda> &&guarded) {
|
||||
return internal::CallDelayed(
|
||||
duration,
|
||||
std::move(guarded));
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline void CallDelayed(
|
||||
int duration,
|
||||
base::lambda_internal::guard_with_weak<Lambda> &&guarded) {
|
||||
return internal::CallDelayed(
|
||||
duration,
|
||||
std::move(guarded));
|
||||
template <typename Guard, typename Lambda>
|
||||
inline void CallDelayed(int duration, Guard &&object, Lambda &&lambda) {
|
||||
return internal::CallDelayed(duration, crl::guard(
|
||||
std::forward<Guard>(object),
|
||||
std::forward<Lambda>(lambda)));
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline void CallDelayed(
|
||||
int duration,
|
||||
const QObject *object,
|
||||
Lambda &&lambda) {
|
||||
return internal::CallDelayed(
|
||||
duration,
|
||||
base::lambda_guarded(object, std::forward<Lambda>(lambda)));
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline void CallDelayed(
|
||||
int duration,
|
||||
const base::has_weak_ptr *object,
|
||||
Lambda &&lambda) {
|
||||
return internal::CallDelayed(
|
||||
duration,
|
||||
base::lambda_guarded(object, std::forward<Lambda>(lambda)));
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto LambdaDelayed(
|
||||
int duration,
|
||||
const QObject *object,
|
||||
Lambda &&lambda) {
|
||||
auto guarded = base::lambda_guarded(
|
||||
object,
|
||||
template <typename Guard, typename Lambda>
|
||||
inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
|
||||
auto guarded = crl::guard(
|
||||
std::forward<Guard>(object),
|
||||
std::forward<Lambda>(lambda));
|
||||
return [saved = std::move(guarded), duration] {
|
||||
auto copy = saved;
|
||||
@ -81,46 +56,6 @@ inline auto LambdaDelayed(
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto LambdaDelayed(
|
||||
int duration,
|
||||
const base::has_weak_ptr *object,
|
||||
Lambda &&lambda) {
|
||||
auto guarded = base::lambda_guarded(
|
||||
object,
|
||||
std::forward<Lambda>(lambda));
|
||||
return [saved = std::move(guarded), duration] {
|
||||
auto copy = saved;
|
||||
internal::CallDelayed(duration, std::move(copy));
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto LambdaDelayedOnce(
|
||||
int duration,
|
||||
const QObject *object,
|
||||
Lambda &&lambda) {
|
||||
auto guarded = base::lambda_guarded(
|
||||
object,
|
||||
std::forward<Lambda>(lambda));
|
||||
return [saved = std::move(guarded), duration]() mutable {
|
||||
internal::CallDelayed(duration, std::move(saved));
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Lambda>
|
||||
inline auto LambdaDelayedOnce(
|
||||
int duration,
|
||||
const base::has_weak_ptr *object,
|
||||
Lambda &&lambda) {
|
||||
auto guarded = base::lambda_guarded(
|
||||
object,
|
||||
std::forward<Lambda>(lambda));
|
||||
return [saved = std::move(guarded), duration]() mutable {
|
||||
internal::CallDelayed(duration, std::move(saved));
|
||||
};
|
||||
}
|
||||
|
||||
void sendBotCommand(
|
||||
PeerData *peer,
|
||||
UserData *bot,
|
||||
|
@ -134,7 +134,7 @@ QPoint UserCheckbox::prepareRippleStartPosition() const {
|
||||
|
||||
class FilterBox::Inner : public TWidget, private base::Subscriber {
|
||||
public:
|
||||
Inner(QWidget *parent, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, base::lambda<void()> changedCallback);
|
||||
Inner(QWidget *parent, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, Fn<void()> changedCallback);
|
||||
|
||||
template <typename Widget>
|
||||
QPointer<Widget> addRow(object_ptr<Widget> widget, int marginTop) {
|
||||
@ -176,11 +176,11 @@ private:
|
||||
};
|
||||
std::vector<Row> _rows;
|
||||
|
||||
base::lambda<void()> _changedCallback;
|
||||
Fn<void()> _changedCallback;
|
||||
|
||||
};
|
||||
|
||||
FilterBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, base::lambda<void()> changedCallback) : TWidget(parent)
|
||||
FilterBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, Fn<void()> changedCallback) : TWidget(parent)
|
||||
, _channel(channel)
|
||||
, _changedCallback(std::move(changedCallback)) {
|
||||
createControls(admins, filter);
|
||||
@ -344,7 +344,7 @@ void FilterBox::Inner::resizeEvent(QResizeEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
FilterBox::FilterBox(QWidget*, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, base::lambda<void(FilterValue &&filter)> saveCallback) : BoxContent()
|
||||
FilterBox::FilterBox(QWidget*, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, Fn<void(FilterValue &&filter)> saveCallback) : BoxContent()
|
||||
, _channel(channel)
|
||||
, _admins(admins)
|
||||
, _initialFilter(filter)
|
||||
|
@ -14,7 +14,7 @@ namespace AdminLog {
|
||||
|
||||
class FilterBox : public BoxContent {
|
||||
public:
|
||||
FilterBox(QWidget*, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, base::lambda<void(FilterValue &&filter)> saveCallback);
|
||||
FilterBox(QWidget*, not_null<ChannelData*> channel, const std::vector<not_null<UserData*>> &admins, const FilterValue &filter, Fn<void(FilterValue &&filter)> saveCallback);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@ -26,7 +26,7 @@ private:
|
||||
not_null<ChannelData*> _channel;
|
||||
std::vector<not_null<UserData*>> _admins;
|
||||
FilterValue _initialFilter;
|
||||
base::lambda<void(FilterValue &&filter)> _saveCallback;
|
||||
Fn<void(FilterValue &&filter)> _saveCallback;
|
||||
|
||||
class Inner;
|
||||
QPointer<Inner> _inner;
|
||||
|
@ -419,7 +419,7 @@ void InnerWidget::requestAdmins() {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void InnerWidget::showFilter(base::lambda<void(FilterValue &&filter)> callback) {
|
||||
void InnerWidget::showFilter(Fn<void(FilterValue &&filter)> callback) {
|
||||
if (_admins.empty()) {
|
||||
_showFilterCallback = std::move(callback);
|
||||
} else {
|
||||
@ -1089,7 +1089,7 @@ void InnerWidget::savePhotoToFile(PhotoData *photo) {
|
||||
lang(lng_save_photo),
|
||||
filter,
|
||||
filedialogDefaultName(qsl("photo"), qsl(".jpg")),
|
||||
base::lambda_guarded(this, [=](const QString &result) {
|
||||
crl::guard(this, [=](const QString &result) {
|
||||
if (!result.isEmpty()) {
|
||||
photo->full->pix().toImage().save(result, "JPG");
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
// Empty "flags" means all events.
|
||||
void applyFilter(FilterValue &&value);
|
||||
void applySearch(const QString &query);
|
||||
void showFilter(base::lambda<void(FilterValue &&filter)> callback);
|
||||
void showFilter(Fn<void(FilterValue &&filter)> callback);
|
||||
|
||||
// Ui::AbstractTooltipShower interface.
|
||||
QString tooltipText() const override;
|
||||
@ -260,7 +260,7 @@ private:
|
||||
QString _searchQuery;
|
||||
std::vector<not_null<UserData*>> _admins;
|
||||
std::vector<not_null<UserData*>> _adminsCanEdit;
|
||||
base::lambda<void(FilterValue &&filter)> _showFilterCallback;
|
||||
Fn<void(FilterValue &&filter)> _showFilterCallback;
|
||||
|
||||
std::shared_ptr<LocalIdManager> _idManager;
|
||||
|
||||
|
@ -327,7 +327,7 @@ void GenerateItems(
|
||||
not_null<History*> history,
|
||||
not_null<LocalIdManager*> idManager,
|
||||
const MTPDchannelAdminLogEvent &event,
|
||||
base::lambda<void(OwnedItem item)> callback) {
|
||||
Fn<void(OwnedItem item)> callback) {
|
||||
Expects(history->peer->isChannel());
|
||||
|
||||
auto id = event.vid.v;
|
||||
|
@ -22,7 +22,7 @@ void GenerateItems(
|
||||
not_null<History*> history,
|
||||
not_null<LocalIdManager*> idManager,
|
||||
const MTPDchannelAdminLogEvent &event,
|
||||
base::lambda<void(OwnedItem item)> callback);
|
||||
Fn<void(OwnedItem item)> callback);
|
||||
|
||||
// Smart pointer wrapper for HistoryItem* that destroys the owned item.
|
||||
class OwnedItem {
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
void hideFast();
|
||||
|
||||
void setDroppedCallback(base::lambda<void(const QMimeData *data)> callback) {
|
||||
void setDroppedCallback(Fn<void(const QMimeData *data)> callback) {
|
||||
_droppedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ private:
|
||||
bool _hiding = false;
|
||||
bool _in = false;
|
||||
QPixmap _cache;
|
||||
base::lambda<void(const QMimeData *data)> _droppedCallback;
|
||||
Fn<void(const QMimeData *data)> _droppedCallback;
|
||||
|
||||
Animation _a_opacity;
|
||||
Animation _a_in;
|
||||
|
@ -1744,7 +1744,7 @@ void HistoryInner::savePhotoToFile(not_null<PhotoData*> photo) {
|
||||
filedialogDefaultName(
|
||||
qsl("photo"),
|
||||
qsl(".jpg")),
|
||||
base::lambda_guarded(this, [=](const QString &result) {
|
||||
crl::guard(this, [=](const QString &result) {
|
||||
if (!result.isEmpty()) {
|
||||
photo->full->pix().toImage().save(result, "JPG");
|
||||
}
|
||||
|
@ -209,15 +209,15 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||
return false;
|
||||
};
|
||||
auto copyLinkCallback = canCopyLink
|
||||
? base::lambda<void()>(std::move(copyCallback))
|
||||
: base::lambda<void()>();
|
||||
? Fn<void()>(std::move(copyCallback))
|
||||
: Fn<void()>();
|
||||
Ui::show(Box<ShareBox>(
|
||||
std::move(copyLinkCallback),
|
||||
std::move(submitCallback),
|
||||
std::move(filterCallback)));
|
||||
}
|
||||
|
||||
base::lambda<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
const FullMsgId &msgId) {
|
||||
return [dependent = msgId](ChannelData *channel, MsgId msgId) {
|
||||
if (auto item = App::histItemById(dependent)) {
|
||||
|
@ -15,7 +15,7 @@ class Message;
|
||||
|
||||
struct HistoryMessageEdited;
|
||||
|
||||
base::lambda<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
const FullMsgId &msgId);
|
||||
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
|
||||
QString GetErrorTextForForward(
|
||||
|
@ -3221,7 +3221,7 @@ void HistoryWidget::chooseAttach() {
|
||||
|
||||
auto filter = FileDialog::AllFilesFilter() + qsl(";;Image files (*") + cImgExtensions().join(qsl(" *")) + qsl(")");
|
||||
|
||||
FileDialog::GetOpenPaths(this, lang(lng_choose_files), filter, base::lambda_guarded(this, [this](FileDialog::OpenResult &&result) {
|
||||
FileDialog::GetOpenPaths(this, lang(lng_choose_files), filter, crl::guard(this, [this](FileDialog::OpenResult &&result) {
|
||||
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -3891,7 +3891,7 @@ void HistoryWidget::pushTabbedSelectorToThirdSection(
|
||||
auto destroyingPanel = std::move(_tabbedPanel);
|
||||
auto memento = ChatHelpers::TabbedMemento(
|
||||
destroyingPanel->takeSelector(),
|
||||
base::lambda_guarded(this, [this](
|
||||
crl::guard(this, [this](
|
||||
object_ptr<TabbedSelector> selector) {
|
||||
returnTabbedSelector(std::move(selector));
|
||||
}));
|
||||
@ -4179,7 +4179,7 @@ bool HistoryWidget::confirmSendingFiles(
|
||||
text,
|
||||
boxCompressConfirm);
|
||||
_field->setTextWithTags({});
|
||||
box->setConfirmedCallback(base::lambda_guarded(this, [=](
|
||||
box->setConfirmedCallback(crl::guard(this, [=](
|
||||
Storage::PreparedList &&list,
|
||||
SendFilesWay way,
|
||||
TextWithTags &&caption,
|
||||
@ -4200,7 +4200,7 @@ bool HistoryWidget::confirmSendingFiles(
|
||||
replyToId(),
|
||||
album);
|
||||
}));
|
||||
box->setCancelledCallback(base::lambda_guarded(this, [=] {
|
||||
box->setCancelledCallback(crl::guard(this, [=] {
|
||||
_field->setTextWithTags(text);
|
||||
auto cursor = _field->textCursor();
|
||||
cursor.setPosition(anchor);
|
||||
@ -4611,7 +4611,7 @@ void HistoryWidget::documentFailed(const FullMsgId &newId) {
|
||||
|
||||
void HistoryWidget::onReportSpamClicked() {
|
||||
auto text = lang(_peer->isUser() ? lng_report_spam_sure : ((_peer->isChat() || _peer->isMegagroup()) ? lng_report_spam_sure_group : lng_report_spam_sure_channel));
|
||||
Ui::show(Box<ConfirmBox>(text, lang(lng_report_spam_ok), st::attentionBoxButton, base::lambda_guarded(this, [this, peer = _peer] {
|
||||
Ui::show(Box<ConfirmBox>(text, lang(lng_report_spam_ok), st::attentionBoxButton, crl::guard(this, [this, peer = _peer] {
|
||||
if (_reportSpamRequest) return;
|
||||
|
||||
Ui::hideLayer();
|
||||
@ -5840,7 +5840,7 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
|
||||
Ui::show(Box<InformBox>(lang(lng_reply_cant)));
|
||||
} else {
|
||||
const auto itemId = item->fullId();
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_reply_cant_forward), lang(lng_selected_forward), base::lambda_guarded(this, [=] {
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_reply_cant_forward), lang(lng_selected_forward), crl::guard(this, [=] {
|
||||
App::main()->setForwardDraft(
|
||||
_peer->id,
|
||||
{ 1, itemId });
|
||||
@ -5965,7 +5965,7 @@ void HistoryWidget::unpinMessage(FullMsgId itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_pinned_unpin_sure), lang(lng_pinned_unpin), base::lambda_guarded(this, [=] {
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_pinned_unpin_sure), lang(lng_pinned_unpin), crl::guard(this, [=] {
|
||||
channel->clearPinnedMessage();
|
||||
|
||||
Ui::hideLayer();
|
||||
@ -6318,7 +6318,7 @@ void HistoryWidget::onCancel() {
|
||||
lang(lng_cancel_edit_post_sure),
|
||||
lang(lng_cancel_edit_post_yes),
|
||||
lang(lng_cancel_edit_post_no),
|
||||
base::lambda_guarded(this, [this] {
|
||||
crl::guard(this, [this] {
|
||||
if (_editMsgId) {
|
||||
cancelEdit();
|
||||
Ui::hideLayer();
|
||||
|
@ -53,7 +53,7 @@ void SavePhotoToFile(not_null<PhotoData*> photo) {
|
||||
lang(lng_save_photo),
|
||||
qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(),
|
||||
filedialogDefaultName(qsl("photo"), qsl(".jpg")),
|
||||
base::lambda_guarded(&Auth(), [=](const QString &result) {
|
||||
crl::guard(&Auth(), [=](const QString &result) {
|
||||
if (!result.isEmpty()) {
|
||||
photo->full->pix().toImage().save(result, "JPG");
|
||||
}
|
||||
@ -474,7 +474,7 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||
&& (list->delegate()->listContext() == Context::Feed)) {
|
||||
Window::PeerMenuAddMuteAction(peer, [&](
|
||||
const QString &text,
|
||||
base::lambda<void()> handler) {
|
||||
Fn<void()> handler) {
|
||||
return result->addAction(text, handler);
|
||||
});
|
||||
AddToggleGroupingAction(result, linkPeer->peer());
|
||||
|
@ -187,12 +187,12 @@ void TopBarWidget::showMenu() {
|
||||
weak->_menuToggle->setForceRippled(false);
|
||||
}
|
||||
});
|
||||
_menu->setShowStartCallback(base::lambda_guarded(this, [this, menu = _menu.data()] {
|
||||
_menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.data()] {
|
||||
if (_menu == menu) {
|
||||
_menuToggle->setForceRippled(true);
|
||||
}
|
||||
}));
|
||||
_menu->setHideStartCallback(base::lambda_guarded(this, [this, menu = _menu.data()] {
|
||||
_menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.data()] {
|
||||
if (_menu == menu) {
|
||||
_menuToggle->setForceRippled(false);
|
||||
}
|
||||
@ -200,7 +200,7 @@ void TopBarWidget::showMenu() {
|
||||
_menuToggle->installEventFilter(_menu);
|
||||
const auto addAction = [&](
|
||||
const QString &text,
|
||||
base::lambda<void()> callback) {
|
||||
Fn<void()> callback) {
|
||||
return _menu->addAction(text, std::move(callback));
|
||||
};
|
||||
if (const auto peer = _activeChat.peer()) {
|
||||
|
@ -238,11 +238,11 @@ object_ptr<InnerWidget::ListWidget> InnerWidget::setupList(
|
||||
return result;
|
||||
}
|
||||
|
||||
void InnerWidget::peerListSetTitle(base::lambda<QString()> title) {
|
||||
void InnerWidget::peerListSetTitle(Fn<QString()> title) {
|
||||
}
|
||||
|
||||
void InnerWidget::peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) {
|
||||
Fn<QString()> title) {
|
||||
}
|
||||
|
||||
bool InnerWidget::peerListIsRowSelected(not_null<PeerData*> peer) {
|
||||
|
@ -48,9 +48,9 @@ private:
|
||||
using ListWidget = PeerListContent;
|
||||
|
||||
// PeerListContentDelegate interface.
|
||||
void peerListSetTitle(base::lambda<QString()> title) override;
|
||||
void peerListSetTitle(Fn<QString()> title) override;
|
||||
void peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) override;
|
||||
Fn<QString()> title) override;
|
||||
bool peerListIsRowSelected(not_null<PeerData*> peer) override;
|
||||
int peerListSelectedRowsCount() override;
|
||||
std::vector<not_null<PeerData*>> peerListCollectSelectedRows() override;
|
||||
|
@ -289,11 +289,11 @@ void Channels::visibleTopBottomUpdated(
|
||||
setChildVisibleTopBottom(_list, visibleTop, visibleBottom);
|
||||
}
|
||||
|
||||
void Channels::peerListSetTitle(base::lambda<QString()> title) {
|
||||
void Channels::peerListSetTitle(Fn<QString()> title) {
|
||||
}
|
||||
|
||||
void Channels::peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) {
|
||||
Fn<QString()> title) {
|
||||
}
|
||||
|
||||
bool Channels::peerListIsRowSelected(not_null<PeerData*> peer) {
|
||||
|
@ -61,9 +61,9 @@ private:
|
||||
using ListWidget = PeerListContent;
|
||||
|
||||
// PeerListContentDelegate interface.
|
||||
void peerListSetTitle(base::lambda<QString()> title) override;
|
||||
void peerListSetTitle(Fn<QString()> title) override;
|
||||
void peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) override;
|
||||
Fn<QString()> title) override;
|
||||
bool peerListIsRowSelected(not_null<PeerData*> peer) override;
|
||||
int peerListSelectedRowsCount() override;
|
||||
std::vector<not_null<PeerData*>> peerListCollectSelectedRows() override;
|
||||
|
@ -195,7 +195,7 @@ base::unique_qptr<Ui::PopupMenu> ChannelsController::rowContextMenu(
|
||||
auto result = base::make_unique_q<Ui::PopupMenu>(nullptr);
|
||||
Window::PeerMenuAddMuteAction(channel, [&](
|
||||
const QString &text,
|
||||
base::lambda<void()> handler) {
|
||||
Fn<void()> handler) {
|
||||
return result->addAction(text, handler);
|
||||
});
|
||||
//result->addAction( // #feed
|
||||
|
@ -134,7 +134,7 @@ private:
|
||||
QPointer<Ui::FadeWrap<Ui::IconButton>> _delete;
|
||||
rpl::event_stream<> _cancelSelectionClicks;
|
||||
|
||||
using UpdateCallback = base::lambda<bool(anim::type)>;
|
||||
using UpdateCallback = Fn<bool(anim::type)>;
|
||||
std::map<QObject*, UpdateCallback> _updateControlCallbacks;
|
||||
|
||||
};
|
||||
|
@ -497,7 +497,7 @@ void WrapWidget::showProfileMenu() {
|
||||
|
||||
const auto addAction = [=](
|
||||
const QString &text,
|
||||
base::lambda<void()> callback) {
|
||||
Fn<void()> callback) {
|
||||
return _topBarMenu->addAction(text, std::move(callback));
|
||||
};
|
||||
if (const auto peer = key().peer()) {
|
||||
|
@ -1297,20 +1297,20 @@ void ListWidget::showContextMenu(
|
||||
if (canForwardAll()) {
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_forward_selected),
|
||||
base::lambda_guarded(this, [this] {
|
||||
crl::guard(this, [this] {
|
||||
forwardSelected();
|
||||
}));
|
||||
}
|
||||
if (canDeleteAll()) {
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_delete_selected),
|
||||
base::lambda_guarded(this, [this] {
|
||||
crl::guard(this, [this] {
|
||||
deleteSelected();
|
||||
}));
|
||||
}
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_clear_selection),
|
||||
base::lambda_guarded(this, [this] {
|
||||
crl::guard(this, [this] {
|
||||
clearSelected();
|
||||
}));
|
||||
} else {
|
||||
@ -1318,21 +1318,21 @@ void ListWidget::showContextMenu(
|
||||
if (item->allowsForward()) {
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_forward_msg),
|
||||
base::lambda_guarded(this, [this, universalId] {
|
||||
crl::guard(this, [this, universalId] {
|
||||
forwardItem(universalId);
|
||||
}));
|
||||
}
|
||||
if (item->canDelete()) {
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_delete_msg),
|
||||
base::lambda_guarded(this, [this, universalId] {
|
||||
crl::guard(this, [this, universalId] {
|
||||
deleteItem(universalId);
|
||||
}));
|
||||
}
|
||||
}
|
||||
_contextMenu->addAction(
|
||||
lang(lng_context_select_msg),
|
||||
base::lambda_guarded(this, [this, universalId] {
|
||||
crl::guard(this, [this, universalId] {
|
||||
if (hasSelectedText()) {
|
||||
clearSelected();
|
||||
} else if (_selected.size() == MaxSelectedItems) {
|
||||
@ -1344,7 +1344,7 @@ void ListWidget::showContextMenu(
|
||||
}));
|
||||
}
|
||||
|
||||
_contextMenu->setDestroyedCallback(base::lambda_guarded(
|
||||
_contextMenu->setDestroyedCallback(crl::guard(
|
||||
this,
|
||||
[this, universalId] {
|
||||
_contextMenu = nullptr;
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
SectionToggle(
|
||||
const style::InfoToggle &st,
|
||||
bool checked,
|
||||
base::lambda<void()> updateCallback);
|
||||
Fn<void()> updateCallback);
|
||||
|
||||
QSize getSize() const override;
|
||||
void paint(
|
||||
@ -56,7 +56,7 @@ private:
|
||||
SectionToggle::SectionToggle(
|
||||
const style::InfoToggle &st,
|
||||
bool checked,
|
||||
base::lambda<void()> updateCallback)
|
||||
Fn<void()> updateCallback)
|
||||
: AbstractCheckView(st.duration, checked, std::move(updateCallback))
|
||||
, _st(st) {
|
||||
}
|
||||
|
@ -409,11 +409,11 @@ void Members::visibleTopBottomUpdated(
|
||||
setChildVisibleTopBottom(_list, visibleTop, visibleBottom);
|
||||
}
|
||||
|
||||
void Members::peerListSetTitle(base::lambda<QString()> title) {
|
||||
void Members::peerListSetTitle(Fn<QString()> title) {
|
||||
}
|
||||
|
||||
void Members::peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) {
|
||||
Fn<QString()> title) {
|
||||
}
|
||||
|
||||
bool Members::peerListIsRowSelected(not_null<PeerData*> peer) {
|
||||
|
@ -63,9 +63,9 @@ private:
|
||||
using ListWidget = PeerListContent;
|
||||
|
||||
// PeerListContentDelegate interface.
|
||||
void peerListSetTitle(base::lambda<QString()> title) override;
|
||||
void peerListSetTitle(Fn<QString()> title) override;
|
||||
void peerListSetAdditionalTitle(
|
||||
base::lambda<QString()> title) override;
|
||||
Fn<QString()> title) override;
|
||||
bool peerListIsRowSelected(not_null<PeerData*> peer) override;
|
||||
int peerListSelectedRowsCount() override;
|
||||
std::vector<not_null<PeerData*>> peerListCollectSelectedRows() override;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user