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

source code of qttools/src/designer/src/components/formeditor/default_actionprovider.h