Sometimes only replace in crafting.

This commit is contained in:
John Preston
2026-02-18 23:19:04 +04:00
parent f5bee133a4
commit f14c592148
3 changed files with 29 additions and 9 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Mini / mini_replace2</title>
<g id="Mini-/-mini_replace2" stroke="none" fill="none" fill-rule="nonzero">
<path d="M8.27981904,18.1901792 C8.35180301,18.2477663 8.41718661,18.3131499 8.47477379,18.3851339 L14.6887446,26.1525974 C14.9040856,26.4217737 14.8604435,26.8145527 14.5912672,27.0298938 C14.4805955,27.1184311 14.3430866,27.1666667 14.2013577,27.1666667 L9.42766478,27.1670537 C10.878665,33.9028527 16.8626042,38.95 24.0232121,38.95 C27.9154401,38.95 31.5678594,37.4552395 34.3277951,34.8190502 C35.1465138,34.0370401 36.4441608,34.0667983 37.2261709,34.885517 C38.0081809,35.7042357 37.9784227,37.0018828 37.159704,37.7838928 C33.6445004,41.1414863 28.981083,43.05 24.0232121,43.05 C14.5899526,43.05 6.76036297,36.1801958 5.25373571,27.166733 L0.798642328,27.1666667 C0.453928405,27.1666667 0.174482557,26.8872208 0.174482557,26.5425069 C0.174482557,26.400778 0.222718094,26.263269 0.311255431,26.1525974 L6.52522621,18.3851339 C6.95590837,17.8467812 7.74146633,17.759497 8.27981904,18.1901792 Z M24.0232121,4.95 C33.5722941,4.95 41.4780844,11.9895362 42.8453157,21.1662324 L47.2013577,21.1666667 C47.3430866,21.1666667 47.4805955,21.2149022 47.5912672,21.3034395 C47.8604435,21.5187806 47.9040856,21.9115596 47.6887446,22.180736 L41.4747738,29.9481994 C41.4171866,30.0201834 41.351803,30.085567 41.279819,30.1431542 C40.7414663,30.5738363 39.9559084,30.4865521 39.5252262,29.9481994 L33.3112554,22.180736 C33.2227181,22.0700643 33.1744826,21.9325553 33.1744826,21.7908264 C33.1744826,21.4461125 33.4539284,21.1666667 33.7986423,21.1666667 L38.6865289,21.1659705 C37.363877,14.2641899 31.3013507,9.05 24.0232121,9.05 C19.9913296,9.05 16.2185331,10.6547806 13.4323785,13.4617549 C12.6347893,14.2653042 11.3368101,14.2701357 10.5332608,13.4725465 C9.72971154,12.6749573 9.72487998,11.3769781 10.5224692,10.5734288 C14.070616,6.99876826 18.8872155,4.95 24.0232121,4.95 Z" id="Shape" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

@@ -292,13 +292,12 @@ AbstractButton *MakeRemoveButton(
int size, int size,
const GiftForCraft &gift, const GiftForCraft &gift,
Fn<void()> onClick, Fn<void()> onClick,
rpl::producer<QColor> edgeColor) { rpl::producer<QColor> edgeColor,
const style::icon &icon) {
auto remove = object_ptr<RpWidget>(parent); auto remove = object_ptr<RpWidget>(parent);
const auto &icon = st::stickerPanDeleteIconFg;
const auto add = (size - icon.width()) / 2; const auto add = (size - icon.width()) / 2;
remove->resize(icon.size() + QSize(add, add) * 2); remove->resize(icon.size() + QSize(add, add) * 2);
remove->paintOn([=](QPainter &p) { remove->paintOn([=, &icon](QPainter &p) {
const auto &icon = st::stickerPanDeleteIconFg;
icon.paint(p, add, add, add * 2 + icon.width(), st::white->c); icon.paint(p, add, add, add * 2 + icon.width(), st::white->c);
}); });
remove->setAttribute(Qt::WA_TransparentForMouseEvents); remove->setAttribute(Qt::WA_TransparentForMouseEvents);
@@ -419,19 +418,32 @@ AbstractButton *MakeRemoveButton(
nullptr, nullptr,
&Entry::button); &Entry::button);
const auto canRemove = (count > 1); const auto canRemove = (count > 1);
const auto secondHasAddress = state->entries[1].gift
&& !state->entries[1].gift.unique->giftAddress.isEmpty();
for (auto i = 0; i != 4; ++i) { for (auto i = 0; i != 4; ++i) {
auto &entry = state->entries[i]; auto &entry = state->entries[i];
if (entry.button) { if (entry.button) {
if (!canRemove) { delete base::take(entry.remove);
delete base::take(entry.remove); if (canRemove) {
} else if (!entry.remove) { const auto needReplace = (i == 0) && secondHasAddress;
const auto callback = [=] {
if (needReplace) {
state->editRequests.fire_copy(0);
} else {
state->removeRequests.fire_copy(i);
}
};
const auto &icon = needReplace
? st::craftReplaceIcon
: st::stickerPanDeleteIconFg;
entry.remove = MakeRemoveButton( entry.remove = MakeRemoveButton(
raw, raw,
entry.button, entry.button,
entry.percent->height(), entry.percent->height(),
entry.gift, entry.gift,
[=] { state->removeRequests.fire_copy(i); }, callback,
state->edgeColor.value()); state->edgeColor.value(),
icon);
} }
} }
} }
@@ -624,6 +624,7 @@ craftPattern: IconEmoji {
padding: margins(0px, 0px, 0px, 0px); padding: margins(0px, 0px, 0px, 0px);
} }
craftAddIcon: icon {{ "settings/plus", windowFgActive }}; craftAddIcon: icon {{ "settings/plus", windowFgActive }};
craftReplaceIcon: icon {{ "mini_replace-12x12", windowFgActive }};
craftPreviewPadding: margins(24px, 8px, 40px, 8px); craftPreviewPadding: margins(24px, 8px, 40px, 8px);
craftBoxButtonPadding: margins(22px, 12px, 22px, 22px); craftBoxButtonPadding: margins(22px, 12px, 22px, 22px);
craftAttributesMargin: margins(22px, 12px, 22px, 16px); craftAttributesMargin: margins(22px, 12px, 22px, 16px);