mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
feat: clear selected & close box after shot & scroll to bottom
This commit is contained in:
parent
8bfb7e221b
commit
2414e51a9b
8 changed files with 28 additions and 12 deletions
|
@ -411,7 +411,7 @@ QImage Make(not_null<QWidget*> box, const ShotConfig &config) {
|
|||
return newResult;
|
||||
}
|
||||
|
||||
void Wrapper(not_null<HistoryView::ListWidget*> widget) {
|
||||
void Wrapper(not_null<HistoryView::ListWidget*> widget, Fn<void()> clearSelected) {
|
||||
const auto items = widget->getSelectedIds();
|
||||
if (items.empty()) {
|
||||
return;
|
||||
|
@ -436,6 +436,10 @@ void Wrapper(not_null<HistoryView::ListWidget*> widget) {
|
|||
messages,
|
||||
};
|
||||
auto box = Box<MessageShotBox>(config);
|
||||
box->boxClosing() | rpl::start_with_next([=]
|
||||
{
|
||||
clearSelected();
|
||||
}, box->lifetime());
|
||||
Ui::show(std::move(box));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ struct ShotConfig
|
|||
std::shared_ptr<Ui::ChatStyle> st;
|
||||
std::vector<not_null<HistoryItem*>> messages;
|
||||
|
||||
bool showBackground;
|
||||
bool showBackground = true;
|
||||
bool showDate;
|
||||
bool showReactions;
|
||||
};
|
||||
|
@ -69,6 +69,6 @@ QColor makeDefaultBackgroundColor();
|
|||
|
||||
QImage Make(not_null<QWidget*> box, const ShotConfig &config);
|
||||
|
||||
void Wrapper(not_null<HistoryView::ListWidget*> widget);
|
||||
void Wrapper(not_null<HistoryView::ListWidget*> widget, Fn<void()> clearSelected);
|
||||
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ void MessageShotBox::setupContent() {
|
|||
content,
|
||||
tr::ayu_MessageShotShowBackground(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(rpl::single(false)
|
||||
)->toggleOn(rpl::single(_config.showBackground)
|
||||
)->toggledValue(
|
||||
) | start_with_next(
|
||||
[=](bool enabled)
|
||||
|
@ -128,7 +128,7 @@ void MessageShotBox::setupContent() {
|
|||
content,
|
||||
tr::ayu_MessageShotShowDate(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(rpl::single(false)
|
||||
)->toggleOn(rpl::single(_config.showDate)
|
||||
)->toggledValue(
|
||||
) | start_with_next(
|
||||
[=](bool enabled)
|
||||
|
@ -143,7 +143,7 @@ void MessageShotBox::setupContent() {
|
|||
content,
|
||||
tr::ayu_MessageShotShowReactions(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(rpl::single(false)
|
||||
)->toggleOn(rpl::single(_config.showReactions)
|
||||
)->toggledValue(
|
||||
) | start_with_next(
|
||||
[=](bool enabled)
|
||||
|
@ -154,11 +154,12 @@ void MessageShotBox::setupContent() {
|
|||
},
|
||||
content->lifetime());
|
||||
|
||||
AddButtonWithIcon(
|
||||
const auto latestToggle = AddButtonWithIcon(
|
||||
content,
|
||||
tr::ayu_MessageShotShowColorfulReplies(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(rpl::single(savedShowColorfulReplies)
|
||||
);
|
||||
latestToggle->toggleOn(rpl::single(savedShowColorfulReplies)
|
||||
)->toggledValue(
|
||||
) | start_with_next(
|
||||
[=](bool enabled)
|
||||
|
@ -186,11 +187,15 @@ void MessageShotBox::setupContent() {
|
|||
if (!path.isEmpty()) {
|
||||
image.save(path);
|
||||
}
|
||||
|
||||
closeBox();
|
||||
});
|
||||
addButton(tr::ayu_MessageShotCopy(),
|
||||
[=]
|
||||
{
|
||||
QGuiApplication::clipboard()->setImage(imageView->getImage());
|
||||
|
||||
closeBox();
|
||||
});
|
||||
|
||||
updatePreview();
|
||||
|
@ -210,4 +215,7 @@ void MessageShotBox::setupContent() {
|
|||
content->lifetime());
|
||||
|
||||
setDimensionsToContent(boxWidth, content);
|
||||
|
||||
// scroll to the end
|
||||
scrollToWidget(latestToggle);
|
||||
}
|
||||
|
|
|
@ -7927,6 +7927,10 @@ void HistoryWidget::messageShotSelected() {
|
|||
messages
|
||||
};
|
||||
auto box = Box<MessageShotBox>(config);
|
||||
box->boxClosing() | rpl::start_with_next([=]
|
||||
{
|
||||
clearSelected();
|
||||
}, box->lifetime());
|
||||
Ui::show(std::move(box));
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ PinnedWidget::PinnedWidget(
|
|||
}, _topBar->lifetime());
|
||||
_topBar->messageShotSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
AyuFeatures::MessageShot::Wrapper(_inner);
|
||||
AyuFeatures::MessageShot::Wrapper(_inner, [=] { clearSelected(); });
|
||||
}, _topBar->lifetime());
|
||||
_topBar->forwardSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
@ -268,7 +268,7 @@ RepliesWidget::RepliesWidget(
|
|||
}, _topBar->lifetime());
|
||||
_topBar->messageShotSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
AyuFeatures::MessageShot::Wrapper(_inner);
|
||||
AyuFeatures::MessageShot::Wrapper(_inner, [=] { clearSelected(); });
|
||||
}, _topBar->lifetime());
|
||||
_topBar->forwardSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
@ -127,7 +127,7 @@ ScheduledWidget::ScheduledWidget(
|
|||
}, _topBar->lifetime());
|
||||
_topBar->messageShotSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
AyuFeatures::MessageShot::Wrapper(_inner);
|
||||
AyuFeatures::MessageShot::Wrapper(_inner, [=] { clearSelected(); });
|
||||
}, _topBar->lifetime());
|
||||
_topBar->clearSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
@ -117,7 +117,7 @@ SublistWidget::SublistWidget(
|
|||
}, _topBar->lifetime());
|
||||
_topBar->messageShotSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
AyuFeatures::MessageShot::Wrapper(_inner);
|
||||
AyuFeatures::MessageShot::Wrapper(_inner, [=] { clearSelected(); });
|
||||
}, _topBar->lifetime());
|
||||
_topBar->forwardSelectionRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
Loading…
Add table
Reference in a new issue