From 766e7dadb127b2999bd9238714e410ee7013e7a8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 18 Sep 2017 20:04:45 +0300 Subject: [PATCH] Use improved rpl::start(). --- .../SourceFiles/boxes/edit_privacy_box.cpp | 6 +-- .../SourceFiles/boxes/notifications_box.cpp | 3 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 5 ++- .../SourceFiles/boxes/sticker_set_box.cpp | 5 +-- Telegram/SourceFiles/boxes/stickers_box.cpp | 3 +- .../SourceFiles/chat_helpers/tabbed_panel.cpp | 5 ++- .../chat_helpers/tabbed_selector.cpp | 8 ++-- .../history/history_shared_media.cpp | 35 +++++++-------- .../history/history_user_photos.cpp | 16 +++---- Telegram/SourceFiles/info/info_layer_wrap.cpp | 15 +++---- Telegram/SourceFiles/info/info_memento.cpp | 11 +++-- .../SourceFiles/info/info_narrow_wrap.cpp | 5 +-- .../info/info_profile_inner_widget.cpp | 44 ++++++++----------- .../SourceFiles/info/info_profile_lines.cpp | 30 ++++++------- Telegram/SourceFiles/info/info_side_wrap.cpp | 3 +- Telegram/SourceFiles/info/info_top_bar.cpp | 5 +-- Telegram/SourceFiles/mainwidget.cpp | 10 ++--- Telegram/SourceFiles/mediaview.cpp | 8 ++-- .../settings/settings_block_widget.cpp | 15 ++++--- .../settings/settings_inner_widget.cpp | 9 ++-- .../SourceFiles/settings/settings_layer.cpp | 10 ++--- .../settings/settings_scale_widget.cpp | 3 +- .../SourceFiles/settings/settings_widget.h | 2 - .../storage/storage_shared_media.cpp | 5 +-- .../storage/storage_user_photos.cpp | 4 +- Telegram/SourceFiles/ui/rp_widget.h | 2 +- Telegram/SourceFiles/ui/widgets/labels.cpp | 10 ++--- .../SourceFiles/ui/wrap/vertical_layout.cpp | 8 ++-- Telegram/SourceFiles/ui/wrap/wrap.h | 29 +++++------- .../SourceFiles/window/player_wrap_widget.cpp | 5 +-- .../SourceFiles/window/top_bar_widget.cpp | 5 ++- 31 files changed, 145 insertions(+), 179 deletions(-) diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index f66802e93..81f80243b 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -288,9 +288,9 @@ void EditPrivacyBox::createWidgets() { auto createExceptionLink = [this](Exception exception) { exceptionLink(exception).create(this, object_ptr(this, exceptionLinkText(exception)), exceptionLinkMargins()); exceptionLink(exception)->heightValue() - | rpl::start( - [this](int) { resizeToWidth(width()); }, - lifetime()); + | rpl::start([this](int) { + resizeToWidth(width()); + }, lifetime()); exceptionLink(exception)->entity()->setClickedCallback([this, exception] { editExceptionUsers(exception); }); }; diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index 141daf59a..b61cc10d4 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -128,8 +128,7 @@ void NotificationsBox::prepare() { } _countSlider->setActiveSectionFast(_oldCount - 1); _countSlider->sectionActivated() - | rpl::on_next([this](int) { countChanged(); }) - | rpl::start(lifetime()); + | rpl::start([this](int) { countChanged(); }, lifetime()); setMouseTracking(true); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 85ce75236..e018bd1a1 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -46,8 +46,9 @@ void PeerListBox::createMultiSelect() { auto entity = object_ptr(this, st::contactsMultiSelect, langFactory(lng_participant_filter)); _select.create(this, std::move(entity)); _select->heightValue() - | rpl::on_next([this](int) { updateScrollSkips(); }) - | rpl::start(lifetime()); + | rpl::start( + [this](int) { updateScrollSkips(); }, + lifetime()); _select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { _inner->submitted(); }); _select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); }); _select->entity()->setItemRemovedCallback([this](uint64 itemId) { diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 84605f166..9c13ac9d9 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -57,11 +57,10 @@ void StickerSetBox::prepare() { connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons())); _inner->setInstalled() - | rpl::on_next([this](auto &&setId) { + | rpl::start([this](auto &&setId) { Auth().api().stickerSetInstalled(setId); closeBox(); - }) - | rpl::start(lifetime()); + }, lifetime()); } void StickerSetBox::onAddStickers() { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 64855d810..54fe058c7 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -244,8 +244,7 @@ void StickersBox::prepare() { } setNoContentMargin(true); _tabs->sectionActivated() - | rpl::on_next([this](int) { switchTab(); }) - | rpl::start(lifetime()); + | rpl::start([this](int) { switchTab(); }, lifetime()); refreshTabs(); } if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide(); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index 921c23ca9..f0e8d6c4b 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -63,8 +63,9 @@ TabbedPanel::TabbedPanel( } }); _selector->showRequests() - | rpl::on_next([this](auto&&) { showFromSelector(); }) - | rpl::start(lifetime()); + | rpl::start([this](auto&&) { + showFromSelector(); + }, lifetime()); resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size()); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 3ecea89aa..690ef2e2c 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -347,12 +347,11 @@ TabbedSelector::TabbedSelector(QWidget *parent, not_null co })); Auth().api().stickerSetInstalled() - | rpl::on_next([this](uint64 setId) { + | rpl::start([this](uint64 setId) { _tabsSlider->setActiveSection(static_cast(SelectorTab::Stickers)); stickers()->showStickerSet(setId); _showRequests.fire({}); - }) - | rpl::start(lifetime()); + }, lifetime()); // setAttribute(Qt::WA_AcceptTouchEvents); setAttribute(Qt::WA_OpaquePaintEvent, false); @@ -608,8 +607,7 @@ void TabbedSelector::createTabsSlider() { _tabsSlider->setActiveSectionFast(static_cast(_currentTabType)); _tabsSlider->sectionActivated() - | rpl::on_next([this](int) { switchTab(); }) - | rpl::start(lifetime()); + | rpl::start([this](int) { switchTab(); }, lifetime()); _tabsSlider->resizeToWidth(width()); _tabsSlider->moveToLeft(0, 0); diff --git a/Telegram/SourceFiles/history/history_shared_media.cpp b/Telegram/SourceFiles/history/history_shared_media.cpp index 9717943f6..7979011db 100644 --- a/Telegram/SourceFiles/history/history_shared_media.cpp +++ b/Telegram/SourceFiles/history/history_shared_media.cpp @@ -449,26 +449,23 @@ rpl::producer SharedMediaViewer( data.second); }; builder->insufficientMediaAround() - | rpl::on_next(requestMediaAround) - | rpl::start(lifetime); + | rpl::start(requestMediaAround, lifetime); Auth().storage().sharedMediaSliceUpdated() - | rpl::on_next(applyUpdate) - | rpl::start(lifetime); + | rpl::start(applyUpdate, lifetime); Auth().storage().sharedMediaOneRemoved() - | rpl::on_next(applyUpdate) - | rpl::start(lifetime); + | rpl::start(applyUpdate, lifetime); Auth().storage().sharedMediaAllRemoved() - | rpl::on_next(applyUpdate) - | rpl::start(lifetime); + | rpl::start(applyUpdate, lifetime); Auth().storage().query(Storage::SharedMediaQuery( key, limitBefore, limitAfter)) - | rpl::on_next(applyUpdate) - | rpl::on_done([=] { builder->checkInsufficientMedia(); }) - | rpl::start(lifetime); + | rpl::start( + applyUpdate, + [=] { builder->checkInsufficientMedia(); }, + lifetime); return lifetime; }; @@ -600,20 +597,20 @@ rpl::producer SharedMediaMergedViewer( SharedMediaMergedSlice::PartKey(key), limitBefore, limitAfter - ) | rpl::on_next([=](SharedMediaSlice &&update) { + ) | rpl::start([=](SharedMediaSlice &&update) { builder->applyPartUpdate(std::move(update)); consumer.put_next(builder->snapshot()); - }) | rpl::start(lifetime); + }, lifetime); if (key.migratedPeerId) { SharedMediaViewer( SharedMediaMergedSlice::MigratedKey(key), limitBefore, limitAfter - ) | rpl::on_next([=](SharedMediaSlice &&update) { + ) | rpl::start([=](SharedMediaSlice &&update) { builder->applyMigratedUpdate(std::move(update)); consumer.put_next(builder->snapshot()); - }) | rpl::start(lifetime); + }, lifetime); } return lifetime; @@ -752,20 +749,20 @@ rpl::producer SharedMediaWithLastViewer( SharedMediaWithLastSlice::ViewerKey(key), limitBefore, limitAfter - ) | rpl::on_next([=](SharedMediaMergedSlice &&update) { + ) | rpl::start([=](SharedMediaMergedSlice &&update) { builder->applyViewerUpdate(std::move(update)); consumer.put_next(builder->snapshot()); - }) | rpl::start(lifetime); + }, lifetime); if (base::get_if(&key.universalId)) { SharedMediaMergedViewer( SharedMediaWithLastSlice::EndingKey(key), 1, 1 - ) | rpl::on_next([=](SharedMediaMergedSlice &&update) { + ) | rpl::start([=](SharedMediaMergedSlice &&update) { builder->applyEndingUpdate(std::move(update)); consumer.put_next(builder->snapshot()); - }) | rpl::start(lifetime); + }, lifetime); } return lifetime; diff --git a/Telegram/SourceFiles/history/history_user_photos.cpp b/Telegram/SourceFiles/history/history_user_photos.cpp index 1e4b9fe60..59990db2d 100644 --- a/Telegram/SourceFiles/history/history_user_photos.cpp +++ b/Telegram/SourceFiles/history/history_user_photos.cpp @@ -231,21 +231,19 @@ rpl::producer UserPhotosViewer( Auth().api().requestUserPhotos(user, photoId); }; builder->insufficientPhotosAround() - | rpl::on_next(requestPhotosAround) - | rpl::start(lifetime); + | rpl::start(requestPhotosAround, lifetime); Auth().storage().userPhotosSliceUpdated() - | rpl::on_next(applyUpdate) - | rpl::start(lifetime); + | rpl::start(applyUpdate, lifetime); Auth().storage().query(Storage::UserPhotosQuery( key, limitBefore, - limitAfter - )) - | rpl::on_next(applyUpdate) - | rpl::on_done([=] { builder->checkInsufficientPhotos(); }) - | rpl::start(lifetime); + limitAfter)) + | rpl::start( + applyUpdate, + [=] { builder->checkInsufficientPhotos(); }, + lifetime); return lifetime; }; diff --git a/Telegram/SourceFiles/info/info_layer_wrap.cpp b/Telegram/SourceFiles/info/info_layer_wrap.cpp index 24fb408d1..5038a8b4f 100644 --- a/Telegram/SourceFiles/info/info_layer_wrap.cpp +++ b/Telegram/SourceFiles/info/info_layer_wrap.cpp @@ -54,18 +54,16 @@ LayerWrap::LayerWrap( void LayerWrap::setupHeightConsumers() { _content->desiredHeightValue() - | rpl::on_next([this](int height) { + | rpl::start([this](int height) { _desiredHeight = height; resizeToWidth(width()); - }) - | rpl::start(lifetime()); + }, lifetime()); heightValue() - | rpl::on_next([this](int height) { + | rpl::start([this](int height) { _content->resize( width(), height - _topBar->bottomNoMargins() - st::boxRadius); - }) - | rpl::start(lifetime()); + }, lifetime()); } object_ptr LayerWrap::createTopBar() { @@ -76,10 +74,9 @@ object_ptr LayerWrap::createTopBar() { result.data(), st::infoLayerTopBarClose)); close->clicks() - | rpl::on_next([this](auto&&) { + | rpl::start([this](auto&&) { _controller->hideSpecialLayer(); - }) - | rpl::start(close->lifetime()); + }, close->lifetime()); result->setTitle(TitleValue( _content->section(), _content->peer())); diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index 490b318ed..994eb2a2b 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -104,12 +104,11 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget( _inner->move(0, 0); scrollTopValue() - | rpl::on_next([this, inner = _inner](int value) { + | rpl::start([this, inner = _inner](int value) { inner->setVisibleTopBottom( value, value + _scroll->height()); // TODO rpl::combine - }) - | rpl::start(_inner->lifetime()); + }, _inner->lifetime()); return _inner; } @@ -208,14 +207,14 @@ object_ptr MoveMemento::createWidget( controller, this); result->setGeometry(geometry); - return result; + return std::move(result); } else if (_wrap == Wrap::Side && column == Window::Column::Third) { auto result = object_ptr( parent, controller, this); result->setGeometry(geometry); - return result; + return std::move(result); } return nullptr; } @@ -226,7 +225,7 @@ object_ptr MoveMemento::createLayer( auto result = object_ptr( controller, this); - return result; + return std::move(result); } return nullptr; } diff --git a/Telegram/SourceFiles/info/info_narrow_wrap.cpp b/Telegram/SourceFiles/info/info_narrow_wrap.cpp index cf60e9c5f..8d54f9175 100644 --- a/Telegram/SourceFiles/info/info_narrow_wrap.cpp +++ b/Telegram/SourceFiles/info/info_narrow_wrap.cpp @@ -87,10 +87,9 @@ object_ptr NarrowWrap::createTopBar() { st::infoLayerTopBar); result->enableBackButton(true); result->backRequest() - | rpl::on_next([this](auto&&) { + | rpl::start([this](auto&&) { controller()->showBackFromStack(); - }) - | rpl::start(result->lifetime()); + }, result->lifetime()); result->setTitle(TitleValue( _content->section(), _content->peer())); diff --git a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp index 43fcef6ab..a19165555 100644 --- a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp @@ -55,9 +55,9 @@ void InnerWidget::setupContent() { std::move(hiddenDetailsContent))); cover->setHasToggle(true); cover->toggled() - | rpl::on_next([=](bool expanded) { + | rpl::start([=](bool expanded) { hiddenDetails->toggleAnimated(expanded); - }) | rpl::start(_lifetime); + }, _lifetime); hiddenDetails->hideFast(); } else { _content->add(setupDetailsContent(_content)); @@ -65,9 +65,9 @@ void InnerWidget::setupContent() { _content->add(object_ptr(this)); _content->heightValue() - | rpl::on_next([this](int height) { + | rpl::start([this](int height) { TWidget::resizeToWidth(width()); - }) | rpl::start(_lifetime); + }, _lifetime); } object_ptr InnerWidget::setupDetailsContent( @@ -87,7 +87,7 @@ object_ptr InnerWidget::setupDetailsContent( result->add(object_ptr>(result, skipPadding)); - return result; + return std::move(result); } object_ptr InnerWidget::setupMuteToggle( @@ -98,24 +98,22 @@ object_ptr InnerWidget::setupMuteToggle( Lang::Viewer(lng_profile_enable_notifications), st::infoNotificationsButton)); NotificationsEnabledViewer(_peer) - | rpl::on_next([button](bool enabled) { + | rpl::start([button](bool enabled) { button->setToggled(enabled); - }) - | rpl::start(button->lifetime()); + }, button->lifetime()); button->clicks() - | rpl::on_next([this](auto) { + | rpl::start([this](auto) { App::main()->updateNotifySetting( _peer, _peer->isMuted() ? NotifySettingSetNotify : NotifySettingSetMuted); - }) - | rpl::start(button->lifetime()); + }, button->lifetime()); object_ptr( result, st::infoIconNotifications); - return result; + return std::move(result); } void InnerWidget::setupMainUserButtons( @@ -126,12 +124,11 @@ void InnerWidget::setupMainUserButtons( Lang::Viewer(lng_profile_send_message) | ToUpperValue(), st::infoMainButton)); sendMessage->clicks() - | rpl::on_next([this, user](auto&&) { + | rpl::start([this, user](auto&&) { _controller->showPeerHistory( user, Ui::ShowWay::Forward); - }) - | rpl::start(sendMessage->lifetime()); + }, sendMessage->lifetime()); auto addContact = wrap->add(object_ptr>( wrap, @@ -140,16 +137,14 @@ void InnerWidget::setupMainUserButtons( Lang::Viewer(lng_info_add_as_contact) | ToUpperValue(), st::infoMainButton))); CanAddContactViewer(user) - | rpl::on_next([addContact](bool canAdd) { + | rpl::start([addContact](bool canAdd) { addContact->toggleAnimated(canAdd); - }) - | rpl::start(addContact->lifetime()); + }, addContact->lifetime()); addContact->finishAnimations(); addContact->entity()->clicks() - | rpl::on_next([user](auto&&) { + | rpl::start([user](auto&&) { App::main()->shareContactLayer(user); - }) - | rpl::start(addContact->lifetime()); + }, addContact->lifetime()); } object_ptr InnerWidget::setupInfoLines( @@ -181,15 +176,14 @@ object_ptr InnerWidget::setupInfoLines( return base::find(values, true) != values.end(); }) | rpl::distinct_until_changed() - | rpl::on_next([separator](bool someShown) { + | rpl::start([separator](bool someShown) { separator->toggleAnimated(someShown); - }) - | rpl::start(separator->lifetime()); + }, separator->lifetime()); separator->finishAnimations(); object_ptr(result, st::infoIconInformation); - return result; + return std::move(result); } void InnerWidget::visibleTopBottomUpdated( diff --git a/Telegram/SourceFiles/info/info_profile_lines.cpp b/Telegram/SourceFiles/info/info_profile_lines.cpp index 3919c3cb9..9ae45ea54 100644 --- a/Telegram/SourceFiles/info/info_profile_lines.cpp +++ b/Telegram/SourceFiles/info/info_profile_lines.cpp @@ -232,13 +232,12 @@ FloatingIcon::FloatingIcon( setAttribute(Qt::WA_TransparentForMouseEvents); if (above) { above->geometryValue() - | rpl::on_next([this](QRect &&geometry) { + | rpl::start([this](const QRect &geometry) { auto topLeft = rtlpoint( geometry.topLeft(), parentWidget()->width()); moveToLeft(topLeft.x(), topLeft.y() + geometry.height()); - }) - | rpl::start(lifetime()); + }, lifetime()); } else { moveToLeft(0, 0); } @@ -323,15 +322,18 @@ void CoverLine::setHasToggle(bool hasToggle) { void CoverLine::initViewers() { using Flag = Notify::PeerUpdate::Flag; PeerUpdateViewer(_peer, Flag::PhotoChanged) - | rpl::on_next([this](auto&&) { refreshUserpicLink(); }) - | rpl::start(_lifetime); + | rpl::start( + [this](auto&&) { refreshUserpicLink(); }, + _lifetime); PeerUpdateViewer(_peer, Flag::NameChanged) - | rpl::on_next([this](auto&&) { refreshNameText(); }) - | rpl::start(_lifetime); + | rpl::start( + [this](auto&&) { refreshNameText(); }, + _lifetime); PeerUpdateViewer(_peer, Flag::UserOnlineChanged | Flag::MembersChanged) - | rpl::on_next([this](auto&&) { refreshStatusText(); }) - | rpl::start(_lifetime); + | rpl::start( + [this](auto&&) { refreshStatusText(); }, + _lifetime); } void CoverLine::initUserpicButton() { @@ -449,10 +451,9 @@ Button::Button( : RippleButton(parent, st.ripple) , _st(st) { std::move(text) - | rpl::on_next([this](QString &&value) { + | rpl::start([this](QString &&value) { setText(std::move(value)); - }) - | rpl::start(lifetime()); + }, lifetime()); } void Button::setToggled(bool toggled) { @@ -462,10 +463,9 @@ void Button::setToggled(bool toggled) { toggled, [this] { rtlupdate(toggleRect()); }); clicks() - | rpl::on_next([this](auto) { + | rpl::start([this](auto) { _toggle->setCheckedAnimated(!_toggle->checked()); - }) - | rpl::start(lifetime()); + }, lifetime()); } else { _toggle->setCheckedAnimated(toggled); } diff --git a/Telegram/SourceFiles/info/info_side_wrap.cpp b/Telegram/SourceFiles/info/info_side_wrap.cpp index c6506fc9a..29494ce7e 100644 --- a/Telegram/SourceFiles/info/info_side_wrap.cpp +++ b/Telegram/SourceFiles/info/info_side_wrap.cpp @@ -62,8 +62,7 @@ void SideWrap::setupTabs() { _tabs->setSections(sections); _tabs->sectionActivated() | rpl::map([](int index) { return static_cast(index); }) - | rpl::on_next([this](Tab tab) { showTab(tab); }) - | rpl::start(_lifetime); + | rpl::start([this](Tab tab) { showTab(tab); }, _lifetime); _tabs->move(0, 0); _tabs->resizeToWidth(width()); diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index 79498f527..fd21ab5b2 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -59,10 +59,9 @@ void TopBar::pushButton(object_ptr button) { auto weak = Ui::AttachParentChild(this, button); _buttons.push_back(std::move(button)); weak->widthValue() - | rpl::on_next([this](auto) { + | rpl::start([this](auto) { updateControlsGeometry(width()); - }) - | rpl::start(_lifetime); + }, _lifetime); } int TopBar::resizeGetHeight(int newWidth) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 0b5b25444..62d876403 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1846,8 +1846,9 @@ void MainWidget::createPlayer() { if (!_player) { _player.create(this); _player->heightValue() - | rpl::on_next([this](int) { playerHeightUpdated(); }) - | rpl::start(lifetime()); + | rpl::start( + [this](int) { playerHeightUpdated(); }, + lifetime()); _player->entity()->setCloseCallback([this] { closeBothPlayers(); }); _playerVolume.create(this); _player->entity()->volumeWidgetCreated(_playerVolume); @@ -1906,10 +1907,9 @@ void MainWidget::createCallTopBar() { Expects(_currentCall != nullptr); _callTopBar.create(this, object_ptr(this, _currentCall)); _callTopBar->heightValue() - | rpl::on_next([this](int value) { + | rpl::start([this](int value) { callTopBarHeightUpdated(value); - }) - | rpl::start(lifetime()); + }, lifetime()); orderWidgets(); if (_a_show.animating()) { _callTopBar->showFast(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index cc8615a25..35743e0c1 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -1064,9 +1064,9 @@ void MediaView::validateSharedMedia() { *key, kIdsLimit, kIdsLimit - ) | rpl::on_next([this](SharedMediaWithLastSlice &&update) { + ) | rpl::start([this](SharedMediaWithLastSlice &&update) { handleSharedMediaUpdate(std::move(update)); - }) | rpl::start(_sharedMedia->lifetime); + }, _sharedMedia->lifetime); } else { _sharedMedia = nullptr; _sharedMediaData = base::none; @@ -1123,9 +1123,9 @@ void MediaView::validateUserPhotos() { *key, kIdsLimit, kIdsLimit - ) | rpl::on_next([this](UserPhotosSlice &&update) { + ) | rpl::start([this](UserPhotosSlice &&update) { handleUserPhotosUpdate(std::move(update)); - }) | rpl::start(_userPhotos->lifetime); + }, _userPhotos->lifetime); } else { _userPhotos = nullptr; _userPhotosData = base::none; diff --git a/Telegram/SourceFiles/settings/settings_block_widget.cpp b/Telegram/SourceFiles/settings/settings_block_widget.cpp index 61c238994..fa20dac07 100644 --- a/Telegram/SourceFiles/settings/settings_block_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_block_widget.cpp @@ -28,14 +28,17 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Settings { BlockWidget::BlockWidget(QWidget *parent, UserData *self, const QString &title) : RpWidget(parent) +, _content(this) , _self(self) -, _title(title) -, _content(this) { +, _title(title) { _content->heightValue() - | rpl::on_next([this](int contentHeight) { - resize(width(), contentTop() + contentHeight + st::settingsBlockMarginBottom); - }) - | rpl::start(lifetime()); + | rpl::start([this](int contentHeight) { + resize( + width(), + contentTop() + + contentHeight + + st::settingsBlockMarginBottom); + }, lifetime()); } void BlockWidget::setContentLeft(int contentLeft) { diff --git a/Telegram/SourceFiles/settings/settings_inner_widget.cpp b/Telegram/SourceFiles/settings/settings_inner_widget.cpp index bc529ad4c..460fa3619 100644 --- a/Telegram/SourceFiles/settings/settings_inner_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_inner_widget.cpp @@ -36,8 +36,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Settings { InnerWidget::InnerWidget(QWidget *parent) : LayerInner(parent) -, _self(App::self()) -, _blocks(this) { +, _blocks(this) +, _self(App::self()) { refreshBlocks(); subscribe(Global::RefSelfChanged(), [this] { fullRebuild(); }); subscribe(Lang::Current().updated(), [this] { fullRebuild(); }); @@ -83,10 +83,9 @@ void InnerWidget::refreshBlocks() { } _blocks->show(); _blocks->heightValue() - | rpl::on_next([this](int blocksHeight) { + | rpl::start([this](int blocksHeight) { resize(width(), _blocks->y() + blocksHeight); - }) - | rpl::start(lifetime()); + }, lifetime()); } void InnerWidget::showFinished() { diff --git a/Telegram/SourceFiles/settings/settings_layer.cpp b/Telegram/SourceFiles/settings/settings_layer.cpp index 12bfd1c14..3c20825fb 100644 --- a/Telegram/SourceFiles/settings/settings_layer.cpp +++ b/Telegram/SourceFiles/settings/settings_layer.cpp @@ -53,10 +53,9 @@ Layer::Layer() _scroll->scrollTopValue() | rpl::map([](int scrollTop) { return scrollTop > 0; }) | rpl::distinct_until_changed() - | rpl::on_next([this](bool scrolled) { + | rpl::start([this](bool scrolled) { _fixedBarShadow->toggleAnimated(scrolled); - }) - | rpl::start(lifetime()); + }, lifetime()); } void Layer::setCloseClickHandler(base::lambda callback) { @@ -74,10 +73,9 @@ void Layer::resizeToWidth(int newWidth, int newContentLeft) { void Layer::doSetInnerWidget(object_ptr widget) { _inner = _scroll->setOwnedWidget(std::move(widget)); _inner->heightValue() - | rpl::on_next([this](int innerHeight) { + | rpl::start([this](int innerHeight) { resizeUsingInnerHeight(width(), innerHeight); - }) - | rpl::start(lifetime()); + }, lifetime()); } void Layer::paintEvent(QPaintEvent *e) { diff --git a/Telegram/SourceFiles/settings/settings_scale_widget.cpp b/Telegram/SourceFiles/settings/settings_scale_widget.cpp index e555b4b47..412156c58 100644 --- a/Telegram/SourceFiles/settings/settings_scale_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_scale_widget.cpp @@ -61,8 +61,7 @@ void ScaleWidget::createControls() { _scale->addSection(scaleLabel(dbisTwo)); _scale->setActiveSectionFast(cEvalScale(cConfigScale()) - 1); _scale->sectionActivated() - | rpl::on_next([this](int) { scaleChanged(); }) - | rpl::start(lifetime()); + | rpl::start([this](int) { scaleChanged(); }, lifetime()); } void ScaleWidget::onAutoChanged() { diff --git a/Telegram/SourceFiles/settings/settings_widget.h b/Telegram/SourceFiles/settings/settings_widget.h index e432ca67d..f99417cc0 100644 --- a/Telegram/SourceFiles/settings/settings_widget.h +++ b/Telegram/SourceFiles/settings/settings_widget.h @@ -43,8 +43,6 @@ private: QPointer _inner; - int _contentLeft = 0; - }; } // namespace Settings diff --git a/Telegram/SourceFiles/storage/storage_shared_media.cpp b/Telegram/SourceFiles/storage/storage_shared_media.cpp index 1d0f1e5e9..df1be97b1 100644 --- a/Telegram/SourceFiles/storage/storage_shared_media.cpp +++ b/Telegram/SourceFiles/storage/storage_shared_media.cpp @@ -234,15 +234,14 @@ std::map::iterator auto type = static_cast(index); list.sliceUpdated() - | rpl::on_next([this, peer, type](const SliceUpdate &update) { + | rpl::start([this, peer, type](const SliceUpdate &update) { _sliceUpdated.fire(SharedMediaSliceUpdate( peer, type, update.messages, update.range, update.count)); - }) - | rpl::start(_lifetime); + }, _lifetime); } return result; } diff --git a/Telegram/SourceFiles/storage/storage_user_photos.cpp b/Telegram/SourceFiles/storage/storage_user_photos.cpp index 817f043e9..6398a982f 100644 --- a/Telegram/SourceFiles/storage/storage_user_photos.cpp +++ b/Telegram/SourceFiles/storage/storage_user_photos.cpp @@ -122,12 +122,12 @@ UserPhotos::enforceLists(UserId user) { } result = _lists.emplace(user, List {}).first; result->second.sliceUpdated( - ) | rpl::on_next([this, user](const SliceUpdate &update) { + ) | rpl::start([this, user](const SliceUpdate &update) { _sliceUpdated.fire(UserPhotosSliceUpdate( user, update.photoIds, update.count)); - }) | rpl::start(_lifetime); + }, _lifetime); return result; } diff --git a/Telegram/SourceFiles/ui/rp_widget.h b/Telegram/SourceFiles/ui/rp_widget.h index 3c2320692..3fd489eb5 100644 --- a/Telegram/SourceFiles/ui/rp_widget.h +++ b/Telegram/SourceFiles/ui/rp_widget.h @@ -28,7 +28,7 @@ namespace Ui { class RpWidget : public TWidget { public: - RpWidget::RpWidget(QWidget *parent = nullptr) : TWidget(parent) { + RpWidget(QWidget *parent = nullptr) : TWidget(parent) { setGeometry(0, 0, 0, 0); } diff --git a/Telegram/SourceFiles/ui/widgets/labels.cpp b/Telegram/SourceFiles/ui/widgets/labels.cpp index d3d932530..83132dc6f 100644 --- a/Telegram/SourceFiles/ui/widgets/labels.cpp +++ b/Telegram/SourceFiles/ui/widgets/labels.cpp @@ -171,10 +171,9 @@ FlatLabel::FlatLabel( , _st(st) , _contextCopyText(lang(lng_context_copy_text)) { std::move(text) - | rpl::on_next([this](const QString &value) { + | rpl::start([this](const QString &value) { setText(value); - }) - | rpl::start(lifetime()); + }, lifetime()); } FlatLabel::FlatLabel( @@ -186,10 +185,9 @@ FlatLabel::FlatLabel( , _st(st) , _contextCopyText(lang(lng_context_copy_text)) { std::move(text) - | rpl::on_next([this](const TextWithEntities &value) { + | rpl::start([this](const TextWithEntities &value) { setMarkedText(value); - }) - | rpl::start(lifetime()); + }, lifetime()); } void FlatLabel::init() { diff --git a/Telegram/SourceFiles/ui/wrap/vertical_layout.cpp b/Telegram/SourceFiles/ui/wrap/vertical_layout.cpp index a56187070..1875a5d43 100644 --- a/Telegram/SourceFiles/ui/wrap/vertical_layout.cpp +++ b/Telegram/SourceFiles/ui/wrap/vertical_layout.cpp @@ -115,13 +115,11 @@ RpWidget *VerticalLayout::addChild( width() - margins.left() - margins.right(), height() - margins.top() - margins.bottom()); weak->heightValue() - | rpl::on_next([this, weak](int) { + | rpl::start([this, weak](int) { childHeightUpdated(weak); - }) - | rpl::on_done([this, weak] { + }, [this, weak] { removeChild(weak); - }) - | rpl::start(lifetime()); + }, lifetime()); return weak; } return nullptr; diff --git a/Telegram/SourceFiles/ui/wrap/wrap.h b/Telegram/SourceFiles/ui/wrap/wrap.h index 27285f3c5..89258ff1e 100644 --- a/Telegram/SourceFiles/ui/wrap/wrap.h +++ b/Telegram/SourceFiles/ui/wrap/wrap.h @@ -30,20 +30,12 @@ class Wrap; namespace details { struct UnwrapHelper { - struct Large { - char data[2]; - }; - static char Check(...); - template - static Large Check(Wrap*); - template - static Large Check(const Wrap*); + template < + typename Widget, + typename = typename std::decay_t::WrapParentType> + static std::true_type Is(Widget &&widget); + static std::false_type Is(...); - template - static constexpr bool Is() { - return sizeof(Check(std::declval())) - == sizeof(Large); - } template static auto Unwrap(Entity *entity, std::true_type) { return entity @@ -56,10 +48,12 @@ struct UnwrapHelper { } template static auto Unwrap(Entity *entity) { + using Selector = decltype(Is(std::declval())); return Unwrap( entity, - std::integral_constant()>()); + Selector()); } + }; } // namespace details @@ -126,10 +120,9 @@ Wrap::Wrap(QWidget *parent, object_ptr child) , _wrapped(std::move(child)) { if (_wrapped) { _wrapped->sizeValue() - | rpl::on_next([this](const QSize &value) { + | rpl::start([this](const QSize &value) { wrappedSizeUpdated(value); - }) - | rpl::start(lifetime()); + }, lifetime()); AttachParentChild(this, _wrapped); _wrapped->move(0, 0); _wrapped->alive() @@ -160,6 +153,8 @@ public: return details::UnwrapHelper::Unwrap(wrapped()); } + using WrapParentType = ParentType; + }; } // namespace Ui diff --git a/Telegram/SourceFiles/window/player_wrap_widget.cpp b/Telegram/SourceFiles/window/player_wrap_widget.cpp index 235967106..d35876a70 100644 --- a/Telegram/SourceFiles/window/player_wrap_widget.cpp +++ b/Telegram/SourceFiles/window/player_wrap_widget.cpp @@ -27,10 +27,9 @@ namespace Window { PlayerWrapWidget::PlayerWrapWidget(QWidget *parent) : Parent(parent, object_ptr(parent)) { sizeValue() - | rpl::on_next([this](const QSize &size) { + | rpl::start([this](const QSize &size) { updateShadowGeometry(size); - }) - | rpl::start(lifetime()); + }, lifetime()); } void PlayerWrapWidget::updateShadowGeometry(const QSize &size) { diff --git a/Telegram/SourceFiles/window/top_bar_widget.cpp b/Telegram/SourceFiles/window/top_bar_widget.cpp index 77e504773..a83719dce 100644 --- a/Telegram/SourceFiles/window/top_bar_widget.cpp +++ b/Telegram/SourceFiles/window/top_bar_widget.cpp @@ -98,8 +98,9 @@ TopBarWidget::TopBarWidget(QWidget *parent, not_null contro updateControlsVisibility(); }); Auth().data().thirdSectionInfoEnabledValue() - | rpl::on_next([this](bool) { updateInfoToggleActive(); }) - | rpl::start(lifetime()); + | rpl::start( + [this](bool) { updateInfoToggleActive(); }, + lifetime()); setCursor(style::cur_pointer); updateControlsVisibility();