Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdesigner_menu_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists for the convenience
10// of Qt Designer. This header
11// file may change from version to version without notice, or even be removed.
12//
13// We mean it.
14//
15
16#ifndef QDESIGNER_MENU_H
17#define QDESIGNER_MENU_H
18
20
21#include <QtWidgets/qmenu.h>
22
23#include <QtGui/qaction.h>
24#include <QtGui/qpixmap.h>
25
26#include <QtCore/qhash.h>
27
29
30class QTimer;
31class QLineEdit;
32
33class QDesignerFormWindowInterface;
35class QDesignerMenu;
36class QDesignerMenuBar;
37class QPainter;
38class QMimeData;
39
40namespace qdesigner_internal {
41 class CreateSubmenuCommand;
42 class ActionInsertionCommand;
44}
45
47{
48 Q_OBJECT
49public:
50 QDesignerMenu(QWidget *parent = nullptr);
51 ~QDesignerMenu() override;
52
53 bool handleEvent(QEvent *event); // for the event filter
54 void deactivateMenu(); // for the event filter
55
56 QDesignerFormWindowInterface *formWindow() const;
57 QDesignerActionProviderExtension *actionProvider();
58
59 QDesignerMenu *parentMenu() const;
60 QDesignerMenuBar *parentMenuBar() const;
61
62 void setVisible(bool visible) override;
63
64 void adjustSpecialActions();
65
66 void createRealMenuAction(QAction *action);
67 void removeRealMenu(QAction *action);
68
69 static void drawSelection(QPainter *p, const QRect &r);
70
71 bool dragging() const;
72
73 void closeMenuChain();
74
75 void moveLeft();
76 void moveRight();
77 void moveUp(bool ctrl);
78 void moveDown(bool ctrl);
79
80 // Helper for MenuTaskMenu extension
81 void deleteAction(QAction *a);
82
83private slots:
84 void slotAddSeparator();
85 void slotRemoveSelectedAction();
86 void slotShowSubMenuNow();
87 void slotDeactivateNow();
88 void slotAdjustSizeNow();
89 void stopInlineEditing();
90
91protected:
92 void actionEvent(QActionEvent *event) override;
93 void dragEnterEvent(QDragEnterEvent *event) override;
94 void dragMoveEvent(QDragMoveEvent *event) override;
95 void dragLeaveEvent(QDragLeaveEvent *event) override;
96 void dropEvent(QDropEvent *event) override;
97 void paintEvent(QPaintEvent *event) override;
98 void keyPressEvent(QKeyEvent *event) override;
99 void keyReleaseEvent(QKeyEvent *event) override;
100 void showEvent(QShowEvent *event) override;
101
102 bool handleMouseDoubleClickEvent(QMouseEvent *event);
103 bool handleMousePressEvent(QMouseEvent *event);
104 bool handleMouseReleaseEvent(QMouseEvent *event);
105 bool handleMouseMoveEvent(QMouseEvent *event);
106 bool handleContextMenuEvent(QContextMenuEvent *event);
107 bool handleKeyPressEvent(QKeyEvent *event);
108
109 void startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers);
110
111 void adjustIndicator(const QPoint &pos);
112 int findAction(const QPoint &pos) const;
113
114 QAction *currentAction() const;
115 int realActionCount() const;
116 enum ActionDragCheck { NoActionDrag, ActionDragOnSubMenu, AcceptActionDrag };
117 ActionDragCheck checkAction(QAction *action) const;
118
119 void showSubMenu(QAction *action);
120
121 enum LeaveEditMode {
122 Default = 0,
123 ForceAccept
124 };
125
126 void enterEditMode();
127 void leaveEditMode(LeaveEditMode mode);
128 void showLineEdit();
129
130 QAction *createAction(const QString &text, bool separator = false);
131 QDesignerMenu *findOrCreateSubMenu(QAction *action);
132
133 QAction *safeActionAt(int index) const;
134 QAction *safeMenuAction(QDesignerMenu *menu) const;
135 bool swap(int a, int b);
136
137 void hideSubMenu();
138 void deleteAction();
139
140 bool canCreateSubMenu(QAction *action) const;
141 QDesignerMenu *findRootMenu() const;
142 QDesignerMenu *findActivatedMenu() const;
143
144 QRect subMenuPixmapRect(QAction *action) const;
145 bool hasSubMenuPixmap(QAction *action) const;
146
147 void selectCurrentAction();
148
149private:
150 bool hideSubMenuOnCursorKey();
151 bool showSubMenuOnCursorKey();
152 const QPixmap m_subMenuPixmap;
153
154 QPoint m_startPosition;
155 int m_currentIndex = 0;
156 QAction *m_addItem;
157 QAction *m_addSeparator;
158 QHash<QAction*, QDesignerMenu*> m_subMenus;
159 QTimer *m_showSubMenuTimer;
160 QTimer *m_deactivateWindowTimer;
161 QTimer *m_adjustSizeTimer;
162 qdesigner_internal::MenuActionLineEdit *m_editor;
163 bool m_dragging = false;
164 int m_lastSubMenuIndex = -1;
165
166 friend class qdesigner_internal::CreateSubmenuCommand;
167 friend class qdesigner_internal::ActionInsertionCommand;
168};
169
170QT_END_NAMESPACE
171
172#endif // QDESIGNER_MENU_H
virtual bool isDynamicProperty(int index) const =0
virtual bool isLanguageResource(const QString &path) const =0
friend class QPainter
friend class QWidget
Definition qpainter.h:432
QDesignerFormEditorInterface * core() const override
Returns a pointer to \QD's current QDesignerFormEditorInterface object.
void setLayoutDefault(int margin, int spacing) override
Sets the default margin and spacing for the form's layout.
void layoutDefault(int *margin, int *spacing) override
Fills in the default margin and spacing for the form's default layout in the margin and spacing varia...
QWidget * mainContainer() const override
Returns the main container widget for the form window.
void manageWidget(QWidget *w) override
Instructs the form window to manage the specified widget.
int toolCount() const override
Returns the number of tools available.
QVariant toNativeValue(const QVariant &value) const override
bool isResourceType(const QVariant &value) const override
QVariant loadResource(const QDir &workingDirectory, const DomProperty *icon) const override
QDesignerResourceBuilder(QDesignerFormEditorInterface *core, DesignerPixmapCache *pixmapCache, DesignerIconCache *iconCache)
DomProperty * saveResource(const QDir &workingDirectory, const QVariant &value) const override
void setIconCache(DesignerIconCache *iconCache)
void setPixmapCache(DesignerPixmapCache *pixmapCache)
DomActionGroup * createDom(QActionGroup *actionGroup) override
QWidget * load(QIODevice *dev, QWidget *parentWidget) override
Loads an XML representation of a widget from the given device, and constructs a new widget with the s...
bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout) override
DomLayoutItem * createDom(QLayoutItem *item, DomLayout *ui_layout, DomWidget *ui_parentWidget) override
DomLayout * createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget) override
void applyProperties(QObject *o, const QList< DomProperty * > &properties) override
void createCustomWidgets(DomCustomWidgets *) override
QLayout * create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget) override
void applyTabStops(QWidget *widget, DomTabStops *tabStops) override
DomWidget * saveWidget(QToolBar *toolBar, DomWidget *ui_parentWidget)
DomCustomWidgets * saveCustomWidgets() override
DomWidget * saveWidget(QDesignerDockWidget *dockWidget, DomWidget *ui_parentWidget)
DomUI * copy(const FormBuilderClipboard &selection) override
QAction * create(DomAction *ui_action, QObject *parent) override
QActionGroup * create(DomActionGroup *ui_action_group, QObject *parent) override
DomWidget * saveWidget(QWizardPage *wizardPage, DomWidget *ui_parentWidget)
void saveDom(DomUI *ui, QWidget *widget) override
void createResources(DomResources *) override
void save(QIODevice *dev, QWidget *widget) override
Saves an XML representation of the given widget to the specified device in the standard UI file forma...
QLayoutItem * create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget) override
QWidget * create(DomUI *ui, QWidget *parentWidget) override
QWidget * loadUi(DomUI *ui, QWidget *parentWidget)
void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) override
DomWidget * createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive=true) override
DomWidget * saveWidget(QTabWidget *widget, DomWidget *ui_parentWidget)
DomWidget * saveWidget(QToolBox *widget, DomWidget *ui_parentWidget)
FormBuilderClipboard paste(DomUI *ui, QWidget *widgetParent, QObject *actionParent=nullptr) override
DomWidget * saveWidget(QWidget *widget, QDesignerContainerExtension *container, DomWidget *ui_parentWidget)
bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) override
void layoutInfo(DomLayout *layout, QObject *parent, int *margin, int *spacing) override
FormBuilderClipboard paste(QIODevice *dev, QWidget *widgetParent, QObject *actionParent=nullptr) override
QList< DomProperty * > computeProperties(QObject *obj) override
DomWidget * saveWidget(QStackedWidget *widget, DomWidget *ui_parentWidget)
QWidget * create(DomWidget *ui_widget, QWidget *parentWidget) override
bool copy(QIODevice *dev, const FormBuilderClipboard &selection) override
QVariant toNativeValue(const QVariant &value) const override
DomProperty * saveText(const QVariant &value) const override
QVariant loadText(const DomProperty *icon) const override
static bool checkProperty(const QString &propertyName)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QString messageBoxTitle()
static void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory, QString path, PropertySheetIconValue &icon, const QDesignerLanguageExtension *lang=nullptr)
static DomProperty * stringToDomProperty(const QString &value, const PropertySheetTranslatableData &translatableData)
QString msgUnmanagedPage(QDesignerFormEditorInterface *core, QWidget *container, int index, QWidget *page)
static DomProperty * stringToDomProperty(const QString &value)
void translationParametersToDom(const PropertySheetTranslatableData &data, DomElement *e)
static bool supportsQualifiedEnums(const QVersionNumber &qtVersion)
static bool hasSetter(QDesignerFormEditorInterface *core, QObject *object, const QString &propertyName)
static bool isDeprecatedQt5Property(const QObject *o, const DomProperty *p)
static bool readDomEnumerationValue(const DomProperty *p, const QDesignerPropertySheetExtension *sheet, int index, QVariant &v)
static bool checkContainerProperty(const QWidget *w, const QString &propertyName)
void translationParametersFromDom(const DomElement *e, PropertySheetTranslatableData *data)
static bool supportsSeparateSizeConstraints(const QVersionNumber &qtVersion)
#define OLD_RESOURCE_FORMAT
static constexpr auto clipboardObjectName
QFormBuilderExtra QFBE
static constexpr auto currentUiVersion
#define QDESIGNER_SHARED_EXPORT