Use improved rpl::start().

This commit is contained in:
John Preston 2017-09-18 20:04:45 +03:00
parent ee9763c98f
commit 766e7dadb1
31 changed files with 145 additions and 179 deletions

View File

@ -288,9 +288,9 @@ void EditPrivacyBox::createWidgets() {
auto createExceptionLink = [this](Exception exception) { auto createExceptionLink = [this](Exception exception) {
exceptionLink(exception).create(this, object_ptr<Ui::LinkButton>(this, exceptionLinkText(exception)), exceptionLinkMargins()); exceptionLink(exception).create(this, object_ptr<Ui::LinkButton>(this, exceptionLinkText(exception)), exceptionLinkMargins());
exceptionLink(exception)->heightValue() exceptionLink(exception)->heightValue()
| rpl::start( | rpl::start([this](int) {
[this](int) { resizeToWidth(width()); }, resizeToWidth(width());
lifetime()); }, lifetime());
exceptionLink(exception)->entity()->setClickedCallback([this, exception] { editExceptionUsers(exception); }); exceptionLink(exception)->entity()->setClickedCallback([this, exception] { editExceptionUsers(exception); });
}; };

View File

@ -128,8 +128,7 @@ void NotificationsBox::prepare() {
} }
_countSlider->setActiveSectionFast(_oldCount - 1); _countSlider->setActiveSectionFast(_oldCount - 1);
_countSlider->sectionActivated() _countSlider->sectionActivated()
| rpl::on_next([this](int) { countChanged(); }) | rpl::start([this](int) { countChanged(); }, lifetime());
| rpl::start(lifetime());
setMouseTracking(true); setMouseTracking(true);

View File

@ -46,8 +46,9 @@ void PeerListBox::createMultiSelect() {
auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, langFactory(lng_participant_filter)); auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, langFactory(lng_participant_filter));
_select.create(this, std::move(entity)); _select.create(this, std::move(entity));
_select->heightValue() _select->heightValue()
| rpl::on_next([this](int) { updateScrollSkips(); }) | rpl::start(
| rpl::start(lifetime()); [this](int) { updateScrollSkips(); },
lifetime());
_select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { _inner->submitted(); }); _select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { _inner->submitted(); });
_select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); }); _select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); });
_select->entity()->setItemRemovedCallback([this](uint64 itemId) { _select->entity()->setItemRemovedCallback([this](uint64 itemId) {

View File

@ -57,11 +57,10 @@ void StickerSetBox::prepare() {
connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons())); connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons()));
_inner->setInstalled() _inner->setInstalled()
| rpl::on_next([this](auto &&setId) { | rpl::start([this](auto &&setId) {
Auth().api().stickerSetInstalled(setId); Auth().api().stickerSetInstalled(setId);
closeBox(); closeBox();
}) }, lifetime());
| rpl::start(lifetime());
} }
void StickerSetBox::onAddStickers() { void StickerSetBox::onAddStickers() {

View File

@ -244,8 +244,7 @@ void StickersBox::prepare() {
} }
setNoContentMargin(true); setNoContentMargin(true);
_tabs->sectionActivated() _tabs->sectionActivated()
| rpl::on_next([this](int) { switchTab(); }) | rpl::start([this](int) { switchTab(); }, lifetime());
| rpl::start(lifetime());
refreshTabs(); refreshTabs();
} }
if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide(); if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide();

View File

@ -63,8 +63,9 @@ TabbedPanel::TabbedPanel(
} }
}); });
_selector->showRequests() _selector->showRequests()
| rpl::on_next([this](auto&&) { showFromSelector(); }) | rpl::start([this](auto&&) {
| rpl::start(lifetime()); showFromSelector();
}, lifetime());
resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size()); resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size());

View File

