File indexing completed on 2024-05-12 05:39:19
0001 #pragma once 0002 0003 #include <QKeyEvent> 0004 #include <QMouseEvent> 0005 #include <QObject> 0006 #include <QQuickItem> 0007 0008 class QQuickView; 0009 0010 class SelectionEditorPrivate; 0011 0012 class SelectionEditor : public QObject 0013 { 0014 Q_OBJECT 0015 0016 Q_PROPERTY(QRect rect READ rect NOTIFY rectChanged FINAL) 0017 Q_PROPERTY(bool isDragging READ isDragging NOTIFY isDraggingChanged FINAL) 0018 0019 public: 0020 explicit SelectionEditor(QObject *parent = nullptr); 0021 ~SelectionEditor() override; 0022 0023 bool isDragging() const; 0024 QRect rect() const; 0025 0026 Q_SCRIPTABLE void dragStart(const QString &screenName, int x, int y); 0027 Q_SCRIPTABLE void setMousePosition(const QString &screenName, int x, int y); 0028 Q_SCRIPTABLE void dragRelease(const QString &screenName, int x, int y); 0029 Q_SCRIPTABLE void dragReset(); 0030 Q_SCRIPTABLE void reject(); 0031 0032 bool exec(); 0033 0034 Q_SIGNALS: 0035 void rectChanged(); 0036 void emptyChanged(); 0037 void isDraggingChanged(); 0038 0039 protected: 0040 bool eventFilter(QObject *watched, QEvent *event) override; 0041 void keyPressEvent(QKeyEvent *event); 0042 0043 void showViews(); 0044 0045 private: 0046 void accept(); 0047 0048 SelectionEditorPrivate *d; 0049 QQmlEngine *m_engine; 0050 QList<QQuickView *> m_views; 0051 QEventLoop m_execLoop; 0052 };