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 | // |
30 | // W A R N I N G |
31 | // ------------- |
32 | // |
33 | // This file is not part of the Qt API. It exists for the convenience |
34 | // of Qt Designer. This header |
35 | // file may change from version to version without notice, or even be removed. |
36 | // |
37 | // We mean it. |
38 | // |
39 | |
40 | #ifndef QDESIGNER_TABWIDGET_H |
41 | #define QDESIGNER_TABWIDGET_H |
42 | |
43 | #include "shared_global_p.h" |
44 | #include "qdesigner_propertysheet_p.h" |
45 | #include "qdesigner_utils_p.h" |
46 | |
47 | #include <QtCore/qpointer.h> |
48 | #include <QtGui/qicon.h> |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | class QDesignerFormWindowInterface; |
53 | class QTabWidget; |
54 | class QTabBar; |
55 | class ; |
56 | class QAction; |
57 | |
58 | namespace qdesigner_internal { |
59 | class ; |
60 | } |
61 | |
62 | class QDESIGNER_SHARED_EXPORT QTabWidgetEventFilter : public QObject |
63 | { |
64 | Q_OBJECT |
65 | public: |
66 | explicit QTabWidgetEventFilter(QTabWidget *parent); |
67 | ~QTabWidgetEventFilter(); |
68 | |
69 | // Install helper on QTabWidget |
70 | static void install(QTabWidget *tabWidget); |
71 | static QTabWidgetEventFilter *eventFilterOf(const QTabWidget *tabWidget); |
72 | // Convenience to add a menu on a tackedWidget |
73 | static QMenu *(const QTabWidget *tabWidget, QMenu *); |
74 | |
75 | // Add context menu and return page submenu or 0. |
76 | QMenu *(QMenu *); |
77 | |
78 | bool eventFilter(QObject *o, QEvent *e) override; |
79 | |
80 | QDesignerFormWindowInterface *formWindow() const; |
81 | |
82 | private slots: |
83 | void removeCurrentPage(); |
84 | void addPage(); |
85 | void addPageAfter(); |
86 | |
87 | private: |
88 | int pageFromPosition(const QPoint &pos, QRect &rect) const; |
89 | QTabBar *tabBar() const; |
90 | |
91 | QTabWidget *m_tabWidget; |
92 | mutable QPointer<QTabBar> m_cachedTabBar; |
93 | QPoint m_pressPoint; |
94 | QWidget *m_dropIndicator; |
95 | int m_dragIndex; |
96 | QWidget *m_dragPage; |
97 | QString m_dragLabel; |
98 | QIcon m_dragIcon; |
99 | bool m_mousePressed; |
100 | QAction *m_actionDeletePage; |
101 | QAction *m_actionInsertPage; |
102 | QAction *m_actionInsertPageAfter; |
103 | qdesigner_internal::PromotionTaskMenu* ; |
104 | }; |
105 | |
106 | // PropertySheet to handle the page properties |
107 | class QDESIGNER_SHARED_EXPORT QTabWidgetPropertySheet : public QDesignerPropertySheet { |
108 | public: |
109 | explicit QTabWidgetPropertySheet(QTabWidget *object, QObject *parent = nullptr); |
110 | |
111 | void setProperty(int index, const QVariant &value) override; |
112 | QVariant property(int index) const override; |
113 | bool reset(int index) override; |
114 | bool isEnabled(int index) const override; |
115 | |
116 | // Check whether the property is to be saved. Returns false for the page |
117 | // properties (as the property sheet has no concept of 'stored') |
118 | static bool checkProperty(const QString &propertyName); |
119 | |
120 | private: |
121 | enum TabWidgetProperty { PropertyCurrentTabText, PropertyCurrentTabName, PropertyCurrentTabIcon, |
122 | PropertyCurrentTabToolTip, PropertyCurrentTabWhatsThis, PropertyTabWidgetNone }; |
123 | |
124 | static TabWidgetProperty tabWidgetPropertyFromName(const QString &name); |
125 | QTabWidget *m_tabWidget; |
126 | struct PageData |
127 | { |
128 | qdesigner_internal::PropertySheetStringValue text; |
129 | qdesigner_internal::PropertySheetStringValue tooltip; |
130 | qdesigner_internal::PropertySheetStringValue whatsthis; |
131 | qdesigner_internal::PropertySheetIconValue icon; |
132 | }; |
133 | QMap<QWidget *, PageData> m_pageToData; |
134 | }; |
135 | |
136 | using QTabWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QTabWidget, QTabWidgetPropertySheet>; |
137 | |
138 | QT_END_NAMESPACE |
139 | |
140 | #endif // QDESIGNER_TABWIDGET_H |
141 | |