@ -347,12 +347,11 @@ TabbedSelector::TabbedSelector(QWidget *parent, not_null<Window::Controller*> co
})); }));
Auth().api().stickerSetInstalled() Auth().api().stickerSetInstalled()
| rpl::on_next([this](uint64 setId) { | rpl::start([this](uint64 setId) {
_tabsSlider->setActiveSection(static_cast<int>(SelectorTab::Stickers)); _tabsSlider->setActiveSection(static_cast<int>(SelectorTab::Stickers));
stickers()->showStickerSet(setId); stickers()->showStickerSet(setId);
_showRequests.fire({}); _showRequests.fire({});
}) }, lifetime());
| rpl::start(lifetime());
// setAttribute(Qt::WA_AcceptTouchEvents); // setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_OpaquePaintEvent, false);
@ -608,8 +607,7 @@ void TabbedSelector::createTabsSlider() {
_tabsSlider->setActiveSectionFast(static_cast<int>(_currentTabType)); _tabsSlider->setActiveSectionFast(static_cast<int>(_currentTabType));
_tabsSlider->sectionActivated() _tabsSlider->sectionActivated()
| rpl::on_next([this](int) { switchTab(); }) | rpl::start([this](int) { switchTab(); }, lifetime());
| rpl::start(lifetime());
_tabsSlider->resizeToWidth(width()); _tabsSlider->resizeToWidth(width());
_tabsSlider->moveToLeft(0, 0); _tabsSlider->moveToLeft(0, 0);

View File

@ -449,26 +449,23 @@ rpl::producer<SharedMediaSlice> SharedMediaViewer(
data.second); data.second);
}; };
builder->insufficientMediaAround() builder->insufficientMediaAround()
| rpl::on_next(requestMediaAround) | rpl::start(requestMediaAround, lifetime);
| rpl::start(lifetime);
Auth().storage().sharedMediaSliceUpdated() Auth().storage().sharedMediaSliceUpdated()
| rpl::on_next(applyUpdate) | rpl::start(applyUpdate, lifetime);
| rpl::start(lifetime);
Auth().storage().sharedMediaOneRemoved() Auth().storage().sharedMediaOneRemoved()
| rpl::on_next(applyUpdate) | rpl::start(applyUpdate, lifetime);
| rpl::start(lifetime);
Auth().storage().sharedMediaAllRemoved() Auth().storage().sharedMediaAllRemoved()
| rpl::on_next(applyUpdate) | rpl::start(applyUpdate, lifetime);
| rpl::start(lifetime);
Auth().storage().query(Storage::SharedMediaQuery( Auth().storage().query(Storage::SharedMediaQuery(
key, key,
limitBefore, limitBefore,
limitAfter)) limitAfter))
| rpl::on_next(applyUpdate) | rpl::start(
| rpl::on_done([=] { builder->checkInsufficientMedia(); }) applyUpdate,
| rpl::start(lifetime); [=] { builder->checkInsufficientMedia(); },
lifetime);
return lifetime; return lifetime;
}; };
@ -600,20 +597,20 @@ rpl::producer<SharedMediaMergedSlice> SharedMediaMergedViewer(
SharedMediaMergedSlice::PartKey(key), SharedMediaMergedSlice::PartKey(key),
limitBefore, limitBefore,
limitAfter limitAfter
) | rpl::on_next([=](SharedMediaSlice &&update) { ) | rpl::start([=](SharedMediaSlice &&update) {
builder->applyPartUpdate(std::move(update)); builder->applyPartUpdate(std::move(update));
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}) | rpl::start(lifetime); }, lifetime);
if (key.migratedPeerId) { if (key.migratedPeerId) {
SharedMediaViewer( SharedMediaViewer(
SharedMediaMergedSlice::MigratedKey(key), SharedMediaMergedSlice::MigratedKey(key),
limitBefore, limitBefore,
limitAfter limitAfter
) | rpl::on_next([=](SharedMediaSlice &&update) { ) | rpl::start([=](SharedMediaSlice &&update) {
builder->applyMigratedUpdate(std::move(update)); builder->applyMigratedUpdate(std::move(update));
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}) | rpl::start(lifetime); }, lifetime);
} }
return lifetime; return lifetime;
@ -752,20 +749,20 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
SharedMediaWithLastSlice::ViewerKey(key), SharedMediaWithLastSlice::ViewerKey(key),
limitBefore, limitBefore,
limitAfter limitAfter
) | rpl::on_next([=](SharedMediaMergedSlice &&update) { ) | rpl::start([=](SharedMediaMergedSlice &&update) {
builder->applyViewerUpdate(std::move(update)); builder->applyViewerUpdate(std::move(update));
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}) | rpl::start(lifetime); }, lifetime);
if (base::get_if<SharedMediaWithLastSlice::MessageId>(&key.universalId)) { if (base::get_if<SharedMediaWithLastSlice::MessageId>(&key.universalId)) {
SharedMediaMergedViewer( SharedMediaMergedViewer(
SharedMediaWithLastSlice::EndingKey(key), SharedMediaWithLastSlice::EndingKey(key),
1, 1,
1 1
) | rpl::on_next([=](SharedMediaMergedSlice &&update) { ) | rpl::start([=](SharedMediaMergedSlice &&update) {
builder->applyEndingUpdate(std::move(update)); builder->applyEndingUpdate(std::move(update));
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}) | rpl::start(lifetime); }, lifetime);
} }
return lifetime; return lifetime;

View File

