forked from linuxdeepin/qt5platform-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddesktopinputselectioncontrol.h
116 lines (93 loc) · 3.09 KB
/
ddesktopinputselectioncontrol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-FileCopyrightText: 2020 - 2022 Uniontech Software Technology Co.,Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef DESKTOPINPUTSELECTIONCONTROL_H
#define DESKTOPINPUTSELECTIONCONTROL_H
#include "global.h"
#include <QMap>
#include <QSize>
#include <QPoint>
#include <QObject>
#include <QVector>
#include <QPointer>
#include <QScopedPointer>
QT_BEGIN_NAMESPACE
class QMouseEvent;
class QInputMethod;
QT_END_NAMESPACE
DPP_BEGIN_NAMESPACE
class DInputSelectionHandle;
class DApplicationEventMonitor;
class DSelectedTextTooltip;
class DDesktopInputSelectionControl : public QObject
{
Q_OBJECT
public:
enum HandleState {
HandleIsReleased = 0,
HandleIsHeld = 1,
HandleIsMoving = 2
};
enum HandleType {
AnchorHandle = 0,
CursorHandle = 1
};
DDesktopInputSelectionControl(QObject *parent, QInputMethod *inputMethod);
~DDesktopInputSelectionControl() override;
void createHandles();
void setApplicationEventMonitor(DApplicationEventMonitor *pMonitor);
public Q_SLOTS:
void updateAnchorHandlePosition();
void updateCursorHandlePosition();
void updateTooltipPosition();
void onWindowStateChanged(Qt::WindowState state);
void updateSelectionControlVisible();
void onOptAction(int type);
void onFocusWindowChanged();
signals:
void anchorPositionChanged();
void cursorPositionChanged();
void anchorRectangleChanged();
void cursorRectangleChanged();
void selectionControlVisibleChanged();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
private:
void setHandleState(HandleState state);
int anchorPosition() const;
int cursorPosition() const;
Qt::InputMethodHints inputMethodHints() const;
QRectF anchorRectangle() const;
QRectF cursorRectangle() const;
QRectF keyboardRectangle() const;
bool anchorRectIntersectsClipRect() const;
bool cursorRectIntersectsClipRect() const;
void updateHandleFlags();
void setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos);
QRect anchorHandleRect() const;
QRect cursorHandleRect() const;
QRect handleRectForCursorRect(const QRectF &cursorRect) const;
QRect handleRectForAnchorRect(const QRectF &anchorRect) const;
bool testHandleVisible() const;
private:
QInputMethod *m_pInputMethod;
QScopedPointer<DInputSelectionHandle> m_anchorSelectionHandle;
QScopedPointer<DInputSelectionHandle> m_cursorSelectionHandle;
QScopedPointer<DSelectedTextTooltip> m_selectedTextTooltip;
QPointer<DApplicationEventMonitor> m_pApplicationEventMonitor;
QSize m_handleImageSize;
HandleState m_handleState;
HandleType m_currentDragHandle;
bool m_eventFilterEnabled;
bool m_anchorHandleVisible;
bool m_cursorHandleVisible;
bool m_handleVisible;
QPoint m_otherSelectionPoint;
QVector<QMouseEvent *> m_eventQueue;
QPoint m_distanceBetweenMouseAndCursor;
QPoint m_handleDragStartedPosition;
QSize m_fingerOptSize;
QMap<QObject*, QPointF> m_focusWindow;
};
DPP_END_NAMESPACE
#endif // DESKTOPINPUTSELECTIONCONTROL_H