1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt Designer of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef BUTTON_TASKMENU_H
|
---|
43 | #define BUTTON_TASKMENU_H
|
---|
44 |
|
---|
45 | #include <QtGui/QAbstractButton>
|
---|
46 | #include <QtGui/QCommandLinkButton>
|
---|
47 | #include <QtGui/QButtonGroup>
|
---|
48 |
|
---|
49 | #include <qdesigner_taskmenu_p.h>
|
---|
50 | #include <extensionfactory_p.h>
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | class QMenu;
|
---|
55 | class QActionGroup;
|
---|
56 | class QDesignerFormWindowCursorInterface;
|
---|
57 |
|
---|
58 | namespace qdesigner_internal {
|
---|
59 |
|
---|
60 | // ButtonGroupMenu: Mixin menu for the 'select members'/'break group' options of
|
---|
61 | // the task menu of buttons and button group
|
---|
62 | class ButtonGroupMenu : public QObject
|
---|
63 | {
|
---|
64 | Q_OBJECT
|
---|
65 | Q_DISABLE_COPY(ButtonGroupMenu)
|
---|
66 | public:
|
---|
67 | ButtonGroupMenu(QObject *parent = 0);
|
---|
68 |
|
---|
69 | void initialize(QDesignerFormWindowInterface *formWindow,
|
---|
70 | QButtonGroup *buttonGroup = 0,
|
---|
71 | /* Current button for selection in ButtonMode */
|
---|
72 | QAbstractButton *currentButton = 0);
|
---|
73 |
|
---|
74 | QAction *selectGroupAction() const { return m_selectGroupAction; }
|
---|
75 | QAction *breakGroupAction() const { return m_breakGroupAction; }
|
---|
76 |
|
---|
77 | private slots:
|
---|
78 | void selectGroup();
|
---|
79 | void breakGroup();
|
---|
80 |
|
---|
81 | private:
|
---|
82 | QAction *m_selectGroupAction;
|
---|
83 | QAction *m_breakGroupAction;
|
---|
84 |
|
---|
85 | QDesignerFormWindowInterface *m_formWindow;
|
---|
86 | QButtonGroup *m_buttonGroup;
|
---|
87 | QAbstractButton *m_currentButton;
|
---|
88 | };
|
---|
89 |
|
---|
90 | // Task menu extension of a QButtonGroup
|
---|
91 | class ButtonGroupTaskMenu : public QObject, public QDesignerTaskMenuExtension
|
---|
92 | {
|
---|
93 | Q_OBJECT
|
---|
94 | Q_DISABLE_COPY(ButtonGroupTaskMenu)
|
---|
95 | Q_INTERFACES(QDesignerTaskMenuExtension)
|
---|
96 | public:
|
---|
97 | explicit ButtonGroupTaskMenu(QButtonGroup *buttonGroup, QObject *parent = 0);
|
---|
98 |
|
---|
99 | virtual QAction *preferredEditAction() const;
|
---|
100 | virtual QList<QAction*> taskActions() const;
|
---|
101 |
|
---|
102 | private:
|
---|
103 | QButtonGroup *m_buttonGroup;
|
---|
104 | QList<QAction*> m_taskActions;
|
---|
105 | mutable ButtonGroupMenu m_menu;
|
---|
106 | };
|
---|
107 |
|
---|
108 | // Task menu extension of a QAbstractButton
|
---|
109 | class ButtonTaskMenu: public QDesignerTaskMenu
|
---|
110 | {
|
---|
111 | Q_OBJECT
|
---|
112 | Q_DISABLE_COPY(ButtonTaskMenu)
|
---|
113 | public:
|
---|
114 | explicit ButtonTaskMenu(QAbstractButton *button, QObject *parent = 0);
|
---|
115 | virtual ~ButtonTaskMenu();
|
---|
116 |
|
---|
117 | virtual QAction *preferredEditAction() const;
|
---|
118 | virtual QList<QAction*> taskActions() const;
|
---|
119 |
|
---|
120 | QAbstractButton *button() const;
|
---|
121 |
|
---|
122 | protected:
|
---|
123 | void insertAction(int index, QAction *a);
|
---|
124 |
|
---|
125 | private slots:
|
---|
126 | void createGroup();
|
---|
127 | void addToGroup(QAction *a);
|
---|
128 | void removeFromGroup();
|
---|
129 |
|
---|
130 | private:
|
---|
131 | enum SelectionType {
|
---|
132 | OtherSelection,
|
---|
133 | UngroupedButtonSelection,
|
---|
134 | GroupedButtonSelection
|
---|
135 | };
|
---|
136 |
|
---|
137 | SelectionType selectionType(const QDesignerFormWindowCursorInterface *cursor, QButtonGroup ** ptrToGroup = 0) const;
|
---|
138 | bool refreshAssignMenu(const QDesignerFormWindowInterface *fw, int buttonCount, SelectionType st, QButtonGroup *currentGroup);
|
---|
139 | QMenu *createGroupSelectionMenu(const QDesignerFormWindowInterface *fw);
|
---|
140 |
|
---|
141 | QList<QAction*> m_taskActions;
|
---|
142 | mutable ButtonGroupMenu m_groupMenu;
|
---|
143 | QMenu *m_assignGroupSubMenu;
|
---|
144 | QActionGroup *m_assignActionGroup;
|
---|
145 | QAction *m_assignToGroupSubMenuAction;
|
---|
146 | QMenu *m_currentGroupSubMenu;
|
---|
147 | QAction *m_currentGroupSubMenuAction;
|
---|
148 |
|
---|
149 | QAction *m_createGroupAction;
|
---|
150 | QAction *m_preferredEditAction;
|
---|
151 | QAction *m_removeFromGroupAction;
|
---|
152 | };
|
---|
153 |
|
---|
154 | // Task menu extension of a QCommandLinkButton
|
---|
155 | class CommandLinkButtonTaskMenu: public ButtonTaskMenu
|
---|
156 | {
|
---|
157 | Q_OBJECT
|
---|
158 | Q_DISABLE_COPY(CommandLinkButtonTaskMenu)
|
---|
159 | public:
|
---|
160 | explicit CommandLinkButtonTaskMenu(QCommandLinkButton *button, QObject *parent = 0);
|
---|
161 | };
|
---|
162 |
|
---|
163 | typedef ExtensionFactory<QDesignerTaskMenuExtension, QButtonGroup, ButtonGroupTaskMenu> ButtonGroupTaskMenuFactory;
|
---|
164 | typedef ExtensionFactory<QDesignerTaskMenuExtension, QCommandLinkButton, CommandLinkButtonTaskMenu> CommandLinkButtonTaskMenuFactory;
|
---|
165 | typedef ExtensionFactory<QDesignerTaskMenuExtension, QAbstractButton, ButtonTaskMenu> ButtonTaskMenuFactory;
|
---|
166 | } // namespace qdesigner_internal
|
---|
167 |
|
---|
168 | QT_END_NAMESPACE
|
---|
169 |
|
---|
170 | #endif // BUTTON_TASKMENU_H
|
---|