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
button_taskmenu.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#ifndef BUTTON_TASKMENU_H
5#define BUTTON_TASKMENU_H
6
7#include <QtWidgets/qabstractbutton.h>
8#include <QtWidgets/qcommandlinkbutton.h>
9#include <QtWidgets/qbuttongroup.h>
10
11#include <qdesigner_taskmenu_p.h>
12#include <extensionfactory_p.h>
13
15
16class QMenu;
17class QActionGroup;
18class QDesignerFormWindowCursorInterface;
19
20namespace qdesigner_internal {
21
22// ButtonGroupMenu: Mixin menu for the 'select members'/'break group' options of
23// the task menu of buttons and button group
25{
26 Q_OBJECT
27 Q_DISABLE_COPY_MOVE(ButtonGroupMenu)
28public:
29 ButtonGroupMenu(QObject *parent = nullptr);
30
31 void initialize(QDesignerFormWindowInterface *formWindow,
32 QButtonGroup *buttonGroup = nullptr,
33 /* Current button for selection in ButtonMode */
34 QAbstractButton *currentButton = nullptr);
35
36 QAction *selectGroupAction() const { return m_selectGroupAction; }
37 QAction *breakGroupAction() const { return m_breakGroupAction; }
38
39private slots:
40 void selectGroup();
41 void breakGroup();
42
43private:
44 QAction *m_selectGroupAction;
45 QAction *m_breakGroupAction;
46
47 QDesignerFormWindowInterface *m_formWindow = nullptr;
48 QButtonGroup *m_buttonGroup = nullptr;
49 QAbstractButton *m_currentButton = nullptr;
50};
51
52// Task menu extension of a QButtonGroup
54{
55 Q_OBJECT
56 Q_DISABLE_COPY_MOVE(ButtonGroupTaskMenu)
58public:
60
61 QAction *preferredEditAction() const override;
62 QList<QAction*> taskActions() const override;
63
64private:
65 QButtonGroup *m_buttonGroup;
66 QList<QAction*> m_taskActions;
67 mutable ButtonGroupMenu m_menu;
68};
69
70// Task menu extension of a QAbstractButton
72{
73 Q_OBJECT
74 Q_DISABLE_COPY_MOVE(ButtonTaskMenu)
75public:
76 explicit ButtonTaskMenu(QAbstractButton *button, QObject *parent = nullptr);
78
79 QAction *preferredEditAction() const override;
80 QList<QAction*> taskActions() const override;
81
82 QAbstractButton *button() const;
83
84protected:
85 void insertAction(int index, QAction *a);
86
87private slots:
88 void createGroup();
89 void addToGroup(QAction *a);
90 void removeFromGroup();
91
92private:
93 enum SelectionType {
94 OtherSelection,
95 UngroupedButtonSelection,
96 GroupedButtonSelection
97 };
98
99 SelectionType selectionType(const QDesignerFormWindowCursorInterface *cursor, QButtonGroup ** ptrToGroup = nullptr) const;
100 bool refreshAssignMenu(const QDesignerFormWindowInterface *fw, int buttonCount, SelectionType st, QButtonGroup *currentGroup);
101 QMenu *createGroupSelectionMenu(const QDesignerFormWindowInterface *fw);
102
103 QList<QAction*> m_taskActions;
104 mutable ButtonGroupMenu m_groupMenu;
105 QMenu *m_assignGroupSubMenu;
106 QActionGroup *m_assignActionGroup;
107 QAction *m_assignToGroupSubMenuAction;
108 QMenu *m_currentGroupSubMenu;
109 QAction *m_currentGroupSubMenuAction;
110
111 QAction *m_createGroupAction;
112 QAction *m_preferredEditAction;
113 QAction *m_removeFromGroupAction;
114};
115
116// Task menu extension of a QCommandLinkButton
118{
119 Q_OBJECT
120 Q_DISABLE_COPY_MOVE(CommandLinkButtonTaskMenu)
121public:
123};
124
128} // namespace qdesigner_internal
129
130QT_END_NAMESPACE
131
132#endif // BUTTON_TASKMENU_H
void init(const ButtonList &bl, QButtonGroup *group)
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
AddButtonsToGroupCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
BreakButtonGroupCommand(QDesignerFormWindowInterface *formWindow)
ButtonGroupCommand(const QString &description, QDesignerFormWindowInterface *formWindow)
static ButtonGroupList managedButtonGroups(const QDesignerFormWindowInterface *formWindow)
void initialize(const ButtonList &bl, QButtonGroup *buttonGroup)
static QString nameList(const ButtonList &bl)
void initialize(QDesignerFormWindowInterface *formWindow, QButtonGroup *buttonGroup=nullptr, QAbstractButton *currentButton=nullptr)
QAction * preferredEditAction() const override
QList< QAction * > taskActions() const override
QAction * preferredEditAction() const override
void insertAction(int index, QAction *a)
QList< QAction * > taskActions() const override
ButtonTextTaskMenuInlineEditor(QAbstractButton *button, QObject *parent)
void redo() override
Applies a change to the document.
CreateButtonGroupCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
LinkDescriptionTaskMenuInlineEditor(QAbstractButton *button, QObject *parent)
RemoveButtonsFromGroupCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static ButtonList buttonList(const QDesignerFormWindowCursorInterface *cursor)
static QUndoCommand * createRemoveButtonsCommand(QDesignerFormWindowInterface *fw, const ButtonList &bl)