Commit e422e06f authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Disable updates of the selection projection while deleting shapes while flattening

We use the same paint device for pixel selection and for projection. This
means that when clearing the shapes while flattening, the pixelSelection should
not be cleared.
parent 592038a7
......@@ -291,9 +291,19 @@ bool KisShapeSelection::loadSelection(KoStore* store)
}
void KisShapeSelection::setUpdatesEnabled(bool enabled)
{
m_model->setUpdatesEnabled(enabled);
}
bool KisShapeSelection::updatesEnabled() const
{
return m_model->updatesEnabled();
}
KUndo2Command* KisShapeSelection::resetToEmpty()
{
return new KisTakeAllShapesCommand(this);
return new KisTakeAllShapesCommand(this, true);
}
bool KisShapeSelection::isEmpty() const
......
......@@ -86,6 +86,11 @@ protected:
virtual void paintComponent(QPainter& painter, const KoViewConverter& converter, KoShapePaintingContext &paintcontext);
private:
friend class KisTakeAllShapesCommand;
void setUpdatesEnabled(bool enabled);
bool updatesEnabled() const;
private:
void renderSelection(KisPaintDeviceSP projection, const QRect& r);
......
......@@ -22,9 +22,10 @@
#include "kis_shape_selection.h"
KisTakeAllShapesCommand::KisTakeAllShapesCommand(KisShapeSelection *shapeSelection)
KisTakeAllShapesCommand::KisTakeAllShapesCommand(KisShapeSelection *shapeSelection, bool takeSilently)
: KUndo2Command(i18nc("(qtundo-format)", "Clear Vector Selection")),
m_shapeSelection(shapeSelection)
m_shapeSelection(shapeSelection),
m_takeSilently(takeSilently)
{
}
......@@ -37,19 +38,35 @@ KisTakeAllShapesCommand::~KisTakeAllShapesCommand()
void KisTakeAllShapesCommand::redo()
{
if (m_takeSilently) {
m_shapeSelection->setUpdatesEnabled(false);
}
m_shapes = m_shapeSelection->shapes();
foreach (KoShape *shape, m_shapes) {
m_shapeSelection->removeShape(shape);
}
if (m_takeSilently) {
m_shapeSelection->setUpdatesEnabled(true);
}
}
void KisTakeAllShapesCommand::undo()
{
if (m_takeSilently) {
m_shapeSelection->setUpdatesEnabled(false);
}
foreach (KoShape *shape, m_shapes) {
m_shapeSelection->addShape(shape);
}
m_shapes.clear();
if (m_takeSilently) {
m_shapeSelection->setUpdatesEnabled(true);
}
}
......@@ -33,7 +33,7 @@ class KisShapeSelection;
class KisTakeAllShapesCommand : public KUndo2Command
{
public:
KisTakeAllShapesCommand(KisShapeSelection *shapeSelection);
KisTakeAllShapesCommand(KisShapeSelection *shapeSelection, bool takeSilently);
~KisTakeAllShapesCommand();
void redo();
......@@ -42,6 +42,7 @@ public:
private:
KisShapeSelection *m_shapeSelection;
QList<KoShape*> m_shapes;
bool m_takeSilently;
};
#endif /* __KIS_TAKE_ALL_SHAPES_COMMAND_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment