mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Moved hasUndo and hasRedo from Editor::Paint to Editor::Scene.
This commit is contained in:
parent
fb511c3e03
commit
aef2148ed0
4 changed files with 15 additions and 16 deletions
|
@ -81,8 +81,8 @@ Paint::Paint(
|
|||
(*it)->setVisible(!isUndo);
|
||||
}
|
||||
|
||||
_hasUndo = hasUndo();
|
||||
_hasRedo = hasRedo();
|
||||
_hasUndo = _scene->hasUndo();
|
||||
_hasRedo = _scene->hasRedo();
|
||||
}, lifetime());
|
||||
|
||||
controllers->undoController->setCanPerformChanges(rpl::merge(
|
||||
|
@ -217,16 +217,6 @@ void Paint::keepResult() {
|
|||
}) | ranges::to_vector;
|
||||
}
|
||||
|
||||
bool Paint::hasUndo() const {
|
||||
return ranges::any_of(_scene->items(), &QGraphicsItem::isVisible);
|
||||
}
|
||||
|
||||
bool Paint::hasRedo() const {
|
||||
return ranges::any_of(
|
||||
_scene->items(),
|
||||
[=](const ItemPtr &i) { return isItemHidden(i); });
|
||||
}
|
||||
|
||||
void Paint::clearRedoList() {
|
||||
const auto items = _scene->items(Qt::AscendingOrder);
|
||||
auto &&filtered = ranges::views::all(
|
||||
|
@ -252,8 +242,8 @@ bool Paint::isItemToRemove(const ItemPtr &item) const {
|
|||
}
|
||||
|
||||
void Paint::updateUndoState() {
|
||||
_hasUndo = hasUndo();
|
||||
_hasRedo = hasRedo();
|
||||
_hasUndo = _scene->hasUndo();
|
||||
_hasRedo = _scene->hasRedo();
|
||||
}
|
||||
|
||||
void Paint::applyBrush(const Brush &brush) {
|
||||
|
|
|
@ -49,8 +49,6 @@ private:
|
|||
|
||||
ItemBase::Data itemBaseData() const;
|
||||
|
||||
bool hasUndo() const;
|
||||
bool hasRedo() const;
|
||||
void clearRedoList();
|
||||
|
||||
bool isItemToRemove(const std::shared_ptr<QGraphicsItem> &item) const;
|
||||
|
|
|
@ -163,6 +163,14 @@ void Scene::restoreItemsState(SaveState state) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Scene::hasUndo() const {
|
||||
return ranges::any_of(_items, &NumberedItem::isNormalStatus);
|
||||
}
|
||||
|
||||
bool Scene::hasRedo() const {
|
||||
return ranges::any_of(_items, &NumberedItem::isUndidStatus);
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
// Prevent destroying by scene of all items.
|
||||
QGraphicsScene::removeItem(_canvas.get());
|
||||
|
|
|
@ -49,6 +49,9 @@ public:
|
|||
|
||||
void saveItemsState(SaveState state);
|
||||
void restoreItemsState(SaveState state);
|
||||
|
||||
[[nodiscard]] bool hasUndo() const;
|
||||
[[nodiscard]] bool hasRedo() const;
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
|
Loading…
Add table
Reference in a new issue