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 ACTIONEDITOR_H
41#define ACTIONEDITOR_H
42
43#include "shared_global_p.h"
44#include "shared_enums_p.h"
45#include <QtDesigner/abstractactioneditor.h>
46
47#include <QtCore/qpointer.h>
48
49QT_BEGIN_NAMESPACE
50
51class QDesignerPropertyEditorInterface;
52class QDesignerSettingsInterface;
53class QMenu;
54class QActionGroup;
55class QItemSelection;
56class QListWidget;
57class QPushButton;
58class QLineEdit;
59class QToolButton;
60
61namespace qdesigner_internal {
62
63class ActionView;
64class ResourceMimeData;
65
66class QDESIGNER_SHARED_EXPORT ActionEditor: public QDesignerActionEditorInterface
67{
68 Q_OBJECT
69public:
70 explicit ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent = nullptr,
71 Qt::WindowFlags flags = {});
72 ~ActionEditor() override;
73
74 QDesignerFormWindowInterface *formWindow() const;
75 void setFormWindow(QDesignerFormWindowInterface *formWindow) override;
76
77 QDesignerFormEditorInterface *core() const override;
78
79 QAction *actionNew() const;
80 QAction *actionDelete() const;
81
82 QString filter() const;
83
84 void manageAction(QAction *action) override;
85 void unmanageAction(QAction *action) override;
86
87 static ObjectNamingMode objectNamingMode() { return m_objectNamingMode; }
88 static void setObjectNamingMode(ObjectNamingMode n) { m_objectNamingMode = n; }
89
90 static QString actionTextToName(const QString &text,
91 const QString &prefix = QLatin1String("action"));
92
93 // Utility to create a configure button with menu for usage on toolbars
94 static QToolButton *createConfigureMenuButton(const QString &t, QMenu **ptrToMenu);
95
96public slots:
97 void setFilter(const QString &filter);
98 void mainContainerChanged();
99
100private slots:
101 void slotCurrentItemChanged(QAction *item);
102 void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
103 void editAction(QAction *item, int column = -1);
104 void editCurrentAction();
105 void navigateToSlotCurrentAction();
106 void slotActionChanged();
107 void slotNewAction();
108 void slotDelete();
109 void resourceImageDropped(const QString &path, QAction *action);
110 void slotContextMenuRequested(QContextMenuEvent *, QAction *);
111 void slotViewMode(QAction *a);
112 void slotSelectAssociatedWidget(QWidget *w);
113#if QT_CONFIG(clipboard)
114 void slotCopy();
115 void slotCut();
116 void slotPaste();
117#endif
118
119signals:
120 void itemActivated(QAction *item, int column);
121 // Context menu for item or global menu if item == 0.
122 void contextMenuRequested(QMenu *menu, QAction *item);
123
124private:
125 using ActionList = QList<QAction *>;
126 void deleteActions(QDesignerFormWindowInterface *formWindow, const ActionList &);
127#if QT_CONFIG(clipboard)
128 void copyActions(QDesignerFormWindowInterface *formWindow, const ActionList &);
129#endif
130
131 void restoreSettings();
132 void saveSettings();
133
134 void updateViewModeActions();
135
136 static ObjectNamingMode m_objectNamingMode;
137
138 QDesignerFormEditorInterface *m_core;
139 QPointer<QDesignerFormWindowInterface> m_formWindow;
140 QListWidget *m_actionGroups;
141
142 ActionView *m_actionView;
143
144 QAction *m_actionNew;
145 QAction *m_actionEdit;
146 QAction *m_actionNavigateToSlot;
147#if QT_CONFIG(clipboard)
148 QAction *m_actionCopy;
149 QAction *m_actionCut;
150 QAction *m_actionPaste;
151#endif
152 QAction *m_actionSelectAll;
153 QAction *m_actionDelete;
154
155 QActionGroup *m_viewModeGroup;
156 QAction *m_iconViewAction;
157 QAction *m_listViewAction;
158
159 QString m_filter;
160 QWidget *m_filterWidget;
161};
162
163} // namespace qdesigner_internal
164
165QT_END_NAMESPACE
166
167#endif // ACTIONEDITOR_H
168

source code of qttools/src/designer/src/lib/shared/actioneditor_p.h