File indexing completed on 2025-01-26 04:04:54

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2007 Peter Simonsson <peter.simonsson@gmail.com>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "KoShapeKeepAspectRatioCommand.h"
0008 
0009 #include <klocalizedstring.h>
0010 
0011 #include <KoShape.h>
0012 
0013 KoShapeKeepAspectRatioCommand::KoShapeKeepAspectRatioCommand(const QList<KoShape *> &shapes, bool newKeepAspectRatio, KUndo2Command *parent)
0014     : KUndo2Command(kundo2_i18n("Keep Aspect Ratio"), parent)
0015     , m_shapes(shapes)
0016 {
0017     Q_FOREACH (KoShape *shape, shapes) {
0018             m_oldKeepAspectRatio << shape->keepAspectRatio();
0019             m_newKeepAspectRatio << newKeepAspectRatio;
0020     }
0021 }
0022 
0023 KoShapeKeepAspectRatioCommand::~KoShapeKeepAspectRatioCommand()
0024 {
0025 }
0026 
0027 void KoShapeKeepAspectRatioCommand::redo()
0028 {
0029     KUndo2Command::redo();
0030     for (int i = 0; i < m_shapes.count(); ++i) {
0031         m_shapes[i]->setKeepAspectRatio(m_newKeepAspectRatio[i]);
0032     }
0033 }
0034 
0035 void KoShapeKeepAspectRatioCommand::undo()
0036 {
0037     KUndo2Command::undo();
0038     for (int i = 0; i < m_shapes.count(); ++i) {
0039         m_shapes[i]->setKeepAspectRatio(m_oldKeepAspectRatio[i]);
0040     }
0041 }