| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef TABORDEREDITOR_H |
| 5 | #define TABORDEREDITOR_H |
| 6 | |
| 7 | #include "tabordereditor_global.h" |
| 8 | |
| 9 | #include <QtCore/qpointer.h> |
| 10 | #include <QtWidgets/qwidget.h> |
| 11 | #include <QtGui/qregion.h> |
| 12 | #include <QtGui/qfont.h> |
| 13 | #include <QtGui/qfontmetrics.h> |
| 14 | |
| 15 | QT_BEGIN_NAMESPACE |
| 16 | |
| 17 | class QUndoStack; |
| 18 | class QDesignerFormWindowInterface; |
| 19 | |
| 20 | namespace qdesigner_internal { |
| 21 | |
| 22 | class QT_TABORDEREDITOR_EXPORT TabOrderEditor : public QWidget |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | |
| 26 | public: |
| 27 | TabOrderEditor(QDesignerFormWindowInterface *form, QWidget *parent); |
| 28 | |
| 29 | QDesignerFormWindowInterface *formWindow() const; |
| 30 | |
| 31 | public slots: |
| 32 | void setBackground(QWidget *background); |
| 33 | void updateBackground(); |
| 34 | void widgetRemoved(QWidget*); |
| 35 | void initTabOrder(); |
| 36 | |
| 37 | private slots: |
| 38 | void showTabOrderDialog(); |
| 39 | |
| 40 | protected: |
| 41 | void paintEvent(QPaintEvent *e) override; |
| 42 | void mouseMoveEvent(QMouseEvent *e) override; |
| 43 | void mousePressEvent(QMouseEvent *e) override; |
| 44 | void mouseDoubleClickEvent(QMouseEvent *e) override; |
| 45 | void contextMenuEvent(QContextMenuEvent *e) override; |
| 46 | void resizeEvent(QResizeEvent *e) override; |
| 47 | void showEvent(QShowEvent *e) override; |
| 48 | |
| 49 | private: |
| 50 | QRect indicatorRect(int index) const; |
| 51 | int widgetIndexAt(QPoint pos) const; |
| 52 | bool skipWidget(QWidget *w) const; |
| 53 | |
| 54 | QPointer<QDesignerFormWindowInterface> m_form_window; |
| 55 | |
| 56 | QWidgetList m_tab_order_list; |
| 57 | |
| 58 | QWidget *m_bg_widget; |
| 59 | QUndoStack *m_undo_stack; |
| 60 | QRegion m_indicator_region; |
| 61 | |
| 62 | QFontMetrics m_font_metrics; |
| 63 | int m_current_index; |
| 64 | bool m_beginning; |
| 65 | }; |
| 66 | |
| 67 | } // namespace qdesigner_internal |
| 68 | |
| 69 | QT_END_NAMESPACE |
| 70 | |
| 71 | #endif |
| 72 |
