| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | #ifndef TOOL_WIDGETEDITOR_H |
| 30 | #define TOOL_WIDGETEDITOR_H |
| 31 | |
| 32 | #include <QtDesigner/abstractformwindowtool.h> |
| 33 | |
| 34 | #include <QtGui/qevent.h> |
| 35 | #include <QtCore/qpointer.h> |
| 36 | |
| 37 | QT_BEGIN_NAMESPACE |
| 38 | |
| 39 | class QAction; |
| 40 | class QMainWindow; |
| 41 | |
| 42 | namespace qdesigner_internal { |
| 43 | |
| 44 | class FormWindow; |
| 45 | class QDesignerMimeData; |
| 46 | |
| 47 | class WidgetEditorTool: public QDesignerFormWindowToolInterface |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | public: |
| 51 | explicit WidgetEditorTool(FormWindow *formWindow); |
| 52 | ~WidgetEditorTool() override; |
| 53 | |
| 54 | QDesignerFormEditorInterface *core() const override; |
| 55 | QDesignerFormWindowInterface *formWindow() const override; |
| 56 | QWidget *editor() const override; |
| 57 | QAction *action() const override; |
| 58 | |
| 59 | void activated() override; |
| 60 | void deactivated() override; |
| 61 | |
| 62 | bool handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event) override; |
| 63 | |
| 64 | bool handleContextMenu(QWidget *widget, QWidget *managedWidget, QContextMenuEvent *e); |
| 65 | bool handleMouseButtonDblClickEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); |
| 66 | bool handleMousePressEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); |
| 67 | bool handleMouseMoveEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); |
| 68 | bool handleMouseReleaseEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); |
| 69 | bool handleKeyPressEvent(QWidget *widget, QWidget *managedWidget, QKeyEvent *e); |
| 70 | bool handleKeyReleaseEvent(QWidget *widget, QWidget *managedWidget, QKeyEvent *e); |
| 71 | bool handlePaintEvent(QWidget *widget, QWidget *managedWidget, QPaintEvent *e); |
| 72 | |
| 73 | bool handleDragEnterMoveEvent(QWidget *widget, QWidget *managedWidget, QDragMoveEvent *e, bool isEnter); |
| 74 | bool handleDragLeaveEvent(QWidget *widget, QWidget *managedWidget, QDragLeaveEvent *e); |
| 75 | bool handleDropEvent(QWidget *widget, QWidget *managedWidget, QDropEvent *e); |
| 76 | |
| 77 | private: |
| 78 | bool restoreDropHighlighting(); |
| 79 | void detectDockDrag(const QDesignerMimeData *mimeData); |
| 80 | |
| 81 | FormWindow *m_formWindow; |
| 82 | QAction *m_action; |
| 83 | |
| 84 | bool mainWindowSeparatorEvent(QWidget *widget, QEvent *event); |
| 85 | QPointer<QMainWindow> m_separator_drag_mw; |
| 86 | QPointer<QWidget> m_lastDropTarget; |
| 87 | bool m_specialDockDrag; |
| 88 | }; |
| 89 | |
| 90 | } // namespace qdesigner_internal |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | |
| 94 | #endif // TOOL_WIDGETEDITOR_H |
| 95 | |