KQuickImageEditor

resizehandle.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2019 Marco Martin <[email protected]>
3  * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <[email protected]>
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7 
8 #pragma once
9 
10 #include <QQuickItem>
11 
12 class ResizeRectangle;
13 
14 class ResizeHandle : public QQuickItem
15 {
16  Q_OBJECT
17  Q_PROPERTY(bool resizeBlocked READ resizeBlocked NOTIFY resizeBlockedChanged)
18  Q_PROPERTY(QQuickItem *rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged)
19 
20 public:
21  enum Corner {
22  Left = 0,
23  TopLeft,
24  Top,
25  TopRight,
26  Right,
28  Bottom,
29  BottomLeft,
30  };
31  Q_ENUM(Corner)
32 
33  ResizeHandle(QQuickItem *parent = nullptr);
34  ~ResizeHandle() = default;
35 
36  QQuickItem *rectangle() const;
37  void setRectangle(QQuickItem *rectangle);
38 
39  bool resizeBlocked() const;
40 
41  void setResizeCorner(Corner corner);
42 
43 protected:
44  void mousePressEvent(QMouseEvent *event) override;
45  void mouseReleaseEvent(QMouseEvent *event) override;
46  void mouseMoveEvent(QMouseEvent *event) override;
47 
48 Q_SIGNALS:
49  void resizeCornerChanged();
50  void resizeBlockedChanged();
51  void rectangleChanged();
52 
53 private:
54  inline bool resizeLeft() const;
55  inline bool resizeTop() const;
56  inline bool resizeRight() const;
57  inline bool resizeBottom() const;
58  void setResizeBlocked(bool width, bool height);
59 
60  QPointF m_mouseDownPosition;
61  QRectF m_mouseDownGeometry;
62 
63  Corner m_resizeCorner = Left;
64  bool m_resizeWidthBlocked = false;
65  bool m_resizeHeightBlocked = false;
66  ResizeRectangle *m_rectangle = nullptr;
67 };
Q_ENUM(...)
Left
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
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.