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
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QDESIGNER_MENU_H
16#define QDESIGNER_MENU_H
17
19
20#include <QtWidgets/qmenu.h>
21
22#include <QtGui/qaction.h>
23#include <QtGui/qpixmap.h>
24
25#include <QtCore/qhash.h>
26
28
29class QTimer;
30class QLineEdit;
31
32class QDesignerFormWindowInterface;
34class QDesignerMenu;
35class QDesignerMenuBar;
36class QPainter;
37class QMimeData;
38
39namespace qdesigner_internal {
40 class CreateSubmenuCommand;
41 class ActionInsertionCommand;
43}
44
46{
47 Q_OBJECT
48public:
49 QDesignerMenu(QWidget *parent = nullptr);
50 ~QDesignerMenu() override;
51
52 bool handleEvent(QEvent *event); // for the event filter
53 void deactivateMenu(); // for the event filter
54
55 QDesignerFormWindowInterface *formWindow() const;
56 QDesignerActionProviderExtension *actionProvider();
57
58 QDesignerMenu *parentMenu() const;
59 QDesignerMenuBar *parentMenuBar() const;
60
61 void setVisible(bool visible) override;
62
63 void adjustSpecialActions();
64
65 void createRealMenuAction(QAction *action);
66 void removeRealMenu(QAction *action);
67
68 static void drawSelection(QPainter *p, const QRect &r);
69
70 bool dragging() const;
71
72 void closeMenuChain();
73
74 void moveLeft();
75 void moveRight();
76 void moveUp(bool ctrl);
77 void moveDown(bool ctrl);
78
79 // Helper for MenuTaskMenu extension
80 void deleteAction(QAction *a);
81
82private slots:
83 void slotAddSeparator();
84 void slotRemoveSelectedAction();
85 void slotShowSubMenuNow();
86 void slotDeactivateNow();
87 void slotAdjustSizeNow();
88 void stopInlineEditing();
89
90protected:
91 void actionEvent(QActionEvent *event) override;
92 void dragEnterEvent(QDragEnterEvent *event) override;
93 void dragMoveEvent(QDragMoveEvent *event) override;
94 void dragLeaveEvent(QDragLeaveEvent *event) override;
95 void dropEvent(QDropEvent *event) override;
96 void paintEvent(QPaintEvent *event) override;
97 void keyPressEvent(QKeyEvent *event) override;
98 void keyReleaseEvent(QKeyEvent *event) override;
99 void showEvent(QShowEvent *event) override;
100
101 bool handleMouseDoubleClickEvent(QMouseEvent *event);
102 bool handleMousePressEvent(QMouseEvent *event);
103 bool handleMouseReleaseEvent(QMouseEvent *event);
104 bool handleMouseMoveEvent(QMouseEvent *event);
105 bool handleContextMenuEvent(QContextMenuEvent *event);
106 bool handleKeyPressEvent(QKeyEvent *event);
107
108 void startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers);
109
110 void adjustIndicator(const QPoint &pos);
111 int findAction(const QPoint &pos) const;
112
113 QAction *currentAction() const;
114 int realActionCount() const;
115 enum ActionDragCheck { NoActionDrag, ActionDragOnSubMenu, AcceptActionDrag };
116 ActionDragCheck checkAction(QAction *action) const;
117
118 void showSubMenu(QAction *action);
119
120 enum LeaveEditMode {
121 Default = 0,
122 ForceAccept
123 };
124
125 void enterEditMode();
126 void leaveEditMode(LeaveEditMode mode);
127 void showLineEdit();
128
129 QAction *createAction(const QString &text, bool separator = false);
130 QDesignerMenu *findOrCreateSubMenu(QAction *action);
131
132 QAction *safeActionAt(int index) const;
133 QAction *safeMenuAction(QDesignerMenu *menu) const;
134 bool swap(int a, int b);
135
136 void hideSubMenu();
137 void deleteAction();
138
139 bool canCreateSubMenu(QAction *action) const;
140 QDesignerMenu *findRootMenu() const;
141 QDesignerMenu *findActivatedMenu() const;
142
143 QRect subMenuPixmapRect(QAction *action) const;
144 bool hasSubMenuPixmap(QAction *action) const;
145
146 void selectCurrentAction();
147
148private:
149 bool hideSubMenuOnCursorKey();
150 bool showSubMenuOnCursorKey();
151 const QPixmap m_subMenuPixmap;
152
153 QPoint m_startPosition;
154 int m_currentIndex = 0;
155 QAction *m_addItem;
156 QAction *m_addSeparator;
157 QHash<QAction*, QDesignerMenu*> m_subMenus;
158 QTimer *m_showSubMenuTimer;
159 QTimer *m_deactivateWindowTimer;
160 QTimer *m_adjustSizeTimer;
161 qdesigner_internal::MenuActionLineEdit *m_editor;
162 bool m_dragging = false;
163 int m_lastSubMenuIndex = -1;
164
165 friend class qdesigner_internal::CreateSubmenuCommand;
166 friend class qdesigner_internal::ActionInsertionCommand;
167};
168
169QT_END_NAMESPACE
170
171#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