2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Fixed updating of undo state on deleting item in photo editor.

This commit is contained in:
23rd
2021-07-04 17:22:57 +03:00
parent b1477260f0
commit 953fa52490
3 changed files with 13 additions and 1 deletions

View File

@@ -138,6 +138,12 @@ Paint::Paint(
clearRedoList();
updateUndoState();
}, lifetime());
_scene->removesItem(
) | rpl::start_with_next([=] {
updateUndoState();
}, lifetime());
}
void Paint::applyTransform(QRect geometry, int angle, bool flipped) {

View File

@@ -67,6 +67,7 @@ void Scene::removeItem(not_null<QGraphicsItem*> item) {
void Scene::removeItem(const ItemPtr &item) {
_items.erase(ranges::remove(_items, item), end(_items));
_removesItem.fire({});
}
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
@@ -101,6 +102,10 @@ rpl::producer<> Scene::addsItem() const {
return _addsItem.events();
}
rpl::producer<> Scene::removesItem() const {
return _removesItem.events();
}
std::vector<ItemPtr> Scene::items(
Qt::SortOrder order) const {
auto copyItems = _items;

View File

@@ -36,6 +36,7 @@ public:
void removeItem(not_null<QGraphicsItem*> item);
void removeItem(const ItemPtr &item);
[[nodiscard]] rpl::producer<> addsItem() const;
[[nodiscard]] rpl::producer<> removesItem() const;
[[nodiscard]] std::vector<MTPInputDocument> attachedStickers() const;
@@ -52,7 +53,7 @@ private:
float64 _lastLineZ = 0.;
int _itemNumber = 0;
rpl::event_stream<> _addsItem;
rpl::event_stream<> _addsItem, _removesItem;
rpl::lifetime _lifetime;
};