Use base::call_delayed.

This commit is contained in:
John Preston 2019-09-26 13:55:35 +03:00
parent 09a7daf164
commit 30a1bd7ba2
29 changed files with 68 additions and 83 deletions

View File

@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "base/openssl_help.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "observer_peer.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
@ -361,7 +362,7 @@ void ApiWrap::requestTermsUpdate() {
}
const auto now = crl::now();
if (_termsUpdateSendAt && now < _termsUpdateSendAt) {
App::CallDelayed(_termsUpdateSendAt - now, _session, [=] {
base::call_delayed(_termsUpdateSendAt - now, _session, [=] {
requestTermsUpdate();
});
return;
@ -1283,7 +1284,7 @@ void ApiWrap::gotUserFull(
const auto &d = result.c_userFull();
if (user == _session->user() && !_session->validateSelf(d.vuser())) {
constexpr auto kRequestUserAgainTimeout = crl::time(10000);
App::CallDelayed(kRequestUserAgainTimeout, _session, [=] {
base::call_delayed(kRequestUserAgainTimeout, _session, [=] {
requestFullPeer(user);
});
return;

View File

@ -780,8 +780,8 @@ themesMenuToggle: IconButton(defaultIconButton) {
width: 44px;
height: 44px;
icon: icon {{ "title_menu_dots", menuIconFg }};
iconOver: icon {{ "title_menu_dots", menuIconFgOver }};
icon: menuToggleIcon;
iconOver: menuToggleIconOver;
iconPosition: point(-1px, -1px);
rippleAreaPosition: point(4px, 4px);

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "base/qthelp_url.h"
#include "base/call_delayed.h"
#include "core/application.h"
#include "main/main_account.h"
#include "ui/widgets/checkbox.h"
@ -1437,7 +1438,7 @@ void ProxiesBoxController::share(const ProxyData &proxy) {
ProxiesBoxController::~ProxiesBoxController() {
if (_saveTimer.isActive()) {
App::CallDelayed(
base::call_delayed(
kSaveSettingsDelayedTimeout,
QCoreApplication::instance(),
[] { Local::writeSettings(); });

View File

@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h"
#include "base/unique_qptr.h"
#include "base/event_filter.h"
#include "facades.h"
#include "base/call_delayed.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_settings.h"
@ -400,7 +400,7 @@ void Options::Option::destroy(FnMut<void()> done) {
return;
}
_field->hide(anim::type::normal);
App::CallDelayed(
base::call_delayed(
st::slideWrapDuration * 2,
_field.get(),
std::move(done));

View File

@ -16,9 +16,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h"
#include "data/data_session.h"
#include "data/data_document.h"
#include "base/call_delayed.h"
#include "apiwrap.h"
#include "app.h"
#include "facades.h"
#include "styles/style_history.h"
#include <QtCore/QBuffer>
@ -601,7 +601,7 @@ base::flat_map<uint64, not_null<DocumentData*>> EmojiPack::collectStickers(
}
void EmojiPack::refreshDelayed() {
App::CallDelayed(details::kRefreshTimeout, _session, [=] {
base::call_delayed(details::kRefreshTimeout, _session, [=] {
refresh();
});
}

View File

@ -220,10 +220,6 @@ public:
void call_handleDelayedPeerUpdates();
void call_handleObservables();
void callDelayed(int duration, FnMut<void()> &&lambda) {
_callDelayedTimer.call(duration, std::move(lambda));
}
protected:
bool eventFilter(QObject *object, QEvent *event) override;
@ -283,7 +279,6 @@ private:
rpl::event_stream<bool> _termsLockChanges;
std::unique_ptr<Window::TermsLock> _termsLock;
base::DelayedCallTimer _callDelayedTimer;
base::Timer _saveSettingsTimer;
struct LeaveSubscription {

View File

@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_cloud_themes.h"
#include "base/platform/base_platform_info.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "facades.h"
#include "app.h"
#include "styles/style_boxes.h" // st::backgroundSize
@ -933,7 +934,7 @@ void Session::suggestStartExport() {
? 0
: (_exportAvailableAt - now);
if (left) {
App::CallDelayed(
base::call_delayed(
std::min(left + 5, 3600) * crl::time(1000),
_session,
[=] { suggestStartExport(); });
@ -991,7 +992,7 @@ void Session::rememberPassportCredentials(
_passportCredentials = std::make_unique<CredentialsWithGeneration>(
std::move(data),
++generation);
App::CallDelayed(rememberFor, _session, [=, check = generation] {
base::call_delayed(rememberFor, _session, [=, check = generation] {
if (_passportCredentials && _passportCredentials->second == check) {
forgetPassportCredentials();
}

View File

@ -33,13 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
namespace App {
namespace internal {
void CallDelayed(int duration, FnMut<void()> &&lambda) {
Core::App().callDelayed(duration, std::move(lambda));
}
} // namespace internal
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) {
if (auto m = App::main()) {

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/type_traits.h"
#include "base/observer.h"
#include "base/call_delayed.h"
#include "ui/effects/animation_value.h"
class History;
@ -28,27 +29,6 @@ class ItemBase;
} // namespace InlineBots
namespace App {
namespace internal {
void CallDelayed(int duration, FnMut<void()> &&lambda);
} // namespace internal
template <typename Guard, typename Lambda>
inline void CallDelayed(
int duration,
crl::guarded_wrap<Guard, Lambda> &&guarded) {
return internal::CallDelayed(
duration,
std::move(guarded));
}
template <typename Guard, typename Lambda>
inline void CallDelayed(int duration, Guard &&object, Lambda &&lambda) {
return internal::CallDelayed(duration, crl::guard(
std::forward<Guard>(object),
std::forward<Lambda>(lambda)));
}
template <typename Guard, typename Lambda>
[[nodiscard]] inline auto LambdaDelayed(int duration, Guard &&object, Lambda &&lambda) {
@ -57,7 +37,7 @@ template <typename Guard, typename Lambda>
std::forward<Lambda>(lambda));
return [saved = std::move(guarded), duration] {
auto copy = saved;
internal::CallDelayed(duration, std::move(copy));
base::call_delayed(duration, std::move(copy));
};
}

View File

@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "inline_bots/inline_bot_result.h"
#include "base/event_filter.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "data/data_drafts.h"
#include "data/data_session.h"
#include "data/data_web_page.h"
@ -3755,7 +3756,7 @@ void HistoryWidget::updateSendButtonType() {
&& (type == Type::Send || type == Type::Record));
if (delay != 0) {
App::CallDelayed(
base::call_delayed(
kRefreshSlowmodeLabelTimeout,
this,
[=] { updateSendButtonType(); });

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/ui_utility.h"
#include "lang/lang_keys.h"
#include "base/event_filter.h"
#include "base/call_delayed.h"
#include "base/qt_signal_producer.h"
#include "history/history.h"
#include "chat_helpers/tabbed_panel.h"
@ -281,7 +282,7 @@ void ComposeControls::updateSendButtonType() {
// && (type == Type::Send || type == Type::Record));
//if (delay != 0) {
// App::CallDelayed(
// base::call_delayed(
// kRefreshSlowmodeLabelTimeout,
// this,
// [=] { updateSendButtonType(); });

View File

@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h"
#include "window/window_peer_menu.h"
#include "base/event_filter.h"
#include "base/call_delayed.h"
#include "core/file_utilities.h"
#include "main/main_session.h"
#include "data/data_session.h"
@ -143,7 +144,7 @@ void ScheduledWidget::setupComposeControls() {
return !_choosingAttach;
}) | rpl::start_with_next([=] {
_choosingAttach = true;
App::CallDelayed(
base::call_delayed(
st::historyAttach.ripple.hideDuration,
this,
[=] { _choosingAttach = false; chooseAttach(); });

View File

@ -753,8 +753,8 @@ topBarCallSkip: -1px;
topBarMenuToggle: IconButton(topBarSearch) {
width: 44px;
icon: icon {{ "title_menu_dots", menuIconFg }};
iconOver: icon {{ "title_menu_dots", menuIconFgOver }};
icon: menuToggleIcon;
iconOver: menuToggleIconOver;
iconPosition: point(16px, 17px);
rippleAreaPosition: point(0px, 7px);

View File

@ -150,8 +150,8 @@ introBackButton: IconButton(defaultIconButton) {
width: 56px;
height: 56px;
icon: icon {{ "box_button_back", menuIconFg }};
iconOver: icon {{ "box_button_back", menuIconFgOver }};
icon: backButtonIcon;
iconOver: backButtonIconOver;
rippleAreaPosition: point(8px, 8px);
rippleAreaSize: 40px;

View File

@ -8,8 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_app_config.h"
#include "main/main_session.h"
#include "base/call_delayed.h"
#include "apiwrap.h"
#include "facades.h"
namespace Main {
namespace {
@ -44,7 +44,7 @@ void AppConfig::refresh() {
}
void AppConfig::refreshDelayed() {
App::CallDelayed(kRefreshTimeout, _session, [=] {
base::call_delayed(kRefreshTimeout, _session, [=] {
refresh();
});
}

View File

@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_intro.h"
#include "platform/platform_notifications_manager.h"
#include "base/platform/base_platform_info.h"
#include "base/call_delayed.h"
#include "window/notifications_manager.h"
#include "window/themes/window_theme.h"
#include "window/themes/window_theme_warning.h"
@ -689,7 +690,7 @@ void MainWindow::fixOrder() {
void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
if (reason != QSystemTrayIcon::Context) {
App::CallDelayed(1, this, [this] {
base::call_delayed(1, this, [this] {
updateTrayMenu();
updateGlobalMenu();
});

View File

@ -8,9 +8,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/dedicated_file_loader.h"
#include "main/main_session.h"
#include "core/application.h"
#include "main/main_account.h" // Account::sessionChanges.
#include "facades.h"
#include "core/application.h"
#include "base/call_delayed.h"
namespace MTP {
namespace {
@ -321,7 +321,7 @@ void DedicatedLoader::sendRequest() {
_offset += kChunkSize;
if (_requests.size() < kRequestsCount) {
App::CallDelayed(kNextRequestDelay, this, [=] { sendRequest(); });
base::call_delayed(kNextRequestDelay, this, [=] { sendRequest(); });
}
}

View File

@ -21,9 +21,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "apiwrap.h"
#include "core/application.h"
#include "base/unixtime.h"
#include "lang/lang_instance.h"
#include "lang/lang_cloud_manager.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "base/timer.h"
#include "facades.h"
@ -450,7 +451,7 @@ void Instance::Private::requestConfigIfOld() {
void Instance::Private::requestConfigIfExpired() {
const auto requestIn = (_configExpiresAt - crl::now());
if (requestIn > 0) {
App::CallDelayed(
base::call_delayed(
std::min(requestIn, 3600 * crl::time(1000)),
_instance,
[=] { requestConfigIfExpired(); });

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/auth_key.h"
#include "base/unixtime.h"
#include "base/openssl_help.h"
#include "base/call_delayed.h"
#include "facades.h"
#include <QtCore/QJsonDocument>
@ -415,7 +416,7 @@ void SpecialConfigRequest::sendNextRequest() {
const auto attempt = _attempts.back();
_attempts.pop_back();
if (!_attempts.empty()) {
App::CallDelayed(kSendNextTimeout, this, [=] {
base::call_delayed(kSendNextTimeout, this, [=] {
sendNextRequest();
});
}
@ -778,7 +779,7 @@ void DomainResolver::sendNextRequest(const AttemptKey &key) {
list.pop_back();
if (!list.empty()) {
App::CallDelayed(kSendNextTimeout, &attempts.guard, [=] {
base::call_delayed(kSendNextTimeout, &attempts.guard, [=] {
sendNextRequest(key);
});
}

View File

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/openssl_help.h"
#include "base/qthelp_url.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "mainwindow.h"
@ -28,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "storage/file_upload.h"
#include "storage/file_download.h"
#include "facades.h"
#include "app.h"
#include <QtCore/QJsonDocument>
@ -756,7 +756,7 @@ std::vector<not_null<const Value*>> FormController::submitGetErrors() {
_view->showToast(tr::lng_passport_success(tr::now));
App::CallDelayed(
base::call_delayed(
(st::toastFadeInDuration
+ Ui::Toast::kDefaultDuration
+ st::toastFadeOutDuration),
@ -2669,7 +2669,7 @@ void FormController::cancelSure() {
UrlClickHandler::Open(url);
}
const auto timeout = _view->closeGetDuration();
App::CallDelayed(timeout, this, [=] {
base::call_delayed(timeout, this, [=] {
_controller->clearPassportForm();
});
}

View File

@ -7,16 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/file_utilities_linux.h"
#include <private/qguiapplication_p.h>
#include "platform/linux/linux_libs.h"
#include "platform/linux/linux_gdk_helper.h"
#include "core/application.h"
#include "mainwindow.h"
#include "boxes/abstract_box.h"
#include "storage/localstorage.h"
#include "base/call_delayed.h"
#include "facades.h"
#include <QtCore/QProcess>
#include <private/qguiapplication_p.h>
QStringList qt_make_filter_list(const QString &filter);
@ -419,7 +420,7 @@ int GtkFileDialog::exec() {
show();
if (const auto parent = parentWidget()) {
App::CallDelayed(200, parent, [=] {
base::call_delayed(200, parent, [=] {
parent->activateWindow();
});
}

View File

@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_cloud_themes.h"
#include "chat_helpers/emoji_sets_manager.h"
#include "base/platform/base_platform_info.h"
#include "base/call_delayed.h"
#include "support/support_common.h"
#include "support/support_templates.h"
#include "main/main_session.h"
@ -809,7 +810,7 @@ void SetupExport(
)->addClickHandler([=] {
const auto session = &controller->session();
Ui::hideSettingsAndLayer();
App::CallDelayed(
base::call_delayed(
st::boxDuration,
session,
[=] { session->data().startExport(); });

View File

@ -30,7 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h"
#include "apiwrap.h"
#include "core/file_utilities.h"
#include "facades.h"
#include "base/call_delayed.h"
#include "app.h"
#include "styles/style_layers.h"
#include "styles/style_settings.h"
@ -367,7 +367,7 @@ BioManager SetupBio(
) | rpl::start_with_next([=](bool changed) {
if (changed) {
const auto saved = *generation = std::abs(*generation) + 1;
App::CallDelayed(kSaveBioTimeout, bio, [=] {
base::call_delayed(kSaveBioTimeout, bio, [=] {
if (*generation == saved) {
save(nullptr);
*generation = 0;

View File

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "window/window_session_controller.h"
#include "core/file_utilities.h"
#include "base/call_delayed.h"
#include "facades.h"
#include "app.h"
#include "styles/style_settings.h"
@ -176,7 +177,7 @@ void SetupInterfaceScale(
App::restart();
});
const auto cancelled = crl::guard(button, [=] {
App::CallDelayed(
base::call_delayed(
st::defaultSettingsSlider.duration,
button,
[=] { (*setScale)(cConfigScale()); });

View File

@ -19,9 +19,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "data/data_session.h"
#include "base/unixtime.h"
#include "base/call_delayed.h"
#include "main/main_session.h"
#include "apiwrap.h"
#include "facades.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_window.h"
#include "styles/style_layers.h"
@ -426,7 +426,7 @@ void Autocomplete::setupContent() {
inner->activated() | rpl::start_with_next(submit, lifetime());
connect(input, &Ui::InputField::blurred, [=] {
App::CallDelayed(10, this, [=] {
base::call_delayed(10, this, [=] {
if (!input->hasFocus()) {
deactivate();
}

View File

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "main/main_session.h"
#include "base/crc32hash.h"
#include "base/call_delayed.h"
#include "ui/toast/toast.h"
#include "ui/ui_utility.h"
#include "apiwrap.h"
@ -348,7 +349,7 @@ void MainWindow::handleActiveChanged() {
if (isActiveWindow()) {
Core::App().checkMediaViewActivation();
}
App::CallDelayed(1, this, [this] {
base::call_delayed(1, this, [this] {
updateTrayMenu();
handleActiveChangedHook();
});
@ -590,7 +591,7 @@ void MainWindow::reActivateWindow() {
}
};
crl::on_main(this, reActivate);
App::CallDelayed(200, this, reActivate);
base::call_delayed(200, this, reActivate);
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
}

View File

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_item.h"
#include "platform/platform_specific.h"
#include "base/call_delayed.h"
#include "facades.h"
#include "app.h"
#include "styles/style_dialogs.h"
@ -402,7 +403,7 @@ void Widget::destroyDelayed() {
_deleted = true;
// Ubuntu has a lag if a fully transparent widget is destroyed immediately.
App::CallDelayed(1000, this, [this] {
base::call_delayed(1000, this, [this] {
manager()->removeWidget(this);
});
}
@ -433,7 +434,7 @@ bool Widget::shiftAnimationCallback(crl::time now) {
void Widget::hideSlow() {
if (anim::Disabled()) {
_hiding = true;
App::CallDelayed(
base::call_delayed(
st::notifySlowHide,
this,
[=, guard = _hidingDelayed.make_guard()] {

View File

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/ui_utility.h"
#include "base/parse_helper.h"
#include "base/zlib_help.h"
#include "base/call_delayed.h"
#include "core/file_utilities.h"
#include "core/application.h"
#include "boxes/edit_color_box.h"
@ -419,7 +420,7 @@ Editor::Inner::Inner(QWidget *parent, const QString &path) : TWidget(parent)
if (update.type == BackgroundUpdate::Type::TestingTheme) {
Revert();
App::CallDelayed(st::slideDuration, this, [] {
base::call_delayed(st::slideDuration, this, [] {
Ui::show(Box<InformBox>(
tr::lng_theme_editor_cant_change_theme(tr::now)));
});
@ -674,7 +675,9 @@ Editor::Editor(
});
});
_inner->setFocusCallback([this] {
App::CallDelayed(2 * st::boxDuration, this, [this] { _select->setInnerFocus(); });
base::call_delayed(2 * st::boxDuration, this, [this] {
_select->setInnerFocus();
});
});
_inner->setScrollCallback([this](int top, int bottom) {
_scroll->scrollToY(top, bottom);
@ -720,12 +723,12 @@ void Editor::showMenu() {
_menuToggle->installEventFilter(_menu);
_menu->addAction(tr::lng_theme_editor_menu_export(tr::now), [=] {
App::CallDelayed(st::defaultRippleAnimation.hideDuration, this, [=] {
base::call_delayed(st::defaultRippleAnimation.hideDuration, this, [=] {
exportTheme();
});
});
_menu->addAction(tr::lng_theme_editor_menu_import(tr::now), [=] {
App::CallDelayed(st::defaultRippleAnimation.hideDuration, this, [=] {
base::call_delayed(st::defaultRippleAnimation.hideDuration, this, [=] {
importTheme();
});
});

View File

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/shadow.h"
#include "boxes/edit_color_box.h"
#include "lang/lang_keys.h"
#include "facades.h"
#include "base/call_delayed.h"
namespace Window {
namespace Theme {
@ -522,7 +522,7 @@ void EditorBlock::mouseReleaseEvent(QMouseEvent *e) {
if (_context->box) {
chooseRow();
} else if (_selected >= 0) {
App::CallDelayed(st::defaultRippleAnimation.hideDuration, this, [this, index = findRowIndex(&rowAtIndex(_selected))] {
base::call_delayed(st::defaultRippleAnimation.hideDuration, this, [this, index = findRowIndex(&rowAtIndex(_selected))] {
if (index >= 0 && index < _data.size()) {
activateRow(_data[index]);
}