15#ifndef QDESIGNER_MENU_H
16#define QDESIGNER_MENU_H
20#include <QtWidgets/qmenu.h>
22#include <QtGui/qaction.h>
23#include <QtGui/qpixmap.h>
25#include <QtCore/qhash.h>
32class QDesignerFormWindowInterface;
35class QDesignerMenuBar;
40 class CreateSubmenuCommand;
41 class ActionInsertionCommand;
48 QDesignerMenu(QWidget *parent =
nullptr);
49 ~QDesignerMenu() override;
51 bool eventFilter(QObject *object, QEvent *event) override;
53 QDesignerFormWindowInterface *formWindow()
const;
54 QDesignerActionProviderExtension *actionProvider();
56 QDesignerMenu *parentMenu()
const;
57 QDesignerMenuBar *parentMenuBar()
const;
59 void setVisible(
bool visible) override;
61 void adjustSpecialActions();
63 void createRealMenuAction(QAction *action);
64 void removeRealMenu(QAction *action);
66 static void drawSelection(QPainter *p,
const QRect &r);
68 bool dragging()
const;
70 void closeMenuChain();
74 void moveUp(
bool ctrl);
75 void moveDown(
bool ctrl);
78 void deleteAction(QAction *a);
81 void slotAddSeparator();
82 void slotRemoveSelectedAction();
83 void slotShowSubMenuNow();
84 void slotDeactivateNow();
85 void slotAdjustSizeNow();
88 void actionEvent(QActionEvent *event) override;
89 void dragEnterEvent(QDragEnterEvent *event) override;
90 void dragMoveEvent(QDragMoveEvent *event) override;
91 void dragLeaveEvent(QDragLeaveEvent *event) override;
92 void dropEvent(QDropEvent *event) override;
93 void paintEvent(QPaintEvent *event) override;
94 void keyPressEvent(QKeyEvent *event) override;
95 void keyReleaseEvent(QKeyEvent *event) override;
96 void showEvent(QShowEvent *event) override;
98 bool handleEvent(QWidget *widget, QEvent *event);
99 bool handleMouseDoubleClickEvent(QWidget *widget, QMouseEvent *event);
100 bool handleMousePressEvent(QWidget *widget, QMouseEvent *event);
101 bool handleMouseReleaseEvent(QWidget *widget, QMouseEvent *event);
102 bool handleMouseMoveEvent(QWidget *widget, QMouseEvent *event);
103 bool handleContextMenuEvent(QWidget *widget, QContextMenuEvent *event);
104 bool handleKeyPressEvent(QWidget *widget, QKeyEvent *event);
106 void startDrag(
const QPoint &pos, Qt::KeyboardModifiers modifiers);
108 void adjustIndicator(
const QPoint &pos);
109 int findAction(
const QPoint &pos)
const;
111 QAction *currentAction()
const;
112 int realActionCount()
const;
113 enum ActionDragCheck { NoActionDrag, ActionDragOnSubMenu, AcceptActionDrag };
114 ActionDragCheck checkAction(QAction *action)
const;
116 void showSubMenu(QAction *action);
123 void enterEditMode();
124 void leaveEditMode(LeaveEditMode mode);
127 QAction *createAction(
const QString &text,
bool separator =
false);
128 QDesignerMenu *findOrCreateSubMenu(QAction *action);
130 QAction *safeActionAt(
int index)
const;
131 QAction *safeMenuAction(QDesignerMenu *menu)
const;
132 bool swap(
int a,
int b);
136 void deactivateMenu();
138 bool canCreateSubMenu(QAction *action)
const;
139 QDesignerMenu *findRootMenu()
const;
140 QDesignerMenu *findActivatedMenu()
const;
142 QRect subMenuPixmapRect(QAction *action)
const;
143 bool hasSubMenuPixmap(QAction *action)
const;
145 void selectCurrentAction();
148 bool hideSubMenuOnCursorKey();
149 bool showSubMenuOnCursorKey();
150 const QPixmap m_subMenuPixmap;
152 QPoint m_startPosition;
153 int m_currentIndex = 0;
155 QAction *m_addSeparator;
156 QHash<QAction*, QDesignerMenu*> m_subMenus;
157 QTimer *m_showSubMenuTimer;
158 QTimer *m_deactivateWindowTimer;
159 QTimer *m_adjustSizeTimer;
161 bool m_dragging =
false;
162 int m_lastSubMenuIndex = -1;
164 friend class qdesigner_internal::CreateSubmenuCommand;
165 friend class qdesigner_internal::ActionInsertionCommand;
virtual bool dynamicPropertiesAllowed() const =0
virtual bool isDynamicProperty(int index) const =0
virtual bool isLanguageResource(const QString &path) const =0
static void markChangedStretchProperties(QDesignerFormEditorInterface *core, QLayout *lt, const DomLayout *domLayout)
static void stretchAttributesToDom(QDesignerFormEditorInterface *core, QLayout *lt, DomLayout *domLayout)
QVariant toNativeValue(const QVariant &value) const override
bool isResourceType(const QVariant &value) const override
QVariant loadResource(const QDir &workingDirectory, const DomProperty *icon) const override
QStringList loadedQrcFiles() const
QStringList usedQrcFiles() const
QDesignerResourceBuilder(QDesignerFormEditorInterface *core, DesignerPixmapCache *pixmapCache, DesignerIconCache *iconCache)
DomProperty * saveResource(const QDir &workingDirectory, const QVariant &value) const override
bool isSaveRelative() const
void setSaveRelative(bool relative)
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
DomUI * readUi(QIODevice *dev)
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
DomResources * saveResources() override
QWidget * create(DomUI *ui, QWidget *parentWidget) override
QWidget * loadUi(DomUI *ui, QWidget *parentWidget)
void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget) override
void setSaveRelative(bool relative)
QDesignerResource(FormWindow *fw)
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
DomTabStops * saveTabStops() override
bool saveRelative() const
bool copy(QIODevice *dev, const FormBuilderClipboard &selection) override
~QDesignerResource() override
QDesignerTextBuilder()=default
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)
#define OLD_RESOURCE_FORMAT
static constexpr auto clipboardObjectName
static constexpr auto currentUiVersion
#define QDESIGNER_SHARED_EXPORT