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 DEFAULT_ACTIONPROVIDER_H |
30 | #define DEFAULT_ACTIONPROVIDER_H |
31 | |
32 | #include "formeditor_global.h" |
33 | #include "actionprovider_p.h" |
34 | #include <extensionfactory_p.h> |
35 | |
36 | #include <QtWidgets/qmenu.h> |
37 | #include <QtWidgets/qmenubar.h> |
38 | #include <QtWidgets/qtoolbar.h> |
39 | |
40 | QT_BEGIN_NAMESPACE |
41 | |
42 | namespace qdesigner_internal { |
43 | |
44 | class FormWindow; |
45 | |
46 | class QT_FORMEDITOR_EXPORT ActionProviderBase: public QDesignerActionProviderExtension |
47 | { |
48 | protected: |
49 | explicit ActionProviderBase(QWidget *widget); |
50 | |
51 | public: |
52 | void adjustIndicator(const QPoint &pos) override; |
53 | virtual Qt::Orientation orientation() const = 0; |
54 | |
55 | protected: |
56 | virtual QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const; |
57 | |
58 | private: |
59 | QWidget *m_indicator; |
60 | }; |
61 | |
62 | class QT_FORMEDITOR_EXPORT QToolBarActionProvider: public QObject, public ActionProviderBase |
63 | { |
64 | Q_OBJECT |
65 | Q_INTERFACES(QDesignerActionProviderExtension) |
66 | public: |
67 | explicit QToolBarActionProvider(QToolBar *widget, QObject *parent = nullptr); |
68 | |
69 | QRect actionGeometry(QAction *action) const override; |
70 | QAction *actionAt(const QPoint &pos) const override; |
71 | Qt::Orientation orientation() const override; |
72 | |
73 | protected: |
74 | QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const override; |
75 | |
76 | private: |
77 | QToolBar *m_widget; |
78 | }; |
79 | |
80 | class QT_FORMEDITOR_EXPORT : public QObject, public ActionProviderBase |
81 | { |
82 | Q_OBJECT |
83 | Q_INTERFACES(QDesignerActionProviderExtension) |
84 | public: |
85 | explicit (QMenuBar *widget, QObject *parent = nullptr); |
86 | |
87 | QRect (QAction *action) const override; |
88 | QAction *(const QPoint &pos) const override; |
89 | Qt::Orientation () const override; |
90 | |
91 | private: |
92 | QMenuBar *; |
93 | }; |
94 | |
95 | class QT_FORMEDITOR_EXPORT : public QObject, public ActionProviderBase |
96 | { |
97 | Q_OBJECT |
98 | Q_INTERFACES(QDesignerActionProviderExtension) |
99 | public: |
100 | explicit (QMenu *widget, QObject *parent = nullptr); |
101 | |
102 | QRect (QAction *action) const override; |
103 | QAction *(const QPoint &pos) const override; |
104 | Qt::Orientation () const override; |
105 | |
106 | private: |
107 | QMenu *; |
108 | }; |
109 | |
110 | using QToolBarActionProviderFactory = ExtensionFactory<QDesignerActionProviderExtension, QToolBar, QToolBarActionProvider>; |
111 | using = ExtensionFactory<QDesignerActionProviderExtension, QMenuBar, QMenuBarActionProvider>; |
112 | using = ExtensionFactory<QDesignerActionProviderExtension, QMenu, QMenuActionProvider>; |
113 | |
114 | } // namespace qdesigner_internal |
115 | |
116 | QT_END_NAMESPACE |
117 | |
118 | #endif // DEFAULT_ACTIONPROVIDER_H |
119 | |