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) {
exceptionLink(exception).create(this, object_ptr<Ui::LinkButton>(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); });
};

View File

@ -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);

View File

@ -46,8 +46,9 @@ void PeerListBox::createMultiSelect() {
auto entity = object_ptr<Ui::MultiSelect>(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) {

View File

@ -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() {

View File

@ -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();

View File

@ -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());

View File

@ -347,12 +347,11 @@ TabbedSelector::TabbedSelector(QWidget *parent, not_null<Window::Controller*> co
}));
Auth().api().stickerSetInstalled()
| rpl::on_next([this](uint64 setId) {
| rpl::start([this](uint64 setId) {
_tabsSlider->setActiveSection(static_cast<int>(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<int>(_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);

View File

@ -449,26 +449,23 @@ rpl::producer<SharedMediaSlice> 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<SharedMediaMergedSlice> 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<SharedMediaWithLastSlice> 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<SharedMediaWithLastSlice::MessageId>(&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;

View File

@ -231,21 +231,19 @@ rpl::producer<UserPhotosSlice> 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;
};

View File

@ -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<TopBar> LayerWrap::createTopBar() {
@ -76,10 +74,9 @@ object_ptr<TopBar> 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()));

View File

@ -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<Window::SectionWidget> 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<SideWrap>(
parent,
controller,
this);
result->setGeometry(geometry);
return result;
return std::move(result);
}
return nullptr;
}
@ -226,7 +225,7 @@ object_ptr<LayerWidget> MoveMemento::createLayer(
auto result = object_ptr<LayerWrap>(
controller,
this);
return result;
return std::move(result);
}
return nullptr;
}

View File

@ -87,10 +87,9 @@ object_ptr<TopBar> 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()));

View File

@ -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<BoxContentDivider>(this));
_content->heightValue()
| rpl::on_next([this](int height) {
| rpl::start([this](int height) {
TWidget::resizeToWidth(width());
}) | rpl::start(_lifetime);
}, _lifetime);
}
object_ptr<Ui::RpWidget> InnerWidget::setupDetailsContent(
@ -87,7 +87,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupDetailsContent(
result->add(object_ptr<Ui::PaddingWrap<>>(result, skipPadding));
return result;
return std::move(result);
}
object_ptr<Ui::RpWidget> InnerWidget::setupMuteToggle(
@ -98,24 +98,22 @@ object_ptr<Ui::RpWidget> 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<FloatingIcon>(
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<Ui::SlideWrap<Button>>(
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<Ui::RpWidget> InnerWidget::setupInfoLines(
@ -181,15 +176,14 @@ object_ptr<Ui::RpWidget> 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<FloatingIcon>(result, st::infoIconInformation);
return result;
return std::move(result);
}
void InnerWidget::visibleTopBottomUpdated(

View File

@ -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);
}

View File

@ -62,8 +62,7 @@ void SideWrap::setupTabs() {
_tabs->setSections(sections);
_tabs->sectionActivated()
| rpl::map([](int index) { return static_cast<Tab>(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());

View File

@ -59,10 +59,9 @@ void TopBar::pushButton(object_ptr<Ui::RpWidget> 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) {

View File

@ -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<Calls::TopBar>(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();

View File

@ -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;

View File

@ -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) {

View File

@ -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() {

View File

@ -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<void()> callback) {
@ -74,10 +73,9 @@ void Layer::resizeToWidth(int newWidth, int newContentLeft) {
void Layer::doSetInnerWidget(object_ptr<LayerInner> 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) {

View File

@ -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() {

View File

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

View File

@ -234,15 +234,14 @@ std::map<PeerId, SharedMedia::Lists>::iterator
auto type = static_cast<SharedMediaType>(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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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() {

View File

@ -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;

View File

@ -30,20 +30,12 @@ class Wrap;
namespace details {
struct UnwrapHelper {
struct Large {
char data[2];
};
static char Check(...);
template <typename Widget, typename Parent>
static Large Check(Wrap<Widget, Parent>*);
template <typename Widget, typename Parent>
static Large Check(const Wrap<Widget, Parent>*);
template <
typename Widget,
typename = typename std::decay_t<Widget>::WrapParentType>
static std::true_type Is(Widget &&widget);
static std::false_type Is(...);
template <typename Entity>
static constexpr bool Is() {
return sizeof(Check(std::declval<Entity>()))
== sizeof(Large);
}
template <typename Entity>
static auto Unwrap(Entity *entity, std::true_type) {
return entity
@ -56,10 +48,12 @@ struct UnwrapHelper {
}
template <typename Entity>
static auto Unwrap(Entity *entity) {
using Selector = decltype(Is(std::declval<Entity>()));
return Unwrap(
entity,
std::integral_constant<bool, Is<Entity*>()>());
Selector());
}
};
} // namespace details
@ -126,10 +120,9 @@ Wrap<Widget, RpWidget>::Wrap(QWidget *parent, object_ptr<Widget> 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

View File

@ -27,10 +27,9 @@ namespace Window {
PlayerWrapWidget::PlayerWrapWidget(QWidget *parent)
: Parent(parent, object_ptr<Media::Player::Widget>(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) {

View File

@ -98,8 +98,9 @@ TopBarWidget::TopBarWidget(QWidget *parent, not_null<Window::Controller*> 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();