@ -231,21 +231,19 @@ rpl::producer<UserPhotosSlice> UserPhotosViewer(
Auth().api().requestUserPhotos(user, photoId); Auth().api().requestUserPhotos(user, photoId);
}; };
builder->insufficientPhotosAround() builder->insufficientPhotosAround()
| rpl::on_next(requestPhotosAround) | rpl::start(requestPhotosAround, lifetime);
| rpl::start(lifetime);
Auth().storage().userPhotosSliceUpdated() Auth().storage().userPhotosSliceUpdated()
| rpl::on_next(applyUpdate) | rpl::start(applyUpdate, lifetime);
| rpl::start(lifetime);
Auth().storage().query(Storage::UserPhotosQuery( Auth().storage().query(Storage::UserPhotosQuery(
key, key,
limitBefore, limitBefore,
limitAfter limitAfter))
)) | rpl::start(
| rpl::on_next(applyUpdate) applyUpdate,
| rpl::on_done([=] { builder->checkInsufficientPhotos(); }) [=] { builder->checkInsufficientPhotos(); },
| rpl::start(lifetime); lifetime);
return lifetime; return lifetime;
}; };

View File

@ -54,18 +54,16 @@ LayerWrap::LayerWrap(
void LayerWrap::setupHeightConsumers() { void LayerWrap::setupHeightConsumers() {
_content->desiredHeightValue() _content->desiredHeightValue()
| rpl::on_next([this](int height) { | rpl::start([this](int height) {
_desiredHeight = height; _desiredHeight = height;
resizeToWidth(width()); resizeToWidth(width());
}) }, lifetime());
| rpl::start(lifetime());
heightValue() heightValue()
| rpl::on_next([this](int height) { | rpl::start([this](int height) {
_content->resize( _content->resize(
width(), width(),
height - _topBar->bottomNoMargins() - st::boxRadius); height - _topBar->bottomNoMargins() - st::boxRadius);
}) }, lifetime());
| rpl::start(lifetime());
} }
object_ptr<TopBar> LayerWrap::createTopBar() { object_ptr<TopBar> LayerWrap::createTopBar() {
@ -76,10 +74,9 @@ object_ptr<TopBar> LayerWrap::createTopBar() {
result.data(), result.data(),
st::infoLayerTopBarClose)); st::infoLayerTopBarClose));
close->clicks() close->clicks()
| rpl::on_next([this](auto&&) { | rpl::start([this](auto&&) {
_controller->hideSpecialLayer(); _controller->hideSpecialLayer();
}) }, close->lifetime());
| rpl::start(close->lifetime());
result->setTitle(TitleValue( result->setTitle(TitleValue(
_content->section(), _content->section(),
_content->peer())); _content->peer()));

View File

@ -104,12 +104,11 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget(
_inner->move(0, 0); _inner->move(0, 0);
scrollTopValue() scrollTopValue()
| rpl::on_next([this, inner = _inner](int value) { | rpl::start([this, inner = _inner](int value) {
inner->setVisibleTopBottom( inner->setVisibleTopBottom(
value, value,
value + _scroll->height()); // TODO rpl::combine value + _scroll->height()); // TODO rpl::combine
}) }, _inner->lifetime());
| rpl::start(_inner->lifetime());
return _inner; return _inner;
} }
@ -208,14 +207,14 @@ object_ptr<Window::SectionWidget> MoveMemento::createWidget(
controller, controller,
this); this);
result->setGeometry(geometry); result->setGeometry(geometry);
return result; return std::move(result);
} else if (_wrap == Wrap::Side && column == Window::Column::Third) { } else if (_wrap == Wrap::Side && column == Window::Column::Third) {
auto result = object_ptr<SideWrap>( auto result = object_ptr<SideWrap>(
parent, parent,
controller, controller,
this); this);
result->setGeometry(geometry); result->setGeometry(geometry);
return result; return std::move(result);
} }
return nullptr; return nullptr;
} }
@ -226,7 +225,7 @@ object_ptr<LayerWidget> MoveMemento::createLayer(
auto result = object_ptr<LayerWrap>( auto result = object_ptr<LayerWrap>(
controller, controller,
this); this);
return result; return std::move(result);
} }
return nullptr; return nullptr;
} }

View File

@ -87,10 +87,9 @@ object_ptr<TopBar> NarrowWrap::createTopBar() {
st::infoLayerTopBar); st::infoLayerTopBar);
result->enableBackButton(true); result->enableBackButton(true);
result->backRequest() result->backRequest()
| rpl::on_next([this](auto&&) { | rpl::start([this](auto&&) {
controller()->showBackFromStack(); controller()->showBackFromStack();
}) }, result->lifetime());
| rpl::start(result->lifetime());
result->setTitle(TitleValue( result->setTitle(TitleValue(
_content->section(), _content->section(),
_content->peer())); _content->peer()));

View File

