Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qaction.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
29 | ** | - | ||||||||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
31 | ** | - | ||||||||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | #include "qaction.h" | - | ||||||||||||||||||||||||
35 | #include "qactiongroup.h" | - | ||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
38 | #include "qaction_p.h" | - | ||||||||||||||||||||||||
39 | #include "qapplication.h" | - | ||||||||||||||||||||||||
40 | #include "qevent.h" | - | ||||||||||||||||||||||||
41 | #include "qlist.h" | - | ||||||||||||||||||||||||
42 | #include <private/qshortcutmap_p.h> | - | ||||||||||||||||||||||||
43 | #include <private/qapplication_p.h> | - | ||||||||||||||||||||||||
44 | #include <private/qmenu_p.h> | - | ||||||||||||||||||||||||
45 | #include <private/qdebug_p.h> | - | ||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||
47 | #define QAPP_CHECK(functionName) \ | - | ||||||||||||||||||||||||
48 | if (!qApp) { \ | - | ||||||||||||||||||||||||
49 | qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ | - | ||||||||||||||||||||||||
50 | return; \ | - | ||||||||||||||||||||||||
51 | } | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | /* | - | ||||||||||||||||||||||||
56 | internal: guesses a descriptive text from a text suited for a menu entry | - | ||||||||||||||||||||||||
57 | */ | - | ||||||||||||||||||||||||
58 | static QString qt_strippedText(QString s) | - | ||||||||||||||||||||||||
59 | { | - | ||||||||||||||||||||||||
60 | s.remove( QString::fromLatin1("...") ); | - | ||||||||||||||||||||||||
61 | for (int i = 0; i < s.size(); ++i) {
| 0 | ||||||||||||||||||||||||
62 | if (s.at(i) == QLatin1Char('&'))
| 0 | ||||||||||||||||||||||||
63 | s.remove(i, 1); never executed: s.remove(i, 1); | 0 | ||||||||||||||||||||||||
64 | } never executed: end of block | 0 | ||||||||||||||||||||||||
65 | return s.trimmed(); never executed: return s.trimmed(); | 0 | ||||||||||||||||||||||||
66 | } | - | ||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), | - | ||||||||||||||||||||||||
70 | visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), | - | ||||||||||||||||||||||||
71 | iconVisibleInMenu(-1), | - | ||||||||||||||||||||||||
72 | menuRole(QAction::TextHeuristicRole), | - | ||||||||||||||||||||||||
73 | priority(QAction::NormalPriority) | - | ||||||||||||||||||||||||
74 | { | - | ||||||||||||||||||||||||
75 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
76 | shortcutId = 0; | - | ||||||||||||||||||||||||
77 | shortcutContext = Qt::WindowShortcut; | - | ||||||||||||||||||||||||
78 | autorepeat = true; | - | ||||||||||||||||||||||||
79 | #endif | - | ||||||||||||||||||||||||
80 | } never executed: end of block | 0 | ||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | QActionPrivate::~QActionPrivate() | - | ||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||
84 | } | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) | - | ||||||||||||||||||||||||
87 | { | - | ||||||||||||||||||||||||
88 | #ifdef QT_NO_STATUSTIP | - | ||||||||||||||||||||||||
89 | Q_UNUSED(widget); | - | ||||||||||||||||||||||||
90 | Q_UNUSED(str); | - | ||||||||||||||||||||||||
91 | #else | - | ||||||||||||||||||||||||
92 | if(QObject *object = widget ? widget : parent) {
| 0 | ||||||||||||||||||||||||
93 | QStatusTipEvent tip(str); | - | ||||||||||||||||||||||||
94 | QApplication::sendEvent(object, &tip); | - | ||||||||||||||||||||||||
95 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
96 | } | - | ||||||||||||||||||||||||
97 | #endif | - | ||||||||||||||||||||||||
98 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
99 | } | - | ||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | void QActionPrivate::sendDataChanged() | - | ||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||
103 | Q_Q(QAction); | - | ||||||||||||||||||||||||
104 | QActionEvent e(QEvent::ActionChanged, q); | - | ||||||||||||||||||||||||
105 | for (int i = 0; i < widgets.size(); ++i) {
| 0 | ||||||||||||||||||||||||
106 | QWidget *w = widgets.at(i); | - | ||||||||||||||||||||||||
107 | QApplication::sendEvent(w, &e); | - | ||||||||||||||||||||||||
108 | } never executed: end of block | 0 | ||||||||||||||||||||||||
109 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||
110 | for (int i = 0; i < graphicsWidgets.size(); ++i) {
| 0 | ||||||||||||||||||||||||
111 | QGraphicsWidget *w = graphicsWidgets.at(i); | - | ||||||||||||||||||||||||
112 | QApplication::sendEvent(w, &e); | - | ||||||||||||||||||||||||
113 | } never executed: end of block | 0 | ||||||||||||||||||||||||
114 | #endif | - | ||||||||||||||||||||||||
115 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | emit q->changed(); | - | ||||||||||||||||||||||||
118 | } never executed: end of block | 0 | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
121 | void QActionPrivate::redoGrab(QShortcutMap &map) | - | ||||||||||||||||||||||||
122 | { | - | ||||||||||||||||||||||||
123 | Q_Q(QAction); | - | ||||||||||||||||||||||||
124 | if (shortcutId)
| 0 | ||||||||||||||||||||||||
125 | map.removeShortcut(shortcutId, q); never executed: map.removeShortcut(shortcutId, q); | 0 | ||||||||||||||||||||||||
126 | if (shortcut.isEmpty())
| 0 | ||||||||||||||||||||||||
127 | return; never executed: return; | 0 | ||||||||||||||||||||||||
128 | shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher); | - | ||||||||||||||||||||||||
129 | if (!enabled)
| 0 | ||||||||||||||||||||||||
130 | map.setShortcutEnabled(false, shortcutId, q); never executed: map.setShortcutEnabled(false, shortcutId, q); | 0 | ||||||||||||||||||||||||
131 | if (!autorepeat)
| 0 | ||||||||||||||||||||||||
132 | map.setShortcutAutoRepeat(false, shortcutId, q); never executed: map.setShortcutAutoRepeat(false, shortcutId, q); | 0 | ||||||||||||||||||||||||
133 | } never executed: end of block | 0 | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | void QActionPrivate::redoGrabAlternate(QShortcutMap &map) | - | ||||||||||||||||||||||||
136 | { | - | ||||||||||||||||||||||||
137 | Q_Q(QAction); | - | ||||||||||||||||||||||||
138 | for(int i = 0; i < alternateShortcutIds.count(); ++i) {
| 0 | ||||||||||||||||||||||||
139 | if (const int id = alternateShortcutIds.at(i))
| 0 | ||||||||||||||||||||||||
140 | map.removeShortcut(id, q); never executed: map.removeShortcut(id, q); | 0 | ||||||||||||||||||||||||
141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
142 | alternateShortcutIds.clear(); | - | ||||||||||||||||||||||||
143 | if (alternateShortcuts.isEmpty())
| 0 | ||||||||||||||||||||||||
144 | return; never executed: return; | 0 | ||||||||||||||||||||||||
145 | for(int i = 0; i < alternateShortcuts.count(); ++i) {
| 0 | ||||||||||||||||||||||||
146 | const QKeySequence& alternate = alternateShortcuts.at(i); | - | ||||||||||||||||||||||||
147 | if (!alternate.isEmpty())
| 0 | ||||||||||||||||||||||||
148 | alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); never executed: alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher)); | 0 | ||||||||||||||||||||||||
149 | else | - | ||||||||||||||||||||||||
150 | alternateShortcutIds.append(0); never executed: alternateShortcutIds.append(0); | 0 | ||||||||||||||||||||||||
151 | } | - | ||||||||||||||||||||||||
152 | if (!enabled) {
| 0 | ||||||||||||||||||||||||
153 | for(int i = 0; i < alternateShortcutIds.count(); ++i) {
| 0 | ||||||||||||||||||||||||
154 | const int id = alternateShortcutIds.at(i); | - | ||||||||||||||||||||||||
155 | map.setShortcutEnabled(false, id, q); | - | ||||||||||||||||||||||||
156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
158 | if (!autorepeat) {
| 0 | ||||||||||||||||||||||||
159 | for(int i = 0; i < alternateShortcutIds.count(); ++i) {
| 0 | ||||||||||||||||||||||||
160 | const int id = alternateShortcutIds.at(i); | - | ||||||||||||||||||||||||
161 | map.setShortcutAutoRepeat(false, id, q); | - | ||||||||||||||||||||||||
162 | } never executed: end of block | 0 | ||||||||||||||||||||||||
163 | } never executed: end of block | 0 | ||||||||||||||||||||||||
164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) | - | ||||||||||||||||||||||||
167 | { | - | ||||||||||||||||||||||||
168 | Q_Q(QAction); | - | ||||||||||||||||||||||||
169 | if (shortcutId)
| 0 | ||||||||||||||||||||||||
170 | map.setShortcutEnabled(enable, shortcutId, q); never executed: map.setShortcutEnabled(enable, shortcutId, q); | 0 | ||||||||||||||||||||||||
171 | for(int i = 0; i < alternateShortcutIds.count(); ++i) {
| 0 | ||||||||||||||||||||||||
172 | if (const int id = alternateShortcutIds.at(i))
| 0 | ||||||||||||||||||||||||
173 | map.setShortcutEnabled(enable, id, q); never executed: map.setShortcutEnabled(enable, id, q); | 0 | ||||||||||||||||||||||||
174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
175 | } never executed: end of block | 0 | ||||||||||||||||||||||||
176 | #endif // QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | /*! | - | ||||||||||||||||||||||||
180 | \class QAction | - | ||||||||||||||||||||||||
181 | \brief The QAction class provides an abstract user interface | - | ||||||||||||||||||||||||
182 | action that can be inserted into widgets. | - | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | \ingroup mainwindow-classes | - | ||||||||||||||||||||||||
185 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||
187 | \omit | - | ||||||||||||||||||||||||
188 | * parent and widget are different | - | ||||||||||||||||||||||||
189 | * parent does not define context | - | ||||||||||||||||||||||||
190 | \endomit | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | In applications many common commands can be invoked via menus, | - | ||||||||||||||||||||||||
193 | toolbar buttons, and keyboard shortcuts. Since the user expects | - | ||||||||||||||||||||||||
194 | each command to be performed in the same way, regardless of the | - | ||||||||||||||||||||||||
195 | user interface used, it is useful to represent each command as | - | ||||||||||||||||||||||||
196 | an \e action. | - | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | Actions can be added to menus and toolbars, and will | - | ||||||||||||||||||||||||
199 | automatically keep them in sync. For example, in a word processor, | - | ||||||||||||||||||||||||
200 | if the user presses a Bold toolbar button, the Bold menu item | - | ||||||||||||||||||||||||
201 | will automatically be checked. | - | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | Actions can be created as independent objects, but they may | - | ||||||||||||||||||||||||
204 | also be created during the construction of menus; the QMenu class | - | ||||||||||||||||||||||||
205 | contains convenience functions for creating actions suitable for | - | ||||||||||||||||||||||||
206 | use as menu items. | - | ||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||
208 | A QAction may contain an icon, menu text, a shortcut, status text, | - | ||||||||||||||||||||||||
209 | "What's This?" text, and a tooltip. Most of these can be set in | - | ||||||||||||||||||||||||
210 | the constructor. They can also be set independently with | - | ||||||||||||||||||||||||
211 | setIcon(), setText(), setIconText(), setShortcut(), | - | ||||||||||||||||||||||||
212 | setStatusTip(), setWhatsThis(), and setToolTip(). For menu items, | - | ||||||||||||||||||||||||
213 | it is possible to set an individual font with setFont(). | - | ||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | Actions are added to widgets using QWidget::addAction() or | - | ||||||||||||||||||||||||
216 | QGraphicsWidget::addAction(). Note that an action must be added to a | - | ||||||||||||||||||||||||
217 | widget before it can be used; this is also true when the shortcut should | - | ||||||||||||||||||||||||
218 | be global (i.e., Qt::ApplicationShortcut as Qt::ShortcutContext). | - | ||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | Once a QAction has been created it should be added to the relevant | - | ||||||||||||||||||||||||
221 | menu and toolbar, then connected to the slot which will perform | - | ||||||||||||||||||||||||
222 | the action. For example: | - | ||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | \snippet mainwindows/application/mainwindow.cpp 19 | - | ||||||||||||||||||||||||
225 | \codeline | - | ||||||||||||||||||||||||
226 | \code | - | ||||||||||||||||||||||||
227 | fileMenu->addAction(openAct); | - | ||||||||||||||||||||||||
228 | \endcode | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | We recommend that actions are created as children of the window | - | ||||||||||||||||||||||||
231 | they are used in. In most cases actions will be children of | - | ||||||||||||||||||||||||
232 | the application's main window. | - | ||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | \sa QMenu, QToolBar, {Application Example} | - | ||||||||||||||||||||||||
235 | */ | - | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | /*! | - | ||||||||||||||||||||||||
238 | \fn void QAction::trigger() | - | ||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||
240 | This is a convenience slot that calls activate(Trigger). | - | ||||||||||||||||||||||||
241 | */ | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | /*! | - | ||||||||||||||||||||||||
244 | \fn void QAction::hover() | - | ||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | This is a convenience slot that calls activate(Hover). | - | ||||||||||||||||||||||||
247 | */ | - | ||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | /*! | - | ||||||||||||||||||||||||
250 | \enum QAction::MenuRole | - | ||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | This enum describes how an action should be moved into the application menu on \macos. | - | ||||||||||||||||||||||||
253 | - | |||||||||||||||||||||||||
254 | \value NoRole This action should not be put into the application menu | - | ||||||||||||||||||||||||
255 | \value TextHeuristicRole This action should be put in the application menu based on the action's text | - | ||||||||||||||||||||||||
256 | as described in the QMenuBar documentation. | - | ||||||||||||||||||||||||
257 | \value ApplicationSpecificRole This action should be put in the application menu with an application specific role | - | ||||||||||||||||||||||||
258 | \value AboutQtRole This action handles the "About Qt" menu item. | - | ||||||||||||||||||||||||
259 | \value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of | - | ||||||||||||||||||||||||
260 | the menu item will be set to "About <application name>". The application name is fetched from the | - | ||||||||||||||||||||||||
261 | \c{Info.plist} file in the application's bundle (See \l{Qt for macOS - Deployment}). | - | ||||||||||||||||||||||||
262 | \value PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. | - | ||||||||||||||||||||||||
263 | \value QuitRole This action should be placed where the Quit menu item is in the application menu. | - | ||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||
265 | Setting this value only has effect on items that are in the immediate menus | - | ||||||||||||||||||||||||
266 | of the menubar, not the submenus of those menus. For example, if you have | - | ||||||||||||||||||||||||
267 | File menu in your menubar and the File menu has a submenu, setting the | - | ||||||||||||||||||||||||
268 | MenuRole for the actions in that submenu have no effect. They will never be moved. | - | ||||||||||||||||||||||||
269 | */ | - | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | /*! | - | ||||||||||||||||||||||||
272 | Constructs an action with \a parent. If \a parent is an action | - | ||||||||||||||||||||||||
273 | group the action will be automatically inserted into the group. | - | ||||||||||||||||||||||||
274 | */ | - | ||||||||||||||||||||||||
275 | QAction::QAction(QObject* parent) | - | ||||||||||||||||||||||||
276 | : QObject(*(new QActionPrivate), parent) | - | ||||||||||||||||||||||||
277 | { | - | ||||||||||||||||||||||||
278 | Q_D(QAction); | - | ||||||||||||||||||||||||
279 | d->group = qobject_cast<QActionGroup *>(parent); | - | ||||||||||||||||||||||||
280 | if (d->group)
| 0 | ||||||||||||||||||||||||
281 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 | ||||||||||||||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | /*! | - | ||||||||||||||||||||||||
286 | Constructs an action with some \a text and \a parent. If \a | - | ||||||||||||||||||||||||
287 | parent is an action group the action will be automatically | - | ||||||||||||||||||||||||
288 | inserted into the group. | - | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | The action uses a stripped version of \a text (e.g. "\&Menu | - | ||||||||||||||||||||||||
291 | Option..." becomes "Menu Option") as descriptive text for | - | ||||||||||||||||||||||||
292 | tool buttons. You can override this by setting a specific | - | ||||||||||||||||||||||||
293 | description with setText(). The same text will be used for | - | ||||||||||||||||||||||||
294 | tooltips unless you specify a different text using | - | ||||||||||||||||||||||||
295 | setToolTip(). | - | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | */ | - | ||||||||||||||||||||||||
298 | QAction::QAction(const QString &text, QObject* parent) | - | ||||||||||||||||||||||||
299 | : QObject(*(new QActionPrivate), parent) | - | ||||||||||||||||||||||||
300 | { | - | ||||||||||||||||||||||||
301 | Q_D(QAction); | - | ||||||||||||||||||||||||
302 | d->text = text; | - | ||||||||||||||||||||||||
303 | d->group = qobject_cast<QActionGroup *>(parent); | - | ||||||||||||||||||||||||
304 | if (d->group)
| 0 | ||||||||||||||||||||||||
305 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 | ||||||||||||||||||||||||
306 | } never executed: end of block | 0 | ||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | /*! | - | ||||||||||||||||||||||||
309 | Constructs an action with an \a icon and some \a text and \a | - | ||||||||||||||||||||||||
310 | parent. If \a parent is an action group the action will be | - | ||||||||||||||||||||||||
311 | automatically inserted into the group. | - | ||||||||||||||||||||||||
312 | - | |||||||||||||||||||||||||
313 | The action uses a stripped version of \a text (e.g. "\&Menu | - | ||||||||||||||||||||||||
314 | Option..." becomes "Menu Option") as descriptive text for | - | ||||||||||||||||||||||||
315 | tool buttons. You can override this by setting a specific | - | ||||||||||||||||||||||||
316 | description with setText(). The same text will be used for | - | ||||||||||||||||||||||||
317 | tooltips unless you specify a different text using | - | ||||||||||||||||||||||||
318 | setToolTip(). | - | ||||||||||||||||||||||||
319 | */ | - | ||||||||||||||||||||||||
320 | QAction::QAction(const QIcon &icon, const QString &text, QObject* parent) | - | ||||||||||||||||||||||||
321 | : QObject(*(new QActionPrivate), parent) | - | ||||||||||||||||||||||||
322 | { | - | ||||||||||||||||||||||||
323 | Q_D(QAction); | - | ||||||||||||||||||||||||
324 | d->icon = icon; | - | ||||||||||||||||||||||||
325 | d->text = text; | - | ||||||||||||||||||||||||
326 | d->group = qobject_cast<QActionGroup *>(parent); | - | ||||||||||||||||||||||||
327 | if (d->group)
| 0 | ||||||||||||||||||||||||
328 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 | ||||||||||||||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | /*! | - | ||||||||||||||||||||||||
332 | \internal | - | ||||||||||||||||||||||||
333 | */ | - | ||||||||||||||||||||||||
334 | QAction::QAction(QActionPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||
335 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
336 | { | - | ||||||||||||||||||||||||
337 | Q_D(QAction); | - | ||||||||||||||||||||||||
338 | d->group = qobject_cast<QActionGroup *>(parent); | - | ||||||||||||||||||||||||
339 | if (d->group)
| 0 | ||||||||||||||||||||||||
340 | d->group->addAction(this); never executed: d->group->addAction(this); | 0 | ||||||||||||||||||||||||
341 | } never executed: end of block | 0 | ||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | /*! | - | ||||||||||||||||||||||||
344 | Returns the parent widget. | - | ||||||||||||||||||||||||
345 | */ | - | ||||||||||||||||||||||||
346 | QWidget *QAction::parentWidget() const | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | QObject *ret = parent(); | - | ||||||||||||||||||||||||
349 | while (ret && !ret->isWidgetType())
| 0 | ||||||||||||||||||||||||
350 | ret = ret->parent(); never executed: ret = ret->parent(); | 0 | ||||||||||||||||||||||||
351 | return (QWidget*)ret; never executed: return (QWidget*)ret; | 0 | ||||||||||||||||||||||||
352 | } | - | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | /*! | - | ||||||||||||||||||||||||
355 | \since 4.2 | - | ||||||||||||||||||||||||
356 | Returns a list of widgets this action has been added to. | - | ||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | \sa QWidget::addAction(), associatedGraphicsWidgets() | - | ||||||||||||||||||||||||
359 | */ | - | ||||||||||||||||||||||||
360 | QList<QWidget *> QAction::associatedWidgets() const | - | ||||||||||||||||||||||||
361 | { | - | ||||||||||||||||||||||||
362 | Q_D(const QAction); | - | ||||||||||||||||||||||||
363 | return d->widgets; never executed: return d->widgets; | 0 | ||||||||||||||||||||||||
364 | } | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||
367 | /*! | - | ||||||||||||||||||||||||
368 | \since 4.5 | - | ||||||||||||||||||||||||
369 | Returns a list of widgets this action has been added to. | - | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | \sa QWidget::addAction(), associatedWidgets() | - | ||||||||||||||||||||||||
372 | */ | - | ||||||||||||||||||||||||
373 | QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const | - | ||||||||||||||||||||||||
374 | { | - | ||||||||||||||||||||||||
375 | Q_D(const QAction); | - | ||||||||||||||||||||||||
376 | return d->graphicsWidgets; never executed: return d->graphicsWidgets; | 0 | ||||||||||||||||||||||||
377 | } | - | ||||||||||||||||||||||||
378 | #endif | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
381 | /*! | - | ||||||||||||||||||||||||
382 | \property QAction::shortcut | - | ||||||||||||||||||||||||
383 | \brief the action's primary shortcut key | - | ||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | Valid keycodes for this property can be found in \l Qt::Key and | - | ||||||||||||||||||||||||
386 | \l Qt::Modifier. There is no default shortcut key. | - | ||||||||||||||||||||||||
387 | */ | - | ||||||||||||||||||||||||
388 | void QAction::setShortcut(const QKeySequence &shortcut) | - | ||||||||||||||||||||||||
389 | { | - | ||||||||||||||||||||||||
390 | QAPP_CHECK("setShortcut"); never executed: return;
| 0 | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | Q_D(QAction); | - | ||||||||||||||||||||||||
393 | if (d->shortcut == shortcut)
| 0 | ||||||||||||||||||||||||
394 | return; never executed: return; | 0 | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | d->shortcut = shortcut; | - | ||||||||||||||||||||||||
397 | d->redoGrab(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
398 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | /*! | - | ||||||||||||||||||||||||
402 | \since 4.2 | - | ||||||||||||||||||||||||
403 | - | |||||||||||||||||||||||||
404 | Sets \a shortcuts as the list of shortcuts that trigger the | - | ||||||||||||||||||||||||
405 | action. The first element of the list is the primary shortcut. | - | ||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||
407 | \sa shortcut | - | ||||||||||||||||||||||||
408 | */ | - | ||||||||||||||||||||||||
409 | void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) | - | ||||||||||||||||||||||||
410 | { | - | ||||||||||||||||||||||||
411 | Q_D(QAction); | - | ||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||
413 | QList <QKeySequence> listCopy = shortcuts; | - | ||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||
415 | QKeySequence primary; | - | ||||||||||||||||||||||||
416 | if (!listCopy.isEmpty())
| 0 | ||||||||||||||||||||||||
417 | primary = listCopy.takeFirst(); never executed: primary = listCopy.takeFirst(); | 0 | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | if (d->shortcut == primary && d->alternateShortcuts == listCopy)
| 0 | ||||||||||||||||||||||||
420 | return; never executed: return; | 0 | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | QAPP_CHECK("setShortcuts"); never executed: return;
| 0 | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | d->shortcut = primary; | - | ||||||||||||||||||||||||
425 | d->alternateShortcuts = listCopy; | - | ||||||||||||||||||||||||
426 | d->redoGrab(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
427 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
428 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | /*! | - | ||||||||||||||||||||||||
432 | \since 4.2 | - | ||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||
434 | Sets a platform dependent list of shortcuts based on the \a key. | - | ||||||||||||||||||||||||
435 | The result of calling this function will depend on the currently running platform. | - | ||||||||||||||||||||||||
436 | Note that more than one shortcut can assigned by this action. | - | ||||||||||||||||||||||||
437 | If only the primary shortcut is required, use setShortcut instead. | - | ||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | \sa QKeySequence::keyBindings() | - | ||||||||||||||||||||||||
440 | */ | - | ||||||||||||||||||||||||
441 | void QAction::setShortcuts(QKeySequence::StandardKey key) | - | ||||||||||||||||||||||||
442 | { | - | ||||||||||||||||||||||||
443 | QList <QKeySequence> list = QKeySequence::keyBindings(key); | - | ||||||||||||||||||||||||
444 | setShortcuts(list); | - | ||||||||||||||||||||||||
445 | } never executed: end of block | 0 | ||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||
447 | /*! | - | ||||||||||||||||||||||||
448 | Returns the primary shortcut. | - | ||||||||||||||||||||||||
449 | - | |||||||||||||||||||||||||
450 | \sa setShortcuts() | - | ||||||||||||||||||||||||
451 | */ | - | ||||||||||||||||||||||||
452 | QKeySequence QAction::shortcut() const | - | ||||||||||||||||||||||||
453 | { | - | ||||||||||||||||||||||||
454 | Q_D(const QAction); | - | ||||||||||||||||||||||||
455 | return d->shortcut; never executed: return d->shortcut; | 0 | ||||||||||||||||||||||||
456 | } | - | ||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | /*! | - | ||||||||||||||||||||||||
459 | \since 4.2 | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | Returns the list of shortcuts, with the primary shortcut as | - | ||||||||||||||||||||||||
462 | the first element of the list. | - | ||||||||||||||||||||||||
463 | - | |||||||||||||||||||||||||
464 | \sa setShortcuts() | - | ||||||||||||||||||||||||
465 | */ | - | ||||||||||||||||||||||||
466 | QList<QKeySequence> QAction::shortcuts() const | - | ||||||||||||||||||||||||
467 | { | - | ||||||||||||||||||||||||
468 | Q_D(const QAction); | - | ||||||||||||||||||||||||
469 | QList <QKeySequence> shortcuts; | - | ||||||||||||||||||||||||
470 | if (!d->shortcut.isEmpty())
| 0 | ||||||||||||||||||||||||
471 | shortcuts << d->shortcut; never executed: shortcuts << d->shortcut; | 0 | ||||||||||||||||||||||||
472 | if (!d->alternateShortcuts.isEmpty())
| 0 | ||||||||||||||||||||||||
473 | shortcuts << d->alternateShortcuts; never executed: shortcuts << d->alternateShortcuts; | 0 | ||||||||||||||||||||||||
474 | return shortcuts; never executed: return shortcuts; | 0 | ||||||||||||||||||||||||
475 | } | - | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | /*! | - | ||||||||||||||||||||||||
478 | \property QAction::shortcutContext | - | ||||||||||||||||||||||||
479 | \brief the context for the action's shortcut | - | ||||||||||||||||||||||||
480 | - | |||||||||||||||||||||||||
481 | Valid values for this property can be found in \l Qt::ShortcutContext. | - | ||||||||||||||||||||||||
482 | The default value is Qt::WindowShortcut. | - | ||||||||||||||||||||||||
483 | */ | - | ||||||||||||||||||||||||
484 | void QAction::setShortcutContext(Qt::ShortcutContext context) | - | ||||||||||||||||||||||||
485 | { | - | ||||||||||||||||||||||||
486 | Q_D(QAction); | - | ||||||||||||||||||||||||
487 | if (d->shortcutContext == context)
| 0 | ||||||||||||||||||||||||
488 | return; never executed: return; | 0 | ||||||||||||||||||||||||
489 | QAPP_CHECK("setShortcutContext"); never executed: return;
| 0 | ||||||||||||||||||||||||
490 | d->shortcutContext = context; | - | ||||||||||||||||||||||||
491 | d->redoGrab(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
492 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
493 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||
496 | Qt::ShortcutContext QAction::shortcutContext() const | - | ||||||||||||||||||||||||
497 | { | - | ||||||||||||||||||||||||
498 | Q_D(const QAction); | - | ||||||||||||||||||||||||
499 | return d->shortcutContext; never executed: return d->shortcutContext; | 0 | ||||||||||||||||||||||||
500 | } | - | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | /*! | - | ||||||||||||||||||||||||
503 | \property QAction::autoRepeat | - | ||||||||||||||||||||||||
504 | \brief whether the action can auto repeat | - | ||||||||||||||||||||||||
505 | \since 4.2 | - | ||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | If true, the action will auto repeat when the keyboard shortcut | - | ||||||||||||||||||||||||
508 | combination is held down, provided that keyboard auto repeat is | - | ||||||||||||||||||||||||
509 | enabled on the system. | - | ||||||||||||||||||||||||
510 | The default value is true. | - | ||||||||||||||||||||||||
511 | */ | - | ||||||||||||||||||||||||
512 | void QAction::setAutoRepeat(bool on) | - | ||||||||||||||||||||||||
513 | { | - | ||||||||||||||||||||||||
514 | Q_D(QAction); | - | ||||||||||||||||||||||||
515 | if (d->autorepeat == on)
| 0 | ||||||||||||||||||||||||
516 | return; never executed: return; | 0 | ||||||||||||||||||||||||
517 | QAPP_CHECK("setAutoRepeat"); never executed: return;
| 0 | ||||||||||||||||||||||||
518 | d->autorepeat = on; | - | ||||||||||||||||||||||||
519 | d->redoGrab(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
520 | d->redoGrabAlternate(qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
521 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||
524 | bool QAction::autoRepeat() const | - | ||||||||||||||||||||||||
525 | { | - | ||||||||||||||||||||||||
526 | Q_D(const QAction); | - | ||||||||||||||||||||||||
527 | return d->autorepeat; never executed: return d->autorepeat; | 0 | ||||||||||||||||||||||||
528 | } | - | ||||||||||||||||||||||||
529 | #endif // QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | /*! | - | ||||||||||||||||||||||||
532 | \property QAction::font | - | ||||||||||||||||||||||||
533 | \brief the action's font | - | ||||||||||||||||||||||||
534 | - | |||||||||||||||||||||||||
535 | The font property is used to render the text set on the | - | ||||||||||||||||||||||||
536 | QAction. The font will can be considered a hint as it will not be | - | ||||||||||||||||||||||||
537 | consulted in all cases based upon application and style. | - | ||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||
539 | By default, this property contains the application's default font. | - | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | \sa QAction::setText(), QStyle | - | ||||||||||||||||||||||||
542 | */ | - | ||||||||||||||||||||||||
543 | void QAction::setFont(const QFont &font) | - | ||||||||||||||||||||||||
544 | { | - | ||||||||||||||||||||||||
545 | Q_D(QAction); | - | ||||||||||||||||||||||||
546 | if (d->font == font)
| 0 | ||||||||||||||||||||||||
547 | return; never executed: return; | 0 | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | d->fontSet = true; | - | ||||||||||||||||||||||||
550 | d->font = font; | - | ||||||||||||||||||||||||
551 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
552 | } never executed: end of block | 0 | ||||||||||||||||||||||||
553 | - | |||||||||||||||||||||||||
554 | QFont QAction::font() const | - | ||||||||||||||||||||||||
555 | { | - | ||||||||||||||||||||||||
556 | Q_D(const QAction); | - | ||||||||||||||||||||||||
557 | return d->font; never executed: return d->font; | 0 | ||||||||||||||||||||||||
558 | } | - | ||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | /*! | - | ||||||||||||||||||||||||
562 | Destroys the object and frees allocated resources. | - | ||||||||||||||||||||||||
563 | */ | - | ||||||||||||||||||||||||
564 | QAction::~QAction() | - | ||||||||||||||||||||||||
565 | { | - | ||||||||||||||||||||||||
566 | Q_D(QAction); | - | ||||||||||||||||||||||||
567 | for (int i = d->widgets.size()-1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
568 | QWidget *w = d->widgets.at(i); | - | ||||||||||||||||||||||||
569 | w->removeAction(this); | - | ||||||||||||||||||||||||
570 | } never executed: end of block | 0 | ||||||||||||||||||||||||
571 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||
572 | for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
573 | QGraphicsWidget *w = d->graphicsWidgets.at(i); | - | ||||||||||||||||||||||||
574 | w->removeAction(this); | - | ||||||||||||||||||||||||
575 | } never executed: end of block | 0 | ||||||||||||||||||||||||
576 | #endif | - | ||||||||||||||||||||||||
577 | if (d->group)
| 0 | ||||||||||||||||||||||||
578 | d->group->removeAction(this); never executed: d->group->removeAction(this); | 0 | ||||||||||||||||||||||||
579 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
580 | if (d->shortcutId && qApp) {
| 0 | ||||||||||||||||||||||||
581 | qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); | - | ||||||||||||||||||||||||
582 | for(int i = 0; i < d->alternateShortcutIds.count(); ++i) {
| 0 | ||||||||||||||||||||||||
583 | const int id = d->alternateShortcutIds.at(i); | - | ||||||||||||||||||||||||
584 | qApp->d_func()->shortcutMap.removeShortcut(id, this); | - | ||||||||||||||||||||||||
585 | } never executed: end of block | 0 | ||||||||||||||||||||||||
586 | } never executed: end of block | 0 | ||||||||||||||||||||||||
587 | #endif | - | ||||||||||||||||||||||||
588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | /*! | - | ||||||||||||||||||||||||
591 | Sets this action group to \a group. The action will be automatically | - | ||||||||||||||||||||||||
592 | added to the group's list of actions. | - | ||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | Actions within the group will be mutually exclusive. | - | ||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | \sa QActionGroup, QAction::actionGroup() | - | ||||||||||||||||||||||||
597 | */ | - | ||||||||||||||||||||||||
598 | void QAction::setActionGroup(QActionGroup *group) | - | ||||||||||||||||||||||||
599 | { | - | ||||||||||||||||||||||||
600 | Q_D(QAction); | - | ||||||||||||||||||||||||
601 | if(group == d->group)
| 0 | ||||||||||||||||||||||||
602 | return; never executed: return; | 0 | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | if(d->group)
| 0 | ||||||||||||||||||||||||
605 | d->group->removeAction(this); never executed: d->group->removeAction(this); | 0 | ||||||||||||||||||||||||
606 | d->group = group; | - | ||||||||||||||||||||||||
607 | if(group)
| 0 | ||||||||||||||||||||||||
608 | group->addAction(this); never executed: group->addAction(this); | 0 | ||||||||||||||||||||||||
609 | } never executed: end of block | 0 | ||||||||||||||||||||||||
610 | - | |||||||||||||||||||||||||
611 | /*! | - | ||||||||||||||||||||||||
612 | Returns the action group for this action. If no action group manages | - | ||||||||||||||||||||||||
613 | this action then 0 will be returned. | - | ||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | \sa QActionGroup, QAction::setActionGroup() | - | ||||||||||||||||||||||||
616 | */ | - | ||||||||||||||||||||||||
617 | QActionGroup *QAction::actionGroup() const | - | ||||||||||||||||||||||||
618 | { | - | ||||||||||||||||||||||||
619 | Q_D(const QAction); | - | ||||||||||||||||||||||||
620 | return d->group; never executed: return d->group; | 0 | ||||||||||||||||||||||||
621 | } | - | ||||||||||||||||||||||||
622 | - | |||||||||||||||||||||||||
623 | - | |||||||||||||||||||||||||
624 | /*! | - | ||||||||||||||||||||||||
625 | \property QAction::icon | - | ||||||||||||||||||||||||
626 | \brief the action's icon | - | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | In toolbars, the icon is used as the tool button icon; in menus, | - | ||||||||||||||||||||||||
629 | it is displayed to the left of the menu text. There is no default | - | ||||||||||||||||||||||||
630 | icon. | - | ||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | If a null icon (QIcon::isNull() is passed into this function, | - | ||||||||||||||||||||||||
633 | the icon of the action is cleared. | - | ||||||||||||||||||||||||
634 | */ | - | ||||||||||||||||||||||||
635 | void QAction::setIcon(const QIcon &icon) | - | ||||||||||||||||||||||||
636 | { | - | ||||||||||||||||||||||||
637 | Q_D(QAction); | - | ||||||||||||||||||||||||
638 | d->icon = icon; | - | ||||||||||||||||||||||||
639 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
640 | } never executed: end of block | 0 | ||||||||||||||||||||||||
641 | - | |||||||||||||||||||||||||
642 | QIcon QAction::icon() const | - | ||||||||||||||||||||||||
643 | { | - | ||||||||||||||||||||||||
644 | Q_D(const QAction); | - | ||||||||||||||||||||||||
645 | return d->icon; never executed: return d->icon; | 0 | ||||||||||||||||||||||||
646 | } | - | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
649 | /*! | - | ||||||||||||||||||||||||
650 | Returns the menu contained by this action. Actions that contain | - | ||||||||||||||||||||||||
651 | menus can be used to create menu items with submenus, or inserted | - | ||||||||||||||||||||||||
652 | into toolbars to create buttons with popup menus. | - | ||||||||||||||||||||||||
653 | - | |||||||||||||||||||||||||
654 | \sa QMenu::addAction() | - | ||||||||||||||||||||||||
655 | */ | - | ||||||||||||||||||||||||
656 | QMenu *QAction::menu() const | - | ||||||||||||||||||||||||
657 | { | - | ||||||||||||||||||||||||
658 | Q_D(const QAction); | - | ||||||||||||||||||||||||
659 | return d->menu; never executed: return d->menu; | 0 | ||||||||||||||||||||||||
660 | } | - | ||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | /*! | - | ||||||||||||||||||||||||
663 | Sets the menu contained by this action to the specified \a menu. | - | ||||||||||||||||||||||||
664 | */ | - | ||||||||||||||||||||||||
665 | void QAction::setMenu(QMenu *menu) | - | ||||||||||||||||||||||||
666 | { | - | ||||||||||||||||||||||||
667 | Q_D(QAction); | - | ||||||||||||||||||||||||
668 | if (d->menu)
| 0 | ||||||||||||||||||||||||
669 | d->menu->d_func()->setOverrideMenuAction(0); //we reset the default action of any previous menu never executed: d->menu->d_func()->setOverrideMenuAction(0); | 0 | ||||||||||||||||||||||||
670 | d->menu = menu; | - | ||||||||||||||||||||||||
671 | if (menu)
| 0 | ||||||||||||||||||||||||
672 | menu->d_func()->setOverrideMenuAction(this); never executed: menu->d_func()->setOverrideMenuAction(this); | 0 | ||||||||||||||||||||||||
673 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
674 | } never executed: end of block | 0 | ||||||||||||||||||||||||
675 | #endif // QT_NO_MENU | - | ||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||
677 | /*! | - | ||||||||||||||||||||||||
678 | If \a b is true then this action will be considered a separator. | - | ||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | How a separator is represented depends on the widget it is inserted | - | ||||||||||||||||||||||||
681 | into. Under most circumstances the text, submenu, and icon will be | - | ||||||||||||||||||||||||
682 | ignored for separator actions. | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | \sa QAction::isSeparator() | - | ||||||||||||||||||||||||
685 | */ | - | ||||||||||||||||||||||||
686 | void QAction::setSeparator(bool b) | - | ||||||||||||||||||||||||
687 | { | - | ||||||||||||||||||||||||
688 | Q_D(QAction); | - | ||||||||||||||||||||||||
689 | if (d->separator == b)
| 0 | ||||||||||||||||||||||||
690 | return; never executed: return; | 0 | ||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | d->separator = b; | - | ||||||||||||||||||||||||
693 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
694 | } never executed: end of block | 0 | ||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||
696 | /*! | - | ||||||||||||||||||||||||
697 | Returns \c true if this action is a separator action; otherwise it | - | ||||||||||||||||||||||||
698 | returns \c false. | - | ||||||||||||||||||||||||
699 | - | |||||||||||||||||||||||||
700 | \sa QAction::setSeparator() | - | ||||||||||||||||||||||||
701 | */ | - | ||||||||||||||||||||||||
702 | bool QAction::isSeparator() const | - | ||||||||||||||||||||||||
703 | { | - | ||||||||||||||||||||||||
704 | Q_D(const QAction); | - | ||||||||||||||||||||||||
705 | return d->separator; never executed: return d->separator; | 0 | ||||||||||||||||||||||||
706 | } | - | ||||||||||||||||||||||||
707 | - | |||||||||||||||||||||||||
708 | /*! | - | ||||||||||||||||||||||||
709 | \property QAction::text | - | ||||||||||||||||||||||||
710 | \brief the action's descriptive text | - | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | If the action is added to a menu, the menu option will consist of | - | ||||||||||||||||||||||||
713 | the icon (if there is one), the text, and the shortcut (if there | - | ||||||||||||||||||||||||
714 | is one). If the text is not explicitly set in the constructor, or | - | ||||||||||||||||||||||||
715 | by using setText(), the action's description icon text will be | - | ||||||||||||||||||||||||
716 | used as text. There is no default text. | - | ||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||
718 | \sa iconText | - | ||||||||||||||||||||||||
719 | */ | - | ||||||||||||||||||||||||
720 | void QAction::setText(const QString &text) | - | ||||||||||||||||||||||||
721 | { | - | ||||||||||||||||||||||||
722 | Q_D(QAction); | - | ||||||||||||||||||||||||
723 | if (d->text == text)
| 0 | ||||||||||||||||||||||||
724 | return; never executed: return; | 0 | ||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||
726 | d->text = text; | - | ||||||||||||||||||||||||
727 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
728 | } never executed: end of block | 0 | ||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | QString QAction::text() const | - | ||||||||||||||||||||||||
731 | { | - | ||||||||||||||||||||||||
732 | Q_D(const QAction); | - | ||||||||||||||||||||||||
733 | QString s = d->text; | - | ||||||||||||||||||||||||
734 | if(s.isEmpty()) {
| 0 | ||||||||||||||||||||||||
735 | s = d->iconText; | - | ||||||||||||||||||||||||
736 | s.replace(QLatin1Char('&'), QLatin1String("&&")); | - | ||||||||||||||||||||||||
737 | } never executed: end of block | 0 | ||||||||||||||||||||||||
738 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
739 | } | - | ||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||
741 | - | |||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||
744 | - | |||||||||||||||||||||||||
745 | /*! | - | ||||||||||||||||||||||||
746 | \property QAction::iconText | - | ||||||||||||||||||||||||
747 | \brief the action's descriptive icon text | - | ||||||||||||||||||||||||
748 | - | |||||||||||||||||||||||||
749 | If QToolBar::toolButtonStyle is set to a value that permits text to | - | ||||||||||||||||||||||||
750 | be displayed, the text defined held in this property appears as a | - | ||||||||||||||||||||||||
751 | label in the relevant tool button. | - | ||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||
753 | It also serves as the default text in menus and tooltips if the action | - | ||||||||||||||||||||||||
754 | has not been defined with setText() or setToolTip(), and will | - | ||||||||||||||||||||||||
755 | also be used in toolbar buttons if no icon has been defined using setIcon(). | - | ||||||||||||||||||||||||
756 | - | |||||||||||||||||||||||||
757 | If the icon text is not explicitly set, the action's normal text will be | - | ||||||||||||||||||||||||
758 | used for the icon text. | - | ||||||||||||||||||||||||
759 | - | |||||||||||||||||||||||||
760 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||
762 | \sa setToolTip(), setStatusTip() | - | ||||||||||||||||||||||||
763 | */ | - | ||||||||||||||||||||||||
764 | void QAction::setIconText(const QString &text) | - | ||||||||||||||||||||||||
765 | { | - | ||||||||||||||||||||||||
766 | Q_D(QAction); | - | ||||||||||||||||||||||||
767 | if (d->iconText == text)
| 0 | ||||||||||||||||||||||||
768 | return; never executed: return; | 0 | ||||||||||||||||||||||||
769 | - | |||||||||||||||||||||||||
770 | d->iconText = text; | - | ||||||||||||||||||||||||
771 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
772 | } never executed: end of block | 0 | ||||||||||||||||||||||||
773 | - | |||||||||||||||||||||||||
774 | QString QAction::iconText() const | - | ||||||||||||||||||||||||
775 | { | - | ||||||||||||||||||||||||
776 | Q_D(const QAction); | - | ||||||||||||||||||||||||
777 | if (d->iconText.isEmpty())
| 0 | ||||||||||||||||||||||||
778 | return qt_strippedText(d->text); never executed: return qt_strippedText(d->text); | 0 | ||||||||||||||||||||||||
779 | return d->iconText; never executed: return d->iconText; | 0 | ||||||||||||||||||||||||
780 | } | - | ||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
782 | /*! | - | ||||||||||||||||||||||||
783 | \property QAction::toolTip | - | ||||||||||||||||||||||||
784 | \brief the action's tooltip | - | ||||||||||||||||||||||||
785 | - | |||||||||||||||||||||||||
786 | This text is used for the tooltip. If no tooltip is specified, | - | ||||||||||||||||||||||||
787 | the action's text is used. | - | ||||||||||||||||||||||||
788 | - | |||||||||||||||||||||||||
789 | By default, this property contains the action's text. | - | ||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | \sa setStatusTip(), setShortcut() | - | ||||||||||||||||||||||||
792 | */ | - | ||||||||||||||||||||||||
793 | void QAction::setToolTip(const QString &tooltip) | - | ||||||||||||||||||||||||
794 | { | - | ||||||||||||||||||||||||
795 | Q_D(QAction); | - | ||||||||||||||||||||||||
796 | if (d->tooltip == tooltip)
| 0 | ||||||||||||||||||||||||
797 | return; never executed: return; | 0 | ||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||
799 | d->tooltip = tooltip; | - | ||||||||||||||||||||||||
800 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | QString QAction::toolTip() const | - | ||||||||||||||||||||||||
804 | { | - | ||||||||||||||||||||||||
805 | Q_D(const QAction); | - | ||||||||||||||||||||||||
806 | if (d->tooltip.isEmpty()) {
| 0 | ||||||||||||||||||||||||
807 | if (!d->text.isEmpty())
| 0 | ||||||||||||||||||||||||
808 | return qt_strippedText(d->text); never executed: return qt_strippedText(d->text); | 0 | ||||||||||||||||||||||||
809 | return qt_strippedText(d->iconText); never executed: return qt_strippedText(d->iconText); | 0 | ||||||||||||||||||||||||
810 | } | - | ||||||||||||||||||||||||
811 | return d->tooltip; never executed: return d->tooltip; | 0 | ||||||||||||||||||||||||
812 | } | - | ||||||||||||||||||||||||
813 | - | |||||||||||||||||||||||||
814 | /*! | - | ||||||||||||||||||||||||
815 | \property QAction::statusTip | - | ||||||||||||||||||||||||
816 | \brief the action's status tip | - | ||||||||||||||||||||||||
817 | - | |||||||||||||||||||||||||
818 | The status tip is displayed on all status bars provided by the | - | ||||||||||||||||||||||||
819 | action's top-level parent widget. | - | ||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||
821 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||
822 | - | |||||||||||||||||||||||||
823 | \sa setToolTip(), showStatusText() | - | ||||||||||||||||||||||||
824 | */ | - | ||||||||||||||||||||||||
825 | void QAction::setStatusTip(const QString &statustip) | - | ||||||||||||||||||||||||
826 | { | - | ||||||||||||||||||||||||
827 | Q_D(QAction); | - | ||||||||||||||||||||||||
828 | if (d->statustip == statustip)
| 0 | ||||||||||||||||||||||||
829 | return; never executed: return; | 0 | ||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||
831 | d->statustip = statustip; | - | ||||||||||||||||||||||||
832 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
833 | } never executed: end of block | 0 | ||||||||||||||||||||||||
834 | - | |||||||||||||||||||||||||
835 | QString QAction::statusTip() const | - | ||||||||||||||||||||||||
836 | { | - | ||||||||||||||||||||||||
837 | Q_D(const QAction); | - | ||||||||||||||||||||||||
838 | return d->statustip; never executed: return d->statustip; | 0 | ||||||||||||||||||||||||
839 | } | - | ||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||
841 | /*! | - | ||||||||||||||||||||||||
842 | \property QAction::whatsThis | - | ||||||||||||||||||||||||
843 | \brief the action's "What's This?" help text | - | ||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||
845 | The "What's This?" text is used to provide a brief description of | - | ||||||||||||||||||||||||
846 | the action. The text may contain rich text. There is no default | - | ||||||||||||||||||||||||
847 | "What's This?" text. | - | ||||||||||||||||||||||||
848 | - | |||||||||||||||||||||||||
849 | \sa QWhatsThis | - | ||||||||||||||||||||||||
850 | */ | - | ||||||||||||||||||||||||
851 | void QAction::setWhatsThis(const QString &whatsthis) | - | ||||||||||||||||||||||||
852 | { | - | ||||||||||||||||||||||||
853 | Q_D(QAction); | - | ||||||||||||||||||||||||
854 | if (d->whatsthis == whatsthis)
| 0 | ||||||||||||||||||||||||
855 | return; never executed: return; | 0 | ||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | d->whatsthis = whatsthis; | - | ||||||||||||||||||||||||
858 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||
861 | QString QAction::whatsThis() const | - | ||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||
863 | Q_D(const QAction); | - | ||||||||||||||||||||||||
864 | return d->whatsthis; never executed: return d->whatsthis; | 0 | ||||||||||||||||||||||||
865 | } | - | ||||||||||||||||||||||||
866 | - | |||||||||||||||||||||||||
867 | /*! | - | ||||||||||||||||||||||||
868 | \enum QAction::Priority | - | ||||||||||||||||||||||||
869 | \since 4.6 | - | ||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||
871 | This enum defines priorities for actions in user interface. | - | ||||||||||||||||||||||||
872 | - | |||||||||||||||||||||||||
873 | \value LowPriority The action should not be prioritized in | - | ||||||||||||||||||||||||
874 | the user interface. | - | ||||||||||||||||||||||||
875 | - | |||||||||||||||||||||||||
876 | \value NormalPriority | - | ||||||||||||||||||||||||
877 | - | |||||||||||||||||||||||||
878 | \value HighPriority The action should be prioritized in | - | ||||||||||||||||||||||||
879 | the user interface. | - | ||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||
881 | \sa priority | - | ||||||||||||||||||||||||
882 | */ | - | ||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | - | |||||||||||||||||||||||||
885 | /*! | - | ||||||||||||||||||||||||
886 | \property QAction::priority | - | ||||||||||||||||||||||||
887 | \since 4.6 | - | ||||||||||||||||||||||||
888 | - | |||||||||||||||||||||||||
889 | \brief the actions's priority in the user interface. | - | ||||||||||||||||||||||||
890 | - | |||||||||||||||||||||||||
891 | This property can be set to indicate how the action should be prioritized | - | ||||||||||||||||||||||||
892 | in the user interface. | - | ||||||||||||||||||||||||
893 | - | |||||||||||||||||||||||||
894 | For instance, when toolbars have the Qt::ToolButtonTextBesideIcon | - | ||||||||||||||||||||||||
895 | mode set, then actions with LowPriority will not show the text | - | ||||||||||||||||||||||||
896 | labels. | - | ||||||||||||||||||||||||
897 | */ | - | ||||||||||||||||||||||||
898 | void QAction::setPriority(Priority priority) | - | ||||||||||||||||||||||||
899 | { | - | ||||||||||||||||||||||||
900 | Q_D(QAction); | - | ||||||||||||||||||||||||
901 | if (d->priority == priority)
| 0 | ||||||||||||||||||||||||
902 | return; never executed: return; | 0 | ||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | d->priority = priority; | - | ||||||||||||||||||||||||
905 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
906 | } never executed: end of block | 0 | ||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | QAction::Priority QAction::priority() const | - | ||||||||||||||||||||||||
909 | { | - | ||||||||||||||||||||||||
910 | Q_D(const QAction); | - | ||||||||||||||||||||||||
911 | return d->priority; never executed: return d->priority; | 0 | ||||||||||||||||||||||||
912 | } | - | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | /*! | - | ||||||||||||||||||||||||
915 | \property QAction::checkable | - | ||||||||||||||||||||||||
916 | \brief whether the action is a checkable action | - | ||||||||||||||||||||||||
917 | - | |||||||||||||||||||||||||
918 | A checkable action is one which has an on/off state. For example, | - | ||||||||||||||||||||||||
919 | in a word processor, a Bold toolbar button may be either on or | - | ||||||||||||||||||||||||
920 | off. An action which is not a toggle action is a command action; | - | ||||||||||||||||||||||||
921 | a command action is simply executed, e.g. file save. | - | ||||||||||||||||||||||||
922 | By default, this property is \c false. | - | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | In some situations, the state of one toggle action should depend | - | ||||||||||||||||||||||||
925 | on the state of others. For example, "Left Align", "Center" and | - | ||||||||||||||||||||||||
926 | "Right Align" toggle actions are mutually exclusive. To achieve | - | ||||||||||||||||||||||||
927 | exclusive toggling, add the relevant toggle actions to a | - | ||||||||||||||||||||||||
928 | QActionGroup with the QActionGroup::exclusive property set to | - | ||||||||||||||||||||||||
929 | true. | - | ||||||||||||||||||||||||
930 | - | |||||||||||||||||||||||||
931 | \sa QAction::setChecked() | - | ||||||||||||||||||||||||
932 | */ | - | ||||||||||||||||||||||||
933 | void QAction::setCheckable(bool b) | - | ||||||||||||||||||||||||
934 | { | - | ||||||||||||||||||||||||
935 | Q_D(QAction); | - | ||||||||||||||||||||||||
936 | if (d->checkable == b)
| 0 | ||||||||||||||||||||||||
937 | return; never executed: return; | 0 | ||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | d->checkable = b; | - | ||||||||||||||||||||||||
940 | d->checked = false; | - | ||||||||||||||||||||||||
941 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||
944 | bool QAction::isCheckable() const | - | ||||||||||||||||||||||||
945 | { | - | ||||||||||||||||||||||||
946 | Q_D(const QAction); | - | ||||||||||||||||||||||||
947 | return d->checkable; never executed: return d->checkable; | 0 | ||||||||||||||||||||||||
948 | } | - | ||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||
950 | /*! | - | ||||||||||||||||||||||||
951 | \fn void QAction::toggle() | - | ||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||
953 | This is a convenience function for the \l checked property. | - | ||||||||||||||||||||||||
954 | Connect to it to change the checked state to its opposite state. | - | ||||||||||||||||||||||||
955 | */ | - | ||||||||||||||||||||||||
956 | void QAction::toggle() | - | ||||||||||||||||||||||||
957 | { | - | ||||||||||||||||||||||||
958 | Q_D(QAction); | - | ||||||||||||||||||||||||
959 | setChecked(!d->checked); | - | ||||||||||||||||||||||||
960 | } never executed: end of block | 0 | ||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||
962 | /*! | - | ||||||||||||||||||||||||
963 | \property QAction::checked | - | ||||||||||||||||||||||||
964 | \brief whether the action is checked. | - | ||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||
966 | Only checkable actions can be checked. By default, this is false | - | ||||||||||||||||||||||||
967 | (the action is unchecked). | - | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | \sa checkable | - | ||||||||||||||||||||||||
970 | */ | - | ||||||||||||||||||||||||
971 | void QAction::setChecked(bool b) | - | ||||||||||||||||||||||||
972 | { | - | ||||||||||||||||||||||||
973 | Q_D(QAction); | - | ||||||||||||||||||||||||
974 | if (!d->checkable || d->checked == b)
| 0 | ||||||||||||||||||||||||
975 | return; never executed: return; | 0 | ||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | QPointer<QAction> guard(this); | - | ||||||||||||||||||||||||
978 | d->checked = b; | - | ||||||||||||||||||||||||
979 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
980 | if (guard)
| 0 | ||||||||||||||||||||||||
981 | emit toggled(b); never executed: toggled(b); | 0 | ||||||||||||||||||||||||
982 | } never executed: end of block | 0 | ||||||||||||||||||||||||
983 | - | |||||||||||||||||||||||||
984 | bool QAction::isChecked() const | - | ||||||||||||||||||||||||
985 | { | - | ||||||||||||||||||||||||
986 | Q_D(const QAction); | - | ||||||||||||||||||||||||
987 | return d->checked; never executed: return d->checked; | 0 | ||||||||||||||||||||||||
988 | } | - | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | /*! | - | ||||||||||||||||||||||||
991 | \fn void QAction::setDisabled(bool b) | - | ||||||||||||||||||||||||
992 | - | |||||||||||||||||||||||||
993 | This is a convenience function for the \l enabled property, that | - | ||||||||||||||||||||||||
994 | is useful for signals--slots connections. If \a b is true the | - | ||||||||||||||||||||||||
995 | action is disabled; otherwise it is enabled. | - | ||||||||||||||||||||||||
996 | */ | - | ||||||||||||||||||||||||
997 | - | |||||||||||||||||||||||||
998 | /*! | - | ||||||||||||||||||||||||
999 | \property QAction::enabled | - | ||||||||||||||||||||||||
1000 | \brief whether the action is enabled | - | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | Disabled actions cannot be chosen by the user. They do not | - | ||||||||||||||||||||||||
1003 | disappear from menus or toolbars, but they are displayed in a way | - | ||||||||||||||||||||||||
1004 | which indicates that they are unavailable. For example, they might | - | ||||||||||||||||||||||||
1005 | be displayed using only shades of gray. | - | ||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||
1007 | \uicontrol{What's This?} help on disabled actions is still available, provided | - | ||||||||||||||||||||||||
1008 | that the QAction::whatsThis property is set. | - | ||||||||||||||||||||||||
1009 | - | |||||||||||||||||||||||||
1010 | An action will be disabled when all widgets to which it is added | - | ||||||||||||||||||||||||
1011 | (with QWidget::addAction()) are disabled or not visible. When an | - | ||||||||||||||||||||||||
1012 | action is disabled, it is not possible to trigger it through its | - | ||||||||||||||||||||||||
1013 | shortcut. | - | ||||||||||||||||||||||||
1014 | - | |||||||||||||||||||||||||
1015 | By default, this property is \c true (actions are enabled). | - | ||||||||||||||||||||||||
1016 | - | |||||||||||||||||||||||||
1017 | \sa text | - | ||||||||||||||||||||||||
1018 | */ | - | ||||||||||||||||||||||||
1019 | void QAction::setEnabled(bool b) | - | ||||||||||||||||||||||||
1020 | { | - | ||||||||||||||||||||||||
1021 | Q_D(QAction); | - | ||||||||||||||||||||||||
1022 | if (b == d->enabled && b != d->forceDisabled)
| 0 | ||||||||||||||||||||||||
1023 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1024 | d->forceDisabled = !b; | - | ||||||||||||||||||||||||
1025 | if (b && (!d->visible || (d->group && !d->group->isEnabled())))
| 0 | ||||||||||||||||||||||||
1026 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1027 | QAPP_CHECK("setEnabled"); never executed: return;
| 0 | ||||||||||||||||||||||||
1028 | d->enabled = b; | - | ||||||||||||||||||||||||
1029 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
1030 | d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
1031 | #endif | - | ||||||||||||||||||||||||
1032 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
1033 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | bool QAction::isEnabled() const | - | ||||||||||||||||||||||||
1036 | { | - | ||||||||||||||||||||||||
1037 | Q_D(const QAction); | - | ||||||||||||||||||||||||
1038 | return d->enabled; never executed: return d->enabled; | 0 | ||||||||||||||||||||||||
1039 | } | - | ||||||||||||||||||||||||
1040 | - | |||||||||||||||||||||||||
1041 | /*! | - | ||||||||||||||||||||||||
1042 | \property QAction::visible | - | ||||||||||||||||||||||||
1043 | \brief whether the action can be seen (e.g. in menus and toolbars) | - | ||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | If \e visible is true the action can be seen (e.g. in menus and | - | ||||||||||||||||||||||||
1046 | toolbars) and chosen by the user; if \e visible is false the | - | ||||||||||||||||||||||||
1047 | action cannot be seen or chosen by the user. | - | ||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | Actions which are not visible are \e not grayed out; they do not | - | ||||||||||||||||||||||||
1050 | appear at all. | - | ||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | By default, this property is \c true (actions are visible). | - | ||||||||||||||||||||||||
1053 | */ | - | ||||||||||||||||||||||||
1054 | void QAction::setVisible(bool b) | - | ||||||||||||||||||||||||
1055 | { | - | ||||||||||||||||||||||||
1056 | Q_D(QAction); | - | ||||||||||||||||||||||||
1057 | if (b == d->visible && b != d->forceInvisible)
| 0 | ||||||||||||||||||||||||
1058 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1059 | QAPP_CHECK("setVisible"); never executed: return;
| 0 | ||||||||||||||||||||||||
1060 | d->forceInvisible = !b; | - | ||||||||||||||||||||||||
1061 | d->visible = b; | - | ||||||||||||||||||||||||
1062 | d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ;
| 0 | ||||||||||||||||||||||||
1063 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
1064 | d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); | - | ||||||||||||||||||||||||
1065 | #endif | - | ||||||||||||||||||||||||
1066 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
1067 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | - | |||||||||||||||||||||||||
1070 | bool QAction::isVisible() const | - | ||||||||||||||||||||||||
1071 | { | - | ||||||||||||||||||||||||
1072 | Q_D(const QAction); | - | ||||||||||||||||||||||||
1073 | return d->visible; never executed: return d->visible; | 0 | ||||||||||||||||||||||||
1074 | } | - | ||||||||||||||||||||||||
1075 | - | |||||||||||||||||||||||||
1076 | /*! | - | ||||||||||||||||||||||||
1077 | \reimp | - | ||||||||||||||||||||||||
1078 | */ | - | ||||||||||||||||||||||||
1079 | bool | - | ||||||||||||||||||||||||
1080 | QAction::event(QEvent *e) | - | ||||||||||||||||||||||||
1081 | { | - | ||||||||||||||||||||||||
1082 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
1083 | if (e->type() == QEvent::Shortcut) {
| 0 | ||||||||||||||||||||||||
1084 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - | ||||||||||||||||||||||||
1085 | Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), | - | ||||||||||||||||||||||||
1086 | "QAction::event", | - | ||||||||||||||||||||||||
1087 | "Received shortcut event from incorrect shortcut"); | - | ||||||||||||||||||||||||
1088 | if (se->isAmbiguous())
| 0 | ||||||||||||||||||||||||
1089 | qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); never executed: QMessageLogger(__FILE__, 1089, __PRETTY_FUNCTION__).warning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); | 0 | ||||||||||||||||||||||||
1090 | else | - | ||||||||||||||||||||||||
1091 | activate(Trigger); never executed: activate(Trigger); | 0 | ||||||||||||||||||||||||
1092 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1093 | } | - | ||||||||||||||||||||||||
1094 | #endif | - | ||||||||||||||||||||||||
1095 | return QObject::event(e); never executed: return QObject::event(e); | 0 | ||||||||||||||||||||||||
1096 | } | - | ||||||||||||||||||||||||
1097 | - | |||||||||||||||||||||||||
1098 | /*! | - | ||||||||||||||||||||||||
1099 | Returns the user data as set in QAction::setData. | - | ||||||||||||||||||||||||
1100 | - | |||||||||||||||||||||||||
1101 | \sa setData() | - | ||||||||||||||||||||||||
1102 | */ | - | ||||||||||||||||||||||||
1103 | QVariant | - | ||||||||||||||||||||||||
1104 | QAction::data() const | - | ||||||||||||||||||||||||
1105 | { | - | ||||||||||||||||||||||||
1106 | Q_D(const QAction); | - | ||||||||||||||||||||||||
1107 | return d->userData; never executed: return d->userData; | 0 | ||||||||||||||||||||||||
1108 | } | - | ||||||||||||||||||||||||
1109 | - | |||||||||||||||||||||||||
1110 | /*! | - | ||||||||||||||||||||||||
1111 | \fn void QAction::setData(const QVariant &userData) | - | ||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||
1113 | Sets the action's internal data to the given \a userData. | - | ||||||||||||||||||||||||
1114 | - | |||||||||||||||||||||||||
1115 | \sa data() | - | ||||||||||||||||||||||||
1116 | */ | - | ||||||||||||||||||||||||
1117 | void | - | ||||||||||||||||||||||||
1118 | QAction::setData(const QVariant &data) | - | ||||||||||||||||||||||||
1119 | { | - | ||||||||||||||||||||||||
1120 | Q_D(QAction); | - | ||||||||||||||||||||||||
1121 | d->userData = data; | - | ||||||||||||||||||||||||
1122 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
1123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | /*! | - | ||||||||||||||||||||||||
1127 | Updates the relevant status bar for the \a widget specified by sending a | - | ||||||||||||||||||||||||
1128 | QStatusTipEvent to its parent widget. Returns \c true if an event was sent; | - | ||||||||||||||||||||||||
1129 | otherwise returns \c false. | - | ||||||||||||||||||||||||
1130 | - | |||||||||||||||||||||||||
1131 | If a null widget is specified, the event is sent to the action's parent. | - | ||||||||||||||||||||||||
1132 | - | |||||||||||||||||||||||||
1133 | \sa statusTip | - | ||||||||||||||||||||||||
1134 | */ | - | ||||||||||||||||||||||||
1135 | bool | - | ||||||||||||||||||||||||
1136 | QAction::showStatusText(QWidget *widget) | - | ||||||||||||||||||||||||
1137 | { | - | ||||||||||||||||||||||||
1138 | return d_func()->showStatusText(widget, statusTip()); never executed: return d_func()->showStatusText(widget, statusTip()); | 0 | ||||||||||||||||||||||||
1139 | } | - | ||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||
1141 | /*! | - | ||||||||||||||||||||||||
1142 | Sends the relevant signals for ActionEvent \a event. | - | ||||||||||||||||||||||||
1143 | - | |||||||||||||||||||||||||
1144 | Action based widgets use this API to cause the QAction | - | ||||||||||||||||||||||||
1145 | to emit signals as well as emitting their own. | - | ||||||||||||||||||||||||
1146 | */ | - | ||||||||||||||||||||||||
1147 | void QAction::activate(ActionEvent event) | - | ||||||||||||||||||||||||
1148 | { | - | ||||||||||||||||||||||||
1149 | Q_D(QAction); | - | ||||||||||||||||||||||||
1150 | if(event == Trigger) {
| 0 | ||||||||||||||||||||||||
1151 | QPointer<QObject> guard = this; | - | ||||||||||||||||||||||||
1152 | if(d->checkable) {
| 0 | ||||||||||||||||||||||||
1153 | // the checked action of an exclusive group cannot be unchecked | - | ||||||||||||||||||||||||
1154 | if (d->checked && (d->group && d->group->isExclusive()
| 0 | ||||||||||||||||||||||||
1155 | && d->group->checkedAction() == this)) {
| 0 | ||||||||||||||||||||||||
1156 | if (!guard.isNull())
| 0 | ||||||||||||||||||||||||
1157 | emit triggered(true); never executed: triggered(true); | 0 | ||||||||||||||||||||||||
1158 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1159 | } | - | ||||||||||||||||||||||||
1160 | setChecked(!d->checked); | - | ||||||||||||||||||||||||
1161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1162 | if (!guard.isNull())
| 0 | ||||||||||||||||||||||||
1163 | emit triggered(d->checked); never executed: triggered(d->checked); | 0 | ||||||||||||||||||||||||
1164 | } else if(event == Hover) { never executed: end of block
| 0 | ||||||||||||||||||||||||
1165 | emit hovered(); | - | ||||||||||||||||||||||||
1166 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1167 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1168 | - | |||||||||||||||||||||||||
1169 | /*! | - | ||||||||||||||||||||||||
1170 | \fn void QAction::triggered(bool checked) | - | ||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | This signal is emitted when an action is activated by the user; | - | ||||||||||||||||||||||||
1173 | for example, when the user clicks a menu option, toolbar button, | - | ||||||||||||||||||||||||
1174 | or presses an action's shortcut key combination, or when trigger() | - | ||||||||||||||||||||||||
1175 | was called. Notably, it is \e not emitted when setChecked() or | - | ||||||||||||||||||||||||
1176 | toggle() is called. | - | ||||||||||||||||||||||||
1177 | - | |||||||||||||||||||||||||
1178 | If the action is checkable, \a checked is true if the action is | - | ||||||||||||||||||||||||
1179 | checked, or false if the action is unchecked. | - | ||||||||||||||||||||||||
1180 | - | |||||||||||||||||||||||||
1181 | \sa QAction::activate(), QAction::toggled(), checked | - | ||||||||||||||||||||||||
1182 | */ | - | ||||||||||||||||||||||||
1183 | - | |||||||||||||||||||||||||
1184 | /*! | - | ||||||||||||||||||||||||
1185 | \fn void QAction::toggled(bool checked) | - | ||||||||||||||||||||||||
1186 | - | |||||||||||||||||||||||||
1187 | This signal is emitted whenever a checkable action changes its | - | ||||||||||||||||||||||||
1188 | isChecked() status. This can be the result of a user interaction, | - | ||||||||||||||||||||||||
1189 | or because setChecked() was called. | - | ||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | \a checked is true if the action is checked, or false if the | - | ||||||||||||||||||||||||
1192 | action is unchecked. | - | ||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | \sa QAction::activate(), QAction::triggered(), checked | - | ||||||||||||||||||||||||
1195 | */ | - | ||||||||||||||||||||||||
1196 | - | |||||||||||||||||||||||||
1197 | /*! | - | ||||||||||||||||||||||||
1198 | \fn void QAction::hovered() | - | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | This signal is emitted when an action is highlighted by the user; | - | ||||||||||||||||||||||||
1201 | for example, when the user pauses with the cursor over a menu option, | - | ||||||||||||||||||||||||
1202 | toolbar button, or presses an action's shortcut key combination. | - | ||||||||||||||||||||||||
1203 | - | |||||||||||||||||||||||||
1204 | \sa QAction::activate() | - | ||||||||||||||||||||||||
1205 | */ | - | ||||||||||||||||||||||||
1206 | - | |||||||||||||||||||||||||
1207 | /*! | - | ||||||||||||||||||||||||
1208 | \fn void QAction::changed() | - | ||||||||||||||||||||||||
1209 | - | |||||||||||||||||||||||||
1210 | This signal is emitted when an action has changed. If you | - | ||||||||||||||||||||||||
1211 | are only interested in actions in a given widget, you can | - | ||||||||||||||||||||||||
1212 | watch for QWidget::actionEvent() sent with an | - | ||||||||||||||||||||||||
1213 | QEvent::ActionChanged. | - | ||||||||||||||||||||||||
1214 | - | |||||||||||||||||||||||||
1215 | \sa QWidget::actionEvent() | - | ||||||||||||||||||||||||
1216 | */ | - | ||||||||||||||||||||||||
1217 | - | |||||||||||||||||||||||||
1218 | /*! | - | ||||||||||||||||||||||||
1219 | \enum QAction::ActionEvent | - | ||||||||||||||||||||||||
1220 | - | |||||||||||||||||||||||||
1221 | This enum type is used when calling QAction::activate() | - | ||||||||||||||||||||||||
1222 | - | |||||||||||||||||||||||||
1223 | \value Trigger this will cause the QAction::triggered() signal to be emitted. | - | ||||||||||||||||||||||||
1224 | - | |||||||||||||||||||||||||
1225 | \value Hover this will cause the QAction::hovered() signal to be emitted. | - | ||||||||||||||||||||||||
1226 | */ | - | ||||||||||||||||||||||||
1227 | - | |||||||||||||||||||||||||
1228 | /*! | - | ||||||||||||||||||||||||
1229 | \property QAction::menuRole | - | ||||||||||||||||||||||||
1230 | \brief the action's menu role | - | ||||||||||||||||||||||||
1231 | \since 4.2 | - | ||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | This indicates what role the action serves in the application menu on | - | ||||||||||||||||||||||||
1234 | \macos. By default all actions have the TextHeuristicRole, which means that | - | ||||||||||||||||||||||||
1235 | the action is added based on its text (see QMenuBar for more information). | - | ||||||||||||||||||||||||
1236 | - | |||||||||||||||||||||||||
1237 | The menu role can only be changed before the actions are put into the menu | - | ||||||||||||||||||||||||
1238 | bar in \macos (usually just before the first application window is | - | ||||||||||||||||||||||||
1239 | shown). | - | ||||||||||||||||||||||||
1240 | */ | - | ||||||||||||||||||||||||
1241 | void QAction::setMenuRole(MenuRole menuRole) | - | ||||||||||||||||||||||||
1242 | { | - | ||||||||||||||||||||||||
1243 | Q_D(QAction); | - | ||||||||||||||||||||||||
1244 | if (d->menuRole == menuRole)
| 0 | ||||||||||||||||||||||||
1245 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||
1247 | d->menuRole = menuRole; | - | ||||||||||||||||||||||||
1248 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
1249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1250 | - | |||||||||||||||||||||||||
1251 | QAction::MenuRole QAction::menuRole() const | - | ||||||||||||||||||||||||
1252 | { | - | ||||||||||||||||||||||||
1253 | Q_D(const QAction); | - | ||||||||||||||||||||||||
1254 | return d->menuRole; never executed: return d->menuRole; | 0 | ||||||||||||||||||||||||
1255 | } | - | ||||||||||||||||||||||||
1256 | - | |||||||||||||||||||||||||
1257 | /*! | - | ||||||||||||||||||||||||
1258 | \property QAction::iconVisibleInMenu | - | ||||||||||||||||||||||||
1259 | \brief Whether or not an action should show an icon in a menu | - | ||||||||||||||||||||||||
1260 | \since 4.4 | - | ||||||||||||||||||||||||
1261 | - | |||||||||||||||||||||||||
1262 | In some applications, it may make sense to have actions with icons in the | - | ||||||||||||||||||||||||
1263 | toolbar, but not in menus. If true, the icon (if valid) is shown in the menu, when it | - | ||||||||||||||||||||||||
1264 | is false, it is not shown. | - | ||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||
1266 | The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute | - | ||||||||||||||||||||||||
1267 | is set for the application. Explicitly settings this property overrides | - | ||||||||||||||||||||||||
1268 | the presence (or abscence) of the attribute. | - | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | For example: | - | ||||||||||||||||||||||||
1271 | \snippet code/src_gui_kernel_qaction.cpp 0 | - | ||||||||||||||||||||||||
1272 | - | |||||||||||||||||||||||||
1273 | \sa QAction::icon, QCoreApplication::setAttribute() | - | ||||||||||||||||||||||||
1274 | */ | - | ||||||||||||||||||||||||
1275 | void QAction::setIconVisibleInMenu(bool visible) | - | ||||||||||||||||||||||||
1276 | { | - | ||||||||||||||||||||||||
1277 | Q_D(QAction); | - | ||||||||||||||||||||||||
1278 | if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
| 0 | ||||||||||||||||||||||||
1279 | int oldValue = d->iconVisibleInMenu; | - | ||||||||||||||||||||||||
1280 | d->iconVisibleInMenu = visible; | - | ||||||||||||||||||||||||
1281 | // Only send data changed if we really need to. | - | ||||||||||||||||||||||||
1282 | if (oldValue != -1
| 0 | ||||||||||||||||||||||||
1283 | || (oldValue == -1
| 0 | ||||||||||||||||||||||||
1284 | && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) {
| 0 | ||||||||||||||||||||||||
1285 | d->sendDataChanged(); | - | ||||||||||||||||||||||||
1286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1287 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1289 | - | |||||||||||||||||||||||||
1290 | bool QAction::isIconVisibleInMenu() const | - | ||||||||||||||||||||||||
1291 | { | - | ||||||||||||||||||||||||
1292 | Q_D(const QAction); | - | ||||||||||||||||||||||||
1293 | if (d->iconVisibleInMenu == -1) {
| 0 | ||||||||||||||||||||||||
1294 | return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); never executed: return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); | 0 | ||||||||||||||||||||||||
1295 | } | - | ||||||||||||||||||||||||
1296 | return d->iconVisibleInMenu; never executed: return d->iconVisibleInMenu; | 0 | ||||||||||||||||||||||||
1297 | } | - | ||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
1300 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) | - | ||||||||||||||||||||||||
1301 | { | - | ||||||||||||||||||||||||
1302 | QDebugStateSaver saver(d); | - | ||||||||||||||||||||||||
1303 | d.nospace(); | - | ||||||||||||||||||||||||
1304 | d << "QAction(" << static_cast<const void *>(action); | - | ||||||||||||||||||||||||
1305 | if (action) {
| 0 | ||||||||||||||||||||||||
1306 | d << " text=" << action->text(); | - | ||||||||||||||||||||||||
1307 | if (!action->toolTip().isEmpty())
| 0 | ||||||||||||||||||||||||
1308 | d << " toolTip=" << action->toolTip(); never executed: d << " toolTip=" << action->toolTip(); | 0 | ||||||||||||||||||||||||
1309 | if (action->isCheckable())
| 0 | ||||||||||||||||||||||||
1310 | d << " checked=" << action->isChecked(); never executed: d << " checked=" << action->isChecked(); | 0 | ||||||||||||||||||||||||
1311 | if (!action->shortcut().isEmpty())
| 0 | ||||||||||||||||||||||||
1312 | d << " shortcut=" << action->shortcut(); never executed: d << " shortcut=" << action->shortcut(); | 0 | ||||||||||||||||||||||||
1313 | d << " menuRole="; | - | ||||||||||||||||||||||||
1314 | QtDebugUtils::formatQEnum(d, action->menuRole()); | - | ||||||||||||||||||||||||
1315 | d << " visible=" << action->isVisible(); | - | ||||||||||||||||||||||||
1316 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
1317 | d << '0'; | - | ||||||||||||||||||||||||
1318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1319 | d << ')'; | - | ||||||||||||||||||||||||
1320 | return d; never executed: return d; | 0 | ||||||||||||||||||||||||
1321 | } | - | ||||||||||||||||||||||||
1322 | #endif // QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
1323 | - | |||||||||||||||||||||||||
1324 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||
1326 | #include "moc_qaction.cpp" | - | ||||||||||||||||||||||||
1327 | - | |||||||||||||||||||||||||
1328 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |