KQuickImageEditor

resizehandle.h
1/*
2 * SPDX-FileCopyrightText: (C) 2019 Marco Martin <mart@kde.org>
3 * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8#pragma once
9
10#include <QQuickItem>
11
12class ResizeRectangle;
13
14class ResizeHandle : public QQuickItem
15{
17 QML_ELEMENT
18 Q_PROPERTY(bool resizeBlocked READ resizeBlocked NOTIFY resizeBlockedChanged)
19 Q_PROPERTY(QQuickItem *rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged)
20
21public:
22 enum Corner {
23 Left = 0,
24 TopLeft,
25 Top,
26 TopRight,
27 Right,
28 BottomRight,
29 Bottom,
30 BottomLeft,
31 };
32 Q_ENUM(Corner)
33
34 explicit ResizeHandle(QQuickItem *parent = nullptr);
35 ~ResizeHandle() = default;
36
37 QQuickItem *rectangle() const;
38 void setRectangle(QQuickItem *rectangle);
39
40 bool resizeBlocked() const;
41
42 void setResizeCorner(Corner corner);
43
44protected:
45 void mousePressEvent(QMouseEvent *event) override;
46 void mouseReleaseEvent(QMouseEvent *event) override;
47 void mouseMoveEvent(QMouseEvent *event) override;
48
50 void resizeCornerChanged();
51 void resizeBlockedChanged();
52 void rectangleChanged();
53
54private:
55 inline bool resizeLeft() const;
56 inline bool resizeTop() const;
57 inline bool resizeRight() const;
58 inline bool resizeBottom() const;
59 void setResizeBlocked(bool width, bool height);
60
61 QPointF m_mouseDownPosition;
62 QRectF m_mouseDownGeometry;
63
64 Corner m_resizeCorner = Left;
65 bool m_resizeWidthBlocked = false;
66 bool m_resizeHeightBlocked = false;
67 ResizeRectangle *m_rectangle = nullptr;
68};
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
virtual bool event(QEvent *ev) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:59:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.