File indexing completed on 2024-12-22 04:40:11
0001 /* 0002 SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic <max@smoothware.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef RICHLINEEDIT_H 0008 #define RICHLINEEDIT_H 0009 0010 #include "gui/treeview/richdocumentptr.h" 0011 0012 #include <QBasicTimer> 0013 #include <QStyleOptionViewItem> 0014 #include <QWidget> 0015 #include <QVector> 0016 0017 QT_FORWARD_DECLARE_CLASS(QAction) 0018 QT_FORWARD_DECLARE_CLASS(QEvent) 0019 QT_FORWARD_DECLARE_CLASS(QKeyEvent) 0020 0021 namespace SubtitleComposer { 0022 class RichDocumentEditor; 0023 0024 class RichLineEdit : public QWidget 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 RichLineEdit(const QStyleOptionViewItem &styleOption, QWidget *parent = nullptr); 0030 virtual ~RichLineEdit(); 0031 0032 void setDocument(RichDocument *document); 0033 inline RichDocument *document() const { return RichDocumentPtr(m_document); } 0034 0035 protected: 0036 bool event(QEvent *e) override; 0037 void mousePressEvent(QMouseEvent *e) override; 0038 void mouseMoveEvent(QMouseEvent *e) override; 0039 void mouseReleaseEvent(QMouseEvent *e) override; 0040 void mouseDoubleClickEvent(QMouseEvent *e) override; 0041 void keyPressEvent(QKeyEvent *e) override; 0042 void inputMethodEvent(QInputMethodEvent *e) override; 0043 QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; 0044 void focusInEvent(QFocusEvent *e) override; 0045 void focusOutEvent(QFocusEvent *e) override; 0046 void changeEvent(QEvent *e) override; 0047 void paintEvent(QPaintEvent *e) override; 0048 #if QT_CONFIG(draganddrop) 0049 void dragEnterEvent(QDragEnterEvent *) override; 0050 void dragMoveEvent(QDragMoveEvent *e) override; 0051 void dragLeaveEvent(QDragLeaveEvent *e) override; 0052 void dropEvent(QDropEvent *) override; 0053 #endif 0054 0055 bool sendMouseEventToInputContext(QMouseEvent *e); 0056 void setupActions(); 0057 void changeTextColor(); 0058 0059 protected: 0060 QVector<QAction *> m_actions; 0061 RichDocument *m_document = nullptr; 0062 QStyleOptionViewItem m_lineStyle; 0063 RichDocumentEditor *m_control = nullptr; 0064 QPoint m_mousePressPos; 0065 int m_mouseYThreshold; 0066 QBasicTimer m_dndTimer; 0067 int m_dndCursor = -1; 0068 QBasicTimer m_tripleClickTimer; 0069 QPoint m_tripleClickPos; 0070 }; 0071 0072 } 0073 0074 #endif // RICHLINEEDIT_H