KQuickImageEditor

cropcommand.cpp
1 /*
2  * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  */
6 
7 #include "cropcommand.h"
8 
10  : m_cropRect(cropRect)
11 {
12 }
13 
15 {
16  Q_UNUSED(image)
17  return m_image;
18 }
19 
21 {
22  m_image = image;
23  if (m_cropRect.x() < 0) {
24  m_cropRect.setWidth(m_cropRect.width() + m_cropRect.x());
25  m_cropRect.setX(0);
26  }
27  if (m_cropRect.y() < 0) {
28  m_cropRect.setHeight(m_cropRect.height() + m_cropRect.y());
29  m_cropRect.setY(0);
30  }
31  if (m_image.width() < m_cropRect.width() + m_cropRect.x()) {
32  m_cropRect.setWidth(m_image.width() - m_cropRect.x());
33  }
34  if (m_image.height() < m_cropRect.height() + m_cropRect.y()) {
35  m_cropRect.setHeight(m_image.height() - m_cropRect.y());
36  }
37  return m_image.copy(m_cropRect);
38 }
CropCommand(const QRect &cropRect)
Contructor.
Definition: cropcommand.cpp:9
int height() const const
int x() const const
int y() const const
QImage copy(const QRect &rectangle) const const
virtual QImage redo(QImage image) override
Applies the change to the document.
Definition: cropcommand.cpp:20
virtual QImage undo(QImage image) override
Revert a change to the document.
Definition: cropcommand.cpp:14
int width() const const
void setWidth(int width)
int width() const const
void setX(int x)
void setY(int y)
void setHeight(int height)
int height() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 18 2021 23:08:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.