author | eckhart.koppen@nokia.com |
Wed, 31 Mar 2010 11:06:36 +0300 | |
changeset 7 | f7bc934e204c |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// |
|
43 |
// W A R N I N G |
|
44 |
// ------------- |
|
45 |
// |
|
46 |
// This file is not part of the Qt API. It exists for the convenience |
|
47 |
// of Qt Designer. This header |
|
48 |
// file may change from version to version without notice, or even be removed. |
|
49 |
// |
|
50 |
// We mean it. |
|
51 |
// |
|
52 |
||
53 |
#ifndef QDESIGNER_MENU_H |
|
54 |
#define QDESIGNER_MENU_H |
|
55 |
||
56 |
#include "shared_global_p.h" |
|
57 |
||
58 |
#include <QtGui/QAction> |
|
59 |
#include <QtGui/QMenu> |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
60 |
#include <QtGui/QPixmap> |
0 | 61 |
#include <QtCore/QHash> |
62 |
||
63 |
QT_BEGIN_NAMESPACE |
|
64 |
||
65 |
class QTimer; |
|
66 |
class QLineEdit; |
|
67 |
||
68 |
class QDesignerFormWindowInterface; |
|
69 |
class QDesignerActionProviderExtension; |
|
70 |
class QDesignerMenu; |
|
71 |
class QDesignerMenuBar; |
|
72 |
class QPainter; |
|
73 |
class QMimeData; |
|
74 |
||
75 |
namespace qdesigner_internal { |
|
76 |
class CreateSubmenuCommand; |
|
77 |
class ActionInsertionCommand; |
|
78 |
} |
|
79 |
||
80 |
class QDESIGNER_SHARED_EXPORT QDesignerMenu: public QMenu |
|
81 |
{ |
|
82 |
Q_OBJECT |
|
83 |
public: |
|
84 |
QDesignerMenu(QWidget *parent = 0); |
|
85 |
virtual ~QDesignerMenu(); |
|
86 |
||
87 |
bool eventFilter(QObject *object, QEvent *event); |
|
88 |
||
89 |
QDesignerFormWindowInterface *formWindow() const; |
|
90 |
QDesignerActionProviderExtension *actionProvider(); |
|
91 |
||
92 |
QDesignerMenu *parentMenu() const; |
|
93 |
QDesignerMenuBar *parentMenuBar() const; |
|
94 |
||
95 |
virtual void setVisible(bool visible); |
|
96 |
||
97 |
void adjustSpecialActions(); |
|
98 |
||
99 |
bool interactive(bool i); |
|
100 |
void createRealMenuAction(QAction *action); |
|
101 |
void removeRealMenu(QAction *action); |
|
102 |
||
103 |
static void drawSelection(QPainter *p, const QRect &r); |
|
104 |
||
105 |
bool dragging() const; |
|
106 |
||
107 |
void closeMenuChain(); |
|
108 |
||
109 |
void moveLeft(); |
|
110 |
void moveRight(); |
|
111 |
void moveUp(bool ctrl); |
|
112 |
void moveDown(bool ctrl); |
|
113 |
||
114 |
// Helper for MenuTaskMenu extension |
|
115 |
void deleteAction(QAction *a); |
|
116 |
||
117 |
private slots: |
|
118 |
void slotAddSeparator(); |
|
119 |
void slotRemoveSelectedAction(); |
|
120 |
void slotShowSubMenuNow(); |
|
121 |
void slotDeactivateNow(); |
|
122 |
void slotAdjustSizeNow(); |
|
123 |
||
124 |
protected: |
|
125 |
virtual void actionEvent(QActionEvent *event); |
|
126 |
virtual void dragEnterEvent(QDragEnterEvent *event); |
|
127 |
virtual void dragMoveEvent(QDragMoveEvent *event); |
|
128 |
virtual void dragLeaveEvent(QDragLeaveEvent *event); |
|
129 |
virtual void dropEvent(QDropEvent *event); |
|
130 |
virtual void paintEvent(QPaintEvent *event); |
|
131 |
virtual void keyPressEvent(QKeyEvent *event); |
|
132 |
virtual void keyReleaseEvent(QKeyEvent *event); |
|
133 |
virtual void showEvent(QShowEvent *event); |
|
134 |
||
135 |
bool handleEvent(QWidget *widget, QEvent *event); |
|
136 |
bool handleMouseDoubleClickEvent(QWidget *widget, QMouseEvent *event); |
|
137 |
bool handleMousePressEvent(QWidget *widget, QMouseEvent *event); |
|
138 |
bool handleMouseReleaseEvent(QWidget *widget, QMouseEvent *event); |
|
139 |
bool handleMouseMoveEvent(QWidget *widget, QMouseEvent *event); |
|
140 |
bool handleContextMenuEvent(QWidget *widget, QContextMenuEvent *event); |
|
141 |
bool handleKeyPressEvent(QWidget *widget, QKeyEvent *event); |
|
142 |
||
143 |
void startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers); |
|
144 |
||
145 |
void adjustIndicator(const QPoint &pos); |
|
146 |
int findAction(const QPoint &pos) const; |
|
147 |
||
148 |
QAction *currentAction() const; |
|
149 |
int realActionCount() const; |
|
150 |
enum ActionDragCheck { NoActionDrag, ActionDragOnSubMenu, AcceptActionDrag }; |
|
151 |
ActionDragCheck checkAction(QAction *action) const; |
|
152 |
||
153 |
void showSubMenu(QAction *action); |
|
154 |
||
155 |
enum LeaveEditMode { |
|
156 |
Default = 0, |
|
157 |
ForceAccept |
|
158 |
}; |
|
159 |
||
160 |
void enterEditMode(); |
|
161 |
void leaveEditMode(LeaveEditMode mode); |
|
162 |
void showLineEdit(); |
|
163 |
||
164 |
QAction *createAction(const QString &text, bool separator = false); |
|
165 |
QDesignerMenu *findOrCreateSubMenu(QAction *action); |
|
166 |
||
167 |
QAction *safeActionAt(int index) const; |
|
168 |
QAction *safeMenuAction(QDesignerMenu *menu) const; |
|
169 |
bool swap(int a, int b); |
|
170 |
||
171 |
void hideSubMenu(); |
|
172 |
void deleteAction(); |
|
173 |
void deactivateMenu(); |
|
174 |
||
175 |
bool canCreateSubMenu(QAction *action) const; |
|
176 |
QDesignerMenu *findRootMenu() const; |
|
177 |
QDesignerMenu *findActivatedMenu() const; |
|
178 |
||
179 |
QRect subMenuPixmapRect(QAction *action) const; |
|
180 |
bool hasSubMenuPixmap(QAction *action) const; |
|
181 |
||
182 |
void selectCurrentAction(); |
|
183 |
||
184 |
private: |
|
185 |
bool hideSubMenuOnCursorKey(); |
|
186 |
bool showSubMenuOnCursorKey(); |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
187 |
const QPixmap m_subMenuPixmap; |
0 | 188 |
|
189 |
QPoint m_startPosition; |
|
190 |
int m_currentIndex; |
|
191 |
QAction *m_addItem; |
|
192 |
QAction *m_addSeparator; |
|
193 |
QHash<QAction*, QDesignerMenu*> m_subMenus; |
|
194 |
QTimer *m_showSubMenuTimer; |
|
195 |
QTimer *m_deactivateWindowTimer; |
|
196 |
QTimer *m_adjustSizeTimer; |
|
197 |
bool m_interactive; |
|
198 |
QLineEdit *m_editor; |
|
199 |
bool m_dragging; |
|
200 |
int m_lastSubMenuIndex; |
|
201 |
||
202 |
friend class qdesigner_internal::CreateSubmenuCommand; |
|
203 |
friend class qdesigner_internal::ActionInsertionCommand; |
|
204 |
}; |
|
205 |
||
206 |
QT_END_NAMESPACE |
|
207 |
||
208 |
#endif // QDESIGNER_MENU_H |