@ -55,9 +55,9 @@ void InnerWidget::setupContent() {
std::move(hiddenDetailsContent))); std::move(hiddenDetailsContent)));
cover->setHasToggle(true); cover->setHasToggle(true);
cover->toggled() cover->toggled()
| rpl::on_next([=](bool expanded) { | rpl::start([=](bool expanded) {
hiddenDetails->toggleAnimated(expanded); hiddenDetails->toggleAnimated(expanded);
}) | rpl::start(_lifetime); }, _lifetime);
hiddenDetails->hideFast(); hiddenDetails->hideFast();
} else { } else {
_content->add(setupDetailsContent(_content)); _content->add(setupDetailsContent(_content));
@ -65,9 +65,9 @@ void InnerWidget::setupContent() {
_content->add(object_ptr<BoxContentDivider>(this)); _content->add(object_ptr<BoxContentDivider>(this));
_content->heightValue() _content->heightValue()
| rpl::on_next([this](int height) { | rpl::start([this](int height) {
TWidget::resizeToWidth(width()); TWidget::resizeToWidth(width());
}) | rpl::start(_lifetime); }, _lifetime);
} }
object_ptr<Ui::RpWidget> InnerWidget::setupDetailsContent( object_ptr<Ui::RpWidget> InnerWidget::setupDetailsContent(
@ -87,7 +87,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupDetailsContent(
result->add(object_ptr<Ui::PaddingWrap<>>(result, skipPadding)); result->add(object_ptr<Ui::PaddingWrap<>>(result, skipPadding));
return result; return std::move(result);
} }
object_ptr<Ui::RpWidget> InnerWidget::setupMuteToggle( object_ptr<Ui::RpWidget> InnerWidget::setupMuteToggle(
@ -98,24 +98,22 @@ object_ptr<Ui::RpWidget> InnerWidget::setupMuteToggle(
Lang::Viewer(lng_profile_enable_notifications), Lang::Viewer(lng_profile_enable_notifications),
st::infoNotificationsButton)); st::infoNotificationsButton));
NotificationsEnabledViewer(_peer) NotificationsEnabledViewer(_peer)
| rpl::on_next([button](bool enabled) { | rpl::start([button](bool enabled) {
button->setToggled(enabled); button->setToggled(enabled);
}) }, button->lifetime());
| rpl::start(button->lifetime());
button->clicks() button->clicks()
| rpl::on_next([this](auto) { | rpl::start([this](auto) {
App::main()->updateNotifySetting( App::main()->updateNotifySetting(
_peer, _peer,
_peer->isMuted() _peer->isMuted()
? NotifySettingSetNotify ? NotifySettingSetNotify
: NotifySettingSetMuted); : NotifySettingSetMuted);
}) }, button->lifetime());
| rpl::start(button->lifetime());
object_ptr<FloatingIcon>( object_ptr<FloatingIcon>(
result, result,
st::infoIconNotifications); st::infoIconNotifications);
return result; return std::move(result);
} }
void InnerWidget::setupMainUserButtons( void InnerWidget::setupMainUserButtons(
@ -126,12 +124,11 @@ void InnerWidget::setupMainUserButtons(
Lang::Viewer(lng_profile_send_message) | ToUpperValue(), Lang::Viewer(lng_profile_send_message) | ToUpperValue(),
st::infoMainButton)); st::infoMainButton));
sendMessage->clicks() sendMessage->clicks()
| rpl::on_next([this, user](auto&&) { | rpl::start([this, user](auto&&) {
_controller->showPeerHistory( _controller->showPeerHistory(
user, user,
Ui::ShowWay::Forward); Ui::ShowWay::Forward);
}) }, sendMessage->lifetime());
| rpl::start(sendMessage->lifetime());
auto addContact = wrap->add(object_ptr<Ui::SlideWrap<Button>>( auto addContact = wrap->add(object_ptr<Ui::SlideWrap<Button>>(
wrap, wrap,
@ -140,16 +137,14 @@ void InnerWidget::setupMainUserButtons(
Lang::Viewer(lng_info_add_as_contact) | ToUpperValue(), Lang::Viewer(lng_info_add_as_contact) | ToUpperValue(),
st::infoMainButton))); st::infoMainButton)));
CanAddContactViewer(user) CanAddContactViewer(user)
| rpl::on_next([addContact](bool canAdd) { | rpl::start([addContact](bool canAdd) {
addContact->toggleAnimated(canAdd); addContact->toggleAnimated(canAdd);
}) }, addContact->lifetime());
| rpl::start(addContact->lifetime());
addContact->finishAnimations(); addContact->finishAnimations();
addContact->entity()->clicks() addContact->entity()->clicks()
| rpl::on_next([user](auto&&) { | rpl::start([user](auto&&) {
App::main()->shareContactLayer(user); App::main()->shareContactLayer(user);
}) }, addContact->lifetime());
| rpl::start(addContact->lifetime());
} }
object_ptr<Ui::RpWidget> InnerWidget::setupInfoLines( object_ptr<Ui::RpWidget> InnerWidget::setupInfoLines(
@ -181,15 +176,14 @@ object_ptr<Ui::RpWidget> InnerWidget::setupInfoLines(
return base::find(values, true) != values.end(); return base::find(values, true) != values.end();
}) })
| rpl::distinct_until_changed() | rpl::distinct_until_changed()
| rpl::on_next([separator](bool someShown) { | rpl::start([separator](bool someShown) {
separator->toggleAnimated(someShown); separator->toggleAnimated(someShown);
}) }, separator->lifetime());
| rpl::start(separator->lifetime());
separator->finishAnimations(); separator->finishAnimations();
object_ptr<FloatingIcon>(result, st::infoIconInformation); object_ptr<FloatingIcon>(result, st::infoIconInformation);
return result; return std::move(result);
} }
void InnerWidget::visibleTopBottomUpdated( void InnerWidget::visibleTopBottomUpdated(

View File

@ -232,13 +232,12 @@ FloatingIcon::FloatingIcon(
setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_TransparentForMouseEvents);
if (above) { if (above) {
above->geometryValue() above->geometryValue()
| rpl::on_next([this](QRect &&geometry) { | rpl::start([this](const QRect &geometry) {
auto topLeft = rtlpoint( auto topLeft = rtlpoint(
geometry.topLeft(), geometry.topLeft(),
parentWidget()->width()); parentWidget()->width());
moveToLeft(topLeft.x(), topLeft.y() + geometry.height()); moveToLeft(topLeft.x(), topLeft.y() + geometry.height());
}) }, lifetime());
| rpl::start(lifetime());
} else { } else {
moveToLeft(0, 0); moveToLeft(0, 0);
} }
@ -323,15 +322,18 @@ void CoverLine::setHasToggle(bool hasToggle) {
void CoverLine::initViewers() { void CoverLine::initViewers() {
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
PeerUpdateViewer(_peer, Flag::PhotoChanged) PeerUpdateViewer(_peer, Flag::PhotoChanged)
| rpl::on_next([this](auto&&) { refreshUserpicLink(); }) | rpl::start(
| rpl::start(_lifetime); [this](auto&&) { refreshUserpicLink(); },
_lifetime);
PeerUpdateViewer(_peer, Flag::NameChanged) PeerUpdateViewer(_peer, Flag::NameChanged)
| rpl::on_next([this](auto&&) { refreshNameText(); }) | rpl::start(
| rpl::start(_lifetime); [this](auto&&) { refreshNameText(); },
_lifetime);
PeerUpdateViewer(_peer, PeerUpdateViewer(_peer,
Flag::UserOnlineChanged | Flag::MembersChanged) Flag::UserOnlineChanged | Flag::MembersChanged)
| rpl::on_next([this](auto&&) { refreshStatusText(); }) | rpl::start(
| rpl::start(_lifetime); [this](auto&&) { refreshStatusText(); },
_lifetime);
} }
void CoverLine::initUserpicButton() { void CoverLine::initUserpicButton() {
@ -449,10 +451,9 @@ Button::Button(
: RippleButton(parent, st.ripple) : RippleButton(parent, st.ripple)
, _st(st) { , _st(st) {
std::move(text) std::move(text)
| rpl::on_next([this](QString &&value) { | rpl::start([this](QString &&value) {
setText(std::move(value)); setText(std::move(value));
}) }, lifetime());
| rpl::start(lifetime());
} }
void Button::setToggled(bool toggled) { void Button::setToggled(bool toggled) {
@ -462,10 +463,9 @@ void Button::setToggled(bool toggled) {
toggled, toggled,
[this] { rtlupdate(toggleRect()); }); [this] { rtlupdate(toggleRect()); });
clicks() clicks()
| rpl::on_next([this](auto) { | rpl::start([this](auto) {
_toggle->setCheckedAnimated(!_toggle->checked()); _toggle->setCheckedAnimated(!_toggle->checked());
}) }, lifetime());
| rpl::start(lifetime());
} else { } else {
_toggle->setCheckedAnimated(toggled); _toggle->setCheckedAnimated(toggled);
} }

View File

@ -62,8 +62,7 @@ void SideWrap::setupTabs() {
_tabs->setSections(sections); _tabs->setSections(sections);
_tabs->sectionActivated() _tabs->sectionActivated()
| rpl::map([](int index) { return static_cast<Tab>(index); }) | rpl::map([](int index) { return static_cast<Tab>(index); })
| rpl::on_next([this](Tab tab) { showTab(tab); }) | rpl::start([this](Tab tab) { showTab(tab); }, _lifetime);
| rpl::start(_lifetime);
_tabs->move(0, 0); _tabs->move(0, 0);
_tabs->resizeToWidth(width()); _tabs->resizeToWidth(width());

View File

@ -59,10 +59,9 @@ void TopBar::pushButton(object_ptr<Ui::RpWidget> button) {
auto weak = Ui::AttachParentChild(this, button); auto weak = Ui::AttachParentChild(this, button);
_buttons.push_back(std::move(button)); _buttons.push_back(std::move(button));
weak->widthValue() weak->widthValue()
| rpl::on_next([this](auto) { | rpl::start([this](auto) {
updateControlsGeometry(width()); updateControlsGeometry(width());
}) }, _lifetime);
| rpl::start(_lifetime);
} }
int TopBar::resizeGetHeight(int newWidth) { int TopBar::resizeGetHeight(int newWidth) {

View File

@ -1846,8 +1846,9 @@ void MainWidget::createPlayer() {
if (!_player) { if (!_player) {
_player.create(this); _player.create(this);
_player->heightValue() _player->heightValue()
| rpl::on_next([this](int) { playerHeightUpdated(); }) | rpl::start(
| rpl::start(lifetime()); [this](int) { playerHeightUpdated(); },
lifetime());
_player->entity()->setCloseCallback([this] { closeBothPlayers(); }); _player->entity()->setCloseCallback([this] { closeBothPlayers(); });
_playerVolume.create(this); _playerVolume.create(this);
_player->entity()->volumeWidgetCreated(_playerVolume); _player->entity()->volumeWidgetCreated(_playerVolume);
@ -1906,10 +1907,9 @@ void MainWidget::createCallTopBar() {
Expects(_currentCall != nullptr); Expects(_currentCall != nullptr);
_callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall)); _callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall));
_callTopBar->heightValue() _callTopBar->heightValue()
| rpl::on_next([this](int value) { | rpl::start([this](int value) {
callTopBarHeightUpdated(value); callTopBarHeightUpdated(value);
}) }, lifetime());
| rpl::start(lifetime());
orderWidgets(); orderWidgets();
if (_a_show.animating()) { if (_a_show.animating()) {
_callTopBar->showFast(); _callTopBar->showFast();

View File

@ -1064,9 +1064,9 @@ void MediaView::validateSharedMedia() {
*key, *key,
kIdsLimit, kIdsLimit,
kIdsLimit kIdsLimit
) | rpl::on_next([this](SharedMediaWithLastSlice &&update) { ) | rpl::start([this](SharedMediaWithLastSlice &&update) {
handleSharedMediaUpdate(std::move(update)); handleSharedMediaUpdate(std::move(update));
}) | rpl::start(_sharedMedia->lifetime); }, _sharedMedia->lifetime);
} else { } else {
_sharedMedia = nullptr; _sharedMedia = nullptr;
_sharedMediaData = base::none; _sharedMediaData = base::none;
@ -1123,9 +1123,9 @@ void MediaView::validateUserPhotos() {
*key, *key,
kIdsLimit, kIdsLimit,
kIdsLimit kIdsLimit
) | rpl::on_next([this](UserPhotosSlice &&update) { ) | rpl::start([this](UserPhotosSlice &&update) {
handleUserPhotosUpdate(std::move(update)); handleUserPhotosUpdate(std::move(update));
}) | rpl::start(_userPhotos->lifetime); }, _userPhotos->lifetime);
} else { } else {
_userPhotos = nullptr; _userPhotos = nullptr;
_userPhotosData = base::none; _userPhotosData = base::none;

View File

@ -28,14 +28,17 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Settings { namespace Settings {
BlockWidget::BlockWidget(QWidget *parent, UserData *self, const QString &title) : RpWidget(parent) BlockWidget::BlockWidget(QWidget *parent, UserData *self, const QString &title) : RpWidget(parent)
, _content(this)
, _self(self) , _self(self)
, _title(title) , _title(title) {
, _content(this) {
_content->heightValue() _content->heightValue()
| rpl::on_next([this](int contentHeight) { | rpl::start([this](int contentHeight) {
resize(width(), contentTop() + contentHeight + st::settingsBlockMarginBottom); resize(
}) width(),
| rpl::start(lifetime()); contentTop()
+ contentHeight
+ st::settingsBlockMarginBottom);
}, lifetime());
} }
void BlockWidget::setContentLeft(int contentLeft) { void BlockWidget::setContentLeft(int contentLeft) {

View File

@ -36,8 +36,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Settings { namespace Settings {
InnerWidget::InnerWidget(QWidget *parent) : LayerInner(parent) InnerWidget::InnerWidget(QWidget *parent) : LayerInner(parent)
, _self(App::self()) , _blocks(this)
, _blocks(this) { , _self(App::self()) {
refreshBlocks(); refreshBlocks();
subscribe(Global::RefSelfChanged(), [this] { fullRebuild(); }); subscribe(Global::RefSelfChanged(), [this] { fullRebuild(); });
subscribe(Lang::Current().updated(), [this] { fullRebuild(); }); subscribe(Lang::Current().updated(), [this] { fullRebuild(); });
@ -83,10 +83,9 @@ void InnerWidget::refreshBlocks() {
} }
_blocks->show(); _blocks->show();
_blocks->heightValue() _blocks->heightValue()
| rpl::on_next([this](int blocksHeight) { | rpl::start([this](int blocksHeight) {
resize(width(), _blocks->y() + blocksHeight); resize(width(), _blocks->y() + blocksHeight);
}) }, lifetime());
| rpl::start(lifetime());
} }
void InnerWidget::showFinished() { void InnerWidget::showFinished() {

View File

@ -53,10 +53,9 @@ Layer::Layer()
_scroll->scrollTopValue() _scroll->scrollTopValue()
| rpl::map([](int scrollTop) { return scrollTop > 0; }) | rpl::map([](int scrollTop) { return scrollTop > 0; })
| rpl::distinct_until_changed() | rpl::distinct_until_changed()
| rpl::on_next([this](bool scrolled) { | rpl::start([this](bool scrolled) {
_fixedBarShadow->toggleAnimated(scrolled); _fixedBarShadow->toggleAnimated(scrolled);
}) }, lifetime());
| rpl::start(lifetime());
} }
void Layer::setCloseClickHandler(base::lambda<void()> callback) { void Layer::setCloseClickHandler(base::lambda<void()> callback) {
@ -74,10 +73,9 @@ void Layer::resizeToWidth(int newWidth, int newContentLeft) {
void Layer::doSetInnerWidget(object_ptr<LayerInner> widget) { void Layer::doSetInnerWidget(object_ptr<LayerInner> widget) {
_inner = _scroll->setOwnedWidget(std::move(widget)); _inner = _scroll->setOwnedWidget(std::move(widget));
_inner->heightValue() _inner->heightValue()
| rpl::on_next([this](int innerHeight) { | rpl::start([this](int innerHeight) {
resizeUsingInnerHeight(width(), innerHeight); resizeUsingInnerHeight(width(), innerHeight);
}) }, lifetime());
| rpl::start(lifetime());
} }
void Layer::paintEvent(QPaintEvent *e) { void Layer::paintEvent(QPaintEvent *e) {

View File

@ -61,8 +61,7 @@ void ScaleWidget::createControls() {
_scale->addSection(scaleLabel(dbisTwo)); _scale->addSection(scaleLabel(dbisTwo));
_scale->setActiveSectionFast(cEvalScale(cConfigScale()) - 1); _scale->setActiveSectionFast(cEvalScale(cConfigScale()) - 1);
_scale->sectionActivated() _scale->sectionActivated()
| rpl::on_next([this](int) { scaleChanged(); }) | rpl::start([this](int) { scaleChanged(); }, lifetime());
| rpl::start(lifetime());
} }
void ScaleWidget::onAutoChanged() { void ScaleWidget::onAutoChanged() {

View File

@ -43,8 +43,6 @@ private:
QPointer<InnerWidget> _inner; QPointer<InnerWidget> _inner;
int _contentLeft = 0;
}; };
} // namespace Settings } // namespace Settings

View File

@ -234,15 +234,14 @@ std::map<PeerId, SharedMedia::Lists>::iterator
auto type = static_cast<SharedMediaType>(index); auto type = static_cast<SharedMediaType>(index);
list.sliceUpdated() list.sliceUpdated()
| rpl::on_next([this, peer, type](const SliceUpdate &update) { | rpl::start([this, peer, type](const SliceUpdate &update) {
_sliceUpdated.fire(SharedMediaSliceUpdate( _sliceUpdated.fire(SharedMediaSliceUpdate(
peer, peer,
type, type,
update.messages, update.messages,
update.range, update.range,
update.count)); update.count));
}) }, _lifetime);
| rpl::start(_lifetime);
} }
return result; return result;
} }

View File

@ -122,12 +122,12 @@ UserPhotos::enforceLists(UserId user) {
} }
result = _lists.emplace(user, List {}).first; result = _lists.emplace(user, List {}).first;
result->second.sliceUpdated( result->second.sliceUpdated(
) | rpl::on_next([this, user](const SliceUpdate &update) { ) | rpl::start([this, user](const SliceUpdate &update) {
_sliceUpdated.fire(UserPhotosSliceUpdate( _sliceUpdated.fire(UserPhotosSliceUpdate(
user, user,
update.photoIds, update.photoIds,
update.count)); update.count));
}) | rpl::start(_lifetime); }, _lifetime);
return result; return result;
} }

View File

@ -28,7 +28,7 @@ namespace Ui {
class RpWidget : public TWidget { class RpWidget : public TWidget {
public: public:
RpWidget::RpWidget(QWidget *parent = nullptr) : TWidget(parent) { RpWidget(QWidget *parent = nullptr) : TWidget(parent) {
setGeometry(0, 0, 0, 0); setGeometry(0, 0, 0, 0);
} }

View File

@ -171,10 +171,9 @@ FlatLabel::FlatLabel(
, _st(st) , _st(st)
, _contextCopyText(lang(lng_context_copy_text)) { , _contextCopyText(lang(lng_context_copy_text)) {
std::move(text) std::move(text)
| rpl::on_next([this](const QString &value) { | rpl::start([this](const QString &value) {
setText(value); setText(value);
}) }, lifetime());
| rpl::start(lifetime());
} }
FlatLabel::FlatLabel( FlatLabel::FlatLabel(
@ -186,10 +185,9 @@ FlatLabel::FlatLabel(
, _st(st) , _st(st)
, _contextCopyText(lang(lng_context_copy_text)) { , _contextCopyText(lang(lng_context_copy_text)) {
std::move(text) std::move(text)
| rpl::on_next([this](const TextWithEntities &value) { | rpl::start([this](const TextWithEntities &value) {
setMarkedText(value); setMarkedText(value);
}) }, lifetime());
| rpl::start(lifetime());
} }
void FlatLabel::init() { void FlatLabel::init() {

View File

@ -115,13 +115,11 @@ RpWidget *VerticalLayout::addChild(
width() - margins.left() - margins.right(), width() - margins.left() - margins.right(),
height() - margins.top() - margins.bottom()); height() - margins.top() - margins.bottom());
weak->heightValue() weak->heightValue()
| rpl::on_next([this, weak](int) { | rpl::start([this, weak](int) {
childHeightUpdated(weak); childHeightUpdated(weak);
}) }, [this, weak] {
| rpl::on_done([this, weak] {
removeChild(weak); removeChild(weak);
}) }, lifetime());
| rpl::start(lifetime());
return weak; return weak;
} }
return nullptr; return nullptr;

View File

@ -30,20 +30,12 @@ class Wrap;
namespace details { namespace details {
struct UnwrapHelper { struct UnwrapHelper {
struct Large { template <
char data[2]; typename Widget,
}; typename = typename std::decay_t<Widget>::WrapParentType>
static char Check(...); static std::true_type Is(Widget &&widget);
template <typename Widget, typename Parent> static std::false_type Is(...);
static Large Check(Wrap<Widget, Parent>*);
template <typename Widget, typename Parent>
static Large Check(const Wrap<Widget, Parent>*);
template <typename Entity>
static constexpr bool Is() {
return sizeof(Check(std::declval<Entity>()))
== sizeof(Large);
}
template <typename Entity> template <typename Entity>
static auto Unwrap(Entity *entity, std::true_type) { static auto Unwrap(Entity *entity, std::true_type) {
return entity return entity
@ -56,10 +48,12 @@ struct UnwrapHelper {
} }
template <typename Entity> template <typename Entity>
static auto Unwrap(Entity *entity) { static auto Unwrap(Entity *entity) {
using Selector = decltype(Is(std::declval<Entity>()));
return Unwrap( return Unwrap(
entity, entity,
std::integral_constant<bool, Is<Entity*>()>()); Selector());
} }
}; };
} // namespace details } // namespace details
@ -126,10 +120,9 @@ Wrap<Widget, RpWidget>::Wrap(QWidget *parent, object_ptr<Widget> child)
, _wrapped(std::move(child)) { , _wrapped(std::move(child)) {
if (_wrapped) { if (_wrapped) {
_wrapped->sizeValue() _wrapped->sizeValue()
| rpl::on_next([this](const QSize &value) { | rpl::start([this](const QSize &value) {
wrappedSizeUpdated(value); wrappedSizeUpdated(value);
}) }, lifetime());
| rpl::start(lifetime());
AttachParentChild(this, _wrapped); AttachParentChild(this, _wrapped);
_wrapped->move(0, 0); _wrapped->move(0, 0);
_wrapped->alive() _wrapped->alive()
@ -160,6 +153,8 @@ public:
return details::UnwrapHelper::Unwrap(wrapped()); return details::UnwrapHelper::Unwrap(wrapped());
} }
using WrapParentType = ParentType;
}; };
} // namespace Ui } // namespace Ui

View File

@ -27,10 +27,9 @@ namespace Window {
PlayerWrapWidget::PlayerWrapWidget(QWidget *parent) PlayerWrapWidget::PlayerWrapWidget(QWidget *parent)
: Parent(parent, object_ptr<Media::Player::Widget>(parent)) { : Parent(parent, object_ptr<Media::Player::Widget>(parent)) {
sizeValue() sizeValue()
| rpl::on_next([this](const QSize &size) { | rpl::start([this](const QSize &size) {
updateShadowGeometry(size); updateShadowGeometry(size);
}) }, lifetime());
| rpl::start(lifetime());
} }
void PlayerWrapWidget::updateShadowGeometry(const QSize &size) { void PlayerWrapWidget::updateShadowGeometry(const QSize &size) {

View File

@ -98,8 +98,9 @@ TopBarWidget::TopBarWidget(QWidget *parent, not_null<Window::Controller*> contro
updateControlsVisibility(); }); updateControlsVisibility(); });
Auth().data().thirdSectionInfoEnabledValue() Auth().data().thirdSectionInfoEnabledValue()
| rpl::on_next([this](bool) { updateInfoToggleActive(); }) | rpl::start(
| rpl::start(lifetime()); [this](bool) { updateInfoToggleActive(); },
lifetime());
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
updateControlsVisibility(); updateControlsVisibility();