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